/* ==========================================================================
   Dead Man's Compass — styles
   ========================================================================== */

@font-face {
  font-family: 'Pirata One';
  src: url('../fonts/pirata-one.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('../fonts/im-fell-english.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English';
  src: url('../fonts/im-fell-english-italic.woff2') format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'IM Fell English SC';
  src: url('../fonts/im-fell-english-sc.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --parchment: #e9d7ae;
  --parchment-light: #f5e8c8;
  --parchment-mid: #ddc799;
  --parchment-deep: #cdb27d;
  --ink: #2b1c0e;
  --ink-soft: #4d3822;
  --ink-faint: #6d5638;
  --gold: #c99534;
  --gold-bright: #f1c962;
  --gold-deep: #8f6220;
  --brass: #9a7535;
  --brass-dark: #5f451c;
  --red: #9c332a;
  --red-bright: #ce5947;
  --sea-deep: #051316;
  --sea: #0b2a2e;
  --sea-light: #17514f;
  --teal: #3f8a83;
  --font-display: 'Pirata One', Georgia, 'Times New Roman', serif;
  --font-body: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --font-label: 'IM Fell English SC', Georgia, 'Times New Roman', serif;
  --font-num: Georgia, 'Times New Roman', 'Nimbus Roman', serif;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.2'/%3E%3C/svg%3E");
  --shadow-deep: 0 24px 50px -18px rgba(0, 0, 0, .85);
  --paper-edge: inset 0 1px 0 rgba(255, 250, 230, .45), inset 0 0 0 1px rgba(82, 57, 25, .35);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--sea-deep);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.45;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
  color: inherit;
}

::selection {
  background: rgba(201, 149, 52, .4);
  color: #fff5d8;
}

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

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Sea + atmosphere
   -------------------------------------------------------------------------- */

.sea {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #1d5a58 0%, #103b3e 28%, #092329 58%, #041013 100%);
}

.sea::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(70% 50% at 50% 0%, rgba(121, 204, 190, .16), transparent 65%),
    radial-gradient(50% 30% at 15% 20%, rgba(50, 120, 115, .12), transparent 70%),
    var(--noise);
  background-size: auto, auto, 220px 220px;
  opacity: .75;
  mix-blend-mode: screen;
}

.sea::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 80% at 50% 45%, transparent 35%, rgba(1, 6, 8, .55) 100%);
  pointer-events: none;
}

.sea-glow {
  position: absolute;
  left: 50%;
  top: 12%;
  width: min(900px, 90vw);
  height: min(520px, 55vh);
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(231, 204, 135, .18), transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

.stars {
  position: absolute;
  inset: 0 0 35% 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(250, 236, 195, .6), transparent 100%),
    radial-gradient(1px 1px at 32% 12%, rgba(250, 236, 195, .4), transparent 100%),
    radial-gradient(1.5px 1.5px at 55% 18%, rgba(250, 236, 195, .5), transparent 100%),
    radial-gradient(1px 1px at 74% 8%, rgba(250, 236, 195, .45), transparent 100%),
    radial-gradient(1.5px 1.5px at 88% 26%, rgba(250, 236, 195, .35), transparent 100%),
    radial-gradient(1px 1px at 43% 30%, rgba(250, 236, 195, .3), transparent 100%);
  opacity: .8;
  animation: twinkle 9s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from { opacity: .5; }
  to { opacity: .95; }
}

.waves {
  position: absolute;
  left: -10%;
  width: 120%;
  bottom: 0;
  height: 20vh;
  min-height: 110px;
  pointer-events: none;
}
.waves svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
.waves-back { bottom: 5vh; opacity: .2; color: #1b6561; animation: wave-drift 26s linear infinite; }
.waves-mid   { bottom: 1vh; opacity: .34; color: #0f4c4c; animation: wave-drift 19s linear infinite reverse; }
.waves-front { bottom: -2vh; opacity: .55; color: #082327; animation: wave-drift 14s linear infinite; }
.waves svg path { fill: currentColor; }
body.screen-game .waves,
body.screen-charts .waves { opacity: .42; }

@keyframes wave-drift {
  from { transform: translateX(-4%); }
  50%  { transform: translateX(2%); }
  to   { transform: translateX(-4%); }
}

.title-ship {
  position: absolute;
  left: 50%;
  bottom: 13vh;
  width: min(320px, 42vw);
  transform: translateX(-50%);
  opacity: .88;
  filter: drop-shadow(0 12px 16px rgba(0, 0, 0, .45));
  animation: ship-bob 7s ease-in-out infinite;
  display: none;
}
body.screen-title .title-ship { display: block; }

.title-ship svg { width: 100%; height: auto; overflow: visible; }
.ship-hull path { fill: #061114; }
.ship-masts path { fill: #071619; stroke: #0a2022; }
.ship-flag { fill: #9c332a; stroke: none !important; }
.ship-reflection { fill: none; stroke: rgba(229, 202, 137, .25); stroke-width: 1.2; }

@keyframes ship-bob {
  0%, 100% { transform: translate(-50%, 0) rotate(-.4deg); }
  50%      { transform: translate(-50%, -7px) rotate(.4deg); }
}

/* --------------------------------------------------------------------------
   Shared type + buttons
   -------------------------------------------------------------------------- */

.eyebrow {
  margin: 0;
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--gold-bright);
  opacity: .9;
}

.gold-text {
  background: linear-gradient(180deg, #fff0b7 0%, #f4cf7d 34%, #d29c3e 62%, #986921 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.btn {
  --btn-bg: rgba(7, 26, 29, .6);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 12px 22px;
  border: 1px solid rgba(201, 149, 52, .55);
  border-radius: 3px;
  background: var(--btn-bg);
  color: var(--parchment);
  font-family: var(--font-label);
  font-size: 13px;
  letter-spacing: .15em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(241, 201, 98, .85);
  background: rgba(18, 48, 51, .72);
  box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .8);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, #f5d98e 0%, #e0b45a 42%, #c19136 70%, #a97828 100%);
  color: #2a1a07;
  border-color: #73511c;
  box-shadow: 0 5px 0 #6d4b18, 0 14px 28px -14px rgba(0, 0, 0, .8);
  text-shadow: 0 1px 0 rgba(255, 244, 201, .45);
  font-weight: 600;
}
.btn-primary:hover {
  background: linear-gradient(180deg, #ffe6a4 0%, #ecc268 42%, #ca9a3c 70%, #b17f2c 100%);
  transform: translateY(-2px);
  box-shadow: 0 7px 0 #6d4b18, 0 18px 30px -14px rgba(0, 0, 0, .85);
}
.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #6d4b18;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: rgba(233, 215, 174, .82);
  box-shadow: none;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(201, 149, 52, .25);
  color: var(--parchment-light);
}

.btn[disabled] {
  opacity: .4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid rgba(201, 149, 52, .35);
  background: rgba(6, 23, 26, .45);
  color: var(--parchment);
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:hover {
  background: rgba(24, 58, 60, .7);
  border-color: rgba(241, 201, 98, .65);
  transform: translateY(-1px);
}
.icon-btn svg { width: 20px; height: 20px; }

/* --------------------------------------------------------------------------
   Screen scaffolding
   -------------------------------------------------------------------------- */

#screen {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

.screen {
  min-height: 100dvh;
  animation: screen-in .45s cubic-bezier(.22, .8, .3, 1) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------------------
   Title screen
   -------------------------------------------------------------------------- */

.title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(34px, 7vh, 80px) 24px clamp(150px, 22vh, 220px);
  position: relative;
}

.title-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: rise-in .9s .05s cubic-bezier(.22, .8, .3, 1) both;
}

.logo-mark {
  width: clamp(86px, 13vw, 132px);
  margin-bottom: 6px;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, .55)) drop-shadow(0 0 22px rgba(226, 181, 82, .25));
  animation: logo-float 8s ease-in-out infinite;
}
.logo-mark svg { width: 100%; height: auto; display: block; }

@keyframes logo-float {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-7px) rotate(1deg); }
}

.title-eyebrow {
  margin-top: 8px;
  font-family: var(--font-label);
  font-size: clamp(10px, 1.3vw, 13px);
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--gold-bright);
  opacity: .85;
}

.game-title {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(72px, 14.5vw, 168px);
  line-height: .76;
  letter-spacing: .005em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff2c2 2%, #f6d585 30%, #dba847 55%, #b47f2b 78%, #8a5c1b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(55, 30, 4, .45)) drop-shadow(0 18px 34px rgba(0, 0, 0, .55));
}
.game-title .title-small {
  display: block;
  font-size: .48em;
  letter-spacing: .045em;
  margin-bottom: .08em;
  opacity: .96;
}
.game-title .title-large { display: block; }

.title-tagline {
  max-width: 580px;
  margin: 18px auto 0;
  font-size: clamp(17px, 2.1vw, 21px);
  font-style: italic;
  color: rgba(236, 220, 181, .82);
  text-wrap: balance;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .5);
}

.prototype-link { text-decoration: none; }

.title-menu {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: clamp(26px, 4vh, 42px);
}
.title-menu .btn { min-width: 158px; }

.title-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 30px;
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(245, 233, 203, .84);
  padding: 0 20px;
  z-index: 2;
  text-shadow: 0 1px 7px rgba(0, 0, 0, .8);
}
.title-footer span { display: inline-flex; align-items: center; gap: 7px; }
.title-footer .dot { width: 3px; height: 3px; border-radius: 50%; background: rgba(240, 224, 185, .45); }
.title-footer .sound-toggle { color: rgba(240, 224, 185, .72); }

/* --------------------------------------------------------------------------
   Charts screen
   -------------------------------------------------------------------------- */

.charts-screen {
  padding: clamp(22px, 4vh, 42px) clamp(16px, 4vw, 56px) 80px;
  max-width: 1160px;
  margin: 0 auto;
  overflow-x: clip;
}

.page-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: clamp(18px, 3vh, 30px);
}
.page-head .head-copy { min-width: 0; }
.page-head h1,
.page-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(36px, 6vw, 62px);
  line-height: .9;
  letter-spacing: .01em;
}
.page-head .eyebrow { margin-bottom: 4px; }

.head-progress {
  margin-left: auto;
  text-align: right;
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(236, 220, 181, .75);
  min-width: 120px;
}
.progress-track {
  width: 120px;
  height: 5px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(201, 149, 52, .2);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #9a6c22, #f1c962);
  transition: width .5s ease;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: clamp(12px, 2vw, 20px);
}

.chart-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 156px;
  padding: 16px 17px 15px;
  text-align: left;
  color: var(--ink);
  background:
    var(--noise),
    linear-gradient(158deg, #efe0bd 0%, #e3cfa3 55%, #d5bb8a 100%);
  background-size: 180px 180px, cover;
  background-blend-mode: multiply, normal;
  border: 1px solid #7c5a2a;
  border-radius: 4px;
  box-shadow: var(--paper-edge), 0 16px 30px -18px rgba(0, 0, 0, .9);
  cursor: pointer;
  overflow: hidden;
  transition: transform .17s ease, box-shadow .2s ease, filter .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.chart-card::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(104, 74, 32, .3);
  border-radius: 2px;
  pointer-events: none;
}
.chart-card::after {
  content: '';
  position: absolute;
  right: -30px;
  bottom: -46px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(120, 85, 38, .13), transparent 68%);
  pointer-events: none;
}
.chart-card:hover {
  transform: translateY(-4px) rotate(-.25deg);
  box-shadow: var(--paper-edge), 0 22px 38px -18px rgba(0, 0, 0, .95), 0 0 0 1px rgba(241, 201, 98, .25);
}
.chart-card:active { transform: translateY(-1px); }

.chart-card.locked {
  cursor: not-allowed;
  filter: grayscale(.4) brightness(.86);
}
.chart-card.locked:hover { transform: none; }

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  justify-content: space-between;
}
.card-no {
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #6a4b23;
}
.card-name {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.15vw, 26px);
  line-height: .95;
  color: #2a1a09;
  letter-spacing: .01em;
}
.card-diff {
  display: flex;
  gap: 3px;
  margin-top: 7px;
  color: #6e4c1e;
  opacity: .8;
}
.card-diff svg { width: 14px; height: 14px; }
.card-diff .lit { color: #8f2f28; opacity: 1; }

.card-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}
.card-status {
  font-family: var(--font-label);
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #6a4b23;
}
.card-status .best { color: #5d3e17; }
.card-status .num { font-family: var(--font-num); font-weight: 600; letter-spacing: .01em; }
.title-footer .num { font-family: var(--font-num); font-weight: 600; }

.mini-chart {
  display: grid;
  grid-template-columns: repeat(var(--mn), 1fr);
  gap: 2px;
  width: 58px;
  height: 58px;
  padding: 4px;
  background: rgba(86, 58, 24, .08);
  border: 1px solid rgba(104, 74, 32, .25);
  border-radius: 2px;
}
.mini-cell {
  border-radius: 1px;
  background: rgba(86, 58, 24, .1);
}
.mini-cell.clue { background: #9d7332; box-shadow: 0 0 0 .5px rgba(70, 45, 16, .35); }
.mini-cell.chest { background: #8f2f28; }

.card-seal {
  position: absolute;
  right: 12px;
  bottom: 10px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(255, 230, 190, .8);
  background:
    radial-gradient(circle at 35% 30%, #c65a45, #8f2f28 62%, #5e1b18 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, .4), inset 0 1px 2px rgba(255, 220, 190, .35), inset 0 -2px 4px rgba(50, 0, 0, .4);
  transform: rotate(-9deg);
  border: 1px solid rgba(70, 15, 12, .6);
}
.card-seal svg { width: 21px; height: 21px; opacity: .9; }
.card-seal::before {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 222, 190, .28);
}

.chart-card .card-lock {
  position: absolute;
  right: 15px;
  bottom: 14px;
  color: rgba(42, 26, 9, .55);
}
.chart-card .card-lock svg { width: 22px; height: 22px; }

/* --------------------------------------------------------------------------
   Game screen
   -------------------------------------------------------------------------- */

.game-screen {
  display: flex;
  flex-direction: column;
  overflow-x: clip;
  padding: clamp(12px, 2.4vh, 22px) clamp(12px, 3.5vw, 44px) clamp(18px, 3vh, 30px);
  min-height: 100dvh;
}

.game-head {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 13px;
}
.game-head .head-copy { min-width: 0; }
.game-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(26px, 3.4vw, 38px);
  line-height: .92;
  color: var(--parchment-light);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .45);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-head .eyebrow { font-size: 9.5px; letter-spacing: .26em; opacity: .7; }

.game-stats {
  margin-left: auto;
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 5px 10px;
  border: 1px solid rgba(201, 149, 52, .24);
  border-radius: 3px;
  background: rgba(5, 21, 24, .38);
  color: var(--parchment);
}
.stat .stat-label {
  font-family: var(--font-label);
  font-size: 8.5px;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: rgba(233, 215, 174, .55);
  line-height: 1;
  margin-bottom: 3px;
}
.stat .stat-value {
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 16px;
  line-height: 1;
  color: var(--parchment-light);
  font-variant-numeric: lining-nums tabular-nums;
}
.stat.warn .stat-value { color: var(--gold-bright); }

.game-body {
  flex: 1;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 4vw, 52px);
  padding: clamp(10px, 2vh, 22px) 0;
  min-height: 0;
}

.board-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  position: relative;
}
.board-wrap::before {
  content: '';
  position: absolute;
  inset: -8%;
  background: radial-gradient(closest-side, rgba(233, 202, 130, .12), transparent 72%);
  filter: blur(14px);
  pointer-events: none;
  z-index: -1;
}

/* The chart itself */

.chart {
  --cell: 56px;
  --gutter: 48px;
  --n: 7;
  position: relative;
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--n), var(--cell));
  grid-template-rows: var(--gutter) repeat(var(--n), var(--cell));
  gap: 1px;
  padding: 1px;
  background: rgba(44, 28, 12, .48);
  border: 2px solid #3c2712;
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(243, 223, 172, .35),
    0 0 0 5px rgba(18, 9, 3, .22),
    0 26px 54px -18px rgba(0, 0, 0, .9);
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.chart::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--noise);
  background-size: 170px 170px;
  opacity: .1;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 4;
  border-radius: 2px;
}

.chart-corner {
  position: relative;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 38% 32%, #3d2b17, #241708 68%, #180e05 100%);
  color: var(--gold);
  z-index: 1;
}
.chart-corner svg {
  width: 74%;
  height: 74%;
  opacity: .85;
  filter: drop-shadow(0 1px 0 rgba(255, 220, 160, .2));
}

.count {
  position: relative;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, #ddc798 0%, #d3ba86 58%, #c9ad75 100%);
  color: #3f2c16;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: calc(var(--cell) * .38);
  line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
  z-index: 1;
  transition: background-color .2s, color .2s, text-shadow .2s;
  text-shadow: 0 1px 0 rgba(255, 245, 215, .35);
}
.col-count { border-bottom: 2px solid rgba(74, 48, 18, .3); }
.row-count { border-right: 2px solid rgba(74, 48, 18, .3); }
.count.done {
  color: #6f4b13;
  text-shadow: 0 0 9px rgba(247, 207, 112, .9), 0 1px 0 rgba(255, 248, 220, .6);
}
.count.over {
  color: #8f2f28;
  text-shadow: 0 0 10px rgba(180, 50, 40, .45);
}
.count.hot { background: linear-gradient(150deg, #f2e2b8, #e8d2a0); }

.cell {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  background: linear-gradient(145deg, #eeddb8 0%, #e5d0a4 58%, #d9c18e 100%);
  cursor: pointer;
  z-index: 1;
  transition: background-color .16s ease, box-shadow .16s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: hidden;
}
.cell:hover { background: linear-gradient(145deg, #f8ebcd, #f0dfb6 60%, #e7d1a3); }
.cell:active { transform: scale(.97); }
.cell:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2.5px var(--gold-bright), 0 0 14px rgba(241, 201, 98, .5);
  z-index: 3;
}

.cell.clue {
  background:
    radial-gradient(circle at 50% 46%, rgba(250, 240, 213, .72) 0%, rgba(238, 220, 180, .4) 48%, transparent 72%),
    linear-gradient(145deg, #eeddb8, #e2cca0 60%, #d6bd8a);
}

.cell .compass-svg,
.cell .chest-svg,
.cell .x-svg {
  position: relative;
  z-index: 2;
  display: block;
  pointer-events: none;
}
.compass-svg { width: 84%; height: 84%; overflow: visible; filter: drop-shadow(0 1px 1px rgba(60, 35, 10, .25)); }
.chest-svg { width: 76%; height: 76%; filter: drop-shadow(0 2px 2px rgba(45, 24, 4, .35)); }
.x-svg { width: 62%; height: 62%; }

.cell.ray::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(236, 186, 80, .26);
  z-index: 1;
  pointer-events: none;
  animation: ray-in .18s ease both;
}
@keyframes ray-in { from { opacity: 0; } to { opacity: 1; } }

/* The eight squares touching a focused compass: treasure is repelled. */
.cell.repel {
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(166, 48, 38, .11) 8px 9px),
    linear-gradient(145deg, #eeddb8 0%, #e5d0a4 58%, #d9c18e 100%);
  box-shadow: inset 0 0 0 2px rgba(172, 58, 43, .4);
}
.cell.repel::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(172, 58, 43, .55);
  box-shadow: 0 0 6px rgba(172, 58, 43, .45);
  z-index: 3;
  pointer-events: none;
}

.cell.focused-clue {
  box-shadow: inset 0 0 0 2px var(--gold-bright), inset 0 0 18px rgba(241, 201, 98, .4);
  z-index: 3;
}

.cell.clue-ok {
  box-shadow: inset 0 0 0 1px rgba(201, 149, 52, .55);
}
.cell.clue-ok .compass-svg {
  filter: drop-shadow(0 0 4px rgba(247, 205, 105, .85)) drop-shadow(0 1px 1px rgba(60, 35, 10, .25));
}

.cell.clue-bad {
  background: rgba(166, 48, 38, .28);
  box-shadow: inset 0 0 0 2px rgba(178, 54, 42, .7);
}
.cell.clue-bad .compass-svg {
  filter: drop-shadow(0 0 6px rgba(206, 72, 55, .95));
}

.cell.wrong {
  background: rgba(166, 48, 38, .34);
  box-shadow: inset 0 0 0 2px rgba(190, 65, 50, .75);
  animation: wrong-shake .42s cubic-bezier(.36, .07, .19, .97);
}
@keyframes wrong-shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}

.cell.shake {
  animation: wrong-shake .42s cubic-bezier(.36, .07, .19, .97);
}

.cell.hinted {
  animation: hint-pulse 1.4s ease;
}
@keyframes hint-pulse {
  0% { box-shadow: inset 0 0 0 0 rgba(241, 201, 98, .9); background-color: rgba(241, 201, 98, .55); }
  45% { box-shadow: inset 0 0 0 3px rgba(241, 201, 98, .95); background-color: rgba(241, 201, 98, .28); }
  100% { box-shadow: inset 0 0 0 0 rgba(241, 201, 98, 0); }
}

.chest-svg { animation: chest-pop .34s cubic-bezier(.2, 1.4, .35, 1) both; }
@keyframes chest-pop {
  0% { transform: scale(.55) translateY(5px); opacity: .5; }
  60% { transform: scale(1.08) translateY(-1px); opacity: 1; }
  100% { transform: scale(1) translateY(0); }
}
.x-svg { animation: x-in .16s ease both; }
@keyframes x-in { from { opacity: 0; transform: scale(.7); } to { opacity: .4; transform: scale(1); } }

/* Ghost preview of a chest on hover? keep it clean */

.cell.cursor {
  box-shadow: inset 0 0 0 2px rgba(241, 201, 98, .85);
  z-index: 4;
}

/* Captain's side panel */

.captain-panel {
  width: 248px;
  flex: 0 0 248px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  align-self: center;
}
.panel-card {
  position: relative;
  padding: 15px 16px;
  background:
    var(--noise),
    linear-gradient(158deg, rgba(238, 223, 187, .96), rgba(221, 201, 157, .95));
  background-size: 170px 170px, cover;
  background-blend-mode: multiply, normal;
  border: 1px solid rgba(124, 90, 42, .7);
  border-radius: 3px;
  box-shadow: var(--paper-edge), 0 14px 24px -16px rgba(0, 0, 0, .8);
  color: var(--ink);
}
.panel-card::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(104, 74, 32, .25);
  pointer-events: none;
  border-radius: 2px;
}
.panel-title {
  margin: 0 0 7px;
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #6c4b20;
}
.panel-flavor {
  margin: 0;
  font-style: italic;
  font-size: 16px;
  color: #3a2712;
  line-height: 1.35;
}
.panel-rule {
  margin: 0;
  font-size: 14.5px;
  color: #3a2712;
  line-height: 1.42;
}
.panel-rule strong { color: #6f4b13; }
.panel-rule + .panel-rule { margin-top: 9px; padding-top: 9px; border-top: 1px solid rgba(104, 74, 32, .2); }

.chest-meter {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
}
.chest-meter svg { width: 24px; height: 24px; flex: 0 0 auto; }
.meter-track {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: rgba(80, 52, 20, .18);
  border: 1px solid rgba(90, 62, 26, .25);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #9b6b20, #eac25f);
  transition: width .3s ease;
}
.chest-meter .meter-label {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: .06em;
  color: #5a3d18;
  min-width: 34px;
  text-align: right;
}

/* Toolbar under the board */

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 13px;
  border: 1px solid rgba(201, 149, 52, .3);
  border-radius: 3px;
  background: rgba(5, 21, 24, .45);
  color: rgba(233, 215, 174, .9);
  font-family: var(--font-label);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.tool-btn:hover {
  background: rgba(22, 56, 58, .75);
  border-color: rgba(241, 201, 98, .6);
  transform: translateY(-1px);
}
.tool-btn svg { width: 16px; height: 16px; opacity: .9; }
.tool-btn[disabled] { opacity: .38; cursor: not-allowed; transform: none; }
.tool-btn.hint-btn { color: var(--gold-bright); border-color: rgba(201, 149, 52, .45); }
.tool-label-short { display: none; }
.toolbar-legend {
  text-shadow: 0 1px 6px rgba(0, 0, 0, .8);
}
.hint-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: rgba(201, 149, 52, .18);
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0;
}
.toolbar-legend {
  width: 100%;
  text-align: center;
  margin: 8px 0 0;
  font-family: var(--font-label);
  font-size: 9.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: rgba(233, 215, 174, .58);
}

/* Solution debug overlay */
.cell.sol-chest {
  box-shadow: inset 0 0 0 2px rgba(241, 201, 98, .9);
}
.cell.sol-chest .solution-ghost {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 3;
  pointer-events: none;
  opacity: .58;
}
.cell.sol-chest .solution-ghost .chest-svg {
  width: 76%;
  height: 76%;
  filter: drop-shadow(0 0 7px rgba(241, 201, 98, .95));
  animation: none;
}
.cell.sol-empty::after {
  content: '';
  position: absolute;
  width: 16%;
  height: 16%;
  border-radius: 50%;
  background: rgba(241, 201, 98, .52);
  box-shadow: 0 0 6px rgba(241, 201, 98, .4);
  z-index: 3;
  pointer-events: none;
}
.tool-btn.active {
  color: var(--gold-bright);
  border-color: rgba(241, 201, 98, .65);
  background: rgba(201, 149, 52, .13);
}

/* Copy snapshot feedback */
.copy-btn.copied {
  color: var(--gold-bright);
  border-color: rgba(241, 201, 98, .7);
  box-shadow: inset 0 0 14px rgba(241, 201, 98, .12);
}

.debug-modal { width: min(900px, 100%); }
.debug-json {
  width: 100%;
  min-height: 260px;
  max-height: 48vh;
  resize: vertical;
  margin: 4px 0 0;
  padding: 10px;
  border-radius: 3px;
  border: 1px solid rgba(104, 74, 32, .35);
  background: rgba(255, 250, 232, .52);
  color: #2b1c0e;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
}

/* --------------------------------------------------------------------------
   Modals
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 26px);
  background: rgba(2, 8, 9, .74);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fade-in .2s ease both;
  overflow-y: auto;
}

.modal {
  position: relative;
  width: min(860px, 100%);
  max-height: min(88dvh, 900px);
  overflow-y: auto;
  padding: clamp(24px, 4vw, 44px);
  background:
    var(--noise),
    radial-gradient(120% 80% at 50% 0%, #f3e7c8, #e6d3a8 55%, #d8bf8d 100%);
  background-size: 180px 180px, cover;
  background-blend-mode: multiply, normal;
  border: 1px solid #7c5a2a;
  border-radius: 5px;
  box-shadow: 0 40px 90px -20px rgba(0, 0, 0, .95), inset 0 0 0 1px rgba(255, 250, 230, .4);
  color: var(--ink);
  animation: modal-in .3s cubic-bezier(.2, .9, .3, 1) both;
  scrollbar-width: thin;
  scrollbar-color: rgba(90, 62, 26, .45) transparent;
}
.modal::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(104, 74, 32, .3);
  border-radius: 3px;
  pointer-events: none;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to   { opacity: 1; transform: none; }
}

.modal-close {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(104, 74, 32, .35);
  background: rgba(255, 250, 232, .22);
  color: #4a3318;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.modal-close:hover { background: rgba(255, 250, 232, .5); transform: rotate(90deg); }
.modal-close svg { width: 16px; height: 16px; }

.modal .eyebrow,
.win-card .eyebrow {
  color: #7a4f16;
  opacity: .95;
}

.modal h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(34px, 5vw, 52px);
  line-height: .95;
  color: #2d1c0a;
}
.modal .modal-sub {
  margin: 0 0 22px;
  font-style: italic;
  color: #6a4d27;
  font-size: 17px;
}

.howto-grid {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: clamp(22px, 4vw, 42px);
  align-items: start;
}
@media (max-width: 720px) {
  .howto-grid { grid-template-columns: 1fr; }
}

.rule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 15px; }
.rule-list li {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 11px;
  align-items: start;
  font-size: 16.5px;
  line-height: 1.4;
  color: #3a2712;
}
.num {
  font-family: var(--font-num);
  font-weight: 600;
  font-style: normal;
  letter-spacing: .01em;
}

.rule-list .rule-no {
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(143, 98, 32, .14);
  border: 1px solid rgba(143, 98, 32, .35);
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 12px;
  color: #6a4a1e;
}
.rule-list strong { color: #52350f; }
.rule-list em { color: #6f4b13; }

.howto-aside {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.demo-card {
  position: relative;
  padding: 13px;
  background: rgba(255, 249, 228, .34);
  border: 1px solid rgba(104, 74, 32, .3);
  border-radius: 3px;
}
.demo-card .demo-caption {
  margin: 9px 2px 0;
  font-size: 13.5px;
  font-style: italic;
  color: #5c411f;
  text-align: center;
}
.demo-board {
  --dc: 34px;
  display: grid;
  grid-template-columns: repeat(5, var(--dc));
  grid-template-rows: repeat(5, var(--dc));
  gap: 1px;
  margin: 0 auto;
  width: max-content;
  background: rgba(60, 39, 15, .35);
  border: 1px solid rgba(60, 39, 15, .5);
  padding: 1px;
  position: relative;
}
.demo-cell {
  position: relative;
  background: linear-gradient(145deg, #f0e0bb, #ddc797);
  display: grid;
  place-items: center;
}
.demo-cell .compass-svg { width: 86%; height: 86%; }
.demo-cell .chest-svg { width: 76%; height: 76%; }
.demo-cell.dim { opacity: .35; }
.demo-cell.near { box-shadow: inset 0 0 0 2px rgba(201, 149, 52, .7); }
.demo-cell.far { opacity: .55; }
.demo-cell.repel {
  background:
    repeating-linear-gradient(135deg, transparent 0 8px, rgba(166, 48, 38, .11) 8px 9px),
    linear-gradient(145deg, #f0e0bb, #ddc797);
  box-shadow: inset 0 0 0 1px rgba(172, 58, 43, .35);
}
.demo-cell.repel::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(172, 58, 43, .5);
}
.demo-line {
  position: absolute;
  pointer-events: none;
  border-top: 1px dashed rgba(143, 47, 40, .7);
  transform-origin: 0 0;
}
.demo-note {
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  font-family: var(--font-label);
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #8f2f28;
  background: #f5e8c8;
  padding: 1px 5px;
  border: 1px solid rgba(143, 47, 40, .35);
  border-radius: 2px;
}
@media (max-width: 720px) {
  .demo-board { --dc: 30px; }
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 26px;
  flex-wrap: wrap;
}
.modal-actions .btn {
  border-color: rgba(124, 90, 42, .5);
  background: rgba(255, 250, 232, .25);
  color: #3b2710;
}
.modal-actions .btn:hover { background: rgba(255, 250, 232, .55); }
.modal-actions .btn-primary {
  background: linear-gradient(180deg, #f5d98e, #d9aa4c 55%, #b4812b);
  color: #2a1a07;
  border-color: #73511c;
}

/* Confirm dialog */
.confirm-modal { width: min(420px, 100%); text-align: center; }
.confirm-modal h2 { font-size: 40px; }
.confirm-modal p { margin: 6px 0 0; color: #4a3318; font-size: 17px; }
.confirm-modal .modal-actions { justify-content: center; }

/* Mobile rule brief (the side panel is hidden below 1040px) */
.mobile-brief { display: none; }

/* --------------------------------------------------------------------------
   Win overlay
   -------------------------------------------------------------------------- */

.win-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 22px;
  background: radial-gradient(circle at 50% 42%, rgba(84, 56, 8, .55), rgba(2, 8, 9, .93) 65%);
  animation: fade-in .45s ease both;
  overflow-y: auto;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.win-card {
  position: relative;
  width: min(560px, 100%);
  padding: clamp(30px, 5vw, 52px) clamp(22px, 4vw, 46px) 30px;
  text-align: center;
  color: var(--ink);
  background:
    var(--noise),
    radial-gradient(120% 100% at 50% 0%, #f6eacd, #e7d4a9 58%, #d6bc8a 100%);
  background-size: 180px 180px, cover;
  background-blend-mode: multiply, normal;
  border: 1px solid #7c5a2a;
  border-radius: 5px;
  box-shadow: 0 40px 90px -20px rgba(0, 0, 0, .95), inset 0 0 0 1px rgba(255, 250, 230, .45);
  transform: rotate(-.45deg);
  animation: win-in .55s cubic-bezier(.2, .9, .3, 1) both;
}
.win-card::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(104, 74, 32, .32);
  pointer-events: none;
  border-radius: 3px;
}
@keyframes win-in {
  from { opacity: 0; transform: translateY(20px) rotate(-2deg) scale(.96); }
  to   { opacity: 1; transform: rotate(-.45deg) scale(1); }
}

.win-seal {
  width: 68px;
  height: 68px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(255, 230, 190, .9);
  background: radial-gradient(circle at 35% 30%, #c65a45, #8f2f28 62%, #5e1b18 100%);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .35), inset 0 1px 2px rgba(255, 220, 190, .35), inset 0 -2px 5px rgba(50, 0, 0, .4);
  border: 1px solid rgba(70, 15, 12, .6);
  transform: rotate(-8deg);
  position: relative;
}
.win-seal::before {
  content: '';
  position: absolute;
  inset: 7px;
  border: 1px dashed rgba(255, 222, 190, .3);
  border-radius: 50%;
}
.win-seal svg { width: 34px; height: 34px; }

.win-card .eyebrow { color: #8f6220; opacity: .9; letter-spacing: .3em; }
.win-title {
  margin: 5px 0 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 8vw, 68px);
  line-height: .85;
  color: #2b1a07;
  text-transform: uppercase;
}
.win-level {
  margin: 10px 0 0;
  font-style: italic;
  font-size: 19px;
  color: #6a4a1e;
}
.win-stats {
  display: flex;
  justify-content: center;
  gap: 0;
  margin: 24px 0 0;
  border-top: 1px solid rgba(104, 74, 32, .24);
  border-bottom: 1px solid rgba(104, 74, 32, .24);
  padding: 14px 0;
}
.win-stat {
  flex: 1;
  padding: 0 10px;
}
.win-stat + .win-stat { border-left: 1px solid rgba(104, 74, 32, .24); }
.win-stat .k {
  display: block;
  font-family: var(--font-label);
  font-size: 9px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #7a5a2c;
}
.win-stat .v {
  display: block;
  margin-top: 3px;
  font-family: var(--font-num);
  font-weight: 600;
  font-size: 24px;
  line-height: 1;
  color: #38240d;
  font-variant-numeric: lining-nums tabular-nums;
}
.win-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 24px;
}
.win-actions .btn {
  border-color: rgba(124, 90, 42, .45);
  background: rgba(255, 250, 232, .28);
  color: #3b2710;
}
.win-actions .btn:hover { background: rgba(255, 250, 232, .58); }
.win-actions .btn-primary { background: linear-gradient(180deg, #f5d98e, #d9aa4c 55%, #b4812b); color: #2a1a07; }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

#toast-root {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(460px, calc(100vw - 32px));
  pointer-events: none;
}
body.screen-game #toast-root { bottom: 86px; }
@media (max-width: 760px) {
  body.screen-game #toast-root { bottom: 118px; }
}
.toast {
  padding: 11px 17px;
  border-radius: 3px;
  border: 1px solid rgba(201, 149, 52, .4);
  background: rgba(6, 22, 25, .94);
  color: var(--parchment);
  font-size: 15.5px;
  line-height: 1.3;
  text-align: center;
  box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .9);
  animation: toast-in .24s ease both;
}
.toast.good { border-color: rgba(241, 201, 98, .6); color: #ffe9b1; }
.toast.bad { border-color: rgba(190, 65, 50, .6); color: #ffc3b8; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.toast.leaving { animation: toast-out .24s ease both; }
@keyframes toast-out {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateY(6px); }
}

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
}

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.svg-defs { position: absolute; overflow: hidden; }

.ken-burns { animation: ken-burns 18s ease-in-out infinite alternate; }
@keyframes ken-burns {
  from { transform: scale(1); }
  to   { transform: scale(1.04); }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1040px) {
  .captain-panel { display: none; }
  .game-body {
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 0;
  }
  .mobile-brief {
    display: block;
    width: min(440px, 100%);
    margin: 12px auto 0;
    padding: 10px 14px;
    border: 1px solid rgba(201, 149, 52, .24);
    border-radius: 3px;
    background: rgba(5, 21, 24, .38);
    text-align: center;
    color: rgba(233, 215, 174, .68);
    box-shadow: 0 10px 24px -18px rgba(0, 0, 0, .8);
  }
  .mobile-brief p { margin: 0; }
  .mobile-brief .mb-flavor {
    font-style: italic;
    font-size: 14.5px;
    color: rgba(241, 214, 160, .85);
    margin-bottom: 4px;
  }
  .mobile-brief .mb-rule {
    font-size: 12.5px;
    line-height: 1.35;
    color: rgba(233, 215, 174, .62);
  }
  .mobile-brief strong { color: var(--gold-bright); font-weight: 400; }
  .mobile-brief .mobile-meter {
    justify-content: center;
    margin-top: 9px;
  }
  .mobile-brief .mobile-meter .meter-track { max-width: 170px; }
  .mobile-brief .mobile-meter .meter-label { min-width: auto; }
  .mobile-brief .mb-tip {
    margin-top: 7px;
    font-family: var(--font-label);
    font-size: 8.5px;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(233, 215, 174, .42);
  }
}

@media (max-width: 760px) {
  body { font-size: 17px; }
  .game-screen { padding-bottom: 128px; }
  .game-head { gap: 7px; }
  .game-head h1 { font-size: clamp(24px, 5.8vw, 30px); }
  .game-stats { gap: 5px; }
  .stat { min-width: 46px; padding: 4px 6px; }
  .stat .stat-value { font-size: 14px; }
  .stat .stat-label { font-size: 7.5px; }
  .icon-btn { width: 40px; height: 40px; }
  .game-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin: 0;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(4, 14, 17, 0) 0%, rgba(4, 14, 17, .88) 30%, rgba(4, 14, 17, .98) 100%);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    border-top: 1px solid rgba(201, 149, 52, .12);
  }
  .tool-btn {
    justify-content: center;
    padding: 7px 2px;
    font-size: 9px;
    letter-spacing: .04em;
    min-height: 40px;
    gap: 4px;
  }
  .tool-btn svg { width: 14px; height: 14px; }
  .hint-count { min-width: 16px; height: 16px; padding: 0 4px; font-size: 9px; }
  .tool-label-long { display: none; }
  .tool-label-short { display: inline; }
  .toolbar-legend { display: none; }
  .game-body { padding-top: 4px; }
  .title-screen { padding-bottom: 150px; }
  .prototype-link { text-decoration: none; }

.title-menu { flex-direction: column; width: min(300px, 100%); }
  .title-menu .btn { width: 100%; }
  .chart-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
  .chart-card { min-height: 138px; padding: 13px 14px; }
  .card-name { font-size: 21px; }
  .mini-chart { width: 48px; height: 48px; }
  .page-head { align-items: flex-start; }
  .head-progress { margin-top: 4px; min-width: 92px; }
  .progress-track { width: 92px; }
}

@media (max-width: 400px) {
  .game-toolbar { gap: 4px; padding-left: 8px; padding-right: 8px; }
  .tool-btn {
    padding: 7px 1px;
    font-size: 8.5px;
    letter-spacing: .02em;
    gap: 3px;
  }
  .tool-btn svg { width: 13px; height: 13px; }
  .hint-count { min-width: 15px; height: 15px; padding: 0 3px; font-size: 8.5px; }
}


@media (max-width: 480px) {
  .logo-mark { width: 74px; }
  .game-title { font-size: clamp(66px, 19vw, 92px); }
  .title-tagline { font-size: 16px; }
  .page-head h1 { font-size: 36px; }
  .page-head .eyebrow { display: none; }
  .head-progress {
    display: block;
    margin-left: auto;
    min-width: 0;
    text-align: right;
  }
  .progress-track { display: none; }
  .progress-word { display: none; }
  .head-progress span { font-size: 11px; letter-spacing: .08em; }
  .chart-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .chart-card { min-height: 126px; }
  .card-name { font-size: 18px; }
  .card-no { font-size: 8.5px; }
  .card-diff svg { width: 12px; height: 12px; }
  .mini-chart { width: 40px; height: 40px; }
  .card-seal { width: 34px; height: 34px; right: 9px; bottom: 8px; }
  .card-seal svg { width: 17px; height: 17px; }
  .game-head .eyebrow { display: none; }
  .game-head h1 { font-size: 25px; }
  .stat { min-width: 42px; padding: 4px 5px; }
  .stat .stat-value { font-size: 13px; }
  .win-stats { flex-wrap: nowrap; }
  .win-stat { flex: 1 1 0; padding: 0 4px; }
  .win-stat:nth-child(3) { border-left: 1px solid rgba(104, 74, 32, .24); }
  .modal { padding: 24px 18px; }
  .modal .eyebrow,
.win-card .eyebrow {
  color: #7a4f16;
  opacity: .95;
}

.modal h2 { font-size: 36px; }
  .modal-actions { justify-content: center; }
}

@media (max-height: 680px) and (orientation: landscape) {
  .title-ship { display: none; }
  .title-screen { padding-top: 20px; padding-bottom: 100px; }
  .logo-mark { width: 70px; }
  .game-title { font-size: clamp(58px, 11vh, 90px); }
  .title-tagline { margin-top: 8px; }
  .prototype-link { text-decoration: none; }

.title-menu { margin-top: 14px; }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .waves, .stars, .title-ship, .logo-mark { animation: none !important; }
}

/* --------------------------------------------------------------------------
   Late additions: links, sound toggle, demo lines, won board
   -------------------------------------------------------------------------- */

a.chart-card { text-decoration: none; color: inherit; }
a.chart-card:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 4px;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: rgba(233, 215, 174, .55);
  font-family: var(--font-label);
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.sound-toggle:hover { color: var(--parchment); background: rgba(255, 255, 255, .05); }
.sound-toggle svg { width: 15px; height: 15px; }
.sound-toggle [data-sound-icon] { display: inline-flex; }
.title-footer .sound-toggle { padding: 2px 4px; }
.title-footer .sound-toggle svg { width: 13px; height: 13px; }

.demo-board { position: relative; }
.demo-lines {
  position: absolute;
  inset: 1px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}
.demo-lines line { stroke-dasharray: 3 3; }
.demo-lines .near-line { stroke: rgba(143, 47, 40, .75); stroke-width: 1.6; }
.demo-lines .far-line { stroke: rgba(60, 39, 18, .32); stroke-width: 1; }

.chart.won {
  box-shadow:
    inset 0 0 0 1px rgba(243, 223, 172, .45),
    0 0 0 5px rgba(18, 9, 3, .22),
    0 0 54px rgba(241, 201, 98, .32),
    0 26px 54px -18px rgba(0, 0, 0, .9);
}

@media (max-width: 560px) {
  .hints-stat { display: none; }
}

@media (max-width: 760px) and (max-height: 660px) {
  .mobile-brief { display: none; }
  .game-screen { padding-bottom: 118px; }
}

/* ==========================================================================
   Home + level select + rules
   ========================================================================== */

.screen-home, .screen-level {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}
.home-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 36px;
  position: relative;
  z-index: 2;
}
.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 0 18px;
  border-bottom: 1px solid rgba(241, 201, 98, .16);
}
.site-nav-left, .site-nav-right { display: flex; align-items: center; gap: 12px; }
.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--parchment);
  text-decoration: none;
  font-family: var(--font-label);
  font-size: .82rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.site-brand-mark { width: 32px; height: 32px; color: var(--gold); display: inline-grid; place-items: center; }
.site-brand-mark svg { width: 100%; height: 100%; }
.site-back {
  width: 38px; height: 38px; flex: 0 0 auto;
  display: inline-grid; place-items: center;
  border: 1px solid rgba(241, 201, 98, .28);
  border-radius: 50%;
  color: var(--parchment);
  transition: background .16s ease, border-color .16s ease;
}
.site-back:hover { background: rgba(241, 201, 98, .1); border-color: var(--gold-bright); }
.site-back svg { width: 17px; height: 17px; }
.site-link {
  color: rgba(245, 233, 207, .78);
  text-decoration: none;
  font-family: var(--font-label);
  font-size: .76rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 8px 2px;
}
.site-link:hover { color: var(--gold-bright); }
.site-sound {
  width: 36px; height: 36px; padding: 8px;
  display: inline-grid; place-items: center;
  border: 1px solid rgba(241, 201, 98, .28);
  border-radius: 50%;
  background: transparent;
  color: var(--parchment);
  cursor: pointer;
}
.site-sound:hover { background: rgba(241, 201, 98, .1); border-color: var(--gold-bright); }
.site-sound svg { width: 17px; height: 17px; }

.home-hero {
  text-align: center;
  padding: clamp(34px, 5vw, 64px) 0 clamp(28px, 4vw, 48px);
  max-width: 920px;
  margin: 0 auto;
}
.home-logo {
  width: 92px; height: 92px;
  margin: 0 auto 8px;
  color: var(--gold);
  filter: drop-shadow(0 8px 22px rgba(0, 0, 0, .5));
}
.home-logo svg { width: 100%; height: 100%; }
.home-eyebrow {
  margin: 0 0 12px;
  font-family: var(--font-label);
  font-size: .76rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold);
}
.home-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3.7rem, 9vw, 7.4rem);
  line-height: .82;
  color: var(--parchment);
  text-shadow: 0 3px 0 rgba(0, 0, 0, .22);
}
.home-title span { color: var(--gold-bright); }
.home-tagline {
  max-width: 690px;
  margin: 20px auto 0;
  color: rgba(245, 233, 207, .8);
  font-size: clamp(1rem, 1.5vw, 1.16rem);
  line-height: 1.5;
}
.home-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
  color: rgba(245, 233, 207, .76);
  font-family: var(--font-label);
  font-size: .8rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.home-stats strong { color: var(--gold-bright); font-size: 1rem; }
.stat-dot, .dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(241, 201, 98, .55);
  display: inline-block;
}
.unlocked-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border: 1px solid rgba(117, 169, 125, .5);
  border-radius: 999px;
  color: #b7d6b4;
  background: rgba(65, 111, 73, .18);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.home-progress {
  margin: 12px 0 0;
  color: rgba(245, 233, 207, .48);
  font-family: var(--font-label);
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.level-section { max-width: 1280px; margin: 0 auto; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 3.2vw, 2.8rem);
  line-height: .95;
  color: var(--parchment);
}
.section-note {
  margin: 0;
  color: rgba(245, 233, 207, .55);
  font-family: var(--font-label);
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}
.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 286px;
  padding: 17px 16px 15px;
  color: var(--ink);
  text-decoration: none;
  background:
    var(--noise),
    linear-gradient(158deg, #efe0bd 0%, #e3cfa3 55%, #d5bb8a 100%);
  background-size: 180px 180px, cover;
  border: 1px solid #7c5a2a;
  border-radius: 4px;
  box-shadow: var(--paper-edge), 0 18px 34px -18px rgba(0, 0, 0, .85);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.level-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--level-accent, var(--gold));
}
.level-card::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(104, 74, 32, .22);
  border-radius: 2px;
  pointer-events: none;
}
.level-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--paper-edge), 0 25px 42px -18px rgba(0, 0, 0, .95);
}
.level-card > * { position: relative; z-index: 1; }
.level-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.level-number {
  font-family: var(--font-label);
  font-size: 2.1rem;
  line-height: .8;
  color: var(--level-accent, var(--gold));
  letter-spacing: .02em;
}
.level-difficulty { display: inline-flex; gap: 2px; color: #8b5428; }
.level-difficulty span { opacity: .18; }
.level-difficulty span.lit { opacity: 1; }
.level-difficulty svg { width: 13px; height: 13px; }
.level-name {
  margin: 1px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.55rem;
  line-height: .95;
  color: #352313;
}
.level-tagline {
  margin: 0;
  color: #64482a;
  font-size: .82rem;
  line-height: 1.35;
  min-height: 2.3em;
}
.level-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 1px;
  color: #7a5a32;
  font-family: var(--font-label);
  font-size: .65rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.level-preview {
  margin: 2px 0 3px;
  padding: 4px;
  background: rgba(75, 51, 24, .08);
  border: 1px solid rgba(104, 74, 32, .2);
  border-radius: 2px;
}
.level-preview .mini-chart {
  width: 100%;
  height: 52px;
  padding: 3px;
  gap: 1px;
  border: 0;
  background: transparent;
}
.level-preview .mini-cell { border-radius: 1px; }
.level-progress { margin-top: auto; }
.level-progress .progress-track {
  height: 4px;
  background: rgba(74, 51, 24, .16);
  border: 0;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 5px;
}
.level-progress .progress-fill {
  height: 100%;
  background: var(--level-accent, var(--gold));
  border-radius: inherit;
}
.level-progress span {
  color: #70512d;
  font-family: var(--font-label);
  font-size: .62rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.level-enter {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid rgba(104, 74, 32, .2);
  font-family: var(--font-label);
  font-size: .7rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #4f371c;
}
.level-enter span { font-size: 1.05rem; color: var(--level-accent, var(--gold)); }

.site-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid rgba(241, 201, 98, .13);
  color: rgba(245, 233, 207, .44);
  font-family: var(--font-label);
  font-size: .67rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.site-footer a { margin-left: auto; color: rgba(245, 233, 207, .7); text-decoration: none; }
.site-footer a:hover { color: var(--gold-bright); }

/* Level page */
.level-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin: 26px 0 22px;
  padding: 24px 26px 22px;
  background:
    var(--noise),
    linear-gradient(155deg, rgba(239, 224, 189, .98), rgba(213, 187, 138, .98));
  background-size: 180px 180px, cover;
  border: 1px solid #7c5a2a;
  border-radius: 4px;
  box-shadow: var(--paper-edge), 0 20px 40px -20px rgba(0,0,0,.9);
  color: var(--ink);
  overflow: hidden;
}
.level-hero::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--level-accent, var(--gold));
}
.level-hero-copy { position: relative; z-index: 1; }
.level-hero .eyebrow { color: #70512d; margin-bottom: 5px; }
.level-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 5vw, 4.3rem);
  line-height: .88;
  color: #352313;
}
.level-hero p {
  max-width: 720px;
  margin: 8px 0 0;
  color: #5e4529;
  font-size: .97rem;
}
.level-hero-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  color: #70512d;
  font-family: var(--font-label);
  font-size: .68rem;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.level-hero .unlocked-pill { color: #426348; border-color: rgba(66, 99, 72, .42); background: rgba(66, 99, 72, .1); }
.level-progress-track { max-width: 420px; margin-top: 10px; height: 4px; background: rgba(74, 51, 24, .16); }
.level-progress-track .progress-fill { background: var(--level-accent, var(--gold)); }
.level-switcher {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 6px;
  align-items: center;
}
.level-switcher a {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border: 1px solid rgba(88, 61, 27, .32);
  border-radius: 50%;
  color: #66492a;
  text-decoration: none;
  font-family: var(--font-label);
  font-size: .68rem;
}
.level-switcher a:hover, .level-switcher a.active {
  background: #3b2916;
  border-color: #3b2916;
  color: var(--parchment-light);
}
.puzzle-grid { margin-top: 0; }
.puzzle-card { min-height: 148px; }
.puzzle-card .card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-clue-count {
  color: rgba(70, 48, 20, .58);
  font-family: var(--font-label);
  font-size: .62rem;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.card-seal svg { width: 100%; height: 100%; color: #e8d6ac; }
.level-footer { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.level-footer .btn { text-decoration: none; }

/* Rules page */
.rules-page .home-shell { max-width: 980px; }
.rules-page .site-nav { margin-bottom: 26px; }
.rules-card {
  padding: clamp(24px, 5vw, 54px);
  background:
    var(--noise),
    linear-gradient(155deg, #f2e4c3, #e2cca0 58%, #d3b881);
  background-size: 180px 180px, cover;
  border: 1px solid #7c5a2a;
  border-radius: 4px;
  box-shadow: var(--paper-edge), 0 28px 60px -22px rgba(0, 0, 0, .95);
  color: var(--ink);
}
.rules-card .eyebrow { color: #7a5728; }
.rules-card h1 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.8rem, 6vw, 4.5rem);
  line-height: .9;
  color: #352313;
}
.rules-card > p { color: #5d4529; }
.rule-block {
  margin: 22px 0 0;
  padding-top: 17px;
  border-top: 1px solid rgba(104, 74, 32, .22);
}
.rule-block h2 {
  margin: 0 0 5px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.55rem;
  color: #3d2a18;
}
.rule-block p { margin: 0; color: #5a4228; font-size: .97rem; line-height: 1.55; }
.rules-card .howto-list { margin: 8px 0 0 20px; padding: 0; color: #5a4228; }
.rules-card .howto-list li { margin: 4px 0; }
.rules-card .rule-final { margin-top: 22px; padding-top: 17px; border-top: 1px solid rgba(104, 74, 32, .22); color: #3f572f; font-weight: 600; }
.rules-cta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
.rules-cta .btn { text-decoration: none; }

/* Home / level responsive */
@media (max-width: 1120px) {
  .level-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .level-card { min-height: 270px; }
}
@media (max-width: 820px) {
  .home-shell { width: min(100% - 28px, 680px); padding-top: 16px; }
  .home-title { font-size: clamp(3.2rem, 13vw, 5.3rem); }
  .home-hero { padding-top: 34px; }
  .level-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .level-card { min-height: 250px; }
  .level-hero { grid-template-columns: 1fr; gap: 16px; padding: 20px; }
  .level-switcher { flex-wrap: wrap; }
  .site-nav { align-items: flex-start; flex-wrap: wrap; }
  .site-nav-right { margin-left: auto; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 6px; }
  .site-footer a { margin-left: 0; }
}
@media (max-width: 520px) {
  .home-shell { width: calc(100% - 22px); }
  .level-grid { grid-template-columns: 1fr; }
  .level-card { min-height: 0; }
  .level-preview .mini-chart { height: 64px; }
  .site-brand { font-size: .7rem; letter-spacing: .1em; }
  .site-link { font-size: .66rem; }
  .home-tagline { font-size: .96rem; }
  .home-stats { gap: 8px; font-size: .68rem; }
  .level-hero h1 { font-size: 2.8rem; }
  .rules-card { padding: 22px 17px; }
}

.rules-cta .btn-ghost {
  color: #5a3d1b;
  border-color: rgba(90, 61, 27, .5);
  background: transparent;
}
.rules-cta .btn-ghost:hover { background: rgba(90, 61, 27, .08); }
