:root {
  --bg: #04120c;
  --green: #39ff9e;
  --dim: rgba(57, 255, 158, 0.55);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  /* touch-action does not inherit, so it has to be set on everything, not just
     body — otherwise double-tapping a button still zooms. #radar overrides
     this with `none` to block gestures on the sonar entirely. */
  touch-action: manipulation;
}

/* The default [hidden] rule loses to any id selector, so state it explicitly. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  /* Kills double-tap-to-zoom without disabling pinch — mis-taps on the sonar
     were zooming the page. Pinch stays available for anyone who needs it. */
  -webkit-text-size-adjust: 100%;
  background: radial-gradient(circle at 50% 45%, #0a2418 0%, var(--bg) 70%);
  color: #dfffef;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  overscroll-behavior: none;
}

#join {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px max(24px, env(safe-area-inset-left));
  text-align: center;
}

h1 { margin: 0; font-size: 2rem; letter-spacing: 0.12em; color: var(--green); }
.lede { margin: 0; color: var(--dim); }
.fine { margin: 8px 0 0; font-size: 0.72rem; color: rgba(223, 255, 239, 0.45); max-width: 30ch; }

#nickname, #go {
  width: min(320px, 100%);
  padding: 14px 16px;
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--dim);
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
}

#nickname:focus { outline: 2px solid var(--green); outline-offset: 2px; }

#go {
  background: var(--green);
  color: #04120c;
  font-weight: 700;
  letter-spacing: 0.08em;
  border: none;
  cursor: pointer;
}

#go:disabled { opacity: 0.5; cursor: progress; }

.error { color: #ff8080; max-width: 34ch; margin: 0; }

.link {
  background: none;
  border: none;
  color: var(--dim);
  font: inherit;
  font-size: 0.78rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 6px;
}

#help {
  width: min(360px, 100%);
  text-align: left;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(57, 255, 158, 0.25);
  border-radius: 12px;
  padding: 16px 18px;
  font-size: 0.8rem;
  line-height: 1.5;
}

.help-intro { margin: 0 0 10px; color: var(--dim); }
#help strong { color: var(--green); font-weight: 700; }
#help ol { margin: 0; padding-left: 1.2em; }
#help li { margin-bottom: 8px; }
#help li:last-child { margin-bottom: 0; }

#reload {
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  font: inherit;
  font-weight: 700;
  border-radius: 10px;
  border: 1px solid var(--green);
  background: transparent;
  color: var(--green);
  cursor: pointer;
}

#sonar-screen { position: fixed; inset: 0; }
#radar { width: 100%; height: 100%; display: block; touch-action: none; }

#zoom {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

#zoom button {
  font: inherit;
  color: var(--green);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(57, 255, 158, 0.35);
  border-radius: 10px;
  padding: 0;
  width: 44px;
  height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#zoom button:active { background: rgba(57, 255, 158, 0.2); }

#zoom button:disabled { opacity: 0.3; cursor: default; }

#zoom-out, #zoom-in { font-size: 1.4rem; line-height: 1; }

#range-label {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  height: auto;
  min-height: 32px;
  padding: 6px 4px;
}

#range-label.auto { color: var(--dim); }

#poke {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  top: max(12px, env(safe-area-inset-top));
  width: min(260px, calc(100vw - 90px));
}

#poke-toggle {
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--green);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(57, 255, 158, 0.35);
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#poke-form {
  margin-top: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(57, 255, 158, 0.25);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#poke-name {
  flex: 1 1 120px;
  min-width: 0;
  font: inherit;
  /* Never below 16px: iOS auto-zooms the page when focusing a smaller input. */
  font-size: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--dim);
  background: rgba(0, 0, 0, 0.4);
  color: inherit;
}

#poke-send {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: var(--green);
  color: #04120c;
  cursor: pointer;
}

#poke-send:disabled { opacity: 0.5; }

.poke-result {
  flex: 1 0 100%;
  margin: 0;
  font-size: 0.72rem;
  color: var(--dim);
  min-height: 1em;
}

.poke-result.bad { color: #ffd479; }

#poke-form .link { flex: 1 0 100%; text-align: left; padding: 2px; }

#hud {
  position: fixed;
  left: 0; right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--dim);
  pointer-events: none;
  padding: 0 12px;
}

#hud span:not([hidden]) {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(57, 255, 158, 0.2);
  border-radius: 999px;
  padding: 5px 12px;
}

#status:empty { display: none; }

#accuracy.poor { color: #ffd479; border-color: rgba(255, 212, 121, 0.35); }
#accuracy.waiting { color: #ff8080; border-color: rgba(255, 128, 128, 0.4); }
