@font-face {
  font-family: Oswald;
  src: url("../fonts/oswald-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Oswald;
  src: url("../fonts/oswald-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #f6f1e4;
  --muted: #b7b1a4;
  --gold: #f0d48a;
  --gold-deep: #c9a24a;
  --bg: #070914;
}

* { box-sizing: border-box; }

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

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 50% 8%, rgba(56, 98, 196, 0.32), transparent 58%),
    radial-gradient(640px 380px at 92% 88%, rgba(201, 162, 74, 0.14), transparent 55%),
    linear-gradient(180deg, #171e34 0%, #070914 42%, #05060d 100%);
}

button, input { font: inherit; color: inherit; }

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

[hidden] { display: none !important; }

svg text { font-family: Oswald, "Arial Narrow", Impact, sans-serif; }

.home {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 8px;
  color: #f7f7f7;
  text-decoration: none;
}

.home svg { width: 0.95rem; height: 0.95rem; }

.home span {
  font-weight: 300;
  letter-spacing: 0.46em;
  text-indent: 0.46em;
  font-size: 1.15rem;
  line-height: 1;
}

#setup {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.setup-card { width: min(980px, 100%); }

.setup-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(240px, 400px);
  gap: 36px;
  align-items: center;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--gold);
}

h1 {
  margin: 0;
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-weight: 700;
  font-size: clamp(3.4rem, 8vw, 5.6rem);
  letter-spacing: 0.06em;
  line-height: 0.88;
  text-transform: uppercase;
  color: var(--gold);
}

.lede {
  margin: 12px 0 18px;
  font-size: 1.12rem;
  color: var(--ink);
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.count { display: flex; flex-wrap: wrap; gap: 8px; }

.count button {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 1px solid rgba(240, 212, 138, 0.45);
  background: transparent;
  cursor: pointer;
}

.count button[aria-pressed="true"] {
  background: var(--gold);
  border-color: var(--gold);
  color: #1b140c;
  font-weight: 700;
}

.names {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

label, .solve-label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.84rem;
}

input[type="text"] {
  width: 100%;
  background: #0e1322;
  border: 1px solid rgba(240, 212, 138, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1.05rem;
  color: var(--ink);
}

#form-error {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: #ff8d97;
}

.start, #btn-spin, #continue, #solve-submit, .hub {
  background: linear-gradient(#f8e7b0, #d7b15a);
  color: #1b140c;
  font-weight: 700;
}

.start, .actions button, #continue, #mute, .sheet-actions button {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.75rem 1.25rem;
  min-width: 8.4rem;
  cursor: pointer;
}

.start { margin-top: 6px; }

.rules {
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.92rem;
}

.rules li { margin: 0.4rem 0 0.4rem 0; }

.fine {
  margin: 14px 0 0;
  color: #8d887c;
  font-size: 0.8rem;
}

#app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 18px 14px;
}

header, .header-actions, .actions, .sheet-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

header { justify-content: space-between; }

.brand strong {
  display: block;
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: 1.7rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  line-height: 1;
  white-space: nowrap;
}

.brand em {
  display: block;
  margin-top: 4px;
  font-style: normal;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--muted);
}

.text-link {
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.08em;
}

#mute, #btn-vowel, #btn-solve, #solve-cancel {
  background: transparent;
  color: var(--ink);
  border-color: rgba(240, 212, 138, 0.45);
}

button:disabled { opacity: 0.38; cursor: default; }

#stage {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) minmax(230px, 380px);
  gap: 16px;
  align-items: center;
}

#players {
  display: grid;
  gap: 10px;
  align-self: stretch;
  align-content: safe center;
  min-height: 0;
  overflow: auto;
}

.player {
  position: relative;
  background: rgba(10, 14, 28, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 12px 12px 14px;
  box-shadow: inset 3px 0 0 var(--accent, var(--gold));
}

.player[data-color="0"] { --accent: #e0b85a; }
.player[data-color="1"] { --accent: #5ee0d0; }
.player[data-color="2"] { --accent: #ff9b8e; }
.player[data-color="3"] { --accent: #8eb6ff; }
.player[data-color="4"] { --accent: #d2a8ff; }

#players[data-count="5"] { gap: 6px; }
#players[data-count="5"] .player { padding: 8px 10px 8px 12px; }
#players[data-count="5"] .total { font-size: 1.35rem; }

.player.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent), 0 0 0 1px var(--accent);
}

.player h2 {
  margin: 0 2rem 0 0;
  font-size: 0.98rem;
  font-weight: 600;
}

.total {
  margin: 4px 0 0;
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

.round-score {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.turn {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.board-frame {
  background: radial-gradient(circle at 50% 0%, #1d56c9, #0b2c86 46%, #071a52);
  border-radius: 18px;
  padding: 14px 12px 12px;
  box-shadow:
    inset 0 0 0 3px #d7b56a,
    inset 0 0 0 7px #071433,
    0 18px 44px rgba(0, 0, 0, 0.35);
}

#category {
  width: fit-content;
  margin: 0 auto 10px;
  padding: 5px 16px;
  border-radius: 999px;
  background: linear-gradient(#fff, #efe6d4);
  color: #1b140c;
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

#board {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  gap: clamp(3px, 0.45vw, 6px);
}

.slot { aspect-ratio: 1; min-width: 0; }

.tile { width: 100%; height: 100%; perspective: 280px; }

.faces {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(.2, .7, .2, 1);
}

.tile.on .faces { transform: rotateX(180deg); }

.face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  backface-visibility: hidden;
  border-radius: 5px;
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-weight: 700;
  font-size: clamp(0.8rem, 1.7vw, 1.65rem);
  line-height: 1;
}

.face.front {
  background: linear-gradient(180deg, #3b74ef 0%, #1847b4 58%, #12368f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), inset 0 -6px 8px rgba(0, 0, 0, 0.28);
}

.face.back {
  background: linear-gradient(180deg, #fffefb, #e5dfd2);
  color: #172033;
  transform: rotateX(180deg);
}

.tile.mark .face.back { color: #8a6a22; }

#status {
  min-height: 2.8em;
  margin: 12px 0;
  text-align: center;
  line-height: 1.35;
}

.actions { justify-content: center; flex-wrap: wrap; }

.shake { animation: shake 0.35s linear; }

@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.wheel-box {
  position: relative;
  width: min(380px, 100%);
  aspect-ratio: 1;
  margin-inline: auto;
}

.wheel-box svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  z-index: 3;
  width: 0;
  height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-top: 22px solid var(--gold);
  filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.45));
  transform-origin: 50% 0;
}

.lights {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bulb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff, #f0d48a 42%, #8a6420);
  box-shadow: 0 0 6px rgba(240, 212, 138, 0.85);
  animation: blink 1.5s ease-in-out infinite;
}

.bulb:nth-child(even) { animation-delay: 0.75s; }

.wheel-box.spinning .bulb { animation-duration: 0.22s; }

@keyframes blink { 50% { opacity: 0.28; } }

.hub {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid var(--gold);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 35%, #4a4030, #14110c 70%);
  color: var(--gold);
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
  min-width: 0;
}

.hub:disabled { cursor: default; }

.callout {
  position: absolute;
  left: 50%;
  top: 22%;
  z-index: 4;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: #10141f;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-family: Oswald, sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.callout.bankrupt { color: #ff8d97; border-color: #ff8d97; }
.callout.lose { color: #1b140c; background: #f4f1ea; border-color: #f4f1ea; }
.callout.free { color: #f6efff; border-color: #d6c2ff; }

.rotor.idle {
  transform-box: view-box;
  transform-origin: center;
  animation: idle-spin 42s linear infinite;
}

@keyframes idle-spin { to { transform: rotate(360deg); } }

#keyboard {
  display: grid;
  gap: 6px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.key-row { display: flex; justify-content: center; gap: 6px; }

.key {
  flex: 0 0 auto;
  width: 2.55rem;
  height: 3rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #1a2236;
  color: var(--ink);
  font-family: Oswald, "Arial Narrow", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.key.vowel { box-shadow: inset 0 -2px 0 var(--gold); }
.key.open { background: #243152; }
.key.hit { background: #b6efc9; color: #0d3b28; }
.key.miss { background: #3a242c; color: #e7b7c0; }
.key.blocked { opacity: 0.4; }
.key:disabled { cursor: default; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: start;
  justify-content: center;
  padding: 9vh 16px 16px;
  background: rgba(5, 7, 14, 0.74);
}

.sheet {
  width: min(480px, 100%);
  max-height: calc(100dvh - 12vh);
  overflow: auto;
  background: #12182b;
  border: 1px solid rgba(240, 212, 138, 0.35);
  border-radius: 18px;
  padding: 22px 20px 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
}

.sheet h2 {
  margin: 0 0 8px;
  text-align: center;
  font-family: Oswald, sans-serif;
  font-size: 2rem;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.answer {
  margin: 0 0 10px;
  text-align: center;
  font-family: Oswald, sans-serif;
  font-weight: 700;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: 0.03em;
  line-height: 1.15;
}

#modal-copy p { margin: 0.3rem 0; text-align: center; color: var(--muted); }

#modal-copy .standings { color: var(--ink); }

#continue { display: block; margin: 16px auto 0; }

#solve-category { text-align: center; }

#solve-pattern {
  margin: 8px 0 12px;
  padding: 12px 10px;
  border-radius: 12px;
  background: #0c2f86;
  color: #f7f4ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.14em;
  line-height: 1.55;
  text-align: center;
  white-space: pre-wrap;
}

.timer-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-family: Oswald, sans-serif;
  letter-spacing: 0.08em;
}

.timer-track {
  height: 8px;
  margin-bottom: 12px;
  border-radius: 99px;
  background: #0e1322;
  overflow: hidden;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: var(--gold);
  transform-origin: left center;
}

.sheet-actions { justify-content: center; margin-top: 12px; }

@media (max-width: 1080px) {
  .setup-grid { grid-template-columns: 1fr; }
  .setup-wheel { order: -1; width: min(320px, 80vw); }
  #app { display: flex; flex-direction: column; }
  #stage { display: contents; }
  header { order: 1; }
  #players { order: 2; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  #play { order: 3; }
  #keyboard { order: 4; }
  #wheel-box { order: 5; width: min(280px, 74vw); }
}

@media (max-width: 720px) {
  h1 { letter-spacing: 0.04em; }
  .key { flex: 1 1 0; width: auto; min-width: 0; height: 2.75rem; }
  .player h2 { font-size: 0.86rem; }
  .total { font-size: 1.3rem; }
  .brand strong { letter-spacing: 0.12em; font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  .faces, .bulb, .rotor.idle, .shake {
    animation: none !important;
    transition: none !important;
  }
}
