/* Same "quiet terminal" palette as pikaroot.com: graphite neutrals, one phosphor-green accent. */
:root {
  --base: #f6f5f1; --mantle: #fdfcfa; --crust: #eeece6;
  --surface0: #ecebe5; --surface1: #dcdad2; --surface2: #c6c3b9;
  --muted: #63615b; --text: #161615;
  --accent: #17734a; --accent-rgb: 23 115 74;
  --hit: #c4302b; --sunk: #8f1f1b; --warn: #a16207;
  --water: #e4e8e3; --water-line: rgba(22, 22, 21, .08);
  --ship: #8b948f;
  --mono: ui-monospace, 'JetBrains Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --base: #0c0d0d; --mantle: #121413; --crust: #080909;
    --surface0: #191c1b; --surface1: #262a28; --surface2: #363b39;
    --muted: #949995; --text: #e7e5e0;
    --accent: #5fc98f; --accent-rgb: 95 201 143;
    --hit: #ef6b63; --sunk: #b53a33; --warn: #e0b04a;
    --water: #101312; --water-line: rgba(231, 229, 224, .06);
    --ship: #5d6662;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--base); color: var(--text);
  font: 16px/1.5 var(--sans); min-height: 100vh;
  background-image: linear-gradient(var(--water-line) 1px, transparent 1px), linear-gradient(90deg, var(--water-line) 1px, transparent 1px);
  background-size: 32px 32px;
}
[hidden] { display: none !important; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1.1; margin: .2em 0 .3em; letter-spacing: -.02em; }
h2 { font-size: .8rem; font-family: var(--mono); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .7rem; }
p { margin: 0; }

.top { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--surface1); background: color-mix(in srgb, var(--mantle) 88%, transparent); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; }
.brand { font-family: var(--mono); font-weight: 700; color: var(--text); text-decoration: none; }
.brand span { color: var(--accent); }
.top-right { display: flex; gap: 12px; align-items: center; }
.conn { font: 12px var(--mono); color: var(--warn); }
main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 60px; }
.eyebrow { font: 13px var(--mono); color: var(--accent); margin-bottom: 4px; }
.lede, .sub { color: var(--muted); max-width: 52ch; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .6rem; }
.center { text-align: center; justify-content: center; }

button, input {
  font: inherit; color: var(--text); background: var(--mantle); border: 1px solid var(--surface2);
  border-radius: 8px; padding: 9px 14px; min-height: 40px;
}
button { cursor: pointer; transition: border-color .15s, background .15s, transform .05s; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--base); font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); font: 12px var(--mono); }
button.ghost:hover { color: var(--text); border-color: var(--surface2); }
input { width: 100%; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#code { text-transform: uppercase; letter-spacing: .3em; font-family: var(--mono); text-align: center; }
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 0; }
.or { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 14px; }

.cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); margin-top: 28px; }
.card { background: var(--mantle); border: 1px solid var(--surface1); border-radius: 14px; padding: 20px; }
.card > button.primary { width: 100%; margin-top: 12px; }
.card > h2 + button.primary { margin-top: 0; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg button[aria-checked='true'] { border-color: var(--accent); background: rgb(var(--accent-rgb) / .12); }

.code-big { font: 700 clamp(3rem, 14vw, 5.5rem)/1 var(--mono); letter-spacing: .15em; text-align: center; margin: 28px 0; color: var(--accent); padding-left: .15em; }

.status { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.timer { font: 600 1.4rem var(--mono); color: var(--muted); border: 1px solid var(--surface2); border-radius: 10px; padding: 6px 12px; }
.timer.low { color: var(--hit); border-color: var(--hit); }
#headline.win { color: var(--accent); }
#headline.lose { color: var(--hit); }

.boards { display: grid; gap: 28px; grid-template-columns: 1fr 1fr; align-items: start; }
.panel { min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.fleet { list-style: none; margin: 0 0 .7rem; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.fleet li { font: 11px var(--mono); padding: 1px 7px; border: 1px solid var(--surface2); border-radius: 99px; color: var(--muted); }
.fleet li.dead { text-decoration: line-through; color: var(--hit); border-color: var(--hit); opacity: .8; }
.fleet li.sel { border-color: var(--accent); color: var(--accent); }
.fleet li.done { color: var(--text); }

.board { overflow: hidden; position: relative; display: grid; grid-template-columns: 1.4em repeat(10, minmax(0, 1fr)); width: 100%; max-width: 460px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.board .lab { font: 11px var(--mono); color: var(--muted); display: grid; place-items: center; aspect-ratio: auto; min-height: 1.4em; }
.board .c { min-width: 0; aspect-ratio: 1; background: var(--water); border: 1px solid var(--water-line); border-color: color-mix(in srgb, var(--surface2) 55%, transparent); position: relative; display: grid; place-items: center; padding: 0; min-height: 0; border-radius: 0; }
.board .c:hover { border-color: color-mix(in srgb, var(--surface2) 55%, transparent); }
.board .c.ship { background: var(--ship); }
.board .c.reveal { background: color-mix(in srgb, var(--ship) 45%, var(--water)); }
.board .c.sunk { background: var(--sunk); }
.board .c.miss::after { content: ''; width: 24%; height: 24%; border-radius: 50%; background: var(--muted); opacity: .75; }
.board .c.hit::after { content: ''; width: 46%; height: 46%; border-radius: 50%; background: var(--hit); box-shadow: 0 0 10px var(--hit); }
.board .c.sunk::after { content: '×'; width: auto; height: auto; background: none; box-shadow: none; color: #fff; font: 700 1.1em var(--mono); border-radius: 0; }
.board .c.cap::before { content: '★'; position: absolute; inset: 0; display: grid; place-items: center; color: #ffd24a; font-size: 1.05em; line-height: 1; text-shadow: 0 0 4px rgb(0 0 0 / .65); pointer-events: none; z-index: 2; }
.board .c.cap.hit::before { color: #fff; }
.board.capmode.placing .c.ship { cursor: pointer; }
#capTool[aria-pressed="true"] { background: rgb(var(--accent-rgb) / .22); border-color: var(--accent); color: var(--text); }
.board .c.prev { background: rgb(var(--accent-rgb) / .35); }
.board .c.prev.bad { background: color-mix(in srgb, var(--hit) 70%, var(--water)); }
.board.aim .c:not(.hit):not(.miss):not(.sunk) { cursor: crosshair; }
.board.aim .c:not(.hit):not(.miss):not(.sunk):hover { background: rgb(var(--accent-rgb) / .28); }
.board.aim { outline: 1px solid rgb(var(--accent-rgb) / .6); outline-offset: 4px; border-radius: 2px; }
.board.dim { opacity: .62; }
.board.sweep::before {
  content: ''; position: absolute; inset: 0 0 0 1.4em; pointer-events: none; z-index: 1; opacity: .5;
  background: conic-gradient(from 0deg, rgb(var(--accent-rgb) / .22), transparent 25%);
  mask-image: radial-gradient(circle, #000 69%, transparent 70%); -webkit-mask-image: radial-gradient(circle, #000 69%, transparent 70%);
  animation: sweep 4s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.c.pop { animation: pop .6s ease-out; }
.c.pop.hit, .c.pop.sunk { animation: boom .7s ease-out; }
@keyframes pop { 0% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / .8); } 100% { box-shadow: 0 0 0 14px transparent; } }
@keyframes boom { 0% { transform: scale(1.35); filter: brightness(2); } 100% { transform: scale(1); filter: none; } }

.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.log { list-style: none; padding: 0; margin: 22px 0 0; font: 13px var(--mono); color: var(--muted); display: grid; gap: 3px; min-height: 5.5em; }
.log li:first-child { color: var(--text); }
.log li.mine::before { content: '> '; color: var(--accent); }
.log li.theirs::before { content: '< '; color: var(--hit); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--base); padding: 10px 16px; border-radius: 10px; font-size: .9rem; z-index: 10; max-width: 90vw; }

@media (max-width: 820px) {
  .boards { grid-template-columns: 1fr; gap: 22px; }
  .board { max-width: 100%; }
  main { padding: 20px 16px 50px; }
}
@media (prefers-reduced-motion: reduce) {
  .board.sweep::before, .c.pop { animation: none; }
}

/* ship placement */
.fleet li button { all: unset; cursor: pointer; font: inherit; }
.fleet li:has(button) { cursor: pointer; }
.fleet li:has(button):hover { border-color: var(--accent); }
.fleet li:has(button:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.board .c.pick { box-shadow: inset 0 0 0 2px var(--accent); filter: brightness(1.15); z-index: 1; }
.board.placing { touch-action: none; }
.board.placing .c.ship { cursor: grab; }
#placeHint { max-width: 46ch; }

/* rule switch */
.switch { display: flex; gap: 14px; align-items: center; margin-top: 20px; padding: 14px 18px; background: var(--mantle); border: 1px solid var(--surface1); border-radius: 14px; cursor: pointer; position: relative; max-width: 640px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; }
.switch .track { flex: none; width: 44px; height: 26px; border-radius: 99px; background: var(--surface2); position: relative; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--mantle); box-shadow: 0 1px 3px rgb(0 0 0 / .35); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { display: grid; gap: 2px; }
.switch-text small { color: var(--muted); font-size: .82rem; }
@media (prefers-reduced-motion: reduce) { .switch .track, .switch .track::after { transition: none; } }

/* missile effects */
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 20; }
.board.shake { animation: shake .35s ease-out; }
.board.shake-big { animation: shake-big .55s ease-out; }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translate(-3px, 2px); } 40% { transform: translate(3px, -2px); } 60% { transform: translate(-2px, -1px); } 80% { transform: translate(2px, 1px); } }
@keyframes shake-big { 0%, 100% { transform: none; } 12% { transform: translate(-6px, 3px); } 28% { transform: translate(6px, -4px); } 44% { transform: translate(-5px, -2px); } 60% { transform: translate(4px, 3px); } 80% { transform: translate(-2px, 1px); } }
@media (prefers-reduced-motion: reduce) { #fx { display: none; } .board.shake, .board.shake-big { animation: none; } }

/* ---------- home: hero, radar, HUD cards ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 32px; align-items: center; }
h1 em { font-style: normal; color: var(--accent); position: relative; }
h1 em::after { content: ''; position: absolute; left: 0; right: 0; bottom: -.08em; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--accent), transparent); }
.statbar { display: inline-flex; align-items: center; gap: 10px; margin-top: 18px; padding: 6px 14px; border: 1px solid var(--surface2); border-radius: 99px; font: 12px var(--mono); color: var(--muted); background: color-mix(in srgb, var(--mantle) 80%, transparent); }
.statbar b { color: var(--text); font-weight: 600; }
.statbar .sep { opacity: .4; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgb(var(--accent-rgb) / 0); } 100% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / 0); } }
.boot { margin: 18px 0 0; font: 12.5px/1.7 var(--mono); color: var(--muted); min-height: 5.2em; white-space: pre-wrap; }
.boot .ok { color: var(--accent); }
.boot .caret { display: inline-block; width: .55em; height: 1em; background: var(--accent); vertical-align: -.15em; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.radar { --period: 6s; position: relative; width: min(100%, 300px); aspect-ratio: 1; border-radius: 50%; margin: 0 auto; justify-self: center;
  background: radial-gradient(circle, rgb(var(--accent-rgb) / .10), rgb(var(--accent-rgb) / .02) 70%, transparent 71%);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--surface2)); box-shadow: 0 0 40px rgb(var(--accent-rgb) / .12), inset 0 0 30px rgb(var(--accent-rgb) / .08); overflow: hidden; }
.radar.big { width: min(100%, 400px); }
.radar .ring { position: absolute; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); inset: 0; }
.radar .ring.r1 { inset: 16.5%; } .radar .ring.r2 { inset: 33%; } .radar .ring.r3 { inset: 49.5%; }
.radar .axis { position: absolute; background: color-mix(in srgb, var(--accent) 24%, transparent); }
.radar .axis.x { left: 0; right: 0; top: 50%; height: 1px; } .radar .axis.y { top: 0; bottom: 0; left: 50%; width: 1px; }
.radar .ticks { position: absolute; inset: 0; border-radius: 50%; opacity: .5;
  background: repeating-conic-gradient(from -.5deg, color-mix(in srgb, var(--accent) 70%, transparent) 0 1deg, transparent 1deg 10deg);
  -webkit-mask-image: radial-gradient(circle, transparent 94%, #000 94.5%); mask-image: radial-gradient(circle, transparent 94%, #000 94.5%); }
.radar .sweep { position: absolute; inset: 0; border-radius: 50%; animation: sweep var(--period) linear infinite;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 270deg, rgb(var(--accent-rgb) / .38) 359deg, rgb(var(--accent-rgb) / .95) 360deg); }
.radar .blip { position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: var(--accent); opacity: 0; animation: blip var(--period) linear infinite; box-shadow: 0 0 10px var(--accent); }
.radar .blip.hostile { background: var(--hit); box-shadow: 0 0 10px var(--hit); }
.radar .blip i { position: absolute; left: 12px; top: -5px; font: 10px var(--mono); font-style: normal; color: var(--accent); white-space: nowrap; }
.radar .blip.hostile i { color: var(--hit); }
@keyframes blip { 0% { opacity: 1; transform: scale(1.7); } 12% { opacity: 1; transform: scale(1); } 60% { opacity: .35; } 100% { opacity: 0; } }
.radar .cardinal { position: absolute; font: 9px var(--mono); color: var(--muted); }
.radar .cardinal.n { top: 4%; left: 50%; transform: translateX(-50%); } .radar .cardinal.s { bottom: 4%; left: 50%; transform: translateX(-50%); }
.radar .cardinal.e { right: 5%; top: 50%; transform: translateY(-50%); } .radar .cardinal.w { left: 5%; top: 50%; transform: translateY(-50%); }
#lobbyRadar { width: min(100%, 240px); margin: 22px auto 0; }
@media (prefers-reduced-motion: reduce) { .radar .sweep, .pulse, .boot .caret { animation: none; } .radar .blip { animation: none; opacity: .8; } }

/* HUD-style cards */
.card { position: relative; transition: border-color .2s, transform .2s, box-shadow .2s; }
.card::before, .card::after { content: ''; position: absolute; width: 14px; height: 14px; border: 2px solid var(--accent); opacity: .7; transition: opacity .2s, width .2s, height .2s; pointer-events: none; }
.card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 14px; }
.card::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 14px; }
.card:hover, .card:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--surface1)); box-shadow: 0 8px 30px rgb(var(--accent-rgb) / .10); }
.card:hover::before, .card:hover::after, .card:focus-within::before, .card:focus-within::after { width: 26px; height: 26px; opacity: 1; }
.card h2 .idx { color: var(--accent); margin-right: 8px; }
.cards { margin-top: 36px; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 22px; } .radar.big { width: min(78vw, 320px); order: -1; } }
@media (prefers-reduced-motion: reduce) { .card, .card::before, .card::after { transition: none; } }

/* Whose turn it is: a banner above the boards, plus a glow on the enemy board when it's yours. */
.turnbanner { text-align: center; font: 700 .95rem var(--mono); letter-spacing: .08em; padding: 11px 14px; border-radius: 10px; margin: 0 0 18px; border: 1px solid var(--surface2); color: var(--muted); background: var(--mantle); }
.turnbanner.mine { color: var(--base); background: var(--accent); border-color: var(--accent); animation: yourturn 1.6s ease-in-out infinite; }
@keyframes yourturn { 0%, 100% { box-shadow: 0 0 0 0 rgb(var(--accent-rgb) / .55); } 50% { box-shadow: 0 0 0 8px rgb(var(--accent-rgb) / 0); } }
#foePanel.active #foeBoard { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .turnbanner.mine { animation: none; } }

/* Enemy hit warning: fixed to the top of the screen so it is seen even when our own board is off-screen. */
.hitalert { position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 9; width: min(92vw, 560px); text-align: center; font: 700 .95rem var(--mono); letter-spacing: .03em; padding: 13px 16px; border-radius: 10px; color: #fff; background: var(--hit); border: 1px solid var(--sunk); box-shadow: 0 10px 30px rgb(0 0 0 / .35); pointer-events: none; }
.hitalert.sunk { background: var(--sunk); font-size: 1.02rem; }
.hitalert.good { background: var(--accent); color: var(--base); border-color: var(--accent); }
.hitalert.good.sunk { font-size: 1.02rem; }
.hitalert.bad.sunk { background: var(--sunk); }
.hitalert.show { animation: alertin .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes alertin { from { opacity: 0; transform: translate(-50%, -24px) scale(.9); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@media (prefers-reduced-motion: reduce) { .hitalert.show { animation: none; } }

/* On a phone the boards stack and the page scrolls, so keep the turn banner pinned under the header. */
@media (max-width: 820px) {
  .turnbanner { position: sticky; top: 58px; z-index: 4; font-size: .82rem; padding: 9px 10px; margin-bottom: 14px; box-shadow: 0 6px 18px rgb(0 0 0 / .18); }
  .hitalert { top: 62px; font-size: .88rem; }
}

/* Daily accent rotation (accent.js sets data-accent on <html>): green is the default above. */
html[data-accent='orange'] { --accent: #b4530f; --accent-rgb: 180 83 15; }
html[data-accent='blue']   { --accent: #1d63b8; --accent-rgb: 29 99 184; }
html[data-accent='violet'] { --accent: #6d3fc4; --accent-rgb: 109 63 196; }
@media (prefers-color-scheme: dark) {
  html[data-accent='orange'] { --accent: #f0954a; --accent-rgb: 240 149 74; }
  html[data-accent='blue']   { --accent: #5aa9f0; --accent-rgb: 90 169 240; }
  html[data-accent='violet'] { --accent: #b28cf0; --accent-rgb: 178 140 240; }
}

/* support card */
.coffee { display: flex; gap: 14px; align-items: center; margin-top: 20px; padding: 12px 18px; max-width: 360px; color: var(--text); text-decoration: none; background: var(--mantle); border: 1px solid var(--surface1); border-radius: 14px; transition: border-color .2s; }
.coffee:hover, .coffee:focus-visible { border-color: var(--accent); }
.coffee-icon { font-size: 1.4rem; line-height: 1; }
.coffee-text { display: grid; gap: 2px; flex: 1; }
.coffee-text small { color: var(--muted); font-size: .8rem; }
.coffee-go { color: var(--accent); font-family: var(--mono); }
