/* Drone Defense. The battlefield is the page. Text sits in the sky above the land, in the same
   thin-line language as the play field (Spin Defense's Night look). */

@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url(fonts/space-grotesk-700.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --font: "Space Grotesk", system-ui, sans-serif;
  --bg: #0b0d12;
  --ink: #e9e4d8;
  --dim: #8a8e9c;
  --line: rgba(233, 228, 216, 0.22);
  --panel: rgba(11, 13, 18, 0.9);
  --strike: #ffffff;
  --gutter: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ground: 30vh; /* set from JS: screen height of the land at the view's centre */
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--font); font-weight: 500; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; touch-action: none; user-select: none; -webkit-user-select: none; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.dim { color: var(--dim); }
.small { font-size: 13px; }

#app { position: fixed; inset: 0; height: 100dvh; }
#app.booting > :not(#gl) { visibility: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; aspect-ratio: auto; }

/* ---- HUD ------------------------------------------------------------------------------------ */
#hud { position: absolute; top: calc(var(--safe-t) + 8px); left: calc(var(--safe-l) + var(--gutter)); right: calc(var(--safe-r) + var(--gutter)); display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; transition: opacity 0.4s; }
#hudWave { display: flex; flex-direction: column; gap: 2px; }
#hWave { font-size: clamp(20px, 3.2vmin, 30px); font-weight: 700; letter-spacing: 0.01em; }
#hLeft { font-size: 13px; font-variant-numeric: tabular-nums; }
#hudPause { pointer-events: auto; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; border-radius: 6px; cursor: pointer; }
#app:not(.kb):not(.pad) #hudPause { display: grid; }
#app.kb #hudPause, #app.pad #hudPause { opacity: 0.6; }
#app:not([data-screen="play"]) #hud, #app:not([data-screen="play"]) #strike { opacity: 0; pointer-events: none; }
#app:not([data-screen="play"]) #hudPause { pointer-events: none; }

/* the strike meter, on the right edge */
#strike { position: absolute; right: calc(var(--safe-r) + 12px); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; transition: opacity 0.4s; }
#sBar { width: 6px; height: min(34vh, 220px); border-radius: 3px; background: rgba(233, 228, 216, 0.12); position: relative; overflow: hidden; }
#sFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: var(--strike); border-radius: 3px; }
#sCharges { display: flex; flex-direction: column; gap: 5px; }
#sCharges i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--strike); display: block; }
#sCharges i.on { background: var(--strike); box-shadow: 0 0 10px rgba(255, 255, 255, 0.55); }
#sLabel { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); writing-mode: vertical-rl; transform: rotate(180deg); }
#strike.deny #sBar { animation: deny 0.35s; }
@keyframes deny { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

#toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 56px); transform: translateX(-50%); font-size: clamp(16px, 2.6vmin, 22px); text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.4s; white-space: nowrap; }
#toast.on { opacity: 1; }
#toast b { font-weight: 700; }

/* ---- the offer --------------------------------------------------------------------------------- */
#offer { position: absolute; top: calc(var(--safe-t) + 10px); left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 var(--gutter); pointer-events: none; }
#offer > * { pointer-events: auto; }
#oHead { margin: 0; font-size: clamp(15px, 2.4vmin, 20px); text-align: center; }
#oHead b { font-weight: 700; }
#oHint { margin: 0; font-size: 14px; text-align: center; min-height: 1.3em; pointer-events: none; }
#cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.card { position: relative; display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; width: clamp(180px, 25vw, 260px); min-height: 64px; padding: 8px 12px 8px 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-align: left; }
.card canvas { grid-row: 1 / span 2; width: 44px; height: 44px; }
.card .name { font-size: 16px; line-height: 1.15; font-weight: 700; }
.card .line { font-size: 12.5px; line-height: 1.3; color: var(--dim); }
.card .cat { font-size: 10.5px; letter-spacing: 0.07em; text-transform: uppercase; color: var(--dim); font-weight: 500; margin-left: 6px; }
.card:hover, .card:focus-visible { border-color: var(--ink); outline: none; }
.card.picked { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.card.faded { opacity: 0.35; }
.card:disabled { opacity: 0.35; cursor: default; }
.card kbd { position: absolute; top: -9px; right: -7px; }
/* phones in landscape: short cards */
@media (max-height: 460px) {
  .card { width: clamp(150px, 27vw, 230px); min-height: 50px; grid-template-columns: 34px 1fr; padding: 5px 10px 5px 6px; }
  .card canvas { width: 34px; height: 34px; }
  .card .name { font-size: 14px; }
  .card .line { font-size: 11.5px; }
  #offer { gap: 6px; }
}

kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; font: 700 11px var(--font); color: var(--bg); background: var(--ink); border-radius: 4px; }
#app:not(.kb):not(.pad) kbd { display: none; }

/* ---- buttons ------------------------------------------------------------------------------------ */
.menu { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); }
.menu .row { display: flex; gap: 10px; flex-wrap: wrap; }
.menu .row > * { flex: 1 1 auto; min-width: 0; }
.menu button, .bar button, .opt, .ghost { min-height: 48px; padding: 0 16px; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; cursor: pointer; font-size: 16px; }
.menu button:hover, .opt:hover, .ghost:hover { border-color: var(--ink); }
button:focus-visible, .opt:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 700; }
button.link { border: 0; background: none; color: var(--dim); font-size: 13px; min-height: 44px; padding: 0 12px; cursor: pointer; }
button.link:hover { color: var(--ink); }

/* ---- screens ------------------------------------------------------------------------------------- */
.screen { position: absolute; inset: 0; }
#title, #over { pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: calc(var(--safe-t) + 18px) calc(var(--safe-r) + var(--gutter)) calc(var(--safe-b) + 12px) calc(var(--safe-l) + var(--gutter)); }
#title > *, #over > * { pointer-events: auto; }
.titleTop, .overTop { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; pointer-events: none; }
.titleBottom, .overBottom { display: flex; flex-direction: column; align-items: center; gap: 8px; }
#logo { margin: 0; font-size: clamp(36px, 8vmin, 72px); font-weight: 700; letter-spacing: -0.01em; line-height: 1; }
#tLine { margin: 0; font-size: clamp(14px, 2.2vmin, 18px); }
#tDaily, #tTurn { margin: 0; font-size: 14px; text-align: center; }
/* the land is the picture: menus sit in the sky. Landscape puts them beside the title. */
#title, #over { justify-content: flex-start; gap: 18px; }
@media (orientation: landscape) {
  #title { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .titleTop { align-items: flex-start; text-align: left; }
  .titleBottom { align-items: flex-end; }
  .titleBottom .menu { width: min(320px, 44vw); }
}

.panel { background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: calc(var(--safe-t) + 16px) var(--gutter) calc(var(--safe-b) + 16px); }
.panel h2 { margin: 0; font-size: 26px; }
.panel > p { max-width: 520px; text-align: center; line-height: 1.45; margin: 0; }
.panel.full { justify-content: flex-start; align-items: stretch; gap: 0; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.bar { display: flex; align-items: center; gap: 12px; padding: 10px var(--gutter); border-bottom: 1px solid var(--line); flex: none; }
.bar h2 { margin: 0; font-size: 20px; flex: 1; }
.bar [data-back] { min-width: 48px; padding: 0; font-size: 20px; }
.scroll { flex: 1; overflow-y: auto; padding: 8px var(--gutter) 24px; touch-action: pan-y; -webkit-overflow-scrolling: touch; user-select: text; }
.scroll h3 { font-size: 13px; color: var(--dim); font-weight: 500; letter-spacing: 0.06em; margin: 22px 0 4px; text-transform: uppercase; max-width: 720px; }

/* over */
#oFacts { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#oWaves { font-size: clamp(30px, 6vmin, 56px); font-weight: 700; line-height: 1; }
#oMeta { font-size: 14px; text-align: center; }
#oStatus { margin: 0; min-height: 1.2em; text-align: center; }
#oPost { display: flex; flex-direction: column; gap: 4px; width: min(360px, 100%); }
#oPost .row { display: flex; gap: 10px; }
#oName { flex: 1; min-width: 0; min-height: 44px; padding: 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 16px; user-select: text; }
#oRank { min-width: 96px; font-variant-numeric: tabular-nums; }
@media (orientation: landscape) {
  #over { flex-direction: row; justify-content: space-between; align-items: flex-start; }
  .overTop { align-items: flex-start; text-align: left; }
  .overBottom { align-items: flex-end; }
  #oFacts { align-items: flex-start; }
  #oMeta { text-align: left; }
  .overBottom .menu, #oPost { width: min(340px, 44vw); }
}

/* board */
#bList { list-style: none; margin: 0 auto; padding: 0; max-width: 560px; counter-reset: r; }
#bList li { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#bList li .n { color: var(--dim); }
#bList li .w { font-weight: 700; }
#bList li .x { grid-column: 2 / span 2; font-size: 12.5px; color: var(--dim); margin-top: -6px; }
#bList li.me { color: #fff; }
#bList li.me .n::after { content: " ●"; font-size: 9px; vertical-align: middle; }
#bEmpty { text-align: center; margin-top: 24px; }

/* guide */
.entry { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid var(--line); max-width: 720px; }
.entry canvas { width: 64px; height: 40px; }
.entry .what { font-size: 16px; font-weight: 700; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.entry .stat { font-size: 12px; color: var(--dim); font-weight: 500; font-variant-numeric: tabular-nums; }
.entry .why { font-size: 13.5px; color: var(--dim); line-height: 1.45; margin-top: 3px; }
.rule { max-width: 720px; font-size: 14px; line-height: 1.5; margin: 6px 0; }

/* settings */
.opt { display: flex; align-items: center; justify-content: space-between; width: 100%; max-width: 560px; margin: 0 auto; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 0; text-align: left; background: none; }
.opt .v { color: var(--dim); }

/* a city hit: the whole screen inverts for a single frame */
#app.invert { filter: invert(1); }

/* first runs: how to fire the strike, until you have */
#hint { position: absolute; left: 50%; top: calc(var(--safe-t) + 64px); transform: translateX(-50%); margin: 0; padding: 6px 12px; border-radius: 6px; background: rgba(11, 13, 18, 0.8); font-size: 15px; white-space: nowrap; pointer-events: none; animation: hintPulse 1.6s ease-in-out infinite; }
@keyframes hintPulse { 50% { opacity: 0.55; } }
#app:not([data-screen="play"]) #hint, #app.breather #hint { display: none; }
.bPlay { display: flex; justify-content: center; margin-top: 18px; }
.bPlay button { min-height: 48px; padding: 0 24px; border-radius: 6px; cursor: pointer; font-size: 16px; }

/* ---- matches ----------------------------------------------------------------------------------- */
.lobby { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.lobby > p { margin: 0; line-height: 1.5; }
.lobby input { min-height: 48px; padding: 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; font-size: 17px; user-select: text; }
.lobby .lrow { display: flex; gap: 10px; }
.lobby .lrow > * { flex: 1; min-height: 48px; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; cursor: pointer; font-size: 16px; }
.lobby .lrow > .primary { background: var(--ink); color: var(--bg); font-weight: 700; }
#lCode { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; flex: 0 0 140px !important; cursor: text !important; }
.code { font-size: 54px; font-weight: 700; letter-spacing: 0.2em; margin: 0 !important; user-select: text; }
#rPlayers { list-style: none; padding: 0; margin: 6px 0; }
#rPlayers li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
#rPlayers li .dim { font-size: 13px; }

#app:not(.mp) #mp { display: none; }
#app.mp #strike, #app.mp #hint { display: none !important; }
#mp { position: absolute; inset: 0; pointer-events: none; }
#mpPanels { position: absolute; right: calc(var(--safe-r) + 10px); top: 60px; bottom: 190px; overflow: hidden; width: var(--panelW, 300px); display: flex; flex-direction: column; gap: 10px; pointer-events: auto; }
.opp { position: relative; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--bg); cursor: crosshair; }
.opp canvas { display: block; width: 100%; aspect-ratio: 16 / 9; }
.opp .who { position: absolute; left: 8px; top: 6px; right: 8px; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; pointer-events: none; text-shadow: 0 1px 3px #0b0d12; }
.opp .who b { font-weight: 700; }
.opp .tags { position: absolute; left: 8px; bottom: 6px; display: flex; gap: 6px; font-size: 12px; pointer-events: none; }
.opp .tags span { padding: 1px 6px; border-radius: 4px; background: rgba(11, 13, 18, 0.8); }
.opp .tags .dog { color: #ffb347; }
.opp.target { border-color: #ff4d5e; box-shadow: 0 0 0 1px #ff4d5e; }
.opp.pickable { border-color: var(--ink); animation: hintPulse 1.2s ease-in-out infinite; }
.opp.out canvas { filter: grayscale(1) brightness(0.6); }
.opp.out .who b::after { content: " · out"; font-weight: 500; color: var(--dim); }
/* aiming: the target's board comes up big */
.opp.aim { position: fixed; left: 6vw; right: 6vw; top: 8vh; z-index: 30; border-color: #ff4d5e; box-shadow: 0 0 0 1px #ff4d5e, 0 0 0 100vmax rgba(11, 13, 18, 0.7); animation: none; }
.opp .mark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: #ff4d5e; box-shadow: 0 0 8px #ff4d5e; pointer-events: none; }
#attack { position: absolute; right: calc(var(--safe-r) + 10px); bottom: calc(var(--safe-b) + 10px); width: var(--panelW, 300px); display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); pointer-events: auto; }
.aTop { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
#aLabel { letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); font-size: 11px; }
#aCharges { display: flex; gap: 5px; }
#aCharges i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #ff4d5e; }
#aCharges i.on { background: #ff4d5e; box-shadow: 0 0 10px rgba(255, 77, 94, 0.6); }
#aBar { height: 6px; border-radius: 3px; background: rgba(233, 228, 216, 0.12); overflow: hidden; }
#aFill { display: block; height: 100%; width: 0; background: #ff4d5e; }
#aTypes { display: flex; gap: 6px; flex-wrap: wrap; }
#aTypes button { min-height: 30px; padding: 0 8px; border: 1px solid var(--line); background: transparent; border-radius: 5px; font-size: 12px; cursor: pointer; color: var(--dim); }
#aTypes button.on { border-color: #ff4d5e; color: var(--ink); }
#aSend { min-height: 40px; border: 1px solid #ff4d5e; background: transparent; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
#aSend:disabled { border-color: var(--line); color: var(--dim); cursor: default; font-weight: 500; }
#mpInfo { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 12px); margin: 0; font-size: 14px; color: var(--dim); white-space: nowrap; }
#mpInfo b { color: #ff4d5e; }
#aimHint { position: fixed; left: 50%; transform: translateX(-50%); top: calc(8vh - 38px); z-index: 31; margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; }
#app.mp #offer { right: calc(var(--panelW, 300px) + 20px); }
#oImg { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -42%); max-width: 96vw; max-height: 70vh; border-radius: 6px; }
#oRanking { list-style: none; padding: 0; margin: 6px 0 0; font-size: 15px; }
#oRanking li { padding: 2px 0; }
#oRanking li b { font-weight: 700; }

#app:not([data-screen="play"]):not([data-screen="paused"]) #hud { visibility: hidden; }

/* about */
.prose p { max-width: 640px; font-size: 15.5px; line-height: 1.6; margin: 0 0 14px; }
.prose b { font-weight: 700; }
.titleBottom .links { display: flex; gap: 4px; }

/* credits */
#cList p { margin: 0 0 14px; font-size: 14px; line-height: 1.45; max-width: 560px; }
#cList .k { display: block; font-size: 12px; color: var(--dim); letter-spacing: 0.05em; }
#cList a { color: inherit; }

/* key and pad prompts: never on touch */
#prompts { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 8px); display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--dim); pointer-events: none; flex-wrap: wrap; padding: 0 60px; }
#prompts span { display: inline-flex; align-items: center; gap: 6px; background: rgba(11, 13, 18, 0.7); padding: 2px 6px; border-radius: 4px; }
#app:not(.kb):not(.pad) #prompts { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* in a breather the offer's own header names the wave; the HUD label steps aside for it */
#app.breather #hudWave { visibility: hidden; }

/* the battlefield is landscape: a phone held upright gets asked to turn */
#rotate { display: none; position: absolute; inset: 0; background: var(--bg); flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 24px; z-index: 5; }
#rotate p { margin: 0; font-size: 18px; }
@media (orientation: portrait) and (pointer: coarse) {
  #app[data-screen="play"] #rotate, #app[data-screen="over"] #rotate { display: flex; }
}
/* facts over a bright drawing stay readable */
#over .overTop, #oStatus { text-shadow: 0 1px 3px #0b0d12, 0 0 12px #0b0d12, 0 0 24px #0b0d12; }

/* the breather's report: what got through, and what each launcher did */
#oReport { margin: -4px 0 0; font-size: 13.5px; text-align: center; max-width: 760px; line-height: 1.4; }
#oReport b { color: var(--ink); font-weight: 700; }
#oReport .leak { color: #ff4d5e; font-weight: 700; }
#badges { position: absolute; inset: 0; pointer-events: none; }
#badges span { position: absolute; transform: translate(-50%, -100%); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; padding: 1px 5px; border-radius: 4px; background: rgba(11, 13, 18, 0.78); line-height: 1.3; }
#badges span i { font-style: normal; color: #ff4d5e; margin-left: 5px; }
#badges span.zero { opacity: 0.55; }
#app:not(.breather) #badges { display: none; }

/* the breather has its own header and report; a message from the wave would only sit on them */
#app.breather #toast { display: none; }
