@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/InstrumentSerif-italic-400-v2.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/InstrumentSerif-normal-400-v2.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/DMSans-normal-400_700-v2.woff2') format('woff2');
}

/* Scripture Gems — styles */
:root {
  color-scheme: dark;
  --ink: #f8efd9;
  --muted: #c2b8cc;
  --gold: #e9bd70;
  --gold-bright: #ffe1a0;
  --border: rgba(212, 173, 114, .26);
  --panel: linear-gradient(150deg, rgba(39, 32, 54, .95), rgba(24, 22, 41, .95));
  --display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --body: "DM Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--body);
  color: var(--ink);
  background: #0d1020;
  position: relative;
  isolation: isolate;
  -webkit-font-smoothing: antialiased;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 55% at 50% -8%, rgba(96, 64, 128, .55), transparent 70%),
    radial-gradient(ellipse 55% 45% at 88% 78%, rgba(148, 96, 84, .32), transparent 72%),
    radial-gradient(ellipse 60% 50% at 6% 92%, rgba(52, 74, 122, .38), transparent 72%),
    linear-gradient(180deg, #111528 0%, #151228 46%, #0c0d1c 100%);
}
.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .35;
  background-image: radial-gradient(rgba(255, 232, 190, .5) .6px, transparent .7px);
  background-size: 26px 26px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 25%, #000 0%, transparent 78%);
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid #ffe495; outline-offset: 3px; }
button:disabled { cursor: default; }

/* ---------- top bar ---------- */
.topbar {
  height: 68px;
  border-bottom: 1px solid rgba(214, 184, 127, .16);
  background: rgba(13, 16, 30, .72);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, calc((100% - 1200px) / 2));
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  display: inline-flex; align-items: center; gap: 11px;
  color: var(--ink); text-decoration: none;
  font-family: var(--display); font-size: 26px; white-space: nowrap;
}
.brand b { font-weight: 400; color: var(--gold); }
.brand-icon {
  width: 35px; height: 35px; display: grid; place-items: center;
  border: 1px solid rgba(181, 137, 80, .45); border-radius: 10px;
  color: #f8d18a; background: linear-gradient(145deg, #4a3455, #2c2038);
  font-size: 20px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}
nav { display: flex; gap: 8px; }
.small-btn {
  border: 1px solid rgba(117, 96, 123, .55);
  background: rgba(33, 27, 47, .88);
  border-radius: 9px; min-height: 36px; padding: 0 12px;
  display: inline-flex; justify-content: center; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; color: #e7dbeb; white-space: nowrap;
  transition: background .16s, border-color .16s, color .16s, transform .12s;
}
.small-btn:hover { color: #ffe6a8; background: #4a374b; border-color: #b18a5e; }
.small-btn:active { transform: translateY(1px); }
.small-btn[aria-pressed="true"] { color: #ffe6a8; background: #4a374b; border-color: #b18a5e; }
.small-btn span[aria-hidden] { color: var(--gold); font-size: 16px; line-height: 1; }
.icon-btn { width: 36px; padding: 0; font-size: 16px; }

/* ---------- masthead ---------- */
main { padding: 0 20px 12px; }
.masthead { text-align: center; padding: 30px 0 22px; }
.kicker, .eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: .19em;
  text-transform: uppercase; color: var(--gold);
}
.kicker { display: flex; align-items: center; justify-content: center; gap: 12px; }
.kicker i { width: 26px; height: 1px; background: rgba(212, 168, 108, .55); }
h1, h2, p { margin: 0; }
h1 {
  font-family: var(--display); font-size: clamp(56px, 7.4vw, 92px);
  line-height: .95; font-weight: 400; letter-spacing: -.04em;
  margin: 6px 0 10px; text-shadow: 0 6px 40px rgba(10, 8, 24, .9);
}
h1 em { font-style: italic; color: #f5cb83; }
.masthead p { font-size: 13.5px; color: #ded0e1; }

/* ---------- layout ---------- */
.layout {
  max-width: 1150px; margin: auto;
  display: grid;
  grid-template-columns: minmax(196px, 1fr) minmax(340px, 486px) minmax(210px, 1fr);
  align-items: start; gap: 18px;
}
.col { display: grid; gap: 12px; }
.panel {
  border: 1px solid var(--border); background: var(--panel);
  border-radius: 14px; padding: 16px;
  box-shadow: 0 12px 34px rgba(9, 7, 20, .45), inset 0 1px 0 rgba(255, 255, 255, .045);
}
.goal-line { display: flex; gap: 11px; margin: 13px 0 13px; align-items: center; }
.chip-icon {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 11px; background: linear-gradient(150deg, #513a52, #33243f);
  border: 1px solid rgba(179, 133, 83, .42); font-size: 22px;
}
.goal-line h2, .story h2 { font: 400 27px/1.05 var(--display); letter-spacing: -.01em; }
.subtext { display: block; color: var(--muted); font-size: 11.5px; margin-top: 5px; }
.track { height: 6px; background: #100f1f; border-radius: 10px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
#goal-bar { height: 100%; width: 0; background: linear-gradient(90deg, #b47a4d, #ffda91); transition: width .3s ease; }

.scoreboard { display: grid; grid-template-columns: 1fr 1fr; text-align: center; padding: 13px 6px; }
.scoreboard div + div { border-left: 1px solid rgba(135, 114, 141, .32); }
.scoreboard strong {
  display: block; font: 400 34px/1 var(--display); margin-top: 7px;
  font-variant-numeric: tabular-nums;
}

/* ---------- hall of gems ---------- */
.hall-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hall-tag { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: #a99ab4; }
.hall-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; counter-reset: none; }
.hall-list li {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 9px; font-size: 12px;
  background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .045);
}
.hall-list li.rank-1 {
  background: linear-gradient(120deg, rgba(233, 189, 112, .2), rgba(233, 189, 112, .05));
  border-color: rgba(233, 189, 112, .5);
}
.hall-list .pos { font-family: var(--display); font-size: 15px; color: var(--gold); }
.hall-list .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; letter-spacing: .02em; }
.hall-list .who small { display: block; font-weight: 500; font-size: 9.5px; color: #a99ab4; letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }
.hall-list .pts { font-variant-numeric: tabular-nums; font-weight: 700; color: #f6dfae; }
.hall-empty { grid-template-columns: 1fr !important; color: var(--muted); font-size: 11.5px; text-align: center; }
.hall-foot { margin-top: 10px; font-size: 10.5px; line-height: 1.5; color: #a99ab4; }
.hall-foot b { color: var(--gold); }

/* ---------- board ---------- */
.game { display: grid; gap: 10px; }
.board-frame {
  background: linear-gradient(160deg, #32243d, #1b182d 52%, #251f38);
  border: 1px solid #be945d;
  box-shadow: 0 0 0 3px #1d1424, 0 18px 60px rgba(6, 6, 18, .75), inset 0 0 0 3px rgba(181, 145, 88, .16);
  border-radius: 16px; padding: 10px 12px 12px;
}
.board-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 2px 2px 9px; font-size: 9px; letter-spacing: .16em;
  text-transform: uppercase; font-weight: 700; color: var(--gold);
}
.board-top span:first-child, .board-top span:last-child { flex: 1; }
.board-top span:last-child { text-align: right; }
.board-star { text-align: center; color: rgba(233, 189, 112, .65); }
.board-wrap { position: relative; }
.board {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px;
  padding: 7px; border-radius: 11px; background: #0d0c1c;
  touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, .65);
}
.tile {
  border: 1px solid var(--rim); position: relative; display: grid; place-items: center;
  aspect-ratio: 1; border-radius: 9px; padding: 0; min-width: 0; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0, var(--shine), transparent 74%),
    linear-gradient(145deg, var(--tone), var(--shade));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), inset 0 -3px 0 rgba(20, 8, 26, .35);
  transition: transform .1s ease-out;
  contain: layout style;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.tile::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, #fff 0, rgba(255, 255, 255, 0) 72%);
}
.tile .piece { font-size: clamp(18px, 3.1vw, 32px); line-height: 1; pointer-events: none; }
.tile .mark {
  position: absolute; right: 2px; bottom: 0; color: #fff;
  font-size: 14px; line-height: 1; text-shadow: 0 0 4px #11071c, 0 0 2px #11071c; pointer-events: none;
}
.tile:active { transform: scale(.93); }
.tile.selected { border-color: #fff0b8; box-shadow: inset 0 0 0 2px #fff0b8, 0 0 0 2px rgba(255, 240, 184, .45); transform: scale(1.07); z-index: 2; }
.tile.hinted { border-color: #fff0b8; box-shadow: inset 0 0 0 2px #fff0b8; z-index: 1; animation: hintPulse .7s ease-in-out infinite alternate; }
.tile.empty { opacity: .2; }
.tile.clearing { animation: pop .22s ease-in forwards; z-index: 2; }
.tile.clearing::after { animation: flash .22s ease-out; }
.tile.fall { animation: fall calc(.12s + var(--fall, 1) * .04s) cubic-bezier(.3, .8, .4, 1.1); }
.tile.slide { animation: slide .12s ease-out; z-index: 2; }
.tile.invalid { animation: slide .12s ease-out, nope .22s .12s ease-in-out; }
.tile.shuffled { animation: shuf .3s ease-out; }
/* power-ups */
.tile[data-power] { box-shadow: inset 0 0 0 2px rgba(255, 240, 184, .9), inset 0 -3px 0 rgba(20, 8, 26, .35), 0 0 8px rgba(255, 210, 120, .5); }
.tile[data-power]::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; border: 2px solid #ffe9a8; pointer-events: none;
  animation: spec 1.3s ease-out infinite;
}
.tile[data-power="burst"]::before { border-style: dashed; border-color: #fff; }
.tile[data-power="color"]::before { border-color: #fff; animation-duration: .9s; }
.tile[data-power="color"] .piece { animation: spin 3.2s linear infinite; }
@keyframes hintPulse { to { transform: scale(1.1); } }
@keyframes pop { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(.15); opacity: 0; } }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
@keyframes fall { from { transform: translateY(calc(var(--fall, 1) * var(--pitch, 48px) * -1)); } }
@keyframes slide { from { transform: translate(var(--dx, 0), var(--dy, 0)); } }
@keyframes nope { 25%, 75% { transform: translateX(-3px); } 50% { transform: translateX(3px); } }
@keyframes shuf { from { transform: scale(.5); opacity: 0; } }
@keyframes spec { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

[data-kind="0"] { --tone: #6d479f; --shade: #342057; --shine: #ab7fd6; --rim: #9d72c7; }
[data-kind="1"] { --tone: #2f6dbd; --shade: #16396f; --shine: #6ba5df; --rim: #639ee3; }
[data-kind="2"] { --tone: #91531f; --shade: #542a21; --shine: #d78e48; --rim: #d28a49; }
[data-kind="3"] { --tone: #2f7d58; --shade: #1e4738; --shine: #66ae78; --rim: #65a981; }
[data-kind="4"] { --tone: #96405f; --shade: #532338; --shine: #d47ca0; --rim: #c37298; }
[data-kind="5"] { --tone: #8a6527; --shade: #4e3818; --shine: #cba454; --rim: #bd984e; }

/* Church Lantern (rare 7th tile): night-indigo with a warm gold glow and the lantern line art */
[data-kind="6"] { --tone: #232b4a; --shade: #0f1428; --shine: #e9b550; --rim: #f2cf7a; }
.tile[data-kind="6"] { box-shadow: inset 0 1px 0 rgba(255, 244, 200, .45), inset 0 -3px 0 rgba(10, 8, 24, .45), inset 0 0 12px rgba(255, 200, 100, .35), 0 0 7px rgba(255, 200, 100, .45); }
.tile[data-kind="6"] .piece { width: 74%; height: 74%; font-size: 0; background: url("data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20viewBox=%220%200%2064%2064%22%20fill=%22none%22%20stroke=%22%23ffe3a0%22%20stroke-width=%223.6%22%20stroke-linecap=%22round%22%20stroke-linejoin=%22round%22%3E%3Cpath%20d=%22M17%2027C16%2014%2024%206%2033%206s17%208%2015%2021%22/%3E%3Cpath%20d=%22M26%2023v-5h12v5%22/%3E%3Cpath%20d=%22M13%2030q20-9%2038%200%22/%3E%3Cpath%20d=%22M20%2031c-5%209-5%2019-1%2025h26c4-6%204-16-1-25%22/%3E%3Cpath%20d=%22M26%2054c-3-6-3-13%200-18M38%2054c3-6%203-13%200-18%22%20stroke-width=%222.6%22/%3E%3Cpath%20d=%22M32%2033c-4%204-4%209%200%2012%204-3%204-8%200-12z%22%20fill=%22%23fff6d6%22%20stroke=%22%23fff6d6%22%20stroke-width=%221.6%22/%3E%3Cpath%20d=%22M16%2056l-3%205h38l-3-5%22/%3E%3C/svg%3E") center / contain no-repeat; filter: drop-shadow(0 0 3px rgba(255, 196, 90, .85)); }

/* score pop-ups */
.pops { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.pop {
  position: absolute; font-family: var(--display); font-size: 26px; color: #ffe6ad;
  text-shadow: 0 2px 14px rgba(0, 0, 0, .85); animation: floatUp 1s ease-out forwards;
}
.pop.big { font-size: 33px; color: #fff3cf; }

/* ---------- under board ---------- */
.under-board { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 2px 0; }
#feedback { font-size: 11.5px; color: #f2e6dc; text-align: center; text-shadow: 0 1px 5px #000; flex: 1; line-height: 1.35; }
.reward-bar { display: flex; align-items: center; gap: 10px; padding: 4px 2px 0; }
.reward-bar[hidden] { display: none; }
.reward-bar > span { font-size: 11.5px; color: #f3e5d0; }
.board.choose-row { outline: 2px solid var(--gold); outline-offset: 1px; }
.board.choose-row .tile { cursor: crosshair; }

/* ---------- scripture panel ---------- */
.story-icon {
  display: grid; place-items: center; width: 42px; height: 42px; margin: 13px 0 10px;
  border-radius: 11px; background: linear-gradient(150deg, #45304b, #2b2039);
  border: 1px solid rgba(179, 133, 83, .35); font-size: 22px;
}
.story blockquote {
  margin: 10px 0 9px; color: #f6e8d4; font: 400 20px/1.24 var(--display); letter-spacing: -.005em;
}
.story cite a, .quiz-verse a { color: var(--gold); font-size: 10.5px; font-weight: 700; text-decoration: none; border-bottom: 1px solid rgba(233, 189, 112, .4); }
.story cite a:hover, .quiz-verse a:hover { color: var(--gold-bright); }
.story-note { margin: 11px 0 0; font-size: 11.5px; line-height: 1.5; color: #b9aac2; }
.challenge-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; min-height: 40px; margin-top: 13px; padding: 7px 11px;
  border: 1px solid #e7c583; border-radius: 9px;
  background: linear-gradient(135deg, #f5d697, #d4a569); color: #251b29;
  font-weight: 700; font-size: 12px; text-align: left;
  transition: background .16s, transform .12s;
}
.challenge-btn:hover { background: linear-gradient(135deg, #ffe7b4, #e3b87c); }
.challenge-btn:active { transform: translateY(1px); }
.challenge-shortcut { display: none; }
.journey-link {
  border: 1px solid var(--border); background: rgba(29, 25, 44, .85);
  border-radius: 11px; width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; font-size: 11.5px; font-weight: 700; color: #f1d292;
}
.journey-link:hover { background: #403047; }

footer { text-align: center; color: rgba(221, 204, 219, .6); font-size: 10.5px; padding: 22px 18px 20px; }
footer span { color: var(--gold); margin-right: 4px; }

/* ---------- modal ---------- */
dialog {
  border: 1px solid #c39960; color: var(--ink); border-radius: 16px; padding: 22px;
  width: min(470px, calc(100% - 26px)); max-height: 88vh; overflow: auto;
  background: linear-gradient(150deg, #32233f, #1b182c);
  box-shadow: 0 24px 90px rgba(6, 5, 16, .9);
}
dialog::backdrop { background: rgba(6, 7, 18, .74); backdrop-filter: blur(6px); }
dialog .close { float: right; }
dialog h2 { font: 400 34px/1.05 var(--display); margin-bottom: 11px; }
dialog p, dialog li { font-size: 13.5px; color: #e7dce9; line-height: 1.55; }
dialog ul { padding-left: 19px; margin: 11px 0; }
dialog .action {
  margin-top: 15px; background: linear-gradient(135deg, #f5d697, #d4a569); color: #211a2b;
  min-height: 42px; width: 100%; border: 1px solid #e7c583; font-size: 13px;
}
dialog .action:hover { background: #ffe1a0; }
.modal-verse {
  border: 1px solid rgba(151, 117, 87, .45); border-radius: 10px; padding: 11px 13px;
  margin: 12px 0; background: rgba(22, 21, 38, .62);
}
.modal-verse blockquote { margin: 0 0 7px; color: #f6e8d4; font: 400 19px/1.25 var(--display); }
.stars-row { display: flex; gap: 6px; justify-content: center; font-size: 28px; margin: 6px 0 2px; color: #5c4a63; }
.stars-row .on { color: #ffd479; text-shadow: 0 0 18px rgba(255, 200, 100, .55); }
.submit-box { margin-top: 14px; border-top: 1px solid rgba(142, 116, 131, .4); padding-top: 13px; }
.submit-box label { display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-bottom: 7px; }
.name-row { display: flex; gap: 7px; }
.name-row input {
  flex: 1; min-width: 0; background: #171528; border: 1px solid #6f5a76; border-radius: 8px;
  color: var(--ink); padding: 0 11px; min-height: 40px; font: inherit; font-size: 13px;
  text-transform: uppercase; letter-spacing: .06em;
}
.name-row input::placeholder { color: #7e6f88; text-transform: none; letter-spacing: 0; }
.name-row button { border: 1px solid #e7c583; background: linear-gradient(135deg, #f5d697, #d4a569); color: #211a2b; border-radius: 8px; padding: 0 15px; font-weight: 700; font-size: 12.5px; min-height: 40px; }
.submit-msg { margin-top: 8px; font-size: 11.5px; color: #c9b9d1; min-height: 15px; }
.submit-msg.good { color: #9fe0b4; }
.submit-msg.bad { color: #f0a89a; }

.level-list { display: grid; gap: 7px; margin-top: 13px; }
.level-button {
  width: 100%; border: 1px solid rgba(142, 116, 131, .45); background: #241f35;
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px;
  min-height: 44px; text-align: left; border-radius: 9px; padding: 6px 10px;
}
.level-button:not(:disabled):hover { background: #4b3851; }
.level-button:disabled { opacity: .5; }
.level-button strong { font-size: 13px; font-weight: 700; }
.level-button small { color: #ecd094; font-size: 10.5px; text-align: right; line-height: 1.35; }
.level-button .lv-icon { font-size: 18px; }

.notebook-list { display: grid; gap: 9px; margin-top: 13px; }
.notebook-item { border: 1px solid rgba(151, 117, 87, .35); border-radius: 10px; padding: 10px 12px; background: rgba(20, 19, 34, .5); }
.notebook-item h3 { font: 400 19px/1.15 var(--display); margin: 0 0 5px; color: #f6dfae; }
.notebook-item p { font-size: 12.5px; color: #ded2e4; font-style: italic; line-height: 1.45; }
.notebook-item small { display: block; margin-top: 6px; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }

.quiz-verse { border: 1px solid rgba(151, 117, 87, .45); border-radius: 10px; padding: 10px 12px; margin: 11px 0 12px; background: rgba(22, 21, 38, .62); }
.quiz-verse blockquote { margin: 0 0 7px; color: #f6e8d4; font: 400 19px/1.25 var(--display); }
.quiz-question { position: relative; margin: 0 0 12px; padding: 8px 0 0; border: 0; border-top: 1px solid rgba(142, 116, 131, .4); min-width: 0; }
.quiz-question legend { padding: 0 6px 0 0; color: #fff2da; font-size: 13.5px; font-weight: 700; }
.quiz-reward { font-size: 10.5px; color: #efca89; margin-bottom: 7px; font-weight: 700; letter-spacing: .04em; }
.quiz-choices { display: grid; gap: 5px; }
.quiz-choice {
  display: flex; justify-content: space-between; align-items: center; width: 100%;
  min-height: 36px; padding: 6px 10px; background: #201c32;
  border: 1px solid #77617d; border-radius: 7px; font-size: 13px; text-align: left;
}
.quiz-choice:not(:disabled):hover { background: #4b3651; border-color: #dfb473; }
.quiz-choice:disabled { opacity: .62; }
.quiz-choice.correct { opacity: 1; background: #254636; border-color: #80b591; color: #e7ffdf; }
.quiz-choice.tried { opacity: .55; }
.quiz-question .quiz-feedback { margin-top: 5px; font-size: 11.5px; color: #e9d6ad; }
.quiz-feedback:empty { margin: 0; }

/* ---------- responsive ---------- */
/* ---------- leaderboard tabs ---------- */
.hall-tabs { display: flex; gap: 6px; margin-top: 11px; }
.hall-tab {
  flex: 1; min-height: 32px; border: 1px solid rgba(142, 116, 131, .45);
  background: rgba(255, 255, 255, .04); border-radius: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #c1b2ca;
  transition: background .15s, border-color .15s, color .15s;
}
.hall-tab:hover { color: #ffe1a0; border-color: rgba(233, 189, 112, .45); }
.hall-tab[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(233, 189, 112, .22), rgba(233, 189, 112, .06));
  border-color: rgba(233, 189, 112, .55); color: #ffe1a0;
}

/* ---------- journey rows ---------- */
.lv-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lv-text strong { font-size: 13px; font-weight: 700; }
.lv-record { font-size: 9.5px; color: #a99ab4; letter-spacing: .02em; }

/* ---------- modal notes ---------- */
.modal-note { font-size: 12.5px; line-height: 1.5; color: #b9aac2; }
.modal-note.bonus { color: #9fe0b4; font-weight: 700; margin: 6px 0 10px; }

/* ---------- embed mode (?embed=1) ---------- */
body.embed .masthead { display: none; }
body.embed footer { display: none; }
body.embed main { padding-top: 10px; }
body.embed .topbar { height: 52px; }
body.embed .brand { font-size: 21px; }
body.embed .brand-icon { width: 28px; height: 28px; font-size: 16px; }
body.embed .story-note { display: none; }
body.embed .panel { padding: 13px; }
body.embed .story blockquote { font-size: 18px; }
body.embed .layout { gap: 12px; }
body.embed .col { gap: 10px; }
body.embed .hall-foot { display: none; }
.embed-tools { display: none; gap: 7px; }
.embed-tools .small-btn { flex: 1; min-height: 34px; }
.modal-tabs { margin: 4px 0 12px; }
.modal-hall-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.modal-hall-list li {
  display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 9px; font-size: 12.5px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .06);
}
.modal-hall-list li.rank-1 { background: linear-gradient(120deg, rgba(233, 189, 112, .2), rgba(233, 189, 112, .05)); border-color: rgba(233, 189, 112, .5); }
.modal-hall-list .pos { font-family: var(--display); font-size: 15px; color: var(--gold); }
.modal-hall-list .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-hall-list .who small { display: block; font-weight: 500; font-size: 9.5px; color: #a99ab4; letter-spacing: .06em; text-transform: uppercase; }
.modal-hall-list .pts { font-weight: 700; color: #f6dfae; font-variant-numeric: tabular-nums; }
.modal-hall-list .hall-empty { grid-template-columns: 1fr; text-align: center; color: var(--muted); font-size: 11.5px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ======================= v2: layers, effects, responsive ======================= */
:root { --bw: clamp(320px, calc(100dvh - 330px), 486px); }
body { padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.topbar { padding-top: env(safe-area-inset-top); height: calc(68px + env(safe-area-inset-top)); }
.layout { grid-template-columns: minmax(196px, 1fr) var(--bw) minmax(210px, 1fr); }
button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.board { position: relative; overflow: hidden; --pitch: 48px; }
.board-wrap { position: relative; overflow: hidden; border-radius: 11px; }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }
.glow {
  position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: 0; border-radius: 11px;
  box-shadow: inset 0 0 22px 4px rgba(255, 214, 130, .9);
}
.glow.on0 { animation: glowA .6s ease-out; }
.glow.on1 { animation: glowB .6s ease-out; }
@keyframes glowA { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
@keyframes glowB { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
.rays {
  position: absolute; inset: -50%; pointer-events: none; z-index: 2; opacity: 0;
  background: repeating-conic-gradient(from 0deg, rgba(255, 226, 150, .42) 0 7deg, transparent 7deg 20deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 62%); mask-image: radial-gradient(circle, #000 0, transparent 62%);
}
.rays.go { animation: rays 1.6s ease-out forwards; }
@keyframes rays { 0% { opacity: 0; transform: rotate(0) scale(.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: rotate(45deg) scale(1.1); } }
.banner {
  position: absolute; left: 50%; top: 20%; z-index: 6; pointer-events: none; white-space: nowrap; opacity: 0;
  transform: translate(-50%, -50%); font: 400 40px/1 var(--display); color: #fff3cf;
  text-shadow: 0 2px 6px #000, 0 0 12px rgba(255, 200, 100, .9);
}
.banner.on0 { animation: banA .95s cubic-bezier(.2, .9, .3, 1.2) forwards; }
.banner.on1 { animation: banB .95s cubic-bezier(.2, .9, .3, 1.2) forwards; }
@keyframes banA { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 35% { transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }
@keyframes banB { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 35% { transform: translate(-50%, -50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }
.board-frame.on0 { animation: shkA .32s ease-out; }
.board-frame.on1 { animation: shkB .32s ease-out; }
@keyframes shkA { 20% { transform: translate(calc(var(--sh) * -1), calc(var(--sh) * .5)); } 40% { transform: translate(var(--sh), calc(var(--sh) * -.5)); } 60% { transform: translate(calc(var(--sh) * -.6), 0); } 80% { transform: translate(calc(var(--sh) * .4), 0); } }
@keyframes shkB { 20% { transform: translate(calc(var(--sh) * -1), calc(var(--sh) * .5)); } 40% { transform: translate(var(--sh), calc(var(--sh) * -.5)); } 60% { transform: translate(calc(var(--sh) * -.6), 0); } 80% { transform: translate(calc(var(--sh) * .4), 0); } }
.pop { animation-duration: .9s; }

#goal-bar { width: 100%; transform: scaleX(0); transform-origin: 0 50%; transition: transform .3s ease; }
#moves.low { color: #ffab98; }
.tools-row { display: none; }
.hall-tab, .small-btn { min-height: 36px; }
#sfx { font-size: 15px; }
.small-btn[aria-pressed="false"].icon-btn { opacity: .55; }
.short { display: none; }

/* readable minimum sizes */
.eyebrow, .kicker { font-size: 11px; }
.board-top { font-size: 10px; }
.hall-list .who small, .modal-hall-list .who small, .lv-record { font-size: 10.5px; }
.hall-foot, .story-note, .subtext { font-size: 12px; }
#feedback { font-size: 12px; }

/* result modal */
.stars-row span.on { animation: starIn .5s var(--d, 0s) cubic-bezier(.3, 1.5, .5, 1) both; }
.modal-verse.reveal blockquote { animation: reveal .9s .3s both; }
.modal-verse.reveal { box-shadow: 0 0 26px rgba(255, 210, 120, .25); }
.stars-row span:nth-child(2) { --d: .18s; }
.stars-row span:nth-child(3) { --d: .36s; }
@media (min-width: 761px) and (max-width: 1000px) {
  :root { --bw: auto; }
  .layout { grid-template-columns: minmax(140px, 1fr) minmax(300px, 1.6fr) minmax(150px, 1fr); gap: 12px; }
}
@keyframes starIn { from { transform: scale(0) rotate(-70deg); opacity: 0; } }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } }
dialog { max-height: 88vh; max-height: 88dvh; }

/* desktop that is short: compact masthead so the board fits 1280x800 */
@media (min-width: 761px) and (max-height: 900px) {
  .masthead { padding: 12px 0 12px; }
  .masthead .kicker, .masthead p { display: none; }
  h1 { font-size: 44px; margin: 0; }
  .topbar { height: 56px; }
}
@media (min-width: 761px) { .tools-row { display: none; } }

/* ---------- phones: compact HUD, board first ---------- */
@media (max-width: 760px) {
  :root { --gap: 6px; }
  main { padding: 0 8px; }
  .topbar { height: calc(46px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 10px 0; backdrop-filter: none; background: #0d101e; }
  .brand { font-size: 20px; gap: 6px; }
  .brand-icon { width: 26px; height: 26px; font-size: 15px; border-radius: 8px; }
  nav { gap: 5px; }
  .icon-btn { width: 38px; }
  .masthead h1, .masthead h1 em { font-style: normal; }
  .masthead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); padding: 0; margin: 0; }
  .layout {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; max-width: 520px; gap: var(--gap); margin-top: 6px;
    grid-template-areas: "goal score" "game game" "hall hall" "story story" "note note";
  }
  .col { display: contents; }
  .goal-panel { grid-area: goal; min-width: 0; }
  .scoreboard { grid-area: score; }
  .game { grid-area: game; gap: var(--gap); width: min(100%, calc(100dvh - 235px)); justify-self: center; }
  .hall { grid-area: hall; }
  .story { grid-area: story; }
  .journey-link { grid-area: note; }
  .panel { padding: 6px 10px; border-radius: 12px; }
  .goal-panel .eyebrow { display: none; }
  .goal-line { margin: 0 0 4px; gap: 8px; }
  .goal-line > div { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-width: 0; }
  .chip-icon { width: 28px; height: 28px; font-size: 15px; border-radius: 8px; }
  .goal-line h2 { font-size: 17px; line-height: 1.05; }
  .subtext { font-size: 12px; margin-top: 0; display: inline; }
  .track { height: 5px; }
  .scoreboard { display: flex; align-items: center; padding: 4px 2px; }
  .scoreboard > div { padding: 0 9px; text-align: center; min-width: 52px; }
  .scoreboard .eyebrow { font-size: 9.5px; letter-spacing: .1em; }
  .scoreboard strong { font-size: 22px; margin-top: 2px; }
  .tools-row { display: flex; gap: 6px; }
  .challenge-shortcut { display: flex; flex: 1.35; min-height: 38px; margin: 0; padding: 4px 10px; font-size: 12.5px; }
  .embed-tools { display: none; flex: 1.5; gap: 6px; }
  body.embed .embed-tools { display: flex; }
  .embed-tools .small-btn { flex: 1; min-height: 38px; padding: 0 6px; }
  .long { display: none; }
  .short { display: inline; }
  .board-frame { padding: 5px 7px 7px; border-radius: 14px; }
  .board-top { padding: 0 2px 4px; }
  .board { padding: 4px; gap: 3px; }
  .tile { border-radius: 8px; }
  .tile .piece { font-size: clamp(20px, 6.4vw, 31px); }
  .under-board { gap: 6px; padding: 0; }
  .under-board .small-btn { min-height: 38px; padding: 0 10px; }
  #feedback { font-size: 11.5px; line-height: 1.25; }
  .story .challenge-btn { display: none; }
  .story blockquote { font-size: 19px; }
  .pop { font-size: 21px; }
  .pop.big { font-size: 26px; }
  .banner { font-size: 32px; }
  footer { padding: 12px 12px 16px; }
  dialog::backdrop { backdrop-filter: none; }
  body.embed .hall, body.embed .story, body.embed .journey-link, body.embed footer { display: none; }
  body.embed .topbar { height: calc(42px + env(safe-area-inset-top)); }
  body.embed main { padding: 0 8px 6px; }
}
@media (max-width: 400px) {
  .brand-icon { display: none; }
  #journey { padding: 0 8px; }
}
@media (hover: none) { .small-btn:hover { background: rgba(33, 27, 47, .88); color: #e7dbeb; border-color: rgba(117, 96, 123, .55); } }
@media (prefers-reduced-motion: reduce) {
  .banner.on0, .banner.on1 { opacity: 1; }
  .tile[data-power]::before { display: none; }
}

.modal-verse a { color: var(--gold); font-size: 12px; font-weight: 700; text-decoration: none; border-bottom: 1px solid rgba(233, 189, 112, .4); }

/* ---------- Top 3 strip (phone embed, where the Hall panel is hidden) ---------- */
.top3-strip { display: none; }
@media (max-width: 760px) {
  body.embed .top3-strip {
    display: flex; align-items: center; gap: 8px; width: 100%; margin: 0; padding: 6px 10px; min-height: 40px;
    border-radius: 12px; border: 1px solid rgba(233, 189, 112, .35); background: rgba(33, 27, 47, .88);
    color: #f2e6dc; font: inherit; text-align: left; cursor: pointer;
  }
  .top3-strip .t3-title { font-family: var(--display); color: var(--gold); font-size: 14px; white-space: nowrap; }
  .top3-strip .t3-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; flex: 1; min-width: 0; }
  .top3-strip .t3-list li { display: flex; gap: 4px; align-items: baseline; min-width: 0; font-size: 12px; }
  .top3-strip .pos { color: var(--gold); font-weight: 700; }
  .top3-strip .who { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9ch; }
  .top3-strip .pts { color: #f6dfae; font-variant-numeric: tabular-nums; }
  .top3-strip .t3-empty { color: var(--muted); font-size: 11.5px; }
}

/* ---------- result screen Top 3 ---------- */
.result-top3 { margin-top: 12px; }
.result-top3 .eyebrow { margin-bottom: 6px; }
.result-top3 .modal-hall-list li { padding: 5px 10px; }
