/* Thunder & Tide — a comic-book tower defence. The battlefield is one
   full-screen canvas; everything else floats over it: inked pills and
   chunky buttons with a hard comic shadow, parchment sheets by day and
   slate at night. The faction in play tints the accent (vikings rune blue,
   pirates crimson). Light and dark follow the system unless the player
   picks one (html[data-theme]). */

:root {
  color-scheme: light;
  --bg: #f3e9d2;
  --ink: #2a1d14;
  --muted: #6e5a46;
  --paper: #fffaf0;
  --paper-2: #f2e6cc;
  --line: rgba(70, 45, 20, 0.16);
  --outline: #20140f;
  --accent: #2f6fd0;
  --accent-2: #1d4c9c;
  --accent-soft: rgba(47, 111, 208, 0.14);
  --ca-accent: #2f63b0; /* the accounts SDK's sheets and chip (white on it 6:1) */
  --gold: #f2c33a;
  --danger: #d23b32;
  --pill: rgba(24, 16, 12, 0.78);
  --pill-ink: #fff7e6;
  --shadow: 0 14px 34px -14px rgba(40, 20, 0, 0.45), 0 2px 6px -2px rgba(40, 20, 0, 0.2);
  --backdrop: rgba(30, 18, 8, 0.42);
  --screen: linear-gradient(180deg, rgba(243, 233, 210, 0.2) 0%, rgba(243, 233, 210, 0.55) 55%, rgba(243, 233, 210, 0.82) 100%);
  --panel: rgba(255, 250, 240, 0.9);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --comic: "Arial Black", "Avenir Next Condensed", "Avenir Next", Impact, ui-rounded, system-ui, sans-serif;
  --ease-out: cubic-bezier(0.2, 0.9, 0.25, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15182a;
    --ink: #f3ecdf;
    --muted: #b9b0a0;
    --paper: #1f2338;
    --paper-2: #2a2f4a;
    --line: rgba(255, 255, 255, 0.12);
    --accent-soft: rgba(120, 170, 255, 0.16);
    --shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.75), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
    --backdrop: rgba(4, 6, 16, 0.6);
    --screen: linear-gradient(180deg, rgba(14, 16, 32, 0.25) 0%, rgba(14, 16, 32, 0.6) 55%, rgba(14, 16, 32, 0.86) 100%);
    --panel: rgba(31, 35, 56, 0.9);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15182a;
  --ink: #f3ecdf;
  --muted: #b9b0a0;
  --paper: #1f2338;
  --paper-2: #2a2f4a;
  --line: rgba(255, 255, 255, 0.12);
  --accent-soft: rgba(120, 170, 255, 0.16);
  --shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.75), 0 2px 6px -2px rgba(0, 0, 0, 0.4);
  --backdrop: rgba(4, 6, 16, 0.6);
  --screen: linear-gradient(180deg, rgba(14, 16, 32, 0.25) 0%, rgba(14, 16, 32, 0.6) 55%, rgba(14, 16, 32, 0.86) 100%);
  --panel: rgba(31, 35, 56, 0.9);
}
body[data-faction="pirates"] { --accent: #c8343c; --accent-2: #8e1f27; --accent-soft: rgba(200, 52, 60, 0.14); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.center { text-align: center; }
[hidden] { display: none !important; }
i[data-icon] { display: inline-grid; place-items: center; font-style: normal; }
i[data-icon] svg { width: 100%; height: 100%; display: block; }

/* ------------------------------------------------------------ the field */
.stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.plots { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.plot-btn {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--w, 56px);
  height: var(--h, 56px);
  transform: translate(calc(var(--x) - 50%), calc(var(--y) - 50%));
  border: 0;
  border-radius: 50%;
  background: transparent;
  pointer-events: auto;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}
.plot-btn.tower { border-radius: 40%; }
.plot-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: -2px; background: rgba(255, 226, 122, 0.16); }
body:not(.mode-battle) .plots, body:not(.mode-battle) .ring, body:not(.mode-battle) .card { display: none; }

/* --------------------------------------------------------- the top bar */
.bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 8px calc(10px + env(safe-area-inset-left));
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.hud { display: flex; gap: 6px; min-width: 0; }
body:not(.mode-battle) .hud { display: none; }
.brand { display: none; font: 900 19px/1 var(--comic); letter-spacing: 0.01em; color: #fff; -webkit-text-stroke: 1.2px var(--outline); paint-order: stroke fill; text-shadow: 0 2px 0 var(--outline); }
.brand-amp { color: var(--gold); margin: 0 3px; }
body.mode-camp .brand { display: block; }
.bar-tools { display: flex; align-items: center; gap: 6px; flex: none; margin-left: auto; }
body.mode-battle .menu-only { display: none; }
body:not(.mode-battle) .battle-only { display: none; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 11px 0 6px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--pill-ink);
  border: 2px solid var(--outline);
  box-shadow: 0 3px 0 rgba(20, 12, 8, 0.55);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill i[data-icon] { width: 22px; height: 22px; }
.pill b { font-size: 16px; min-width: 1.2em; }
.pill.bump { animation: bump 0.35s var(--spring); }
.pill.hurt { animation: hurt 0.5s ease; }
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  grid-auto-flow: column;
  gap: 2px;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  border-radius: 14px;
  border: 2px solid var(--outline);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--outline);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.icon-btn i[data-icon] { width: 22px; height: 22px; }
.icon-btn b { font-size: 13px; font-weight: 900; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.chip-slot { min-width: 40px; display: grid; place-items: center; }

/* ----------------------------------------------------------- the dock */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 8px calc(12px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  pointer-events: none;
}
.dock > * { pointer-events: auto; }
body:not(.mode-battle) .dock { display: none; }
.powers { display: flex; gap: 10px; }
.dock-right { display: flex; align-items: flex-end; gap: 8px; }
.speed-btn { height: 46px; min-width: 52px; border-radius: 16px; }
.speed-btn b { font-size: 14px; }
.power {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2.5px solid var(--outline);
  background: radial-gradient(circle at 35% 30%, #fffaf0, #e8d8b8);
  box-shadow: 0 4px 0 var(--outline), inset 0 -4px 0 rgba(0, 0, 0, 0.1);
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.power i[data-icon] { width: 34px; height: 34px; transition: filter 0.2s ease, opacity 0.2s ease; }
.power::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  background: conic-gradient(rgba(20, 12, 8, 0.62) calc(var(--cd, 0) * 1turn), transparent 0);
  pointer-events: none;
}
.power .cd { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 900 17px var(--comic); -webkit-text-stroke: 1px var(--outline); paint-order: stroke fill; z-index: 1; }
.power.cooling i[data-icon] { filter: grayscale(0.85); opacity: 0.7; }
.power.ready { animation: ready 0.5s var(--spring); }
.power.armed { box-shadow: 0 4px 0 var(--outline), 0 0 0 4px var(--gold), 0 0 18px 6px rgba(255, 210, 60, 0.6); transform: translateY(-3px); }
.power:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.wave-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 18px 0 12px;
  border-radius: 20px;
  border: 2.5px solid var(--outline);
  background: linear-gradient(180deg, #ffd860, #f0a92a);
  color: #2a1606;
  box-shadow: 0 4px 0 var(--outline);
  font-weight: 900;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s ease;
}
.wave-btn i[data-icon] { width: 30px; height: 30px; }
.wave-txt { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.wave-txt b { font: 900 17px/1.05 var(--comic); letter-spacing: 0.01em; }
.wave-txt small { font-size: 12.5px; font-weight: 800; opacity: 0.85; }
.wave-btn.go { animation: pulse 1.4s ease-in-out infinite; }
.wave-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.wave-btn.gone { opacity: 0; pointer-events: none; }

/* ------------------------------------------------- the build and tower ring */
.ring { position: fixed; left: 0; top: 0; z-index: 6; width: 0; height: 0; transform: translate(var(--x), var(--y)); }
.ring .opt {
  position: absolute;
  left: 0;
  top: 0;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  border: 2.5px solid var(--outline);
  background: radial-gradient(circle at 35% 30%, #fffaf0, #e9d7b2);
  box-shadow: 0 4px 0 var(--outline);
  transform: translate(var(--ox), var(--oy)) scale(1);
  animation: opt-in 0.26s var(--spring) both;
  animation-delay: var(--d, 0s);
  display: grid;
  place-items: center;
  padding: 0;
}
.ring .opt canvas { width: 46px; height: 46px; display: block; }
.ring .opt i[data-icon] { width: 30px; height: 30px; }
.ring .opt .price {
  position: absolute;
  bottom: -13px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 21px;
  padding: 0 7px 0 3px;
  border-radius: 999px;
  background: var(--pill);
  color: #ffe27a;
  border: 1.5px solid var(--outline);
  font-size: 12.5px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ring .opt .price i[data-icon] { width: 15px; height: 15px; }
.ring .opt.poor .price { color: #ff9a8a; }
.ring .opt.poor canvas, .ring .opt.poor > i[data-icon] { filter: grayscale(0.7); opacity: 0.65; }
.ring .opt.armed { box-shadow: 0 4px 0 var(--outline), 0 0 0 4px var(--gold), 0 0 16px 4px rgba(255, 210, 60, 0.6); }
.ring .opt.armed::after {
  content: "";
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--outline);
  background: #5fd35a url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='%23fff' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.ring .hub {
  position: absolute;
  left: 0;
  top: 0;
  width: 92px;
  height: 92px;
  margin: -46px 0 0 -46px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.85);
  pointer-events: none;
  animation: hub-in 0.24s var(--ease-out) both;
}
.card {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 7;
  width: min(270px, calc(100vw - 24px));
  transform: translate(var(--x), var(--y));
  padding: 10px 12px 11px;
  border-radius: 16px;
  border: 2.5px solid var(--outline);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--outline), var(--shadow);
  pointer-events: none;
  animation: card-in 0.2s var(--ease-out);
}
.card h4 { margin: 0; font: 900 16px/1.15 var(--comic); letter-spacing: 0.005em; }
.card .tier { color: var(--accent); }
.card p { margin: 4px 0 6px; font-size: 13.5px; line-height: 1.35; color: var(--muted); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 999px; background: var(--paper-2); font-size: 12.5px; font-weight: 800; color: var(--ink); }
.chip.up { background: rgba(95, 211, 90, 0.22); }
.hint {
  position: fixed;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top));
  z-index: 6;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--pill);
  color: var(--pill-ink);
  border: 2px solid var(--outline);
  font-weight: 800;
  font-size: 14.5px;
  white-space: nowrap;
  pointer-events: none;
  animation: rise 0.25s var(--ease-out);
}

/* ------------------------------------------------------------ screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--screen);
  padding: calc(60px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  animation: fade 0.35s ease;
}
.home-inner, .camp-inner { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
.logo {
  margin: 4px 0 0;
  font: 900 clamp(44px, 12vw, 92px)/0.92 var(--comic);
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-align: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 0.18em;
  -webkit-text-stroke: clamp(2px, 0.6vw, 4px) var(--outline);
  paint-order: stroke fill;
  filter: drop-shadow(0 5px 0 var(--outline));
  animation: logo-in 0.7s var(--spring) both;
}
.logo-a { color: #9fe8ff; background: linear-gradient(180deg, #e8fbff 10%, #5fc8ff 60%, #2f6fd0); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.logo-amp { color: var(--gold); -webkit-text-fill-color: var(--gold); font-size: 0.72em; }
.logo-b { color: #ffb64a; background: linear-gradient(180deg, #fff2c8 10%, #ffb64a 55%, #c8343c); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
/* a comic narration box */
.tagline { margin: 14px 0 0; max-width: 52ch; padding: 8px 14px; text-align: center; font-weight: 750; font-size: 15px; line-height: 1.35; color: #2a1d14; background: #fff3c4; border: 2.5px solid var(--outline); border-radius: 6px; box-shadow: 0 4px 0 var(--outline); transform: rotate(-0.6deg); }
.choose { margin: 18px 0 10px; padding: 4px 14px; font: 900 16px var(--comic); letter-spacing: 0.06em; text-transform: uppercase; color: #fff; background: var(--outline); border-radius: 999px; }
.sides { display: grid; grid-template-columns: 1fr; gap: 14px; width: 100%; max-width: 760px; }
@media (min-width: 640px) { .sides { grid-template-columns: 1fr 1fr; } }
.side {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border-radius: 22px;
  border: 3px solid var(--outline);
  background: var(--panel);
  box-shadow: 0 6px 0 var(--outline), var(--shadow);
  overflow: hidden;
  animation: card-up 0.5s var(--ease-out) both;
}
.side[data-faction="pirates"] { animation-delay: 0.08s; }
.side::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: linear-gradient(90deg, #5fc8ff, #2f6fd0); }
.side[data-faction="pirates"]::before { background: linear-gradient(90deg, #ffb64a, #c8343c); }
.side-art { flex: none; width: 104px; height: 128px; align-self: center; }
.side-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.side h3 { margin: 4px 0 2px; font: 900 24px/1 var(--comic); letter-spacing: 0.01em; }
.side-d { margin: 0; font-size: 14px; color: var(--muted); font-weight: 600; line-height: 1.35; }
.side-stat { margin: 6px 0 8px; font-size: 13.5px; font-weight: 800; color: var(--ink); }
.side-actions { margin-top: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.home-links { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 15px;
  border: 2.5px solid var(--outline);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 4px 0 var(--outline);
  font-weight: 850;
  font-size: 15.5px;
  white-space: nowrap;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.15s ease;
}
.btn i[data-icon] { width: 22px; height: 22px; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--outline); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: 0 4px 0 var(--outline); }
.btn.primary { background: linear-gradient(180deg, #6fa6ff, var(--accent) 55%, var(--accent-2)); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }
body[data-faction="pirates"] .btn.primary, .side[data-faction="pirates"] .btn.primary { background: linear-gradient(180deg, #f07a78, #c8343c 55%, #8e1f27); }
.side[data-faction="vikings"] .btn.primary { background: linear-gradient(180deg, #6fa6ff, #2f6fd0 55%, #1d4c9c); }
.btn.danger { background: linear-gradient(180deg, #ff8a7a, #d23b32 60%, #9a2620); color: #fff; }
.btn.ghost { background: var(--paper-2); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 13.5px; border-radius: 12px; }
.btn.big { min-height: 58px; padding: 0 26px; font: 900 19px var(--comic); letter-spacing: 0.02em; }
.btn.big i[data-icon] { width: 28px; height: 28px; }
.btn.wide { width: 100%; margin-top: 10px; }
.link-btn { border: 0; background: none; padding: 8px; color: var(--accent); font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #2a1606; border: 2px solid var(--outline); font-size: 12px; font-weight: 900; display: inline-grid; place-items: center; }
.row-btns { display: flex; gap: 10px; margin-top: 10px; }
.row-btns .btn { flex: 1; }

/* --------------------------------------------------------- the campaign */
.camp-head { display: flex; align-items: center; gap: 12px; width: 100%; }
.camp-head h2 { margin: 0; font: 900 clamp(22px, 5.5vw, 32px)/1.05 var(--comic); letter-spacing: 0.01em; -webkit-text-stroke: 1.5px var(--outline); paint-order: stroke fill; color: #fff; text-shadow: 0 3px 0 var(--outline); }
.camp-stats { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; align-self: flex-start; }
.route {
  list-style: none;
  margin: 10px 0 4px;
  padding: 18px 14px 14px;
  width: 100%;
  display: flex;
  gap: 18px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  border-radius: 22px;
  border: 3px solid var(--outline);
  background: var(--panel);
  box-shadow: 0 6px 0 var(--outline);
}
.route::-webkit-scrollbar { display: none; }
.route li { position: relative; flex: none; scroll-snap-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 52px; }
.route li + li::before { content: ""; position: absolute; top: 25px; right: calc(100% + 1px); width: 18px; border-top: 3px dotted var(--muted); }
.node {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2.5px solid var(--outline);
  background: var(--paper-2);
  color: var(--muted);
  font: 900 18px var(--comic);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 0 var(--outline);
  padding: 0;
  cursor: default;
}
.node i[data-icon] { width: 24px; height: 24px; }
.node.done { background: linear-gradient(180deg, #ffe48a, #f0b53a); color: #3a2206; }
.node.now { background: linear-gradient(180deg, #6fa6ff, var(--accent)); color: #fff; -webkit-text-stroke: 1px var(--outline); paint-order: stroke fill; animation: pulse 1.6s ease-in-out infinite; }
body[data-faction="pirates"] .node.now { background: linear-gradient(180deg, #f07a78, var(--accent)); }
.node.locked { opacity: 0.55; }
.node-stars { display: flex; gap: 1px; height: 13px; }
.node-stars i[data-icon] { width: 13px; height: 13px; color: var(--gold); }
.node-stars i.off { color: var(--line); }
.next {
  width: 100%;
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 22px;
  border: 3px solid var(--outline);
  background: var(--panel);
  box-shadow: 0 6px 0 var(--outline);
}
.next-k { margin: 0; font-size: 12.5px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.next h3 { margin: 2px 0 8px; font: 900 22px/1.1 var(--comic); letter-spacing: 0.01em; }
.next-raiders { display: flex; gap: 6px; flex-wrap: wrap; }
.raider { display: inline-flex; flex-direction: column; align-items: center; width: 62px; font-size: 11px; font-weight: 800; color: var(--muted); text-align: center; line-height: 1.15; }
.raider canvas { width: 46px; height: 46px; }
.raider.new { color: var(--danger); }
.next-reward { margin: 10px 0 0; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.next-reward canvas, .next-reward i[data-icon] { width: 38px; height: 38px; flex: none; }
.camp-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; width: 100%; }
.camp-actions .btn.big { flex: 1 1 220px; max-width: 360px; }

/* -------------------------------------------------------------- sheets */
.sheet {
  border: 3px solid var(--outline);
  border-bottom: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 560px;
  max-height: min(90dvh, 880px);
  border-radius: 26px 26px 0 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 -20px 60px -20px rgba(24, 14, 6, 0.55);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sheet:not([open]) { display: none; }
.sheet[open] { animation: sheet-up 0.36s var(--ease-out); }
.sheet.closing { animation: sheet-down 0.24s ease forwards; }
.sheet::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.sheet[open]::backdrop { animation: fade 0.3s ease; }
@media (min-width: 720px) and (min-height: 600px) {
  .sheet { margin: auto; border-radius: 26px; border-bottom: 3px solid var(--outline); box-shadow: 0 7px 0 var(--outline), 0 30px 80px -30px rgba(24, 14, 6, 0.55); }
  .sheet[open] { animation: sheet-pop 0.32s var(--spring); }
  .sheet.closing { animation: sheet-out 0.2s ease forwards; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 8px 20px; }
.sheet-head h2 { margin: 0; flex: 1; font: 900 22px/1.1 var(--comic); letter-spacing: 0.01em; }
.close { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 2.5px solid var(--outline); display: grid; place-items: center; background: var(--paper-2); color: var(--ink); box-shadow: 0 3px 0 var(--outline); padding: 0; }
.close i[data-icon] { width: 20px; height: 20px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 4px 20px calc(22px + env(safe-area-inset-bottom)); }
.small-sheet { max-width: 420px; padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); }
.small-sheet p { margin: 0 0 8px; font-weight: 700; font-size: 16.5px; }
.toggles { display: flex; gap: 8px; margin: 6px 0 4px; }
.toggle { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border-radius: 13px; border: 2px solid var(--line); background: var(--paper-2); font-weight: 800; color: var(--muted); }
.toggle i[data-icon] { width: 20px; height: 20px; }
.toggle[aria-pressed="true"] { border-color: var(--outline); color: var(--ink); background: var(--accent-soft); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 56px; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 700; }
.row.last { border-bottom: 0; }
.row select { min-height: 40px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--outline); background: var(--paper-2); font-weight: 700; }
.version { color: var(--muted); font-size: 13px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; position: relative; width: 52px; height: 31px; margin: 0; border-radius: 999px; border: 2px solid var(--outline); background: var(--paper-2); transition: background 0.2s ease; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 23px; height: 23px; border-radius: 50%; border: 2px solid var(--outline); background: #fff; transition: transform 0.24s var(--spring); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(21px); }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 13px; background: var(--paper-2); border: 2px solid var(--outline); }
.seg button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; font-weight: 800; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: 0 2px 0 var(--outline); }
.seg.small button { padding: 0 10px; font-size: 13px; }
.armory-seg { margin: 0 20px 8px; align-self: flex-start; }

/* the war council */
.glory-pill { flex: none; }
.ups { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
@media (min-width: 520px) { .ups { grid-template-columns: 1fr 1fr; } }
.up { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 16px; border: 2px solid var(--line); background: var(--paper-2); }
.up > i[data-icon] { flex: none; width: 40px; height: 40px; }
.up-body { flex: 1; min-width: 0; }
.up h4 { margin: 0; font-size: 15px; font-weight: 900; }
.up p { margin: 1px 0 4px; font-size: 12.5px; color: var(--muted); font-weight: 600; line-height: 1.3; }
.pips { display: flex; gap: 3px; flex-wrap: wrap; }
.pips i { width: 12px; height: 6px; border-radius: 3px; background: var(--line); }
.pips i.on { background: var(--accent); }
.up .btn { flex: none; min-height: 40px; padding: 0 10px; font-size: 14.5px; }
.up .btn i[data-icon] { width: 18px; height: 18px; }
.up.flash { animation: bought 0.6s ease; }

/* the result */
.result { text-align: center; padding: 22px 20px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; }
.result h2 { margin: 6px 0 4px; font: 900 34px/1 var(--comic); letter-spacing: 0.01em; -webkit-text-stroke: 1.5px var(--outline); paint-order: stroke fill; color: var(--gold); text-shadow: 0 3px 0 var(--outline); }
.result.lost h2 { color: #ff8a7a; }
.result-stars { display: flex; justify-content: center; gap: 4px; height: 52px; }
.result-stars i[data-icon] { width: 48px; height: 48px; color: var(--line); }
.result-stars i.on { color: var(--gold); animation: star-pop 0.5s var(--spring) both; }
.result-stars i.on:nth-child(2) { animation-delay: 0.18s; }
.result-stars i.on:nth-child(3) { animation-delay: 0.36s; }
.result.lost .result-stars { display: none; }
.result-line { margin: 4px 0 0; font-weight: 900; font-size: 18px; }
.result-sub { margin: 2px 0 0; font-weight: 700; }
.unlocks { margin: 14px 0 0; }
.unlocks h3, .friends h3 { margin: 0 0 8px; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.unlock-list { display: grid; gap: 8px; }
.unlock { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; border-radius: 16px; border: 2.5px solid var(--outline); background: linear-gradient(180deg, #fff6d6, #ffe7a0); color: #2a1606; box-shadow: 0 4px 0 var(--outline); animation: unlock-in 0.7s var(--spring) both; animation-delay: 0.5s; }
.unlock canvas, .unlock i[data-icon] { flex: none; width: 52px; height: 52px; }
.unlock b { display: block; font-size: 16px; font-weight: 900; }
.unlock span { font-size: 13px; font-weight: 650; color: #6a4a26; }
.friends { margin-top: 14px; text-align: left; }
.friends-board { min-height: 44px; }
.result-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.result-actions .btn { flex: 1 1 140px; }

/* the armory and help */
.arm-h { margin: 14px 0 8px; font-size: 13px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.arm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.arm { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: 14px; background: var(--paper-2); border: 2px solid var(--line); }
.arm canvas, .arm > i[data-icon] { flex: none; width: 46px; height: 46px; }
.arm b { display: block; font-size: 14px; font-weight: 900; line-height: 1.15; }
.arm span { display: block; font-size: 12px; color: var(--muted); font-weight: 650; line-height: 1.25; }
.arm.locked canvas, .arm.locked > i[data-icon] { filter: brightness(0) opacity(0.35); }
.arm.locked b { color: var(--muted); }
.help .rule { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.help .rule > i[data-icon] { flex: none; width: 34px; height: 34px; margin-top: 2px; }
.help .rule h3 { margin: 0 0 2px; font-size: 16px; font-weight: 900; }
.help .rule p { margin: 0; font-size: 14.5px; color: var(--muted); font-weight: 600; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 9; transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 14px; background: var(--pill); color: var(--pill-ink); border: 2px solid var(--outline); font-weight: 800; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; text-align: center; }
.toast.on { opacity: 1; animation: rise 0.3s var(--ease-out); }

/* ------------------------------------- phones held sideways: rails, not bars */
@media (orientation: landscape) and (max-height: 560px) {
  .bar { align-items: flex-start; padding-top: calc(6px + env(safe-area-inset-top)); }
  body.mode-battle .hud { flex-direction: column; align-items: flex-start; }
  body.mode-battle .bar-tools { flex-direction: column; }
  .dock { left: auto; flex-direction: column-reverse; align-items: flex-end; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .dock-right { flex-direction: column; align-items: flex-end; }
  .powers { flex-direction: column; }
  .power { width: 54px; height: 54px; }
  .power i[data-icon] { width: 30px; height: 30px; }
  .wave-btn { min-height: 50px; padding: 0 12px 0 8px; }
  .wave-txt small { display: none; }
  .screen { padding-top: calc(54px + env(safe-area-inset-top)); }
  .logo { font-size: clamp(34px, 8vh, 60px); }
  .choose { margin: 12px 0 8px; }
  .side-art { width: 80px; height: 100px; }
}
@media (max-width: 480px) {
  .side { padding: 10px; gap: 8px; }
  .side-art { width: 78px; height: 100px; }
  .side h3 { font-size: 21px; }
  .side-d { font-size: 13px; }
  .side-stat { font-size: 12.5px; margin: 4px 0 6px; }
  .tagline { font-size: 14px; }
}
@media (max-width: 370px) {
  .pill { padding: 0 8px 0 4px; height: 32px; }
  .pill b { font-size: 14.5px; }
  .icon-btn { min-width: 36px; height: 36px; padding: 0 6px; }
  .power { width: 54px; height: 54px; }
}

/* ----------------------------------------------------------- motion */
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
@keyframes sheet-pop { from { transform: translateY(16px) scale(0.94); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes sheet-out { to { transform: translateY(10px) scale(0.97); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes bump { 40% { transform: scale(1.18); } }
@keyframes hurt { 20% { transform: translateX(-4px); background: #c8343c; } 40% { transform: translateX(4px); } 60% { transform: translateX(-3px); } }
@keyframes pulse { 0%, 100% { transform: none; } 50% { transform: scale(1.05); } }
@keyframes ready { 40% { transform: scale(1.15); } }
@keyframes opt-in { from { transform: translate(0, 0) scale(0.2); opacity: 0; } }
@keyframes hub-in { from { transform: scale(0.4); opacity: 0; } }
@keyframes card-in { from { opacity: 0; } }
@keyframes card-up { from { opacity: 0; transform: translateY(18px); } }
@keyframes logo-in { from { opacity: 0; transform: scale(0.7) rotate(-3deg); } }
@keyframes star-pop { 0% { transform: scale(0.2) rotate(-40deg); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes unlock-in { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes bought { 30% { background: rgba(95, 211, 90, 0.35); } }
html.reduce *, html.reduce *::before, html.reduce *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
@media (prefers-reduced-motion: reduce) {
  html:not(.full) *, html:not(.full) *::before, html:not(.full) *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; transition-duration: 0.001s !important; }
}
