/* Deepwing: Colony. The moon fills the screen behind everything; the menu sits on a card. While
   playing (sideways on a phone, R12.2) the counts run along the top, the sidebar down the right,
   and the groups and the map sit at the bottom left (R12.3). */
:root {
  --kGlow1: rgba(0, 0, 0, .6);
  --kGlow2: rgba(0, 0, 0, .7);
  --kBg1: #10151e;
  --kBg2: #222c3b;
  --kBg3: #34425a;
  --kBg4: #0b0f16;
  --kBg5: rgba(14, 19, 28, .97);
  --kBg6: rgba(16, 22, 32, .66);
  --kBg7: rgba(16, 22, 32, .2);
  --kBg8: #33415a;
  --kBg9: #1b2431;
  --kBg10: rgba(0, 0, 0, .18);
  --kBg11: #1f2836;
  --kBg12: #3a4964;
  --kBg13: rgba(16, 22, 32, .82);
  --kBg14: rgba(16, 22, 32, .9);
  --kBg15: rgba(16, 22, 32, 0);
  --kBg16: rgba(16, 22, 32, .92);
  --kBg17: rgba(255, 255, 255, .12);
  --kBg19: rgba(0, 0, 0, .55);
  --kBg20: rgba(8, 11, 18, .5);
  --kInk1: #ffffff;
  --kInk2: #ffe27a;
  --kInk3: #99ff99;
  --kLine1: #222c3b;
  --kLine2: #ffd27a;
  --hotInk: #2a1a02;
  --bg: #141a24;
  --ink: #f3f6fb;
  --dim: #c4cddb;
  --card: rgba(18, 24, 34, .9);
  --line: rgba(255, 255, 255, .16);
  --hot: #ffb338;
  --good: #57d68d;
  --bad: #ff6b5b;
}

/* R-C40: the light look. This product's own is dark; the other is chosen with the switch beside Home. */
:root[data-theme="light"] {
  --kGlow1: rgba(255, 255, 255, .6);
  --kGlow2: rgba(255, 255, 255, .7);
  --kBg1: #dde4ee;
  --kBg2: #c9d3e1;
  --kBg3: #b4c1d3;
  --kBg4: #e9eef5;
  --kBg5: rgba(236, 241, 247, .98);
  --kBg6: rgba(236, 241, 247, .7);
  --kBg7: rgba(236, 241, 247, .2);
  --kBg8: #b6c4d8;
  --kBg9: #e3e9f1;
  --kBg10: rgba(255, 255, 255, .3);
  --kBg11: #d6dee9;
  --kBg12: #b6c4d8;
  --kBg13: rgba(236, 241, 247, .88);
  --kBg14: rgba(236, 241, 247, .92);
  --kBg15: rgba(236, 241, 247, 0);
  --kBg16: rgba(236, 241, 247, .94);
  --kBg17: rgba(20, 26, 36, .1);
  --kBg19: rgba(255, 255, 255, .7);
  --kBg20: rgba(220, 226, 236, .55);
  --kInk1: #10151e;
  --kInk2: #6b4a00;
  --kInk3: #075a07;
  --kLine1: #c9d3e1;
  --kLine2: #6b4a00;
  --hotInk: #ffffff;
  --bg: #eef2f7;
  --ink: #141a24;
  --dim: #3d4757;
  --card: rgba(240, 244, 249, .92);
  --line: rgba(13, 13, 13, .16);
  --hot: #a35f00;
  --good: #027a45;
  --bad: #c0284e;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none;
}
#app { display: flex; flex-direction: column; height: 100%; }

#hdr {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 6px;
  background: var(--kBg1); border-bottom: 1px solid var(--kLine1); position: relative; z-index: 5;
}
#hdrTitle { flex: 1 1 0; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; font-size: 15px; }
@media (max-width: 380px) { #hdrTitle { visibility: hidden; } }
/* R-C26: [hidden] loses to any display of our own */
[hidden] { display: none !important; }
.pill { min-width: 44px; min-height: 44px; border: 0; border-radius: 12px; background: var(--kBg2); color: var(--ink); font-size: 18px; cursor: pointer; }
.pill:active { background: var(--kBg3); }

#main { position: relative; flex: 1; min-height: 0; }
#stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; background: var(--kBg4); }
#cvs, #ovl { display: block; position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
/* R17 Max draws on a canvas of its own; the one not drawing is hidden but keeps its size */
#ovl { pointer-events: none; }
#glFail { position: absolute; inset: 20% 12% auto; padding: 14px; border-radius: 12px; z-index: 30; background: var(--kBg1); color: var(--ink); font-size: 14px; line-height: 1.5; }

.scr { display: none; position: absolute; inset: 0; overflow-y: auto; padding: 12px; }
.scr.on { display: block; }
#scr-play { padding: 0; overflow: hidden; pointer-events: none; }
#scr-how { background: var(--kBg5); }
#scr-how > * { max-width: 640px; margin-left: auto; margin-right: auto; }

/* the menu: words at the top, a card at the bottom, a level playing itself between */
#scr-menu { display: none; flex-direction: column; justify-content: space-between; }
#scr-menu.on { display: flex; }
#menuTop { max-width: 560px; width: 100%; margin: 0 auto; padding: 4px 10px 8px; border-radius: 16px;
           background: linear-gradient(var(--kBg6), var(--kBg7)); text-shadow: 0 1px 3px var(--kGlow1); }
h1 { font-size: 30px; margin: 4px 0 4px; }
.sub { color: var(--kInk1); font-size: 15px; line-height: 1.4; margin-bottom: 4px; max-width: 30em; }
#menuCard { max-width: 560px; width: 100%; margin: 12px auto 0; background: var(--card); border: 1px solid var(--line);
            border-radius: 18px; padding: 10px 12px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.stat { color: var(--dim); font-size: 13px; margin: 6px 2px 0; }
.goal { color: var(--dim); font-size: 13.5px; line-height: 1.4; margin: 4px 2px 2px; min-height: 18px; }
.big { display: block; width: 100%; min-height: 52px; margin: 8px 0; border: 1px solid var(--line); border-radius: 14px;
       background: var(--kBg2); color: var(--ink); font-size: 17px; font-weight: 600; cursor: pointer; }
.big.primary { background: var(--hot); border-color: var(--kLine2); color: var(--hotInk); }

.pickRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 2px 0 6px; }
.pick { min-width: 0; min-height: 66px; background: var(--kBg2); color: var(--ink); border: 2px solid transparent; border-radius: 14px;
        padding: 6px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 1px; text-align: center; }
.pick .te { font-size: 22px; }
.pick b { font-size: 14px; }
.pick small { color: var(--dim); font-size: 11px; }
.pick.sel { border-color: var(--hot); background: var(--kBg8); }
.modeRow { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 4px 0 6px; }
.mode { min-height: 46px; border-radius: 12px; border: 2px solid transparent; background: var(--kBg9); color: var(--dim); font-size: 14px; font-weight: 700; cursor: pointer; }
.mode.sel { border-color: var(--hot); color: var(--kInk1); background: var(--kBg8); }

.setNav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 4px; }
.setBtn { min-width: 52px; min-height: 44px; border-radius: 12px; border: 0; background: var(--kBg2); color: var(--ink); font-size: 18px; cursor: pointer; }
.setBtn:disabled { opacity: .3; cursor: default; }

#custom { margin: 8px 0 0; border: 1px solid var(--line); border-radius: 14px; background: var(--kBg10); }
#custom > summary { list-style: none; }
#custom > summary::-webkit-details-marker { display: none; }
#custom > summary::after { content: "▾"; margin-left: auto; color: var(--dim); }
#custom[open] > summary::after { content: "▴"; }
summary { min-height: 48px; display: flex; align-items: center; padding: 0 12px; cursor: pointer; font-weight: 600; }
.setBody { padding: 4px 12px 12px; }
.setRow { display: flex; align-items: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.setLbl { flex: 1 1 120px; font-size: 14px; }
.setNote { color: var(--dim); font-size: 12px; line-height: 1.4; }
.knob { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.knobBtn { min-height: 44px; min-width: 56px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg11); color: var(--dim); font-size: 13px; cursor: pointer; }
.knobBtn.on { background: var(--kBg12); color: var(--ink); border: 2px solid var(--hot); font-weight: 700; }

.card { background: var(--kBg9); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 8px 0; font-size: 14px; line-height: 1.5; }
.card h2 { font-size: 17px; margin: 0 0 4px; }

/* ---- playing ---------------------------------------------------------------------------- */
#scr-play .ovl, #scr-play .ovl *, #left, #left *, #side, #side *, #selLine, #selLine *, #btnSpeed { pointer-events: auto; }
#hud { position: absolute; top: 6px; left: 8px; right: 160px; flex-wrap: wrap; height: auto; height: 40px; display: flex; gap: 6px; align-items: center; pointer-events: none; }
/* R-G HUD: chips sized by a fixed track, never by their text, so nothing jumps */
.chip { background: var(--kBg13); color: var(--kInk1); border-radius: 14px; padding: 5px 10px; font-size: 16px; font-weight: 700;
        white-space: nowrap; overflow: hidden; min-width: 0; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
#chipRes { width: 92px; }
#chipFizz { width: 84px; }
#chipPower { width: 116px; }
#chipRoom { width: 112px; }
#chipFlags { width: 84px; }
#chipPower.short { color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
#chipRoom.full { color: var(--bad); }
.chipBtn { min-height: 44px; min-width: 72px; border: 1px solid var(--line); border-radius: 14px; background: var(--kBg13); color: var(--kInk1);
           font-size: 16px; font-weight: 700; cursor: pointer; padding: 0 10px; white-space: nowrap; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
#aimLine { position: absolute; left: 160px; right: 168px; top: 80px; text-align: center; font-size: 13.5px; font-weight: 700; color: var(--kInk1);
           text-shadow: 0 2px 5px var(--kGlow2); pointer-events: none; }
#coachLine { position: absolute; left: 160px; right: 168px; top: 52px; text-align: center; font-size: 15px; font-weight: 700; color: var(--kInk1);
             text-shadow: 0 2px 5px var(--kGlow2); pointer-events: none; }
#selLine { position: absolute; left: 156px; right: 168px; bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); display: flex; gap: 6px; align-items: center; justify-content: center;
           flex-wrap: wrap; font-size: 15px; font-weight: 700; color: var(--kInk1); }
#selLine span { background: var(--kBg13); border-radius: 12px; padding: 8px 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selBtn { min-width: 48px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--kBg2); color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; padding: 0 10px; }

/* the left: groups, the whole army, attack-move, add; the map under them */
#btnPower { width: 100%; font-size: 14px; font-weight: 700; white-space: nowrap; }
#btnPower.ready { background: var(--kBg12); box-shadow: inset 0 0 0 2px var(--hot); }
#left { position: absolute; left: calc(env(safe-area-inset-left, 0px) + 6px); bottom: calc(env(safe-area-inset-bottom, 0px) + 6px); width: 144px;
        display: flex; flex-direction: column; gap: 6px; }
.lgrid { display: grid; grid-template-columns: repeat(3, 44px); gap: 6px; }
.lb { min-width: 44px; min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--kBg13); color: var(--ink);
      font-size: 16px; font-weight: 700; cursor: pointer; padding: 0; white-space: nowrap; overflow: hidden; }
.lb.on { box-shadow: inset 0 0 0 3px var(--hot); }
.lb.kept { background: var(--kBg12); }
#mini { width: 144px; height: 144px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg4); touch-action: none; image-rendering: pixelated; }

/* the sidebar: two tabs, a grid of pictures, the tools */
/* the bottom keeps clear of the version chip in the corner (R-C8) */
#side { position: absolute; right: calc(env(safe-area-inset-right, 0px) + 6px); top: 6px; bottom: calc(env(safe-area-inset-bottom, 0px) + 48px); width: 152px;
        display: flex; flex-direction: column; gap: 6px; background: var(--kBg14); border: 1px solid var(--line); border-radius: 14px; padding: 6px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tab { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg11); color: var(--dim); font-size: 20px; cursor: pointer; }
.tab.on { background: var(--kBg12); border: 2px solid var(--hot); }
#sideList { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-content: start; }
.sbtn { position: relative; min-width: 0; min-height: 66px; border-radius: 12px; border: 1px solid var(--line); background: var(--kBg2); color: var(--ink);
        cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 3px 2px; overflow: hidden; }
.sbtn .si { font-size: 24px; line-height: 1.1; }
.sbtn .sn { font-size: 10.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.sbtn .sc { font-size: 10.5px; color: var(--dim); white-space: nowrap; }
.sbtn.off { opacity: .45; }
.sbtn.hint { box-shadow: inset 0 0 0 3px var(--hot); animation: glow 1.1s ease-in-out infinite alternate; }
.sbtn.ready { box-shadow: inset 0 0 0 3px var(--good); }
.sbtn.armed { background: var(--kBg12); box-shadow: inset 0 0 0 3px var(--kInk1); }
.sbtn .prog { position: absolute; left: 0; bottom: 0; height: 5px; background: var(--good); }
.sbtn .badge { position: absolute; right: 4px; top: 3px; font-size: 11px; color: var(--hot); }
@keyframes glow { from { background: var(--kBg2); } to { background: var(--kBg12); } }
#sideTools { display: grid; grid-template-columns: repeat(3, 44px); gap: 4px; justify-content: space-between; }
.tool { min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg11); color: var(--ink); font-size: 18px; cursor: pointer; padding: 0; }
.tool.on { box-shadow: inset 0 0 0 3px var(--hot); }
#fpsNow { position: absolute; left: 8px; top: 52px; background: var(--kBg19); color: var(--kInk3); font: 12px ui-monospace, monospace; padding: 3px 6px; border-radius: 6px; pointer-events: none; z-index: 4; }

.ovl { position: absolute; inset: 0; display: none; align-items: flex-start; justify-content: center; overflow-y: auto; background: var(--kBg20); padding: 12px; z-index: 10; }
.ovl.on { display: flex; }
#turnPhone { z-index: 12; background: var(--kBg5); }
.ovlCard { width: min(420px, 100%); margin: auto; background: var(--kBg9); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; text-align: center; }
.ovlCard h2 { margin: 4px 0 8px; font-size: 24px; }
.ovlCard p { color: var(--dim); font-size: 15px; line-height: 1.45; margin: 6px 0; }
.toast { background: var(--kBg14); color: var(--ink); padding: 10px 14px; border-radius: 12px; font-weight: 700; font-size: 15px; margin-bottom: 60px; border: 1px solid var(--line); }
.toast-host { position: fixed; left: 0; right: 0; bottom: 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 40; }
#moonName { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sideRow .mode { font-size: 16px; }
#foeRow { grid-template-columns: repeat(5, minmax(0, 1fr)); }
#foeRow .mode { font-size: 12.5px; padding: 0 2px; min-height: 46px; }
/* a phone on its side: the header slims, the menu words shrink, the cards put their buttons in a row */
@media (max-height: 480px) {
  #hdr { padding-top: calc(env(safe-area-inset-top, 0px) + 2px); padding-bottom: 2px; }
  .pill { min-height: 44px; }
  .ovlCard { padding: 10px 12px; }
  .ovlCard h2 { font-size: 19px; margin: 2px 0; }
  #over .big, #paused .big { display: inline-block; width: calc(33% - 8px); min-width: 120px; min-height: 46px; margin: 4px 2px; padding: 0 8px; font-size: 15px; }
  #paused .big { width: calc(50% - 8px); }
  #menuTop .sub { display: none; }
  h1 { font-size: 22px; }
  #mini { width: 96px; height: 96px; }
  /* R5.8 the big power beside the smaller map, so the column stays clear of the counts */
  #left { display: grid; grid-template-columns: 96px 44px; column-gap: 4px; row-gap: 6px; }
  #left .lgrid { grid-column: 1 / -1; grid-row: 1; }
  #mini { grid-column: 1; grid-row: 2; }
  #btnPower { grid-column: 2; grid-row: 2; width: 44px; min-height: 96px; font-size: 12px; white-space: normal; padding: 0 2px; line-height: 1.3; }
  .sbtn { min-height: 54px; }
  #sideList { gap: 5px; }
  .sbtn .sn { display: none; }
}
/* a narrow screen held upright (a tablet): the counts wrap under the header, the map shrinks */
@media (max-width: 560px) {
  #hud { right: 8px; top: 6px; flex-wrap: wrap; height: auto; }
  #side { top: 98px; width: 132px; }
  #sideTools { grid-template-columns: repeat(3, 38px); }
  .tool { min-width: 38px; }
}

/* R9.3 the map maker: the map on the left as big as the screen allows, the tools beside it */
#scr-make { background: var(--kBg5); }
#makeWrap { display: flex; gap: 12px; align-items: flex-start; max-width: 980px; margin: 0 auto; }
#makeCvs { width: min(calc(100vh - 96px), 58vw); height: min(calc(100vh - 96px), 58vw); flex: 0 0 auto; border-radius: 10px; border: 1px solid var(--line);
           touch-action: none; image-rendering: pixelated; background: var(--kBg4); }
#makeCvs { width: min(calc(100dvh - 96px), 58vw); height: min(calc(100dvh - 96px), 58vw); }
#makePanel { flex: 1 1 0; min-width: 0; }
#makeTools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#makeTools .mode { font-size: 13px; padding: 0 2px; min-height: 46px; }
#makeSay { font-size: 13.5px; margin: 8px 0; }
#mkCode, #mkOpenIn { width: 100%; min-height: 44px; font-size: 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--kBg9); color: var(--ink); padding: 0 10px; }
#scr-make .big { min-height: 46px; margin: 6px 0; font-size: 15px; }

/* R12.4 the field guide, and the line about what is picked */
#selLine span.about { flex-basis: 100%; white-space: normal; font-weight: 500; font-size: 13.5px; padding: 6px 12px; text-align: center; }
#guideTabs { margin: 6px 0 4px; }
#guideList { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); column-gap: 14px; }
#guideList h3 { grid-column: 1 / -1; font-size: 15px; margin: 12px 0 4px; }
.gcard { border-top: 1px solid var(--line); padding: 8px 0; min-width: 0; }
.gcard .gh { display: flex; align-items: baseline; gap: 8px; }
.gcard .gi { font-size: 22px; }
.gcard .gh small { margin-left: auto; font-variant-numeric: tabular-nums; opacity: 0.8; }
.gcard p { margin: 2px 0; }
.gcard .gm, .gcard .gv, .gcard .gj { font-size: 13px; }
#guide > h3 { font-size: 15px; margin: 14px 0 4px; }
.lgRow { display: flex; align-items: baseline; gap: 10px; padding: 4px 0; border-top: 1px solid var(--line); font-size: 13.5px; }
.lgRow .gi { min-width: 30px; text-align: center; font-size: 18px; }
