/* octomob — mobile-first styles. Dark theme with a squishy aquatic palette. */

:root {
  --bg: #0b1220;
  --bg-2: #111a2e;
  --fg: #eaf2ff;
  --fg-dim: #93a5c4;
  --accent: #7c5cff;
  --accent-2: #34d3b7;
  --warn: #ff6b7a;
  --good: #6dd48f;
  --card: #152037;
  --card-2: #1b2947;
  --radius: 14px;
  --pad: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(var(--safe-top) + 8px) 0 var(--safe-bottom);
}

.hidden { display: none !important; }

/* --- Home / lobby --- */

.home, .home body {
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.screen {
  display: none;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 480px;
  padding: 24px 20px;
  margin: 0 auto;
}
.screen.active { display: flex; }

.brand {
  text-align: center;
  padding: 16px 0 8px;
}
.brand.small { padding: 8px 0; }
.logo {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo.small { font-size: 26px; }
/* Make "mob" visible. The parent uses background-clip:text with
 * color:transparent, so a child <span> that inherits color:transparent
 * and has no background of its own would render as nothing. Set an
 * explicit fill color (and drop any background-clip) so it paints. */
.logo span {
  color: var(--accent-2);
  -webkit-text-fill-color: var(--accent-2);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
}
.tag { color: var(--fg-dim); margin: 4px 0 0; }

.howto {
  background: var(--card);
  border: 1px solid var(--card-2);
  border-radius: 12px;
  padding: 14px 18px;
  color: var(--fg);
}
.howto-title {
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 6px;
}
.howto ol {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg-dim);
}
.howto ol li { margin-bottom: 3px; }
.howto ol li::marker { color: var(--accent-2); }

.card {
  background: var(--card);
  border: 1px solid var(--card-2);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 10px 30px -15px #000;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
input[type="text"] {
  font-size: 18px;
  padding: 14px 16px;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid #223053;
  border-radius: 10px;
  outline: none;
  text-transform: none;
  letter-spacing: 0;
}
input[type="text"]:focus { border-color: var(--accent); }
#code-input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-weight: 700;
  font-size: 22px;
  text-align: center;
}

button {
  font-size: 17px;
  font-weight: 700;
  padding: 16px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  color: var(--fg);
  background: var(--card-2);
  min-height: 52px;
}
button.primary {
  background: linear-gradient(135deg, var(--accent), #4a78ff);
  color: white;
}
button.secondary { background: #243556; }
button.link {
  background: transparent;
  color: var(--fg-dim);
  padding: 8px;
  min-height: 0;
  font-size: 14px;
  font-weight: 500;
}
button.link.danger { color: var(--warn); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.or {
  text-align: center;
  color: var(--fg-dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin: 4px 0;
}

.error {
  color: var(--warn);
  font-size: 14px;
  text-align: center;
}

.foot {
  text-align: center;
  color: var(--fg-dim);
  font-size: 13px;
  margin-top: auto;
  padding: 12px;
}
.foot a { color: var(--fg-dim); text-decoration: none; }
.foot a:hover { color: var(--fg); }

/* --- Team lobby --- */

.code-wrap {
  text-align: center;
  padding: 10px 0 4px;
}
.code-label {
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.3em;
}
.code {
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--accent-2);
  font-family: "SF Mono", Menlo, monospace;
  padding: 8px 0;
}

.members {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.members li {
  padding: 12px 14px;
  background: var(--bg-2);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}
.members .name { font-weight: 600; }
.members .badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #243556;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.members .badge.captain { background: var(--accent); color: white; }
.members .badge.off { background: #3b2638; color: var(--warn); }

#lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.status {
  color: var(--fg-dim);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

/* --- Tabs / world picker (home page) --- */

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 10px;
}
.tab {
  flex: 1;
  font-size: 14px;
  padding: 10px;
  background: transparent;
  color: var(--fg-dim);
  border-radius: 8px;
  min-height: 0;
  letter-spacing: 0.03em;
}
.tab.active {
  background: var(--card-2);
  color: var(--fg);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.world-picker {
  background: var(--bg-2);
  border: 1px solid #223053;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.world-picker-label {
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.world-tabs {
  display: flex;
  gap: 4px;
}
.world-tab {
  flex: 1;
  font-size: 12px;
  padding: 8px 6px;
  background: #0f172a;
  color: var(--fg-dim);
  border-radius: 6px;
  min-height: 0;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  font-weight: 600;
}
.world-tab.active {
  background: var(--accent);
  color: white;
}
.world-panel { display: none; flex-direction: column; gap: 10px; }
.world-panel.active { display: flex; }
.world-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--fg);
  font-size: 14px;
  padding: 10px 0;
}
.world-info span { color: var(--fg-dim); font-size: 12px; }

.subhead {
  font-size: 11px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #1a2544;
}
.slider span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.slider em {
  font-style: normal;
  color: var(--accent-2);
  font-family: "SF Mono", Menlo, monospace;
}
.slider input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

label select,
label input[type="number"] {
  font-size: 16px;
  padding: 12px 14px;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid #223053;
  border-radius: 10px;
  outline: none;
  font-family: inherit;
}
label select:focus,
label input[type="number"]:focus { border-color: var(--accent); }

/* --- Lobby team name + world summary --- */

.team-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  padding: 6px 0;
}
.world-summary {
  text-align: center;
  font-size: 13px;
  color: var(--fg-dim);
  padding: 8px 0 4px;
  border-top: 1px solid #1a2544;
  border-bottom: 1px solid #1a2544;
  margin: 0 -4px;
}
.world-summary strong { color: var(--accent-2); font-weight: 700; }

/* --- Toast --- */
.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 16px);
  transform: translateX(-50%);
  background: #1a2544;
  border: 1px solid #2a3a63;
  color: var(--fg);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 30px -15px #000;
  z-index: 100;
}

/* --- Player controller v2 (full-canvas) --- */

body.player-v2 {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: calc(var(--safe-top) + 6px) 0 var(--safe-bottom);
  margin: 0;
  overflow: hidden;
}
body.player-v2 .player-hud {
  padding: 6px 12px 4px;
}
body.player-v2 .player-foot {
  padding: 8px 14px calc(8px + var(--safe-bottom));
}

/* Team name + "you" dots (shows which of the 8 tentacle colors the
 * current player controls). */
.team-name-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.1;
}
.you-dots {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.you-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  opacity: 0.3;
  border: 1px solid #0b1220;
}
.you-dots .dot.mine {
  opacity: 1;
  width: 12px;
  height: 12px;
  box-shadow: 0 0 0 2px #ffffff55;
}

.score-box {
  font-size: 22px;
  font-weight: 800;
  font-family: "SF Mono", Menlo, monospace;
  color: var(--accent-2);
  padding: 4px 10px;
  background: var(--bg-2);
  border-radius: 8px;
  min-width: 40px;
  text-align: center;
}

.help-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  min-height: 0;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--fg-dim);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  margin-right: 8px;
}
.help-btn:hover { color: var(--fg); }

/* Contextual status line — tells the player what to do right now. */
.status-line {
  text-align: center;
  padding: 6px 12px 4px;
  font-size: 13px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  min-height: 20px;
  font-weight: 600;
}
.status-line.hot { color: var(--accent-2); }
.status-line.warn { color: var(--warn); }
.status-line.win { color: var(--good); }

.world-area {
  flex: 1;
  position: relative;
  touch-action: none;
  user-select: none;
  overflow: hidden;
}
#world {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Full-canvas flash used for squid hits (red) and fish eats (white). */
.flash-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: transparent;
  opacity: 0;
  transition: opacity 220ms ease-out;
}
.flash-overlay.fish { background: #ffffffbb; opacity: 0.55; transition: opacity 80ms linear; }
.flash-overlay.hit  { background: #ff3a4ccc; opacity: 0.55; transition: opacity 80ms linear; }

/* --- Tutorial overlay ------------------------------------------------- */

.tutorial-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 24, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
  backdrop-filter: blur(3px);
}
.tutorial-card {
  max-width: 420px;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--card-2);
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 20px 60px -20px #000;
}
.tutorial-card h2 {
  margin: 0 0 12px;
  font-size: 22px;
  text-transform: lowercase;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.tutorial-tips {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tutorial-tips li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--fg);
}
.tutorial-tips b { color: var(--accent-2); font-weight: 700; }
.tutorial-tips em { color: var(--warn); font-style: normal; font-weight: 700; }
.tut-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-top: 3px;
  box-shadow: 0 0 0 2px #0b122055;
}

/* --- Old player layout (unused; kept so old anchors still style) ----- */

body.player {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: calc(var(--safe-top) + 8px) 12px var(--safe-bottom);
  overflow: hidden;
}

.player-hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.team-badge {
  font-family: "SF Mono", Menlo, monospace;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--accent-2);
}
.tentacle-label {
  font-size: 12px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.hud-right { text-align: right; min-width: 160px; }
.phase {
  font-size: 13px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
}
.coherence-label {
  font-size: 10px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}
.coherence-bar {
  width: 140px;
  height: 8px;
  background: #223053;
  border-radius: 4px;
  overflow: hidden;
  margin-left: auto;
  margin-top: 3px;
}
.coherence-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--warn), #f2c94c, var(--good));
  transition: width 0.15s linear;
}

.joystick-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  touch-action: none;
  position: relative;
}
#joystick {
  width: min(90vw, 86vh, 420px);
  height: min(90vw, 86vh, 420px);
  touch-action: none;
  user-select: none;
}
.hint {
  color: var(--fg-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 10px;
}

.player-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
}
.goal-indicator {
  font-size: 12px;
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.player-foot a { color: var(--fg-dim); font-size: 13px; text-decoration: none; }

/* --- Display (spectator) --- */

body.display {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  margin: 0;
}
.display-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  gap: 16px;
  background: #0a0f1d;
  border-bottom: 1px solid #1a2544;
}
.display-hud .phase { margin: 0; }
.scores { display: flex; gap: 14px; color: var(--fg-dim); font-size: 13px; }
.scores .score {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--fg);
  font-family: "SF Mono", Menlo, monospace;
}
#world {
  flex: 1;
  display: block;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, #0f1a33 0%, #060a18 100%);
  image-rendering: auto;
}
.display-foot {
  background: #0a0f1d;
  padding: 10px 18px;
  color: var(--fg-dim);
  font-size: 12px;
  text-align: center;
  border-top: 1px solid #1a2544;
}
