/* Paws of War. Mobile first (390x844, down to 360 wide). One palette: warm parchment and dusk for the shell,
   a deep plum ink, cat blue against Jay pink. The field is a canvas; the controls are big chunky buttons. */
:root {
  --font: "Baloo 2", ui-rounded, system-ui, sans-serif;
  --ink: #2a2238; --ink-soft: #5b4e6e;
  --panel: #2f2742; --panel-2: #3b3152; --panel-line: rgba(255, 240, 220, 0.12);
  --cat: #4aa8ff; --jay: #ff5f9a; --gold: #ffd34e; --xp: #7ee8ff;
  --good: #49c46a; --warn: #ffb347;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { touch-action: manipulation; box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #1d1828; color: #fff; font-family: var(--font); overflow: hidden; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* the shared title screen's colors */
#mm, .sg-sheet {
  --sg-bg: radial-gradient(120% 80% at 50% 0%, #f6c27a 0%, #e88a5a 34%, #8a4a62 70%, #2f2742 100%);
  --sg-ink: #fff8ec; --sg-ink-soft: #ffe2cf;
  --sg-title: #fff2c0; --sg-title-shadow: 0 3px 0 #b8452f, 0 6px 0 #2a2238, 0 10px 18px rgba(20, 8, 30, 0.5);
  --sg-accent: #e8573f; --sg-accent-ink: #fff;
  --sg-card: rgba(255, 248, 236, 0.95); --sg-card-ink: #2a2238; --sg-line: rgba(232, 87, 63, 0.5);
  --sg-sheet-bg: #fff8ec; --sg-sheet-ink: #2a2238;
  --sg-font: var(--font);
}
/* the sheets are light parchment: their quieter text needs the dark soft ink (the title's is for its dusk sky) */
.sg-sheet { --sg-ink-soft: #5b4e6e; }
#mm .sg-play { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -5px 0 rgba(90, 20, 10, 0.35), 0 5px 0 #8a2a1e; }
.title-art { position: relative; width: 100%; display: flex; justify-content: center; }
.title-art canvas { width: 340px; max-width: 100%; height: auto; aspect-ratio: 340 / 170; border-radius: 18px; box-shadow: 0 8px 22px rgba(30, 10, 30, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.2); }

/* ---------- the battle ---------- */
.play { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--panel); }
.play[hidden] { display: none; }
.field { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #6a5a7a; touch-action: none; }
.field canvas#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud { position: absolute; left: 0; right: 0; top: 0; padding: var(--sg-corner-top) 8px 0 var(--sg-corner-left); display: flex; align-items: center; gap: 6px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-btn { flex: none; width: 44px; height: 44px; border: 0; border-radius: 14px; background: rgba(42, 34, 56, 0.72); display: grid; place-items: center; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.hud-btn svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.hud-btn:active { transform: translateY(1px); }
.hud-btn[aria-pressed="false"] { opacity: 0.55; }
.hud-btn.speed { font: 800 17px/1 var(--font); }
.hud-btn.speed.fast { background: rgba(232, 87, 63, 0.85); }
.hud-ages { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 6px; pointer-events: none; }
.age-chip { padding: 3px 9px; border-radius: 999px; font: 800 13px/1.2 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(42, 34, 56, 0.7); }
.age-chip.you { color: #bfe6ff; box-shadow: inset 0 0 0 2px rgba(74, 168, 255, 0.7); }
.age-chip.foe { color: #ffd0e2; box-shadow: inset 0 0 0 2px rgba(255, 95, 154, 0.7); }
.hud-time { font: 800 16px/1 var(--font); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); min-width: 40px; text-align: center; }
.overtime { position: absolute; top: calc(var(--sg-corner-top) + 50px); left: 50%; transform: translateX(-50%); margin: 0; padding: 4px 12px; border-radius: 999px; background: rgba(216, 60, 50, 0.85); font: 800 13px/1.2 var(--font); white-space: nowrap; pointer-events: none; }
.mini { position: absolute; left: 6px; right: 6px; bottom: 6px; height: 30px; width: calc(100% - 12px); border-radius: 10px; background: rgba(28, 22, 40, 0.62); touch-action: none; }
.banner { position: absolute; left: 50%; top: 30%; transform: translate(-50%, -50%) scale(0.6); opacity: 0; pointer-events: none; text-align: center; padding: 10px 22px 12px; border-radius: 20px; background: linear-gradient(#fff6d8, #ffd98a); color: var(--ink); box-shadow: 0 6px 0 #b8452f, 0 14px 30px rgba(20, 8, 30, 0.45); min-width: 230px; }
.banner b { display: block; font: 800 34px/1 var(--font); letter-spacing: 0.5px; }
.banner small { display: block; margin-top: 4px; font: 700 14px/1.25 var(--font); color: var(--ink-soft); }
.banner.show { animation: banner 2.6s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.endcard { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); opacity: 0; pointer-events: none; text-align: center; z-index: 12; }
.endcard b { display: block; font: 800 58px/1 var(--font); letter-spacing: 2px; color: #fff3c4; -webkit-text-stroke: 2px #6b2a12; text-shadow: 0 5px 0 #b8452f, 0 12px 26px rgba(20, 8, 30, 0.6); }
.endcard small { display: block; margin-top: 8px; font: 800 16px/1.2 var(--font); color: #fff; text-shadow: 0 2px 6px rgba(20, 8, 30, 0.8); }
.endcard.lose b { color: #e6e1f2; -webkit-text-stroke-color: #2c2240; text-shadow: 0 5px 0 #4b3c6e, 0 12px 26px rgba(20, 8, 30, 0.6); }
.endcard.show { animation: endcard 0.55s cubic-bezier(.2, 1.5, .4, 1) 0.2s forwards; }
@keyframes endcard { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.4) rotate(-6deg); } 60% { opacity: 1; transform: translate(-50%, -50%) scale(0.94) rotate(-2deg); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); } }
@media (prefers-reduced-motion: reduce) { .endcard.show { animation: endfade 0.4s linear forwards; } @keyframes endfade { to { opacity: 1; transform: translate(-50%, -50%); } } }
.banner.foe { background: linear-gradient(#ffe6ef, #ffb3cf); box-shadow: 0 6px 0 #a3305e, 0 14px 30px rgba(20, 8, 30, 0.45); }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } 20% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(0.96); } }

/* ---------- the controls ---------- */
.panel { flex: none; padding: 8px 8px calc(var(--safe-b) + 8px); background: linear-gradient(var(--panel-2), var(--panel)); box-shadow: 0 -2px 0 rgba(255, 240, 220, 0.08), 0 -10px 20px rgba(0, 0, 0, 0.25); display: flex; flex-direction: column; gap: 8px; }
.econ { display: flex; align-items: center; gap: 8px; height: 48px; }
.gold { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 104px; height: 46px; padding: 0 9px 0 7px; border: 0; border-radius: 14px; background: rgba(0, 0, 0, 0.25); text-align: left; }
.gold:active { transform: translateY(1px); }
.gold-top { display: flex; align-items: center; gap: 6px; }
.gold b { font: 800 20px/1 var(--font); color: var(--gold); font-variant-numeric: tabular-nums; }
/* income a second: from fighting (sword) and from the trickle (drop; it glows while it rallies) */
.inc { display: flex; align-items: center; gap: 5px; font: 800 12px/1 var(--font); color: #ffe9a8; white-space: nowrap; }
.inc > span { display: inline-flex; align-items: center; gap: 2px; }
.inc svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.inc b { font: 800 12px/1 var(--font); color: inherit; font-variant-numeric: tabular-nums; }
.inc .inc-t { color: #b9b0c9; }
.inc .inc-t svg { fill: currentColor; stroke: none; }
.inc.rally .inc-t { color: #8fe6ff; }
.inc small { font: 700 11px/1 var(--font); color: #b9b0c9; }
.coin { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd34e 45%, #c98a12); box-shadow: inset 0 0 0 2px rgba(120, 70, 0, 0.45); }
.xp { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.xp-bar { height: 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
.xp-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #4fc8ff, #9ef0ff); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.35); transition: width 0.2s; }
.xp small { font: 700 13px/1 var(--font); color: #cfe9ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.evolve { flex: none; height: 46px; min-width: 96px; padding: 0 10px; border: 0; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; background: #4a4060; color: #bdb0d0; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.ev-k { font: 800 17px/1 var(--font); }
.ev-to { font: 700 11px/1.1 var(--font); opacity: 0.85; margin-top: 2px; }
.evolve.ready { background: linear-gradient(#a8f0ff, #4fc8ff 55%, #2a8ad8); color: #10284a; box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), inset 0 -4px 0 rgba(0, 40, 90, 0.3), 0 0 0 3px rgba(158, 240, 255, 0.55); animation: glow 1.1s ease-in-out infinite; }
.evolve.max { opacity: 0.6; }
@keyframes glow { 50% { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), inset 0 -4px 0 rgba(0, 40, 90, 0.3), 0 0 0 6px rgba(158, 240, 255, 0.25); } }

.units, .towers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; height: 96px; }
.units[hidden], .towers[hidden], .ups[hidden] { display: none; }
/* upgrades: a row of cards that scrolls sideways (a tap buys the next level) */
.ups { display: flex; gap: 6px; height: 96px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; touch-action: pan-x; scrollbar-width: none; margin: 0 -8px; padding: 0 8px; }
.ups::-webkit-scrollbar { display: none; }
.upc { position: relative; flex: 0 0 104px; height: 96px; border: 0; border-radius: 16px; padding: 7px 7px 6px; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; scroll-snap-align: start; text-align: left;
  background: linear-gradient(#fff8ec, #f1e2cc); color: var(--ink); box-shadow: inset 0 -4px 0 rgba(90, 50, 20, 0.18), 0 3px 0 #1a1426; }
.upc.xp { background: linear-gradient(#eefcff, #cfeef8); }
.upc .up-nm { font: 800 13px/1.05 var(--font); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upc .up-pips { display: flex; gap: 3px; margin: 2px 0 1px; }
.upc .up-pips i { width: 14px; height: 5px; border-radius: 3px; background: rgba(42, 34, 56, 0.16); }
.upc .up-pips i.on { background: #e8573f; }
.upc.xp .up-pips i.on { background: #2a8ad8; }
.upc .up-v { font: 800 14px/1.1 var(--font); color: #2a2238; white-space: nowrap; }
.upc .up-tag { font: 700 12px/1.1 var(--font); color: var(--ink-soft); white-space: nowrap; }
.upc .up-cost { margin-top: auto; display: flex; align-items: center; gap: 3px; font: 800 14px/1 var(--font); color: #8a5a00; }
.upc.xp .up-cost { color: #17608f; }
.upc .ci { width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd34e 45%, #c98a12); }
.upc.poor { filter: saturate(0.5) brightness(0.86); }
.upc.poor .up-cost { color: #b0302a; }
.upc.later { opacity: 0.62; }
.upc.later .up-cost { font-size: 12px; color: var(--ink-soft); }
.upc.max .up-cost { color: #2a7a3a; }
.upc:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(90, 50, 20, 0.18), 0 1px 0 #1a1426; }
.upc.pop { animation: pop 0.22s ease-out; }
.ubtn, .tslot { position: relative; min-width: 0; height: 96px; border: 0; border-radius: 16px; padding: 4px 2px 6px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; overflow: hidden;
  background: linear-gradient(#fff8ec, #f1e2cc); color: var(--ink); box-shadow: inset 0 -4px 0 rgba(90, 50, 20, 0.18), 0 3px 0 #1a1426; }
.ubtn canvas { position: absolute; left: 50%; top: 2px; width: 56px; height: 56px; transform: translateX(-50%); pointer-events: none; }
.ubtn .nm { position: relative; font: 800 13px/1 var(--font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ubtn .cost { position: relative; display: flex; align-items: center; gap: 3px; margin-top: 3px; font: 800 15px/1 var(--font); color: #8a5a00; }
.ubtn .cost i { width: 13px; height: 13px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0, #ffd34e 45%, #c98a12); }
.ubtn .prog { position: absolute; left: 0; bottom: 0; height: 5px; width: 0; background: var(--good); }
.ubtn .count { position: absolute; top: 4px; right: 5px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 999px; background: var(--cat); color: #fff; font: 800 14px/22px var(--font); text-align: center; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.ubtn .count:empty { display: none; }
.ubtn.poor { filter: saturate(0.4) brightness(0.82); }
.ubtn.poor .cost { color: #b0302a; }
.ubtn:active, .tslot:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(90, 50, 20, 0.18), 0 1px 0 #1a1426; }
.ubtn.locked { background: #4a4060; color: #bdb0d0; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); }
.ubtn.locked .lock { position: relative; font: 700 12px/1.15 var(--font); text-align: center; padding: 0 4px; }
.ubtn.pop { animation: pop 0.22s ease-out; }
.units.five { gap: 4px; }
.units.five .ubtn canvas { width: 50px; height: 50px; }
.units.five .ubtn .nm { font-size: 12px; }
.ubtn.titan { background: linear-gradient(#fff3c4, #f2cf6a); }
@keyframes pop { 40% { transform: scale(0.94); } }

.tslot { justify-content: center; gap: 2px; }
.tslot canvas { width: 54px; height: 32px; pointer-events: none; }
.tslot .nm { font: 800 13px/1.05 var(--font); text-align: center; padding: 0 2px; }
.tslot small { font: 700 12px/1.1 var(--font); color: var(--ink-soft); }
.tslot.sel { box-shadow: inset 0 0 0 3px var(--cat), inset 0 -4px 0 rgba(90, 50, 20, 0.18), 0 3px 0 #1a1426; }
.tslot.empty { background: linear-gradient(#e9e2f2, #d6cce6); }
.tslot.locked { background: #4a4060; color: #d8cceb; }
.tslot.locked small { color: var(--gold); }

.actions { display: flex; align-items: stretch; gap: 6px; height: 64px; }
.queue { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 4px; padding: 0 6px; border: 0; border-radius: 14px; background: rgba(0, 0, 0, 0.22); color: inherit; }
.queue:active { transform: translateY(1px); background: rgba(0, 0, 0, 0.32); }
.queue[hidden], .topts[hidden] { display: none; }
.pip { position: relative; flex: 0 1 40px; min-width: 0; height: 40px; border-radius: 10px; background: rgba(255, 255, 255, 0.08) center / 90% no-repeat; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08); overflow: hidden; }
.pip.on { background-color: rgba(255, 248, 236, 0.92); }
.pip.old { box-shadow: inset 0 0 0 2px rgba(255, 211, 78, 0.85); } /* paid for in an earlier age */
.pip i { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--good); }
.topts { flex: 1 1 auto; min-width: 0; display: flex; gap: 6px; }
.tbtn { flex: 1 1 0; min-width: 0; border: 0; border-radius: 14px; padding: 4px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(#fff8ec, #f1e2cc); color: var(--ink); box-shadow: inset 0 -3px 0 rgba(90, 50, 20, 0.18), 0 3px 0 #1a1426; }
.tbtn[hidden] { display: none; }
@media (max-width: 370px) { .tbtn b { font-size: 12px; } }
.tbtn b { font: 800 13px/1.05 var(--font); max-width: 100%; text-align: center; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.tbtn small { font: 800 13px/1.1 var(--font); color: #8a5a00; }
.tbtn.sell small { color: #2a7a3a; }
.tbtn:disabled, .tbtn.off { opacity: 0.45; }
.tbtn:active:not(:disabled) { transform: translateY(2px); }
.act { flex: none; width: 60px; border: 0; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: #4a4060; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25); font: 800 13px/1 var(--font); }
.act svg { width: 26px; height: 26px; fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.act[aria-pressed="true"] { background: var(--cat); }
.special { position: relative; flex: none; width: 92px; border: 0; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; overflow: hidden; padding: 0 3px;
  background: linear-gradient(#ffb36a, #e8573f 60%, #b8352a); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -4px 0 rgba(90, 20, 10, 0.35), 0 3px 0 #1a1426; }
.special svg { flex: none; width: 15px; height: 15px; fill: #fff6d8; stroke: #6a1a10; stroke-width: 1.6; stroke-linejoin: round; }
.special > span { position: relative; text-align: center; text-shadow: 0 1px 0 rgba(90, 20, 10, 0.5); }
.special .sp-name { display: flex; align-items: center; gap: 2px; font: 800 12px/1.05 var(--font); }
.special .sp-cost { font: 800 13px/1 var(--font); color: #e6fbff; padding: 2px 6px; border-radius: 999px; background: rgba(20, 60, 110, 0.45); text-shadow: none; }
.special .sp-delay { font: 700 11px/1 var(--font); color: #fff1d8; }
.special .sp-delay:empty { display: none; }
.special.cooling .sp-cost, .special.poor .sp-cost { background: rgba(30, 20, 40, 0.55); color: #fff1d8; }
.sp-ring { position: absolute; inset: 0; background: conic-gradient(rgba(30, 20, 40, 0.72) calc(var(--cd, 0) * 360deg), transparent 0); }
.special.cooling, .special.poor { filter: saturate(0.5); }
.special.ready { animation: ready 1.2s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -4px 0 rgba(90, 20, 10, 0.35), 0 3px 0 #1a1426, 0 0 0 4px rgba(255, 179, 106, 0.6); } }
.special:active { transform: translateY(2px); }

/* ---------- sheets ---------- */
dialog.sheet { width: min(420px, calc(100% - 24px)); max-height: calc(100% - 40px); border: 0; border-radius: 24px; padding: 20px 18px 18px; background: #fff8ec; color: var(--ink); font-family: var(--font); box-shadow: 0 14px 40px rgba(20, 8, 30, 0.5); overflow: auto; }
dialog.sheet::backdrop { background: rgba(20, 10, 30, 0.62); }
dialog.sheet[open] { animation: sheetpop 0.32s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes sheetpop { 0% { transform: scale(0.85); opacity: 0; } }
.sheet h2 { margin: 0 0 4px; font: 800 34px/1.05 var(--font); text-align: center; }
.sheet h2.win { color: #2a7a3a; }
.sheet h2.lose { color: #b0302a; }
.res-sub { margin: 0 0 10px; text-align: center; font: 700 16px/1.35 var(--font); color: var(--ink-soft); }
.res-stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0 0 12px; padding: 12px 14px; border-radius: 16px; background: #f1e6d4; font: 700 16px/1.3 var(--font); }
.res-stats dt { color: var(--ink-soft); }
.res-stats dd { margin: 0; text-align: right; font-weight: 800; }
.res-ach { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.res-ach:empty { display: none; }
.res-ach li { padding: 8px 12px; border-radius: 12px; background: linear-gradient(#fff3c4, #ffe08a); font: 700 15px/1.25 var(--font); }
.res-ach li b { display: block; font-weight: 800; }
.stack { display: flex; flex-direction: column; gap: 10px; }
/* a long results card (several achievements on a short phone) scrolls under its buttons, which stay in reach */
#results .stack { position: sticky; bottom: -18px; margin: 0 -18px -18px; padding: 10px 18px 18px; background: linear-gradient(rgba(255, 248, 236, 0), #fff8ec 14px); }
.btn { height: 56px; border: 0; border-radius: 18px; font: 800 20px/1 var(--font); }
.btn.primary { color: #fff; background: linear-gradient(#ff8a5a, #e8573f 55%, #b8352a); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -4px 0 rgba(90, 20, 10, 0.3), 0 4px 0 #8a2a1e; text-shadow: 0 2px 0 rgba(90, 20, 10, 0.4); }
.btn.secondary { height: 48px; font-size: 17px; color: var(--ink); background: linear-gradient(#ffffff, #f1e6d4); box-shadow: inset 0 -3px 0 rgba(90, 50, 20, 0.18), 0 3px 0 #c9b49a; }
.btn:active { transform: translateY(2px); }

/* the difficulty pick, the codex and the records (lent to shared/mainmenu.js's openSheet) */
.diffs { display: flex; flex-direction: column; gap: 10px; }
.diff { display: flex; align-items: center; gap: 12px; min-height: 64px; width: 100%; border: 0; border-radius: 16px; padding: 10px 14px; text-align: left; background: #f1e6d4; color: var(--ink); box-shadow: inset 0 -3px 0 rgba(90, 50, 20, 0.15); }
.diff b { display: block; font: 800 20px/1.1 var(--font); }
.diff small { display: block; font: 600 14px/1.3 var(--font); color: var(--ink-soft); }
.diff .pips { flex: none; display: flex; gap: 3px; }
.diff .pips i { width: 8px; height: 22px; border-radius: 3px; background: rgba(42, 34, 56, 0.15); }
.diff .pips i.on { background: #e8573f; }
.diff.sel { box-shadow: inset 0 0 0 3px #e8573f, inset 0 -3px 0 rgba(90, 50, 20, 0.15); }
.diff:disabled { opacity: 0.5; }
.diff:active:not(:disabled) { transform: translateY(2px); }
.diff-go { margin-top: 12px; width: 100%; }
/* the new-battle sheet: Battle or Skirmish, then a skirmish's start age */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 18px; background: #eadcc6; }
.seg button { min-height: 52px; border: 0; border-radius: 14px; background: transparent; color: var(--ink); padding: 6px 8px; }
.seg button b { display: block; font: 800 18px/1.1 var(--font); }
.seg button small { display: block; font: 600 13px/1.2 var(--font); color: var(--ink-soft); }
.seg button.on { background: #fff8ec; box-shadow: inset 0 0 0 3px #e8573f, 0 2px 0 rgba(90, 50, 20, 0.15); }
.diff-about { margin: 0; font: 600 14px/1.35 var(--font); color: var(--ink-soft); }
.skirm-ages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.skirm-ages[hidden] { display: none; }
.skirm-ages button { min-height: 52px; border: 0; border-radius: 12px; padding: 4px 2px; background: #f1e6d4; color: var(--ink); box-shadow: inset 0 -3px 0 rgba(90, 50, 20, 0.15); }
.skirm-ages button b { display: block; font: 800 15px/1.1 var(--font); }
.skirm-ages button small { display: block; font: 600 12px/1.2 var(--font); color: var(--ink-soft); }
.skirm-ages button.on { box-shadow: inset 0 0 0 3px #e8573f; background: #fff8ec; }
.skirm-ages button:disabled { opacity: 0.45; }
.codex { display: flex; flex-direction: column; gap: 14px; }
.cx-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.cx-tab { flex: none; height: 44px; padding: 0 14px; border: 0; border-radius: 999px; background: #f1e6d4; color: var(--ink); font: 800 15px/1 var(--font); }
.cx-tab.sel { background: #2a2238; color: #fff; }
.cx-unit { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 10px; border-radius: 16px; background: #f6ecdc; }
.cx-pics { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.cx-pics canvas { width: 60px; height: 60px; }
.cx-unit h3 { margin: 0; font: 800 18px/1.1 var(--font); }
.cx-unit .role { font: 700 13px/1.2 var(--font); color: #b8452f; text-transform: uppercase; letter-spacing: 0.4px; }
.cx-unit p { margin: 2px 0 4px; font: 600 14px/1.3 var(--font); color: var(--ink-soft); }
.cx-unit ul { margin: 0; padding: 0; list-style: none; font: 700 14px/1.35 var(--font); }
.cx-unit .vs { margin-top: 4px; font: 700 13px/1.3 var(--font); }
.cx-unit .vs .up { color: #2a7a3a; } .cx-unit .vs .down { color: #b0302a; }
.cx-row { padding: 10px 12px; border-radius: 14px; background: #f6ecdc; font: 600 14px/1.35 var(--font); }
.cx-row b { display: block; font: 800 16px/1.2 var(--font); }
.cx-lv { margin: 4px 0 0; padding: 0 0 0 16px; font: 600 14px/1.35 var(--font); }
.cx-h { margin: 6px 0 -4px; font: 800 15px/1 var(--font); color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.5px; }
.rec-table { width: 100%; border-collapse: collapse; font: 700 15px/1.3 var(--font); }
.rec-table th, .rec-table td { padding: 6px 4px; text-align: right; border-bottom: 1px solid rgba(42, 34, 56, 0.1); }
.rec-table th:first-child, .rec-table td:first-child { text-align: left; }
.rec-table th { font-weight: 800; color: var(--ink-soft); font-size: 13px; }
.rec-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rec-list li { padding: 8px 12px; border-radius: 12px; background: #f1e6d4; font: 600 14px/1.3 var(--font); opacity: 0.6; }
.rec-list li.got { background: linear-gradient(#fff3c4, #ffe08a); opacity: 1; }
.rec-list li b { display: block; font-weight: 800; font-size: 15px; }
.banners { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.bnr { min-height: 64px; border: 0; border-radius: 14px; padding: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; background: #f1e6d4; color: var(--ink); font: 700 13px/1.15 var(--font); text-align: center; }
.bnr i { width: 34px; height: 22px; border-radius: 4px 4px 4px 0; clip-path: polygon(0 0, 100% 15%, 80% 50%, 100% 85%, 0 100%); }
.bnr.sel { box-shadow: inset 0 0 0 3px #2a2238; }
.bnr:disabled { opacity: 0.45; }
.bnr small:empty { display: none; }

/* the Barracks: rank, the ladder, the medal wall (art in barracks.js) */
.rank-badge { position: absolute; top: 6px; left: 50%; margin-left: calc(min(340px, 100%) * -0.5 + 6px); width: 46px; height: 46px; pointer-events: none; filter: drop-shadow(0 3px 4px rgba(20, 8, 30, 0.35)); }
.rank-badge svg { display: block; width: 46px; height: 46px; }
.barracks { color: var(--ink); }
.bk-rank { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: linear-gradient(#fff3c4, #ffe08a); box-shadow: inset 0 -3px 0 rgba(150, 90, 20, 0.18); }
.bk-rank > svg { flex: none; }
.bk-rank > div { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bk-rank small { font: 800 12px/1 var(--font); text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-soft); }
.bk-rank b { font: 800 22px/1.1 var(--font); }
.bk-rank span { font: 700 14px/1.25 var(--font); color: var(--ink-soft); }
.bk-pb { margin-top: 4px; --pb-track: rgba(42, 34, 56, 0.14); --pb-ink: var(--ink-soft); }
.bk-pb .pb-text { font: 700 14px/1.25 var(--font); }
.bk-note { margin: 8px 2px 0; font: 600 14px/1.35 var(--font); color: var(--ink-soft); }
.bk-ranks { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; margin-top: 10px; }
.bk-step { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 12px; background: #f1e6d4; text-align: center; }
.bk-step b { font: 800 12px/1.1 var(--font); }
.bk-step small { font: 600 12px/1.1 var(--font); color: var(--ink-soft); }
.bk-step.now { background: linear-gradient(#fff3c4, #ffe08a); box-shadow: inset 0 0 0 2px #e8573f; }
.bk-step.locked b { color: var(--ink-soft); }
.bk-wall { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding: 6px 6px 8px; border-radius: 16px; background: #f1e6d4; }
.bk-row { display: grid; grid-template-columns: 62px repeat(4, minmax(0, 1fr)); align-items: center; gap: 2px; }
.bk-top { margin-bottom: 2px; }
.bk-diff { justify-self: center; padding: 3px 6px; border-radius: 999px; background: var(--rib); color: #fff; font: 800 11px/1.1 var(--font); text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); }
.bk-age { font: 800 13px/1.1 var(--font); }
.bk-medal { display: grid; place-items: center; }
.bk-medal svg { display: block; width: 48px; height: 48px; }
.res-ach li.res-rank { display: flex; align-items: center; gap: 10px; }
.res-ach li.res-rank svg { flex: none; }
.res-ach li.res-medals .medal-row { display: flex; flex-wrap: wrap; gap: 2px; margin: 4px 0 2px; }
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 60px); transform: translateX(-50%); padding: 8px 16px; border-radius: 20px; background: rgba(42, 34, 56, 0.9); font: 700 15px/1.25 var(--font); opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 50; max-width: calc(100% - 24px); text-align: center; }
.toast.on { opacity: 1; }
.toast.low { top: auto; bottom: calc(var(--safe-b) + 120px); z-index: 60; }

/* the coach: a parchment bubble just above the controls, its arrow at the control it's about (which glows) */
.coach { position: absolute; left: 50%; transform: translateX(-50%); width: min(372px, calc(100% - 20px)); z-index: 40; padding: 12px 14px 8px; border-radius: 18px; background: linear-gradient(#fff9ea, #ffeec6); color: var(--ink); box-shadow: 0 5px 0 #c98a3a, 0 12px 26px rgba(20, 8, 30, 0.45); }
.coach[hidden] { display: none; }
.coach.pop { animation: coachpop 0.28s cubic-bezier(.2, 1.5, .4, 1); }
.coach p { margin: 0; font: 700 16px/1.3 var(--font); }
.coach p b { color: #b8452f; }
.coach-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.coach-row button { min-height: 44px; border: 0; border-radius: 999px; font: 800 15px/1 var(--font); }
.coach-skip { padding: 0 6px; background: none; color: var(--ink-soft); text-decoration: underline; text-underline-offset: 3px; }
.coach-ok { padding: 0 22px; background: #e8573f; color: #fff; box-shadow: inset 0 -3px 0 rgba(90, 20, 10, 0.35); }
.coach-ok:active { transform: translateY(1px); }
.coach-arrow { position: absolute; bottom: -9px; width: 20px; height: 20px; margin-left: -10px; background: #ffeec6; transform: rotate(45deg); box-shadow: 4px 4px 0 #c98a3a; border-radius: 3px; }
.coach-hi { position: relative; z-index: 1; animation: coachglow 1.1s ease-in-out infinite alternate; }
@keyframes coachpop { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.94); } }
@keyframes coachglow { from { box-shadow: 0 0 0 3px #ffd34e, 0 0 12px 2px rgba(255, 211, 78, 0.55); } to { box-shadow: 0 0 0 4px #fff2c0, 0 0 22px 6px rgba(255, 211, 78, 0.85); } }

@media (max-width: 370px) {
  .gold { min-width: 80px; padding: 0 8px 0 6px; } .gold b { font-size: 19px; }
  .evolve { min-width: 84px; } .act { width: 54px; font-size: 12px; } .special { width: 86px; } .gold { min-width: 98px; }
  .age-chip { font-size: 12px; padding: 3px 7px; }
}
@media (prefers-reduced-motion: reduce) {
  .banner.show { animation-duration: 2.6s; animation-timing-function: linear; }
  .evolve.ready, .special.ready { animation: none; }
  .coach.pop { animation: none; }
  .coach-hi { animation: none; box-shadow: 0 0 0 4px #ffd34e; }
  dialog.sheet[open] { animation-duration: 0.01s; }
}
#mm.sg-scened .title-art canvas { border-radius: 0; box-shadow: none; }
