/* Phones run current browsers: this sheet is never loaded by a screen (test/syntax.test.mjs skips it). */
body.phone { background: var(--field); overflow: auto; color: #fff; }
body.phone.playing, body.phone.ghost { overflow: hidden; background: var(--me); }
#app { min-height: 100%; }
.stack { padding: max(20px, env(safe-area-inset-top)) 18px 28px; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.stack h2.big { margin: 4px 0; font-family: KFuture, SG, sans-serif; font-weight: 400; font-size: 34px; line-height: 1.05; }
.lede { margin: 0; font-size: 19px; font-weight: 700; }
.hint { margin: 0; font-size: 15px; color: #dff7f4; }
.hint.big { font-size: 22px; font-weight: 700; color: #fff; }
.me { display: flex; align-items: center; gap: 12px; background: var(--me); border: 3px solid var(--ink); border-radius: 12px; padding: 10px 14px; box-shadow: 0 5px 0 var(--ink); }
.me .chip { font-size: 34px; --c: var(--me); }
.me .name { font-family: SG, sans-serif; font-weight: 700; font-size: 26px; background: none; border: 0; text-align: left; cursor: pointer; padding: 0; color: var(--ink); overflow-wrap: anywhere; }
.roster, .scores { display: flex; flex-direction: column; gap: 6px; }
.who, .srow { display: flex; align-items: center; gap: 10px; background: var(--ink); border-radius: 10px; padding: 8px 12px; border-left: 8px solid var(--c); font-size: 18px; }
.who .chip, .srow .chip { font-size: 22px; }
.who.bot b { color: #9fd8d2; font-weight: 500; }
.who.you, .srow.you { outline: 3px solid #fff; }
.srow b { flex: 1; }
.srow .k { font-weight: 700; font-size: 15px; }
.choice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.choice .lab { font-weight: 700; min-width: 110px; }
.seg { display: flex; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; box-shadow: 0 3px 0 var(--ink); }
.seg button { background: #fff; color: var(--ink); border: 0; border-right: 2px solid var(--ink); padding: 10px 14px; font-weight: 700; font-size: 16px; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--act); color: #fff; }
.full { color: #fff; font-size: 22px; padding: 40px 24px; font-weight: 700; }
.credits { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 40; background: rgba(13,34,54,.96); overflow: auto; }
.credits .inner { max-width: 560px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 20px 32px; color: #fff; display: flex; flex-direction: column; gap: 10px; }
.credits h2 { margin: 0 0 6px; font-family: KFuture, SG, sans-serif; font-weight: 400; font-size: 32px; }
.credits p { margin: 0; font-size: 15px; line-height: 1.35; }
.credits .btn { align-self: flex-start; margin-top: 10px; }
.shelf { padding: 10px 0 24px; }

/* ---- the pad: your tank's colour, stick left, buttons right ---------------------------------- */
.padtop { position: fixed; top: 0; left: 0; right: 0; height: 44px; padding: env(safe-area-inset-top) 16px 0; display: flex; align-items: center; gap: 12px; color: var(--ink); font-size: 18px; z-index: 3; }
.padtop .wins { font-size: 16px; }
.padtop .note { margin-left: auto; font-weight: 700; }
.padtop .note.warn { background: var(--ink); color: #fff; padding: 2px 10px; border-radius: 99px; }
.pad { position: fixed; top: 44px; left: 0; right: 0; height: calc(var(--h, 100vh) - 44px); display: flex; touch-action: none; }
.pad .stickzone { position: relative; flex: 1; touch-action: none; }
.pad .stickhint { position: absolute; left: 0; right: 0; top: 12%; text-align: center; color: var(--ink); font-weight: 700; font-size: 17px; opacity: 0.7; pointer-events: none; }
.pad .stickbase { position: absolute; left: 50%; top: 55%; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; border: 5px solid var(--ink); background: rgba(255,255,255,.22); opacity: 0.45; pointer-events: none; }
.pad .stickzone.held .stickbase { opacity: 1; }
.pad .stickbase::before { content: ""; position: absolute; left: 50%; top: 50%; width: 0; height: 0; margin: -14px 0 0 -10px; border: 10px solid transparent; border-bottom: 14px solid var(--ink); opacity: 0; }
.pad .stickbase.d0::before, .pad .stickbase.d1::before, .pad .stickbase.d2::before, .pad .stickbase.d3::before { opacity: 0.9; }
.pad .stickbase.d0::before { transform: translateY(-48px); }
.pad .stickbase.d1::before { transform: translateX(48px) rotate(90deg); }
.pad .stickbase.d2::before { transform: translateY(48px) rotate(180deg); }
.pad .stickbase.d3::before { transform: translateX(-48px) rotate(270deg); }
.pad .knob { position: absolute; left: 50%; top: 50%; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; background: var(--ink); }
.pad .buttons { position: relative; flex: 1; }
.pb { position: absolute; border: 5px solid var(--ink); background: #fff; color: var(--ink); font-family: KFuture, SG, sans-serif; font-size: 20px; border-radius: 50%; box-shadow: 0 6px 0 var(--ink); touch-action: none; display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 0; -webkit-user-select: none; user-select: none; }
.pb.down { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); }
.pb.off { visibility: hidden; }
.pb.fire { right: 6%; bottom: 10%; width: 40vmin; height: 40vmin; max-width: 190px; max-height: 190px; background: var(--act); color: #fff; font-size: 26px; }
.pb.drop { right: calc(6% + min(40vmin, 190px) + 14px); bottom: 10%; width: 24vmin; height: 24vmin; max-width: 118px; max-height: 118px; }
.pb.build { right: calc(6% + min(40vmin, 190px) + 14px); bottom: calc(10% + min(24vmin, 118px) + 18px); width: 24vmin; height: 24vmin; max-width: 118px; max-height: 118px; --ringc: var(--act); }
.pb.build .ring { position: absolute; top: -9px; left: -9px; right: -9px; bottom: -9px; border-radius: 50%; -webkit-mask: radial-gradient(circle, transparent 62%, #000 63%); mask: radial-gradient(circle, transparent 62%, #000 63%); }
.pb.special { right: 6%; bottom: calc(10% + min(40vmin, 190px) + 18px); width: 26vmin; height: 26vmin; max-width: 124px; max-height: 124px; background: var(--sun); }
.pb.special .count { position: absolute; top: -8px; right: -8px; background: var(--ink); color: #fff; border-radius: 99px; min-width: 30px; height: 30px; font: 700 18px SG, sans-serif; display: flex; align-items: center; justify-content: center; }
.pad.dead { opacity: 0.35; pointer-events: none; }
/* a laptop playing with keys: no on-screen buttons, the keys instead */
.pad.keys .stickzone, .pad.keys .buttons { visibility: hidden; }

/* the controls under the map, for the phone's own campaign and daily (portrait) */
.pad.bottom { position: relative; top: auto; height: 100%; }
.pad.bottom .pb.fire { width: 30vmin; height: 30vmin; right: 5%; bottom: 12%; }
.pad.bottom .pb.drop { width: 19vmin; height: 19vmin; right: calc(5% + 30vmin + 10px); bottom: 12%; }
.pad.bottom .pb.build { width: 19vmin; height: 19vmin; right: calc(5% + 30vmin + 10px); bottom: calc(12% + 19vmin + 14px); }
.pad.bottom .pb.special { width: 19vmin; height: 19vmin; right: 5%; bottom: calc(12% + 30vmin + 14px); }
.pad.bottom .stickbase { width: 120px; height: 120px; margin: -60px 0 0 -60px; }
.pad.bottom .knob { width: 56px; height: 56px; margin: -28px 0 0 -28px; }

/* ---- the ghost: the map, tap a cell ------------------------------------------------------------ */
.ghostwrap { padding: max(16px, env(safe-area-inset-top)) 12px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--ink); }
.ghostwrap h2 { margin: 0; font-family: KFuture, SG, sans-serif; font-weight: 400; font-size: 28px; }
.ghostwrap .hint { color: var(--ink); font-weight: 700; font-size: 18px; }
.ghostwrap canvas { border: 4px solid var(--ink); border-radius: 8px; opacity: 0.6; touch-action: none; }
.ghostwrap canvas.ready { opacity: 1; }
.ghostwrap .why { min-height: 1.4em; margin: 0; font-weight: 700; }

/* ---- the door: a live bot round behind the name, the daily and the campaign big ---------------- */
.door { min-height: 100%; display: grid; grid-template-columns: 100%; grid-template-areas: "hero" "side"; grid-template-rows: auto 1fr; padding: 0 0 20px; }
/* the bot round's page fills the whole window behind the door; its board plays in the hero */
.door .hero { grid-area: hero; position: relative; height: 52vh; min-height: 300px; }
.door .herobg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.door .side { position: relative; z-index: 1; }
.door .side > .hint, .door .doorbtns .hint, .door .side > .linkish { color: #fff; font-weight: 700; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.door > .wordmark { grid-area: hero; align-self: start; justify-self: center; position: relative; z-index: 1; width: 92%; max-width: 520px; margin-top: max(14px, env(safe-area-inset-top)); filter: drop-shadow(0 6px 0 rgba(13,34,54,.6)); pointer-events: none; }
.door .side { grid-area: side; display: flex; flex-direction: column; }
.door .doorbtns, .door .codeform, .door .side > .hint, .door .side > .linkish, .door .shelf { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; padding-left: 18px; padding-right: 18px; }
/* a laptop: the round fills the left, the name and the doors stand on the right */
@media (min-width: 900px) and (orientation: landscape) {
  .door { height: 100vh; min-height: 0; padding: 0; grid-template-columns: 1fr minmax(420px, 34vw); grid-template-areas: "hero mark" "hero side"; }
  .door .hero { height: 100vh; min-height: 0; overflow: hidden; border-right: 5px solid var(--ink); }
  .door .herobg { position: absolute; }
  .door .side { background: var(--field); }
  .door > .wordmark { grid-area: mark; width: 88%; margin-top: 4vh; }
  .door .side { overflow: auto; justify-content: center; padding-bottom: 2vh; }
}
.door .doorbtns { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.door .btn.daily { font-size: 30px; padding: 20px; }
.door .btn.daily b { font-family: KFuture, SG, sans-serif; font-weight: 400; }
.door .btn.campaign { font-size: 26px; background: var(--sun); }
.door .doorbtns .hint { margin: -2px 0 6px; }
.codeform { display: flex; gap: 10px; margin-top: 22px; }
.codeform input { flex: 1; min-width: 0; font-family: SG, sans-serif; font-weight: 700; font-size: 22px; letter-spacing: 0.16em; text-transform: uppercase; text-align: center; border: 3px solid var(--ink); border-radius: 10px; padding: 10px; color: var(--ink); }
.codeform input.bad { animation: shake 0.3s; }
.door .side > .hint { margin-top: 8px; }
.door .side > .linkish { align-self: center; width: auto; margin-top: 8px; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---- a level on the phone: top bar, the map, the pad -------------------------------------------- */
body.phone.level { overflow: hidden; background: var(--field2); }
.levelscreen { position: fixed; top: 0; left: 0; right: 0; height: var(--h, 100vh); display: flex; flex-direction: column; }
.lvtop { flex: none; min-height: calc(52px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0; display: flex; align-items: center; gap: 10px; background: var(--ink); color: #fff; }
.lvback, .lvrestart { background: #fff; color: var(--ink); border: 0; border-radius: 8px; font-weight: 700; padding: 7px 12px; font-size: 16px; cursor: pointer; }
.lvhead { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 4px 0; }
.lvtitle { font-family: KFuture, SG, sans-serif; font-weight: 400; font-size: 18px; line-height: 1.1; overflow-wrap: anywhere; }
.lvgoal { font-size: 14px; color: #cfeee9; line-height: 1.2; }
.lvback, .lvrestart, .lvtime { flex: none; }
.lvtime { font: 700 18px SG, sans-serif; color: var(--sun); min-width: 64px; text-align: right; }
.lvstage { flex: 2 1 0; position: relative; min-height: 0; }
.lvcanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; }
.lvctl { flex: 1 1 0; position: relative; min-height: 180px; background: var(--me); border-top: 4px solid var(--ink); }
.lvctl .pad { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
.lvkeys { flex: none; display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; padding: 10px; background: var(--ink); color: #fff; font-weight: 700; }
.lvkeys kbd { display: inline-block; background: #fff; color: var(--ink); border-radius: 6px; padding: 2px 8px; font: 700 15px SG, sans-serif; box-shadow: 0 3px 0 #6a8da0; }
.levelscreen.desk .lvctl { display: none; }
.levelscreen.desk .lvstage { flex: 1 1 0; }
@media (orientation: landscape) and (pointer: coarse) {
  .levelscreen { flex-direction: row; flex-wrap: wrap; }
  .lvtop { width: 100%; height: calc(44px + env(safe-area-inset-top)); }
  .lvhead { flex-direction: row; align-items: baseline; gap: 10px; }
  .levelscreen .lvctl, .levelscreen .lvctl .pad { display: contents; }
  .levelscreen .stickzone { order: 1; flex: 0 0 24%; height: calc(100% - 44px - env(safe-area-inset-top)); position: relative; background: var(--me); }
  .levelscreen .lvstage { order: 2; flex: 1 1 0; height: calc(100% - 44px - env(safe-area-inset-top)); }
  .levelscreen .buttons { order: 3; flex: 0 0 26%; height: calc(100% - 44px - env(safe-area-inset-top)); position: relative; background: var(--me); }
}
.lvover { position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 10; background: rgba(13,34,54,.72); display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.card { width: 100%; max-width: 460px; background: var(--field2); border: 4px solid var(--ink); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; color: #fff; box-shadow: 0 8px 0 var(--ink); margin: auto; }
.card h2 { margin: 0; font-size: 24px; line-height: 1.15; }
.card h2.big { font-family: KFuture, SG, sans-serif; font-weight: 400; font-size: 40px; text-align: center; }
.card .taunt { margin: 0; font-size: 17px; font-style: italic; color: #ffe9f3; }
.card .taunt b { font-style: normal; color: var(--sun); }
.card ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.card .starlist li { font-weight: 700; color: #9fd8d2; }
.card .starlist li.on, .card > .starlist:first-of-type li { color: var(--sun); }
.card.result .starlist li { color: #7fb7b1; }
.card.result .starlist li.on { color: var(--sun); }
.card .things li { font-size: 15px; color: #dff7f4; }
.card .things b { color: #fff; }
.card .stars { display: flex; justify-content: center; gap: 8px; font-size: 54px; }
.card .stars i { font-style: normal; color: rgba(255,255,255,.25); -webkit-text-stroke: 2px var(--ink); }
.card .stars i.on { color: var(--sun); animation: starpop 0.4s ease-out both; }
.card .stars i.on:nth-child(2) { animation-delay: 0.15s; } .card .stars i.on:nth-child(3) { animation-delay: 0.3s; }
@keyframes starpop { from { transform: scale(2); opacity: 0; } to { transform: none; opacity: 1; } }
.card .time { margin: 0; text-align: center; font: 700 40px SG, sans-serif; }
.card .row { display: flex; gap: 10px; }
.card .row .btn { flex: 1; }
.card .rank { margin: 0; font-weight: 700; font-size: 20px; color: var(--sun); }
.card .toplist { margin: 4px 0 0; padding: 0 0 0 4px; list-style: none; font-size: 15px; }
.card .toplist li.me { color: var(--sun); }

/* ---- the battle board ----------------------------------------------------------------------------- */
body.phone.board { background: var(--field); }
/* the header and tabs hold still; only the map scrolls, in its own box under them */
.boardscreen { position: fixed; top: 0; left: 0; right: 0; height: var(--h, 100vh); display: flex; flex-direction: column; }
.bscroll { flex: 1 1 0; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 40px; }
.bhead { flex: none; z-index: 5; display: flex; align-items: center; gap: 12px; padding: max(10px, env(safe-area-inset-top)) 12px 10px; background: var(--ink); }
.bhead h1 { flex: 1; margin: 0; font-family: KFuture, SG, sans-serif; font-weight: 400; font-size: 22px; color: #fff; }
.bstars { color: var(--sun); font-weight: 700; font-size: 18px; white-space: nowrap; }
.wtabs { flex: none; display: flex; gap: 6px; padding: 10px 12px; }
.wtabs button { flex: 1; background: var(--field2); color: #fff; border: 3px solid var(--ink); border-radius: 8px; padding: 8px 6px; font-weight: 700; font-size: 14px; }
.wtabs button.on { background: var(--sun); color: var(--ink); }
.wtabs button.shut { opacity: 0.5; }
.bmap { position: relative; margin: 0 auto; max-width: 560px; }
.bpath { position: absolute; top: 0; left: 0; pointer-events: none; }
.bpath path { fill: none; stroke: var(--field2); stroke-width: 10; stroke-dasharray: 2 16; stroke-linecap: round; }
.bpath path.lit { stroke: var(--sun); }
.bpath path.gate { stroke: #fff; opacity: 0.5; }
.node { position: absolute; width: 120px; padding: 0; background: none; border: 0; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.node .dio { width: 120px; height: 88px; border: 4px solid var(--ink); border-radius: 10px; background: var(--field2); box-shadow: 0 6px 0 var(--ink); filter: grayscale(0.85) brightness(0.7); }
.node.open .dio { filter: none; }
.node.open:not(.done) .dio { outline: 4px solid var(--act); animation: nodepulse 1.4s ease-in-out infinite; }
@keyframes nodepulse { 50% { outline-color: var(--sun); transform: translateY(-3px); } }
.node.boss { width: 150px; }
.node.boss .dio { width: 150px; height: 110px; border-color: var(--act); }
.node.bonus .dio { border-style: dashed; }
.node .nl { margin-top: 8px; display: flex; flex-direction: column; align-items: center; color: #fff; text-align: center; }
.node .nl b { font-size: 14px; line-height: 1.15; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.node .nl i { font-style: normal; color: var(--sun); font-size: 15px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.bnote { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; width: max-content; max-width: 90vw; opacity: 0; pointer-events: none; }
.bnote.show { animation: noteshow 2.6s ease both; }
@keyframes noteshow { 0% { opacity: 0; transform: translate(-50%, 10px); } 10%, 85% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
/* the story: the picture fills everything the words and the button do not need; the words box holds four lines on
   every panel so the picture and the button never move between panels */
.comic { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 0 0 max(14px, env(safe-area-inset-bottom)); }
.comic img { flex: 1; min-height: 0; width: 100%; object-fit: cover; display: block; border-bottom: 5px solid var(--ink); animation: comicin .35s ease-out both; }
.comic p { flex: none; margin: 0; padding: 0 16px; min-height: 4.6em; font-size: 20px; line-height: 1.15; font-weight: 700; color: #fff; }
.comic .btn { flex: none; width: auto; margin: 0 16px; }
@keyframes comicin { from { opacity: 0; transform: scale(1.04) } to { opacity: 1; transform: none } }
@media (orientation: landscape) {
  .comic { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 30vw, 460px); grid-template-rows: 1fr auto auto; gap: 18px 0; padding: 0; }
  .comic img { grid-column: 1; grid-row: 1 / 4; height: 100%; border-bottom: 0; border-right: 5px solid var(--ink); }
  .comic p { grid-column: 2; grid-row: 2; align-self: end; padding: 0 24px; font-size: clamp(20px, 2vw, 30px); }
  .comic .btn { grid-column: 2; grid-row: 3; margin: 0 24px max(24px, env(safe-area-inset-bottom)); }
}
