/* ═══════════════════════════════════════════════════════════════════════════
   THRONEBOUND — game.css  (medieval premium theme, mobile-first)

   ── CLASS / ID INVENTORY — binding for every web/js module ────────────────
   All ids exist in index.html; all classes below are styled here and safe to
   use from JS. Show/hide is ALWAYS the `hidden` attribute (el.hidden = bool);
   [hidden] wins over every display rule.

   SHELL
     #kingdom-canvas        full-viewport scene canvas (z 0). TBScene.init.
     #top-bar               fixed top chrome. #kingdom-crest #kingdom-name
     #power-chip #power-value           kingdom power readout
     #resource-bar          strip of six .resource entries (h-scroll on phones)
     .resource[data-res="gold|food|wood|stone|mana|influence"]
        .resource-icon      inline svg
        .resource-count     ids #res-gold #res-food #res-wood #res-stone
                            #res-mana #res-influence — JS sets textContent
        .resource-tip       hover/focus tooltip; ids #res-rate-gold … — JS sets
                            "+12.3/s" text
        JS adds .gain to the .resource for ~600ms → count pulses gold
     #chip-gems #gem-count  premium gems     #chip-crowns #crown-count  crowns today
   NAV
     #bottom-nav  .nav-btn[data-panel="kingdom|heroes|expeditions|quests|
                  rewards|shop|more"]  .nav-icon .nav-label
     .nav-btn.active        currently-open panel
     .nav-badge             count bubble; toggle `hidden`, set textContent
     .claimable             gold pulse-glow — valid on .nav-btn, .btn, .card,
                            .list-row, anything
     #nav-more  #more-menu  .more-item[data-panel="leaderboard|dynasty|settings"]
                            popover; toggle `hidden`; #more-menu.open not needed
   PANEL (TBUI.registerPanel renders into #panel-body)
     #panel-host  #panel-scrim  #panel  #panel-header  #panel-title
     #panel-close #panel-body   — unhide #panel-host to open (slide-in animates
     each open); full-screen sheet on phones, right 420px sheet on ≥768px
   MODALS (toggle `hidden`)
     .modal-host  .modal    generic centered modal scaffolding
     #login-modal  #btn-guest  #auth-tabs  .auth-tab[data-tab="login|register"]
       #login-form #login-email #login-password #btn-login
       #register-form #register-email #register-password #btn-register
       #auth-error (.form-error)  #btn-wallet  .reassure
     #offline-modal #offline-title #offline-duration #offline-gains
       (fill with li.gain-row → .gain-icon .gain-name .gain-amount)
       #offline-collect
   FX
     #fx-layer              fixed, pointer-events:none overlay for floats/bursts
     .float                 TBUI.float: absolutely-positioned rising number;
                            set style.left/top (px), remove node after ~1.4s.
                            Modifiers: .float-gold .float-food .float-wood
                            .float-stone .float-mana .float-influence
                            .float-xp .float-crown .float-gem .float-dmg .float-big
     .celebrate             append to #fx-layer (default center; may set
                            left/top); CSS box-shadow particle burst + flash;
                            remove node after ~1s. Modifier: .celebrate-big
     #toast-host            fixed stack above nav
     .toast                 append; kinds .toast-good .toast-bad .toast-info
                            (aliases .toast-success .toast-error); add
                            .toast-out then remove after 300ms
   PRIMITIVES for panel renderers
     .parchment .parchment-dark .wood .iron .ornate     surface treatments
     .btn .btn-gold .btn-wood .btn-iron .btn-danger .btn-ghost .btn-big
     .btn-sm .icon-btn      buttons (press animation built in); :disabled dims
     .tabs .tab .tab.active                              tab strip
     .card .card-grid .card-title .card-sub              parchment cards
     .list-row .list-row-main .list-row-actions          stacked rows
     .hero-card .hero-portrait .hero-level               hero cells
     .rarity-common .rarity-rare .rarity-epic .rarity-legendary
                            sets --rarity; tints .card/.hero-card border +
                            .rarity-name text
     .progress .progress-fill (width %)  .progress-active (animated stripes)
     .cost .cost-item .cost-item.short (unaffordable → red)
     .stat-grid .stat-tile .stat-value .stat-label       rewards/stat tiles
     .section-title .divider .fine-print .muted .gold-text .timer
     .badge .pill .locked .empty-state .spinner
     .toggle (label wrapping <input type=checkbox> + .toggle-track>.toggle-thumb)
     .field (label+input)   .form-error
     .btn-row               flex row of buttons
   MISC
     #ad-anchor             hidden strip above nav; TBAds unhides + injects <ins>;
                            while visible the canvas shortens to sit above it
     #boot-veil             decorative; fades itself out, pointer-events none
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --night-900: #0b111c;
  --night-800: #101826;
  --night-700: #182338;

  --parch-50:  #f6ecd2;
  --parch-100: #efe2c0;
  --parch-200: #e5d3a8;
  --parch-300: #d6bf8a;
  --parch-400: #b99f66;

  --ink-900: #2c2013;
  --ink-700: #4a3823;
  --ink-500: #6b5535;

  --wood-700: #33220f;
  --wood-600: #4a3118;
  --wood-500: #63421f;
  --wood-400: #82592b;

  --iron-700: #23272e;
  --iron-600: #2e333c;
  --iron-500: #454c58;
  --iron-400: #5d6674;

  --gold-600: #a8752a;
  --gold-500: #d9a53f;
  --gold-400: #e8bb55;
  --gold-300: #f3cf6d;

  --crimson: #8e2f2f;
  --crimson-bright: #c0554a;
  --mana: #8f7bff;
  --mana-carry: #69b7d4; /* mana-in-transit cyan — must match CARRY[4] in js/scene/life.js */
  --nature: #7da33c;
  --gem: #4fd1c5;
  --good: #5fae52;
  --bad: #c0554a;
  --info: #6f8fc0;

  --rarity-common: #8f97a3;
  --rarity-rare: #5b8fd9;
  --rarity-epic: #a66bd9;
  --rarity-legendary: #e8963a;

  --font-display: Georgia, 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', 'Times New Roman', serif;

  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .35);

  --nav-h: 62px;
  --ad-h: 50px; /* keep equal to #ad-anchor min-height: the scene reserves this much */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --ease-pop: cubic-bezier(.2, .9, .3, 1.05);
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--night-900);
  color: var(--parch-100);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

/* (No CSS vignette: the scene canvas draws its own, phase-tinted.) */

[hidden] { display: none !important; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .015em;
  margin: 0 0 .45em;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
button:disabled { cursor: not-allowed; }

img, svg { max-width: 100%; display: block; }
svg { width: 1.25em; height: 1.25em; }

::selection { background: rgba(217, 165, 63, .45); }

/* Subtle scrollbars inside panels/lists */
* { scrollbar-width: thin; scrollbar-color: rgba(107, 85, 53, .55) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(107, 85, 53, .55); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ── Scene canvas ───────────────────────────────────────────────────────── */
#kingdom-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  touch-action: none;
  cursor: grab;
  background: linear-gradient(180deg, #0a1020 0%, #101a2e 45%, #16202c 100%);
}
#kingdom-canvas:active { cursor: grabbing; }

/* ── Surface treatments ─────────────────────────────────────────────────── */
.parchment {
  background:
    radial-gradient(130% 90% at 50% -5%, rgba(255, 248, 224, .85), transparent 58%),
    repeating-linear-gradient(0deg, rgba(120, 90, 40, .05) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(90deg, rgba(120, 90, 40, .04) 0 3px, transparent 3px 7px),
    linear-gradient(165deg, var(--parch-50) 0%, var(--parch-100) 45%, var(--parch-200) 80%, var(--parch-300) 100%);
  color: var(--ink-900);
}

.parchment-dark {
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .06) 0 2px, transparent 2px 5px),
    linear-gradient(170deg, #d9c69a, #c4ab74 70%, #b39a63);
  color: var(--ink-900);
}

.wood {
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, .14) 0 2px, transparent 2px 26px),
    repeating-linear-gradient(0deg, rgba(255, 220, 160, .05) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, var(--wood-400) 0%, var(--wood-600) 55%, var(--wood-700) 100%);
  color: var(--parch-100);
}

.iron {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .03) 0 2px, transparent 2px 6px),
    linear-gradient(180deg, var(--iron-500), var(--iron-700));
  color: var(--parch-100);
}

/* Ornate double border + gold corner studs */
.ornate {
  position: relative;
  border: 2px solid var(--gold-600);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 1px rgba(58, 40, 12, .6),
    inset 0 0 0 4px rgba(243, 207, 109, .28),
    inset 0 0 0 5px rgba(58, 40, 12, .35),
    var(--shadow-lg);
}
.ornate::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid rgba(107, 85, 53, .45);
  border-radius: 6px;
  pointer-events: none;
}
.ornate::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle, var(--gold-400) 0 2.5px, rgba(58, 40, 12, .8) 2.5px 3.5px, transparent 4px),
    radial-gradient(circle, var(--gold-400) 0 2.5px, rgba(58, 40, 12, .8) 2.5px 3.5px, transparent 4px),
    radial-gradient(circle, var(--gold-400) 0 2.5px, rgba(58, 40, 12, .8) 2.5px 3.5px, transparent 4px),
    radial-gradient(circle, var(--gold-400) 0 2.5px, rgba(58, 40, 12, .8) 2.5px 3.5px, transparent 4px);
  background-repeat: no-repeat;
  background-size: 9px 9px;
  background-position: 4px 4px, calc(100% - 4px) 4px, 4px calc(100% - 4px), calc(100% - 4px) calc(100% - 4px);
}

/* ── Top bar ────────────────────────────────────────────────────────────── */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: calc(4px + var(--safe-t)) calc(8px + var(--safe-r)) 6px calc(8px + var(--safe-l));
  border-bottom: 2px solid rgba(20, 12, 4, .9);
  box-shadow: 0 2px 0 rgba(243, 207, 109, .18), var(--shadow-md);
}

.top-left {
  order: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#kingdom-crest svg {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
}

.top-titles { min-width: 0; }

#kingdom-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .03em;
  color: var(--parch-50);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 34vw;
}

#power-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--gold-300);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .7);
  font-variant-numeric: tabular-nums;
}
#power-chip svg { width: 12px; height: 12px; }

.top-right {
  order: 2;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(12, 8, 4, .6);
  border: 1px solid rgba(233, 187, 85, .3);
  font-size: 13px;
  font-weight: 700;
  color: var(--parch-50);
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5);
}
.chip svg { width: 15px; height: 15px; }
.chip-gem  { color: #b8f3ec; }
.chip-crown { color: var(--gold-300); }

/* Resource strip */
#resource-bar {
  order: 3;
  flex: 1 1 100%;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 1px 4px;
  scrollbar-width: none;
}
#resource-bar::-webkit-scrollbar { display: none; }

.resource {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px 3px 6px;
  border-radius: 999px;
  background: rgba(12, 8, 4, .6);
  border: 1px solid rgba(233, 187, 85, .22);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5);
  cursor: default;
  outline: none;
}
.resource:focus-visible { border-color: var(--gold-300); }

.resource-icon svg {
  width: 17px;
  height: 17px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .55));
}

.resource-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--parch-50);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .7);
  min-width: 3ch;
}

/* Gain pulse: JS toggles .gain on the .resource */
.resource.gain .resource-count { animation: resPulse .6s var(--ease-pop); }
.resource.gain .resource-icon  { animation: resIconPop .6s var(--ease-pop); }

@keyframes resPulse {
  0%   { transform: scale(1);    color: var(--parch-50); }
  30%  { transform: scale(1.35); color: var(--gold-300); text-shadow: 0 0 10px rgba(243, 207, 109, .9); }
  100% { transform: scale(1);    color: var(--parch-50); }
}
@keyframes resIconPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.3) rotate(-8deg); }
  100% { transform: scale(1); }
}

/* +rate/s tooltip */
.resource-tip {
  position: absolute;
  top: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  padding: 3px 9px;
  border-radius: 6px;
  background: #1c1409;
  border: 1px solid var(--gold-600);
  color: var(--gold-300);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
  z-index: 30;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm);
}
.resource-tip::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: #1c1409;
  border-left: 1px solid var(--gold-600);
  border-top: 1px solid var(--gold-600);
}
.resource:hover .resource-tip,
.resource:focus .resource-tip,
.resource:focus-visible .resource-tip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Bottom navigation ──────────────────────────────────────────────────── */
#bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  display: flex;
  align-items: stretch;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 var(--safe-r) var(--safe-b) var(--safe-l);
  border-top: 2px solid rgba(20, 12, 4, .9);
  box-shadow: 0 -2px 0 rgba(243, 207, 109, .18), 0 -8px 24px rgba(0, 0, 0, .5);
}

.nav-btn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px 5px;
  color: rgba(240, 226, 192, .62);
  transition: color .18s ease, transform .1s ease;
  -webkit-user-select: none;
  user-select: none;
}
.nav-btn:active { transform: scale(.92); }

.nav-icon svg {
  width: 23px;
  height: 23px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .6));
  transition: transform .18s var(--ease-pop);
}

.nav-label {
  font-size: 10.5px;
  letter-spacing: .05em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
}

.nav-btn.active { color: var(--gold-300); }
.nav-btn.active .nav-icon svg { transform: translateY(-2px) scale(1.12); }
.nav-btn.active::before {
  content: "";
  position: absolute;
  top: -2px;
  left: 22%;
  right: 22%;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, transparent, var(--gold-300), transparent);
}
.nav-btn:hover { color: var(--parch-50); }

.nav-badge {
  position: absolute;
  top: 3px;
  right: 14%;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: linear-gradient(180deg, var(--crimson-bright), var(--crimson));
  border: 1px solid #571b1b;
  color: #ffefe8;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 15px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  animation: badgeIn .3s var(--ease-pop);
}
@keyframes badgeIn {
  0% { transform: scale(0); }
  70% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* "More" popover */
#more-menu {
  position: fixed;
  right: max(8px, var(--safe-r));
  bottom: calc(var(--nav-h) + var(--safe-b) + 10px);
  z-index: 26;
  display: flex;
  flex-direction: column;
  min-width: 190px;
  padding: 10px;
  animation: morePop .22s var(--ease-pop);
}
@keyframes morePop {
  from { opacity: 0; transform: translateY(10px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

.more-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-900);
  text-align: left;
  transition: background .15s ease;
}
.more-item svg { width: 19px; height: 19px; color: var(--ink-500); }
.more-item:hover, .more-item:focus-visible { background: rgba(168, 117, 42, .16); }
.more-item:active { transform: translateY(1px); }
.more-item + .more-item { border-top: 1px solid rgba(107, 85, 53, .25); }

/* ── Panel sheet ────────────────────────────────────────────────────────── */
#panel-host { position: fixed; inset: 0; z-index: 20; }

#panel-scrim {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 14, .45);
  animation: fadeIn .25s ease;
}

#panel {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  bottom: calc(var(--nav-h) + var(--safe-b));
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
  animation: panelUp .32s var(--ease-pop);
  overflow: hidden;
}
#panel.ornate::after { display: none; } /* corner studs clip oddly on full-bleed sheet */

@keyframes panelUp {
  from { opacity: .4; transform: translateY(6%); }
  to   { opacity: 1; transform: none; }
}

.sheet-handle {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 42px;
  height: 4px;
  border-radius: 2px;
  background: rgba(240, 226, 192, .4);
  z-index: 2;
  display: block;
}

#panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  border-bottom: 2px solid rgba(20, 12, 4, .85);
  box-shadow: 0 2px 0 rgba(243, 207, 109, .16), 0 4px 14px rgba(0, 0, 0, .3);
  flex: 0 0 auto;
}

#panel-title {
  margin: 0;
  font-size: 19px;
  letter-spacing: .04em;
  color: var(--parch-50);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8), 0 0 14px rgba(243, 207, 109, .25);
}

#panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(18px + var(--safe-b));
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .03em;
  line-height: 1.2;
  border: 1px solid rgba(20, 12, 4, .75);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 2px 4px rgba(0, 0, 0, .4);
  transition: filter .15s ease, transform .08s ease, box-shadow .15s ease;
  -webkit-user-select: none;
  user-select: none;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
}
.btn svg { width: 17px; height: 17px; }
.btn:hover:not(:disabled) { filter: brightness(1.09); }
.btn:active:not(:disabled) {
  transform: translateY(1px) scale(.98);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .35);
}
.btn:disabled { opacity: .5; filter: saturate(.5); }
.btn:focus-visible { outline: 2px solid var(--gold-300); outline-offset: 2px; }

.btn-gold {
  background: linear-gradient(180deg, var(--gold-300) 0%, var(--gold-500) 55%, var(--gold-600) 100%);
  color: #2c1d07;
  border-color: #6d4a15;
  text-shadow: 0 1px 0 rgba(255, 240, 200, .5);
}
.btn-wood {
  background: linear-gradient(180deg, var(--wood-400), var(--wood-600) 70%, var(--wood-700));
  color: var(--parch-50);
}
.btn-iron {
  background: linear-gradient(180deg, var(--iron-400), var(--iron-600) 70%, var(--iron-700));
  color: var(--parch-50);
}
.btn-danger {
  background: linear-gradient(180deg, #b04a3e, var(--crimson) 70%, #5f1f1f);
  color: #ffefe8;
}
.btn-ghost {
  background: transparent;
  border: 1px solid rgba(107, 85, 53, .55);
  color: inherit;
  box-shadow: none;
}
.btn-ghost:hover:not(:disabled) { background: rgba(168, 117, 42, .12); }

.btn-big { width: 100%; padding: 13px 18px; font-size: 16px; border-radius: 10px; }
.btn-sm  { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--parch-100);
  background: rgba(12, 8, 4, .35);
  border: 1px solid rgba(233, 187, 85, .3);
  transition: background .15s ease, transform .08s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: rgba(12, 8, 4, .55); }
.icon-btn:active { transform: scale(.92); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row .btn { flex: 1 1 auto; }

/* Claimable glow — anything worth tapping pulses gold */
.claimable {
  animation: claimGlow 1.9s ease-in-out infinite;
  border-color: var(--gold-300) !important;
}
@keyframes claimGlow {
  0%, 100% { box-shadow: 0 0 5px 1px rgba(243, 207, 109, .4); }
  50%      { box-shadow: 0 0 18px 5px rgba(243, 207, 109, .85); }
}
.nav-btn.claimable { animation: none; border-color: transparent !important; }
.nav-btn.claimable .nav-icon svg {
  animation: navClaim 1.9s ease-in-out infinite;
  color: var(--gold-300);
}
@keyframes navClaim {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(243, 207, 109, .5)); transform: scale(1); }
  50%      { filter: drop-shadow(0 0 8px rgba(243, 207, 109, 1)); transform: scale(1.12); }
}

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: rgba(74, 56, 35, .18);
  border: 1px solid rgba(107, 85, 53, .35);
  margin-bottom: 12px;
}
.tab {
  flex: 1 1 0;
  padding: 8px 6px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: .03em;
  color: var(--ink-500);
  transition: background .18s ease, color .18s ease;
  white-space: nowrap;
}
.tab:hover { color: var(--ink-900); }
.tab.active {
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500));
  color: #2c1d07;
  box-shadow: inset 0 1px 0 rgba(255, 250, 220, .6), 0 1px 3px rgba(0, 0, 0, .3);
}

/* ── Cards / lists ──────────────────────────────────────────────────────── */
.card {
  position: relative;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 248, 224, .6), transparent 60%),
    linear-gradient(170deg, var(--parch-50), var(--parch-200));
  border: 1.5px solid var(--parch-400);
  border-radius: 9px;
  padding: 12px;
  color: var(--ink-900);
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--ease-pop), box-shadow .15s ease;
}
.card:active { transform: scale(.985); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.card-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink-900);
  margin: 0 0 2px;
}
.card-sub {
  font-size: 12.5px;
  color: var(--ink-500);
  margin: 0 0 6px;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(246, 236, 210, .75);
  border: 1px solid rgba(185, 159, 102, .55);
  color: var(--ink-900);
  margin-bottom: 8px;
}
.list-row-main { flex: 1 1 auto; min-width: 0; }
.list-row-actions { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }

/* Hero cells */
.hero-card {
  text-align: center;
  border-width: 2px;
  border-color: var(--rarity, var(--parch-400));
}
.hero-portrait {
  width: 58px;
  height: 58px;
  margin: 0 auto 6px;
  border-radius: 50%;
  border: 2px solid var(--rarity, var(--parch-400));
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .35), transparent 55%),
    linear-gradient(160deg, var(--iron-500), var(--iron-700));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .4), 0 0 0 2px rgba(0, 0, 0, .18);
  font-size: 24px;
  color: var(--parch-100);
}
.hero-level {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--iron-700);
  color: var(--gold-300);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Rarity tints (set --rarity, tint borders + .rarity-name) */
.rarity-common    { --rarity: var(--rarity-common); }
.rarity-rare      { --rarity: var(--rarity-rare); }
.rarity-epic      { --rarity: var(--rarity-epic); }
.rarity-legendary { --rarity: var(--rarity-legendary); }
.card.rarity-common, .card.rarity-rare, .card.rarity-epic, .card.rarity-legendary,
.list-row.rarity-common, .list-row.rarity-rare, .list-row.rarity-epic, .list-row.rarity-legendary {
  border-color: var(--rarity);
  box-shadow: inset 0 0 12px -6px var(--rarity), var(--shadow-sm);
}
.rarity-name { color: var(--rarity, var(--ink-500)); font-weight: 700; }
.rarity-legendary.card, .card.rarity-legendary { animation: legendaryShine 3.2s ease-in-out infinite; }
@keyframes legendaryShine {
  0%, 100% { box-shadow: inset 0 0 12px -6px var(--rarity), var(--shadow-sm); }
  50%      { box-shadow: inset 0 0 18px -4px var(--rarity), 0 0 14px -2px var(--rarity); }
}

/* ── Progress bars ──────────────────────────────────────────────────────── */
.progress {
  height: 11px;
  border-radius: 6px;
  background: rgba(44, 32, 19, .35);
  border: 1px solid rgba(44, 32, 19, .45);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .4);
}
.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--gold-300), var(--gold-500) 70%, var(--gold-600));
  transition: width .5s ease;
  min-width: 0;
}
.progress-active .progress-fill {
  background-image:
    repeating-linear-gradient(-55deg, rgba(255, 255, 255, .22) 0 8px, transparent 8px 16px),
    linear-gradient(180deg, var(--gold-300), var(--gold-500) 70%, var(--gold-600));
  animation: stripes 1s linear infinite;
}
@keyframes stripes {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 22px 0, 0 0; }
}

/* ── Costs ──────────────────────────────────────────────────────────────── */
.cost { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.cost-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-700);
  font-variant-numeric: tabular-nums;
}
.cost-item svg { width: 15px; height: 15px; }
.cost-item.short { color: var(--bad); }
.cost-item.short::after { content: " ✗"; font-size: 11px; }

/* ── Stat tiles (Royal Rewards & co.) ───────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stat-tile {
  padding: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(170deg, rgba(44, 32, 19, .88), rgba(35, 24, 12, .92));
  border: 1px solid var(--gold-600);
  box-shadow: inset 0 0 0 1px rgba(243, 207, 109, .15), var(--shadow-sm);
  text-align: center;
}
.stat-value {
  font-size: 21px;
  font-weight: 700;
  color: var(--gold-300);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
  line-height: 1.15;
}
.stat-label {
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(240, 226, 192, .65);
  margin-top: 2px;
}

/* ── Small text pieces ──────────────────────────────────────────────────── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-500);
}
.section-title::before, .section-title::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(107, 85, 53, .55), transparent);
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--ink-500);
  font-size: 12.5px;
  font-style: italic;
}
.divider::before, .divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(107, 85, 53, .5), transparent);
}

.fine-print { font-size: 11.5px; color: var(--ink-500); margin: 6px 0 0; text-align: center; }
.muted { color: var(--ink-500); font-weight: 400; }
.timer { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

.gold-text {
  background: linear-gradient(100deg, var(--gold-600) 0%, var(--gold-300) 38%, #fff4cc 50%, var(--gold-300) 62%, var(--gold-600) 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 3.5s linear infinite;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: 0 0; }
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--crimson);
  color: #ffefe8;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(74, 56, 35, .16);
  border: 1px solid rgba(107, 85, 53, .4);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-700);
}

.locked { filter: grayscale(.75) brightness(.82); opacity: .75; }
.locked .btn { pointer-events: none; }

.empty-state {
  text-align: center;
  padding: 34px 16px;
  color: var(--ink-500);
  font-style: italic;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(107, 85, 53, .3);
  border-top-color: var(--gold-500);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toggle switch ──────────────────────────────────────────────────────── */
.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  background: linear-gradient(180deg, var(--iron-600), var(--iron-700));
  border: 1px solid rgba(20, 12, 4, .8);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .5);
  transition: background .2s ease;
  flex: 0 0 auto;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--parch-50), var(--parch-300));
  box-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  transition: transform .2s var(--ease-pop);
}
.toggle input:checked + .toggle-track {
  background: linear-gradient(180deg, var(--gold-500), var(--gold-600));
}
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--gold-300); outline-offset: 2px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 12px; text-align: left; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-700);
  margin-bottom: 4px;
}
.field input, .field select, .field textarea,
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--parch-400);
  background: rgba(255, 252, 240, .8);
  color: var(--ink-900);
  font-family: var(--font-display);
  font-size: 15px;
  box-shadow: inset 0 1px 3px rgba(107, 85, 53, .25);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold-500);
  box-shadow: inset 0 1px 3px rgba(107, 85, 53, .25), 0 0 0 3px rgba(217, 165, 63, .25);
}

.form-error {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(142, 47, 47, .14);
  border: 1px solid rgba(142, 47, 47, .5);
  color: #7c2323;
  font-size: 13.5px;
  font-weight: 700;
  animation: shake .35s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--safe-t));
  padding-bottom: calc(16px + var(--safe-b));
  background: rgba(5, 8, 14, .74);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 400px;
  margin: auto;
  padding: 24px 22px;
  text-align: center;
  animation: modalIn .38s var(--ease-pop);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(26px) scale(.94); }
  to   { opacity: 1; transform: none; }
}

.modal-title { font-size: 22px; color: var(--ink-900); margin-bottom: 4px; }
.modal-sub { color: var(--ink-500); margin: 0 0 14px; font-size: 14px; }
.modal-crest { margin-bottom: 6px; }
.modal-crest svg {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35));
}

/* Login modal */
.login-modal .game-logo { margin-bottom: 2px; }
.game-logo {
  font-size: 34px;
  font-variant: small-caps;
  letter-spacing: .09em;
  font-weight: 700;
  text-shadow: none;
  /* Static gilded fill; declared after .gold-text so the shimmer stays off the
     logo (reduced-motion .gold-text reset still wins → solid gold fallback). */
  background: linear-gradient(180deg, var(--gold-300) 0%, var(--gold-500) 48%, var(--gold-600) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: none;
}
.tagline {
  color: var(--ink-500);
  font-style: italic;
  font-size: 14px;
  margin: 0 0 18px;
}
#login-form, #register-form { margin: 0 0 4px; }

.reassure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-500);
}
.reassure svg { width: 15px; height: 15px; color: var(--nature); flex: 0 0 auto; }

/* Offline gains modal */
.offline-modal .modal-title { margin-top: 2px; }
.offline-gains {
  list-style: none;
  margin: 0 0 16px;
  padding: 10px 4px;
  border-top: 1px solid rgba(107, 85, 53, .35);
  border-bottom: 1px solid rgba(107, 85, 53, .35);
  max-height: 38vh;
  overflow-y: auto;
}
.gain-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 15px;
  color: var(--ink-900);
  animation: gainRowIn .4s var(--ease-pop) backwards;
}
.gain-row:nth-child(2) { animation-delay: .07s; }
.gain-row:nth-child(3) { animation-delay: .14s; }
.gain-row:nth-child(4) { animation-delay: .21s; }
.gain-row:nth-child(5) { animation-delay: .28s; }
.gain-row:nth-child(6) { animation-delay: .35s; }
.gain-row:nth-child(n+7) { animation-delay: .42s; }
@keyframes gainRowIn {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}
.gain-icon { flex: 0 0 auto; display: inline-flex; }
.gain-icon svg { width: 19px; height: 19px; }
.gain-name { flex: 1 1 auto; text-align: left; }
.gain-amount {
  font-weight: 700;
  color: var(--gold-600);
  font-variant-numeric: tabular-nums;
}

/* ── FX: floats + celebrate ─────────────────────────────────────────────── */
#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  overflow: hidden;
}

.float {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--gold-300);
  text-shadow: 0 1px 2px #000, 0 0 10px rgba(0, 0, 0, .6);
  white-space: nowrap;
  pointer-events: none;
  animation: floatUp 1.3s ease-out forwards;
  font-variant-numeric: tabular-nums;
}
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(.55); }
  12%  { opacity: 1; transform: translate(-50%, -55%) scale(1.18); }
  26%  { transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -240%) scale(.95); }
}
.float-gold      { color: var(--gold-300); }
.float-food      { color: #e3c05c; }
.float-wood      { color: #c89a5b; }
.float-stone     { color: #b8c0cb; }
.float-mana      { color: var(--mana-carry); }
.float-influence { color: #e88b7d; }
.float-xp        { color: #9fd0ff; }
.float-crown     { color: var(--gold-300); text-shadow: 0 0 10px rgba(243, 207, 109, .8), 0 1px 2px #000; }
.float-gem       { color: #7fe6db; }
.float-dmg       { color: #ff8d7a; }
.float-big       { font-size: 26px; }

/* One-element particle burst: box-shadow list interpolates 0 → ring */
.celebrate {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 204, .95), rgba(243, 207, 109, 0) 70%);
  pointer-events: none;
  animation: celebrateBurst .95s ease-out forwards;
}
.celebrate::before {
  content: "";
  position: absolute;
  inset: -34px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 240, 190, .55), transparent 65%);
  animation: celebrateFlash .5s ease-out forwards;
}
@keyframes celebrateFlash {
  0% { opacity: 1; transform: scale(.3); }
  100% { opacity: 0; transform: scale(1.6); }
}
@keyframes celebrateBurst {
  0% {
    opacity: 1;
    transform: scale(.5);
    box-shadow:
      0 0 0 3px #f3cf6d, 0 0 0 3px #e8bb55, 0 0 0 3px #fff4cc, 0 0 0 3px #d9a53f,
      0 0 0 3px #f3cf6d, 0 0 0 3px #c0554a, 0 0 0 3px #e8bb55, 0 0 0 3px #b3a6ff,
      0 0 0 3px #f3cf6d, 0 0 0 3px #d9a53f, 0 0 0 3px #fff4cc, 0 0 0 3px #e8963a;
  }
  60% { opacity: 1; }
  100% {
    opacity: 0;
    transform: scale(1);
    box-shadow:
      0 -92px 0 1px #f3cf6d, 46px -80px 0 1px #e8bb55, 80px -46px 0 1px #fff4cc, 92px 0 0 1px #d9a53f,
      80px 46px 0 1px #f3cf6d, 46px 80px 0 1px #c0554a, 0 92px 0 1px #e8bb55, -46px 80px 0 1px #b3a6ff,
      -80px 46px 0 1px #f3cf6d, -92px 0 0 1px #d9a53f, -80px -46px 0 1px #fff4cc, -46px -80px 0 1px #e8963a;
  }
}
.celebrate-big { animation-duration: 1.2s; transform-origin: center; }
.celebrate-big::before { inset: -60px; }

/* ── Toasts ─────────────────────────────────────────────────────────────── */
#toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  width: min(92vw, 380px);
  pointer-events: none;
}

.toast {
  width: 100%;
  padding: 10px 14px;
  border-radius: 9px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255, 248, 224, .7), transparent 60%),
    linear-gradient(170deg, var(--parch-50), var(--parch-200));
  border: 1.5px solid var(--parch-400);
  border-left-width: 5px;
  color: var(--ink-900);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  box-shadow: var(--shadow-md);
  animation: toastIn .32s var(--ease-pop);
  pointer-events: auto;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
.toast-good, .toast-success { border-left-color: var(--good); }
.toast-bad, .toast-error    { border-left-color: var(--bad); }
.toast-info                 { border-left-color: var(--info); }
.toast-out { animation: toastOut .3s ease forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px) scale(.94); }
}

/* ── Ad anchor ──────────────────────────────────────────────────────────── */
#ad-anchor {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-h) + var(--safe-b));
  z-index: 15;
  display: flex;
  justify-content: center;
  background: rgba(11, 17, 28, .85);
  border-top: 1px solid rgba(233, 187, 85, .2);
  min-height: var(--ad-h);
}
#ad-anchor ins { display: block; width: 100%; max-width: 728px; }

/* A visible ad reserves space instead of covering the scene bottom: the
   canvas shortens (engine has a ResizeObserver on it) and toasts lift above
   the strip. Browsers without :has() keep the old overlay behavior. */
body:has(#ad-anchor:not([hidden])) #kingdom-canvas {
  height: calc(100% - var(--nav-h) - var(--safe-b) - var(--ad-h));
}
body:has(#ad-anchor:not([hidden])) #toast-host {
  bottom: calc(var(--nav-h) + var(--safe-b) + var(--ad-h) + 14px);
}

/* ── Boot veil (decorative; removes itself, never blocks input) ─────────── */
#boot-veil {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background:
    radial-gradient(120% 90% at 50% 30%, var(--night-700), var(--night-900) 75%);
  pointer-events: none;
  animation: veilFade .7s ease 1.5s forwards;
}
@keyframes veilFade { to { opacity: 0; visibility: hidden; } }

.boot-crest svg {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 0 22px rgba(243, 207, 109, .5));
  animation: crestIn .8s var(--ease-pop) backwards;
}
@keyframes crestIn {
  from { opacity: 0; transform: translateY(14px) scale(.7); }
  to   { opacity: 1; transform: none; }
}
#boot-veil .game-logo { font-size: 40px; animation: crestIn .8s var(--ease-pop) .15s backwards; }
.boot-sub {
  color: rgba(240, 226, 192, .55);
  font-style: italic;
  font-size: 14px;
  animation: crestIn .8s var(--ease-pop) .3s backwards;
}

.noscript-note {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--night-900);
  color: var(--parch-100);
  font-size: 17px;
}

/* ── Desktop ≥ 768px ────────────────────────────────────────────────────── */
@media (min-width: 768px) {
  #top-bar { flex-wrap: nowrap; gap: 16px; padding-bottom: 8px; }
  .top-left { order: 1; }
  #resource-bar { order: 2; flex: 1 1 auto; justify-content: center; overflow: visible; }
  .top-right { order: 3; margin-left: 0; }
  #kingdom-name { font-size: 15px; max-width: 220px; }
  .resource-count { font-size: 14px; }

  /* Right-side 420px sheet */
  #panel {
    left: auto;
    width: 420px;
    max-width: 100%;
    border-radius: 12px 0 0 12px;
    border-left: 2px solid var(--gold-600);
    animation: panelSide .32s var(--ease-pop);
    box-shadow:
      inset 0 0 0 1px rgba(58, 40, 12, .6),
      inset 0 0 0 4px rgba(243, 207, 109, .28),
      -18px 0 50px rgba(0, 0, 0, .55);
  }
  #panel.ornate::after { display: block; }
  .sheet-handle { display: none; }
  #panel-header { padding-top: 12px; }

  #panel-scrim { background: rgba(5, 8, 14, .3); }

  .nav-label { font-size: 11px; }
  .nav-btn { max-width: 120px; }
  #bottom-nav { justify-content: center; }

  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .modal { max-width: 430px; padding: 28px 30px; }
}
@keyframes panelSide {
  from { opacity: .4; transform: translateX(8%); }
  to   { opacity: 1; transform: none; }
}

@media (min-width: 1200px) {
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
}

/* ── Short landscape phones ─────────────────────────────────────────────── */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --nav-h: 52px; }
  .nav-label { display: none; }
  #resource-bar { order: 2; flex: 1 1 auto; }
  #top-bar { flex-wrap: nowrap; }
  #kingdom-name { display: none; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  #boot-veil { display: none; }
  .gold-text {
    animation: none;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
    color: var(--gold-500);
  }
  .claimable { box-shadow: 0 0 10px 3px rgba(243, 207, 109, .6); }
  .nav-btn.claimable .nav-icon svg { filter: drop-shadow(0 0 5px rgba(243, 207, 109, .8)); }
}
