/* ============================================================================
   TIDEHOLD — "the deep at dusk, lit by brass"
   Deep-water ground · weathered brass + sea-foam accents · bone-parchment text.
   Cinzel (engraved titles) · Spectral (logbook prose) · JetBrains Mono (instrument data).
   ========================================================================== */

:root {
  --ink:        #0b1a1f;   /* deepest ground            */
  --ink-2:      #0e2127;   /* slightly raised ground    */
  --deep:       #102a31;   /* panels / cards            */
  --deep-2:     #16373f;   /* hover / raised surfaces   */
  --line:       #234c55;   /* hairline borders          */
  --line-soft:  #1a3a42;

  --brass:      #c9a25e;   /* primary metallic accent   */
  --brass-bright:#e3c184;
  --brass-deep: #8f6f3a;
  --foam:       #7fb7ad;   /* cool sea-foam accent/link */
  --foam-bright:#a6d4cb;

  --parchment:  #ece0c6;   /* primary text              */
  --muted:      #9bafab;   /* secondary text (cool)     */
  --faint:      #6f8480;   /* tertiary / captions       */

  --danger:     #d98a6a;
  --good:       #8fc7a0;

  --maxw: 1180px;
  --gutter: clamp(1.1rem, 4vw, 2.6rem);
  --radius: 3px;          /* near-square; weathered, not bubbly */

  --shadow: 0 18px 50px -28px rgba(0,0,0,.85);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  background: var(--ink);
  color: var(--parchment);
  font-family: "Spectral", Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 0.4vw + 0.95rem, 1.12rem);
  line-height: 1.72;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--foam); text-decoration: none; }
a:hover { color: var(--foam-bright); }

:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ---------- type ---------- */
h1, h2, h3, .display {
  font-family: "Cinzel", Georgia, serif;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: .02em;
  color: var(--parchment);
}
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: .72rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 500;
}

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: clamp(3.2rem, 7vw, 6rem); }
.section--tight { padding-block: clamp(2.2rem, 4vw, 3.4rem); }

/* ============================================================================
   SIGNATURE — the tide-line. A drifting brass waterline used as a divider and
   under the hero wordmark. It's the one bold, on-brief element; everything else
   stays quiet.
   ========================================================================== */
.tideline {
  --tide-h: 26px;
  position: relative;
  height: var(--tide-h);
  background:
    repeating-linear-gradient(90deg, transparent 0 6px, rgba(201,162,94,.0) 6px 7px);
  -webkit-mask: var(--wave) repeat-x left center / 120px 100%;
          mask: var(--wave) repeat-x left center / 120px 100%;
  background-color: var(--brass);
  opacity: .55;
  animation: drift 14s linear infinite;
}
.tideline::after {
  content: "";
  position: absolute; inset: 0;
  background-color: var(--foam);
  opacity: .28;
  -webkit-mask: var(--wave) repeat-x left center / 120px 100%;
          mask: var(--wave) repeat-x left center / 120px 100%;
  animation: drift 22s linear infinite reverse;
}
/* a single wave cell, used as a mask so the bar reads as a crested waterline */
.tideline {
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='26' viewBox='0 0 120 26'%3E%3Cpath d='M0 20 C 15 6, 25 6, 40 14 S 65 28, 80 18 S 105 6, 120 14 L120 26 L0 26 Z' fill='%23000'/%3E%3C/svg%3E");
}
@keyframes drift { to { background-position: 240px 0, 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .tideline, .tideline::after { animation: none; }
}

/* ---------- header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--ink);
  background: color-mix(in srgb, var(--ink) 86%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.nav {
  display: flex; align-items: center; gap: 1.2rem;
  padding-block: .9rem;
}
.brand {
  font-family: "Cinzel", serif; font-weight: 700;
  font-size: 1.18rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--parchment); display: inline-flex; align-items: center; gap: .55rem;
}
.brand:hover { color: var(--brass-bright); }
.brand .mark { width: 18px; height: 18px; color: var(--brass); }
.nav-links { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.nav-links a {
  color: var(--muted); font-family: "JetBrains Mono", monospace;
  font-size: .82rem; letter-spacing: .12em; text-transform: uppercase;
  padding: .5rem .8rem; border-radius: var(--radius);
}
.nav-links a:hover { color: var(--parchment); background: var(--deep); }
.nav-links a[aria-current="page"] { color: var(--brass); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--line);
  color: var(--parchment); border-radius: var(--radius); padding: .45rem .6rem;
  font-family: "JetBrains Mono", monospace; cursor: pointer; margin-left: auto;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: "JetBrains Mono", monospace; font-size: .82rem; font-weight: 500;
  letter-spacing: .12em; text-transform: uppercase;
  padding: .72rem 1.15rem; border-radius: var(--radius);
  border: 1px solid var(--line); color: var(--parchment); background: var(--deep);
  cursor: pointer; transition: transform .12s ease, background .18s ease, border-color .18s ease;
}
.btn:hover { background: var(--deep-2); border-color: var(--brass-deep); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--brass {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: #2a1d07; border-color: var(--brass-bright); font-weight: 700;
}
.btn--brass:hover { color: #1c1304; filter: brightness(1.05); }
.btn--ghost { background: transparent; }
.btn--sm { padding: .5rem .8rem; font-size: .74rem; }

/* ---------- hero ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  padding-block: clamp(4rem, 12vw, 9rem) 0;
  text-align: center;
}
/* layered deep-water atmosphere */
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background:
    radial-gradient(120% 80% at 50% 8%, rgba(227,193,132,.16), transparent 46%),
    radial-gradient(140% 90% at 50% 120%, #06141a 30%, transparent 70%),
    linear-gradient(180deg, var(--ink-2), var(--ink) 70%);
}
.hero::after { /* faint horizon glow line */
  content: ""; position: absolute; left: 0; right: 0; top: 18%; height: 1px; z-index: -1;
  background: linear-gradient(90deg, transparent, rgba(227,193,132,.45), transparent);
}
.hero-inner { max-width: 760px; margin-inline: auto; padding-inline: var(--gutter); }
.hero h1 {
  font-size: clamp(2.7rem, 9vw, 5.4rem);
  letter-spacing: .08em; text-transform: uppercase;
  text-shadow: 0 2px 30px rgba(0,0,0,.6);
}
.hero h1 .sub { display:block; font-size: .26em; letter-spacing: .42em; color: var(--brass); margin-top: 1rem; }
.hero .lede {
  font-size: clamp(1.05rem, 1.4vw, 1.3rem); color: var(--muted);
  max-width: 46ch; margin: 1.4rem auto 0; font-style: italic;
}
.hero-cta { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }
.hero-tide { margin-top: clamp(2.5rem, 6vw, 4.5rem); }
.hero-note { font-family:"JetBrains Mono",monospace; font-size:.72rem; color: var(--faint); letter-spacing:.1em; margin-top:1rem; }

/* drifting sea band beneath the hero */
.sea {
  height: clamp(70px, 12vw, 130px); position: relative; z-index: -1; margin-top: -1px;
  background:
    linear-gradient(180deg, transparent, rgba(127,183,173,.05)),
    radial-gradient(100% 60% at 50% 100%, rgba(127,183,173,.10), transparent 70%);
  overflow: hidden;
}
.sea span {
  position: absolute; left: -10%; right: -10%; bottom: 0; height: 60%;
  background: var(--foam); opacity: .06;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='40' viewBox='0 0 200 40'%3E%3Cpath d='M0 28 C 30 14 50 14 80 24 S 140 40 200 22 L200 40 L0 40 Z' fill='%23000'/%3E%3C/svg%3E") repeat-x bottom / 200px 100%;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='40' viewBox='0 0 200 40'%3E%3Cpath d='M0 28 C 30 14 50 14 80 24 S 140 40 200 22 L200 40 L0 40 Z' fill='%23000'/%3E%3C/svg%3E") repeat-x bottom / 200px 100%;
  animation: sea 18s linear infinite;
}
.sea span:nth-child(2){ opacity:.045; height:80%; animation-duration: 28s; animation-direction: reverse; }
@keyframes sea { to { background-position: 400px 0; transform: translateX(-200px); } }
@media (prefers-reduced-motion: reduce){ .sea span { animation: none; } }

/* ---------- generic section heading ---------- */
.head { max-width: 60ch; margin-bottom: 2.2rem; }
.head h2 { font-size: clamp(1.6rem, 3.6vw, 2.4rem); margin-top: .4rem; }
.head p { color: var(--muted); margin-top: .7rem; }

/* ---------- pillar cards ---------- */
.grid { display: grid; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.cell { background: var(--deep); padding: 1.5rem 1.4rem; }
.cell h3 { font-size: 1.02rem; letter-spacing: .06em; color: var(--brass-bright); margin-bottom: .5rem; }
.cell .num { font-family:"JetBrains Mono",monospace; font-size:.74rem; color: var(--faint); letter-spacing:.18em; }
.cell p { color: var(--muted); font-size: .98rem; }

/* ---------- currency duality ---------- */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.coin {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem 1.5rem;
  background: linear-gradient(180deg, var(--deep), var(--ink-2));
}
.coin h3 { display:flex; align-items:center; gap:.6rem; font-size: 1.15rem; }
.coin.bound h3 { color: var(--foam-bright); }
.coin.conv h3 { color: var(--brass-bright); }
.coin .tag { font-family:"JetBrains Mono",monospace; font-size:.66rem; letter-spacing:.16em; text-transform:uppercase; padding:.2rem .5rem; border:1px solid var(--line); border-radius: 99px; color: var(--muted); }
.coin ul { list-style: none; padding: 0; margin: 1rem 0 0; }
.coin li { padding: .35rem 0 .35rem 1.3rem; position: relative; color: var(--parchment); font-size: .98rem; border-top: 1px solid var(--line-soft); }
.coin li:first-of-type { border-top: 0; }
.coin li::before { content: "◆"; position: absolute; left: 0; color: var(--brass); font-size: .7em; top: .7em; }
.coin.bound li::before { content: "•"; color: var(--foam); }

/* ---------- the one rule banner ---------- */
.rule {
  border: 1px solid var(--brass-deep); border-left: 3px solid var(--brass);
  background: linear-gradient(90deg, rgba(201,162,94,.10), transparent 60%);
  border-radius: var(--radius); padding: 1.5rem 1.6rem;
}
.rule .eyebrow { color: var(--brass-bright); }
.rule p { margin-top: .6rem; font-size: 1.08rem; }
.rule strong { color: var(--brass-bright); }

/* ============================================================================
   CODEX (docs) — two-column reference: sticky contents + long-form prose
   ========================================================================== */
.codex { display: grid; grid-template-columns: 230px 1fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: start; }
.toc { position: sticky; top: 84px; align-self: start; }
.toc h4 { font-family:"JetBrains Mono",monospace; font-size:.7rem; letter-spacing:.22em; text-transform:uppercase; color: var(--faint); margin-bottom:.7rem; }
.toc a { display: block; color: var(--muted); padding: .32rem 0 .32rem .8rem; border-left: 1px solid var(--line-soft); font-size: .92rem; }
.toc a:hover { color: var(--parchment); border-left-color: var(--foam); }
.toc a.active { color: var(--brass); border-left-color: var(--brass); }

.doc h2 { font-size: clamp(1.5rem, 3.2vw, 2.1rem); margin: 0 0 .3rem; }
.doc section { scroll-margin-top: 86px; padding-block: clamp(2rem, 4vw, 3rem); border-top: 1px solid var(--line-soft); }
.doc section:first-of-type { border-top: 0; padding-top: .5rem; }
.doc h3 { font-size: 1.15rem; color: var(--brass-bright); margin: 1.6rem 0 .5rem; letter-spacing: .04em; }
.doc p { margin-top: .8rem; color: var(--parchment); }
.doc p.note { color: var(--muted); font-style: italic; font-size: .96rem; }
.doc .eyebrow { display:block; margin-bottom:.5rem; }
.doc ul, .doc ol { margin: .8rem 0 0; padding-left: 1.3rem; color: var(--parchment); }
.doc li { margin-block: .4rem; }
.doc strong { color: var(--brass-bright); font-weight: 600; }
.doc code, .kbd {
  font-family:"JetBrains Mono",monospace; font-size:.86em;
  background: var(--ink-2); border:1px solid var(--line-soft); border-radius: 3px;
  padding: .08em .4em; color: var(--foam-bright);
}

/* definition table (resources / skills) */
.deftable { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: .97rem; }
.deftable th, .deftable td { text-align: left; padding: .7rem .8rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.deftable th { font-family:"JetBrains Mono",monospace; font-size:.7rem; letter-spacing:.14em; text-transform:uppercase; color: var(--faint); font-weight:500; }
.deftable td:first-child { color: var(--brass-bright); font-family:"Cinzel",serif; white-space: nowrap; }
.deftable tr:hover td { background: var(--ink-2); }

/* skill chips row */
.chips { display:flex; flex-wrap:wrap; gap:.5rem; margin-top:1rem; }
.chip { font-family:"JetBrains Mono",monospace; font-size:.74rem; letter-spacing:.1em; padding:.4rem .7rem; border:1px solid var(--line); border-radius:99px; color: var(--muted); }
.chip b { color: var(--foam-bright); font-weight: 500; }

/* ============================================================================
   LEDGER (stats) — instrument gauges + leaderboard
   ========================================================================== */
.ledger-status {
  font-family:"JetBrains Mono",monospace; font-size:.74rem; letter-spacing:.1em;
  color: var(--faint); display:flex; align-items:center; gap:.5rem; margin-bottom: 1.4rem;
}
.dot { width:7px; height:7px; border-radius:50%; background: var(--faint); display:inline-block; }
.dot.live { background: var(--good); box-shadow: 0 0 10px var(--good); }
.dot.sample { background: var(--brass); }

.gauges { display:grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line-soft); border:1px solid var(--line-soft); border-radius: var(--radius); overflow:hidden; }
.gauge { background: var(--deep); padding: 1.5rem 1.4rem; }
.gauge .label { font-family:"JetBrains Mono",monospace; font-size:.68rem; letter-spacing:.2em; text-transform:uppercase; color: var(--faint); }
.gauge .value { font-family:"JetBrains Mono",monospace; font-weight:700; font-size: clamp(1.5rem, 3vw, 2.1rem); color: var(--brass-bright); margin-top:.5rem; letter-spacing:-.01em; }
.gauge .sub { font-size:.85rem; color: var(--muted); margin-top:.2rem; }

.board { display:grid; grid-template-columns: 1.3fr 1fr; gap: 1.4rem; margin-top: 1.4rem; }
.panel { border:1px solid var(--line-soft); border-radius: var(--radius); background: var(--deep); padding: 1.4rem 1.5rem; }
.panel h3 { font-size: 1.05rem; color: var(--parchment); letter-spacing:.05em; margin-bottom: .3rem; }
.panel .eyebrow { display:block; margin-bottom:.8rem; }

.rank { list-style:none; padding:0; margin:0; }
.rank li { display:grid; grid-template-columns: 1.6rem 1fr auto; align-items:center; gap:.7rem; padding:.6rem 0; border-top:1px solid var(--line-soft); }
.rank li:first-child { border-top:0; }
.rank .pos { font-family:"JetBrains Mono",monospace; color: var(--brass); font-size:.9rem; }
.rank .who { color: var(--parchment); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rank .who small { color: var(--faint); font-family:"JetBrains Mono",monospace; font-size:.72rem; }
.rank .amt { font-family:"JetBrains Mono",monospace; color: var(--foam-bright); font-size:.92rem; }

.sale { text-align:center; padding-block:.6rem; }
.sale .item { font-family:"Cinzel",serif; font-size:1.25rem; color: var(--brass-bright); }
.sale .price { font-family:"JetBrains Mono",monospace; font-weight:700; font-size: clamp(1.6rem,4vw,2.4rem); color: var(--parchment); margin:.4rem 0; }
.sale .parties { font-size:.9rem; color: var(--muted); }

.bars { list-style:none; padding:0; margin:.5rem 0 0; }
.bars li { margin-block:.6rem; }
.bars .row { display:flex; justify-content:space-between; font-size:.9rem; margin-bottom:.25rem; }
.bars .row b { color: var(--foam-bright); font-family:"JetBrains Mono",monospace; font-weight:500; }
.bars .track { height:7px; background: var(--ink-2); border-radius:99px; overflow:hidden; }
.bars .fill { height:100%; background: linear-gradient(90deg, var(--brass-deep), var(--brass)); }

/* ---------- footer ---------- */
.site-footer { border-top:1px solid var(--line-soft); background: var(--ink-2); padding-block: 2.6rem; margin-top: 2rem; }
.foot { display:flex; flex-wrap:wrap; gap:1.2rem; justify-content:space-between; align-items:center; }
.foot small, .foot a { font-family:"JetBrains Mono",monospace; font-size:.76rem; letter-spacing:.08em; color: var(--faint); }
.foot a:hover { color: var(--foam); }
.foot .brand { font-size: 1rem; }

/* wallet pill */
#walletState { font-family:"JetBrains Mono",monospace; font-size:.74rem; color: var(--good); }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  .codex { grid-template-columns: 1fr; }
  .toc { position: static; border:1px solid var(--line-soft); border-radius:var(--radius); padding:1rem 1.2rem; background: var(--ink-2); }
  .toc a { display:inline-block; border-left:0; padding:.3rem .6rem; }
  .board { grid-template-columns: 1fr; }
  .gauges { grid-template-columns: repeat(2,1fr); }
  .grid--3, .grid--4 { grid-template-columns: 1fr 1fr; }
  .duo { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .nav-links { display:none; position:absolute; top:100%; left:0; right:0; flex-direction:column; gap:0;
    background: var(--ink); border-bottom:1px solid var(--line); padding:.5rem var(--gutter) 1rem; }
  .nav-links.open { display:flex; }
  .nav-links a { padding:.7rem .2rem; border-bottom:1px solid var(--line-soft); }
  .nav-toggle { display:inline-block; }
  .site-header .nav { position: relative; }
  .gauges { grid-template-columns: 1fr 1fr; }
  .grid--3, .grid--4 { grid-template-columns: 1fr; }
  .hero-cta .btn { width: 100%; }
}

/* ============================================================================
   Live badge · wallet stats panel · embedded game page
   ========================================================================== */
.live-badge {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: "JetBrains Mono", monospace; font-size: .72rem; letter-spacing: .06em;
  color: var(--foam-bright);
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--good); box-shadow: 0 0 8px var(--good);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* a connected player's own stats, shown under the hero */
.wallet-stats {
  margin: 1.6rem auto 0; max-width: 480px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--deep), var(--ink-2));
  padding: 1.3rem 1.4rem; box-shadow: var(--shadow);
}
.ws-head { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.ws-head h3 { font-size: 1.15rem; color: var(--brass-bright); }
.ws-wallet { color: var(--faint); font-size: .74rem; }
.ws-figs { display: grid; grid-template-columns: repeat(4,1fr); gap: .6rem; margin: 1rem 0 .4rem; }
.ws-figs > div { background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: .65rem .5rem; text-align: center; }
.ws-label { display: block; font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.ws-val { display: block; color: var(--parchment); font-weight: 700; margin-top: .25rem; font-size: .98rem; }
.ws-sub { font-family: "JetBrains Mono", monospace; font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); margin: 1rem 0 .4rem; }
.ws-skills { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.ws-skills li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line-soft); padding: .35rem 0; font-size: .92rem; }
.ws-skills b { color: var(--foam-bright); font-weight: 500; font-size: .8rem; }
.ws-empty { color: var(--muted); font-size: .94rem; }
.ws-count { color: var(--faint); font-size: .72rem; }
.ws-achs { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.ws-achs .ws-empty { width: 100%; }
.ws-ach {
  background: var(--ink-2); border: 1px solid var(--line-soft); border-radius: 999px;
  padding: .3rem .7rem; font-size: .82rem; color: var(--foam-bright); line-height: 1;
}

/* embedded game.
   The whole page is locked to the VISIBLE viewport height (--app-height, set from visualViewport by
   app.js; dvh fallback) so in-app browsers like Phantom can't push the bottom of the game behind their
   toolbar. No page scroll: header + bar + fallback are fixed, the stage fills the rest. */
.game-page { height: var(--app-height, 100dvh); overflow: hidden; display: flex; flex-direction: column; }
.game-page .site-header { position: static; flex: 0 0 auto; }     /* part of the column, not sticky */
.game-main { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.game-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-block: .8rem; flex: 0 0 auto; }
.game-bar .eyebrow { color: var(--faint); }
.game-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.game-stage {
  flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center;
  background: #05080a; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft);
}
#gameFrame { display: block; width: 100%; height: 100%; border: 0; }
.game-fallback {
  text-align: center; color: var(--faint); font-family: "JetBrains Mono", monospace; font-size: .76rem;
  padding: .9rem; flex: 0 0 auto; padding-bottom: calc(.9rem + env(safe-area-inset-bottom, 0px));
}
/* Desktop: present the game as a clean 16:9 area so the landscape UI has a fixed design target (1920x1080).
   Wider screens pillarbox at the sides rather than stretching the canvas. */
@media (min-width: 821px) {
  #gameFrame { width: auto; height: 100%; aspect-ratio: 16 / 9; max-width: 100%; }
}

/* small-screen wallet stats + safe-area footer (so in-app browser toolbars don't clip it) */
@media (max-width: 560px) { .ws-figs { grid-template-columns: 1fr 1fr; } }
.site-footer { padding-bottom: calc(2.6rem + env(safe-area-inset-bottom, 0px)); }

/* ---- Hiscores (homepage) ---- */
.hs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.hs-head h3 { font-family: "Cinzel", serif; font-size: 1.5rem; color: var(--brass); letter-spacing: .05em; margin: 0; }
.hs-sub { font-family: "JetBrains Mono", monospace; font-size: .72rem; color: var(--faint); white-space: nowrap; }
.hs-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .9rem; }
.hs-tab {
  background: var(--ink-2); border: 1px solid var(--line-soft); color: var(--muted);
  border-radius: 999px; padding: .34rem .8rem; font-size: .8rem; cursor: pointer;
  font-family: "JetBrains Mono", monospace; transition: background .15s, color .15s, border-color .15s;
}
.hs-tab:hover { border-color: var(--brass-deep); color: var(--parchment); }
.hs-tab.active {
  background: linear-gradient(180deg, var(--brass-bright), var(--brass));
  color: #2a1d07; border-color: var(--brass-bright); font-weight: 700;
}
.hs-scroll { max-height: 30rem; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: var(--radius); }
.hs-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.hs-table thead th {
  position: sticky; top: 0; z-index: 1; background: var(--ink-2); color: var(--faint);
  text-align: left; font-family: "JetBrains Mono", monospace; font-size: .66rem;
  letter-spacing: .18em; text-transform: uppercase; padding: .6rem .75rem; border-bottom: 1px solid var(--line);
}
.hs-table td { padding: .5rem .75rem; vertical-align: middle; }
.hs-table tbody tr { border-bottom: 1px solid var(--line-soft); }
.hs-table tbody tr:last-child { border-bottom: none; }
.hs-table th.hs-num, .hs-table td.hs-num { text-align: right; font-family: "JetBrains Mono", monospace; }
.hs-table th.hs-rank { text-align: center; width: 3rem; }
td.hs-rank { text-align: center; color: var(--faint); font-family: "JetBrains Mono", monospace; font-weight: 700; }
td.hs-rank.hs-top1 { color: #e3c184; }   /* gold   */
td.hs-rank.hs-top2 { color: #cdd3d1; }   /* silver */
td.hs-rank.hs-top3 { color: #c9874e; }   /* bronze */
.hs-who { color: var(--parchment); }
.hs-who small { display: block; color: var(--faint); font-family: "JetBrains Mono", monospace; font-size: .66rem; margin-top: .08rem; }
td.hs-num { color: var(--foam-bright); }
td.hs-num.hs-xp { color: var(--muted); }
.hs-me { background: color-mix(in srgb, var(--brass) 14%, transparent); }
.hs-me .hs-who { color: var(--brass-bright); }
.hs-empty { text-align: center; color: var(--muted); padding: 1.6rem; }
