* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0d1116;
  color: #d8e2ea;
  font: 13px/1.45 ui-monospace, "DejaVu Sans Mono", Menlo, Consolas, monospace;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#view {
  position: fixed;
  inset: 0;
  display: block;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  background: #ff4d4f;
  border: 1px solid rgba(0, 0, 0, 0.42);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

body.hide-crosshair #crosshair {
  display: none;
}

#panel {
  position: fixed;
  left: 10px;
  top: 10px;
  padding: 8px 10px;
  background: rgba(12, 17, 22, 0.62);
  border: 1px solid rgba(160, 190, 210, 0.2);
  border-radius: 8px;
  max-width: 46vw;
  pointer-events: none;
}

#mode {
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

#stats {
  opacity: 0.8;
}

#coords {
  margin-top: 3px;
  opacity: 0.72;
  font-variant-numeric: tabular-nums;
}

#hint {
  opacity: 0.62;
  margin-top: 4px;
}

#why {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(160, 190, 210, 0.22);
  color: #ffd7d2;
  min-height: 1.2em;
}

#why:empty {
  display: none;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(12, 17, 22, 0.78);
  border: 1px solid rgba(160, 190, 210, 0.22);
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}

#toast.show {
  opacity: 1;
}

#toast.bad {
  border-color: rgba(224, 122, 110, 0.65);
  color: #ffd7d2;
}

#menu {
  position: fixed;
  right: 10px;
  top: 10px;
  display: flex;
  gap: 6px;
}

.chip {
  font: inherit;
  color: inherit;
  padding: 6px 10px;
  background: rgba(12, 17, 22, 0.62);
  border: 1px solid rgba(160, 190, 210, 0.24);
  border-radius: 8px;
}

label.chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.chip:active {
  background: rgba(60, 82, 98, 0.7);
}

#help {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 22px;
  background: rgba(8, 11, 15, 0.86);
}

#helpText {
  white-space: pre-wrap;
  max-width: 640px;
  max-height: 74vh;
  overflow: auto;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(8, 11, 15, 0.82);
}

.modal[hidden] {
  display: none !important;
}

.panelBox {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  padding: 16px;
  background: rgba(16, 21, 28, 0.94);
  border: 1px solid rgba(160, 190, 210, 0.24);
  border-radius: 12px;
}

.panelBox .title {
  color: #e7f0f7;
  font-weight: 700;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field > span,
.field > label {
  opacity: 0.72;
}

.passwordRow {
  display: flex;
  align-items: center;
  gap: 6px;
}

.passwordRow input {
  min-width: 0;
  flex: 1;
}

.passwordToggle {
  cursor: pointer;
  padding: 7px 8px;
  flex: 0 0 auto;
}

.checkboxField {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.checkboxField input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #74b7e5;
}

.danger {
  background: rgba(163, 56, 44, 0.68);
}

.panelBox input,
#profileUserId {
  font: inherit;
  color: inherit;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(160, 190, 210, 0.22);
  border-radius: 8px;
}

.panelBox button {
  cursor: pointer;
}

.panelBox .primary {
  background: rgba(58, 122, 168, 0.72);
}

.formStatus {
  min-height: 1.2em;
  color: #ffd7d2;
  white-space: pre-wrap;
}

.formStatus:empty {
  min-height: 0;
}

body.game-active #login {
  display: none !important;
}

#touch {
  display: none;
}

body.touch #touch {
  display: block;
}

body.touch #panel {
  max-width: 40vw;
  font-size: 12px;
}

body.touch .chip {
  font-size: 12px;
  padding: 5px 8px;
}

#stick {
  position: fixed;
  left: 22px;
  bottom: 22px;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  border: 1px solid rgba(160, 190, 210, 0.28);
  background: rgba(12, 17, 22, 0.32);
}

#knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: rgba(200, 220, 235, 0.34);
  border: 1px solid rgba(220, 235, 245, 0.5);
}

#pad {
  position: fixed;
  right: 14px;
  bottom: 22px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 8px;
}

.key {
  font: inherit;
  color: inherit;
  min-width: 92px;
  padding: 14px 10px;
  background: rgba(12, 17, 22, 0.55);
  border: 1px solid rgba(160, 190, 210, 0.28);
  border-radius: 12px;
}

.key:active,
.key.on {
  background: rgba(96, 132, 158, 0.6);
}

body.locked #crosshair {
  border-color: rgba(0, 0, 0, 0.42);
}
