:root {
  --ink: #291318;
  --muted: #755c62;
  --red: #b7162c;
  --red-dark: #770e20;
  --cream: #fff9f4;
  --line: rgba(146, 31, 47, 0.18);
  --shadow: 0 24px 58px rgba(89, 20, 30, 0.16);
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: #fff6f2;
}

button, a { font: inherit; }

.game-shell {
  width: min(980px, calc(100% - 24px));
  margin: 0 auto;
  padding: 22px 0 42px;
}

.utility-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.utility-nav a,
.secondary-button,
.icon-button,
.dialog-actions a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--red-dark);
  background: rgba(255, 255, 255, 0.9);
  font-weight: 850;
  text-decoration: none;
}

.game-panel {
  padding: clamp(16px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 15px;
}

.title-mark {
  width: 70px;
  height: 70px;
  flex: 0 0 70px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: #b7162c;
  box-shadow: 0 12px 24px rgba(188, 23, 48, 0.18);
  font-size: 2.7rem;
}

.eyebrow,
.dialog-kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 5.8vw, 4rem); line-height: 0.94; }
.game-header p { margin-top: 7px; color: var(--muted); font-weight: 650; }

.header-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.secondary-button, .icon-button { border: 0; cursor: pointer; }
.icon-button { gap: 6px; padding-inline: 13px; }
.icon-button > span:first-child { font-size: 1.25rem; }
.button-state { font-size: 0.78rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats > div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--cream);
}

.stats span { display: block; color: var(--muted); font-size: 0.7rem; font-weight: 900; text-transform: uppercase; }
.stats strong { display: block; margin-top: 4px; font-size: clamp(1.15rem, 3vw, 1.6rem); }

.game-status-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
  color: var(--muted);
}

.phase-badge {
  min-width: 86px;
  min-height: 32px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 999px;
  color: #fff;
  background: #7c6267;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.phase-badge.is-watch { background: #b7162c; }
.phase-badge.is-turn { background: #247b80; }

.spotlight-stage {
  position: relative;
  overflow: hidden;
  padding: clamp(12px, 2.6vw, 26px);
  border: 2px solid rgba(183, 22, 44, 0.2);
  border-radius: 8px;
  background: #24151f;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  isolation: isolate;
}

.stage-beams { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0.35; }
.stage-beams span { position: absolute; top: -15%; width: 25%; height: 120%; background: rgba(255, 229, 172, 0.14); clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%); }
.stage-beams span:nth-child(1) { left: 0; transform: rotate(-8deg); }
.stage-beams span:nth-child(2) { left: 25%; transform: rotate(-3deg); }
.stage-beams span:nth-child(3) { left: 50%; transform: rotate(3deg); }
.stage-beams span:nth-child(4) { left: 75%; transform: rotate(8deg); }

.spotlight-grid {
  width: min(100%, 650px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 18px);
}

.spotlight-pad {
  --pad-color: #dc4865;
  position: relative;
  aspect-ratio: 1.15;
  min-width: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 10px;
  border: 2px solid color-mix(in srgb, var(--pad-color), white 22%);
  border-radius: 8px;
  color: #fff;
  background: color-mix(in srgb, var(--pad-color), #24151f 68%);
  box-shadow: inset 0 -16px 28px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.spotlight-pad:disabled { cursor: default; opacity: 1; }
.pad-gold { --pad-color: #e4a315; }
.pad-teal { --pad-color: #2f9998; }
.pad-blue { --pad-color: #477fc3; }

.portrait {
  width: clamp(70px, 17vw, 132px);
  aspect-ratio: 1;
  display: block;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.portrait img { width: 100%; height: 100%; display: block; object-fit: cover; object-position: center 20%; }
.pad-name { font-size: clamp(0.78rem, 2vw, 1rem); font-weight: 900; text-transform: uppercase; pointer-events: none; }

.spotlight-pad.is-lit,
.spotlight-pad.is-correct {
  transform: scale(0.965);
  background: var(--pad-color);
  box-shadow: 0 0 0 5px rgba(255,255,255,0.2), 0 0 38px color-mix(in srgb, var(--pad-color), transparent 25%), inset 0 -8px 22px rgba(255,255,255,0.1);
  filter: brightness(1.25) saturate(1.15);
}

.spotlight-pad.is-wrong { animation: wrong-flash 320ms ease; }

.start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  color: #fff;
  text-align: center;
  background: rgba(30, 12, 21, 0.86);
  backdrop-filter: blur(6px);
}

.start-overlay[hidden] { display: none; }
.overlay-mark { color: #ffd45b; font-size: 4rem; line-height: 1; }
.start-overlay strong { font-size: clamp(1.8rem, 5vw, 3rem); }
.start-overlay p { max-width: 34ch; color: #ffe9df; line-height: 1.5; }
.start-overlay button,
.dialog-actions button {
  min-height: 48px;
  margin-top: 8px;
  padding: 0 22px;
  border: 0;
  border-radius: 8px;
  color: var(--red-dark);
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}
.start-overlay button:disabled { opacity: 0.62; cursor: wait; }

.progress-track { height: 8px; overflow: hidden; margin-top: 14px; border-radius: 999px; background: #f0dfe0; }
.progress-track span { width: 0; height: 100%; display: block; border-radius: inherit; background: #247b80; transition: width 160ms ease; }

.result-dialog {
  width: min(520px, calc(100% - 28px));
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--cream);
  box-shadow: 0 32px 80px rgba(42, 17, 21, 0.35);
  text-align: center;
}

.result-dialog::backdrop { background: rgba(32, 8, 12, 0.72); backdrop-filter: blur(4px); }
.dialog-mark { display: block; color: #e3a00e; font-size: 4.5rem; line-height: 1; }
.result-dialog h2 { margin-bottom: 10px; font-size: 2.1rem; }
.result-dialog p { color: var(--muted); line-height: 1.55; }
.dialog-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
.dialog-actions button { margin: 0; color: #fff; background: var(--red); }

button:focus-visible, a:focus-visible { outline: 4px solid rgba(47, 153, 152, 0.38); outline-offset: 3px; }

@keyframes wrong-flash {
  35% { transform: translateX(-5px); background: #7d1826; filter: brightness(1.25); }
  70% { transform: translateX(5px); }
}

@media (max-width: 620px) {
  .game-shell { width: min(100% - 16px, 980px); padding-top: 10px; }
  .game-panel { padding: 13px; }
  .game-header { align-items: flex-start; }
  .title-lockup { align-items: flex-start; gap: 10px; }
  .title-mark { width: 52px; height: 52px; flex-basis: 52px; font-size: 2rem; }
  .header-actions { flex-direction: column; }
  .secondary-button, .icon-button { min-height: 36px; padding: 0 10px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .stats > div { padding: 9px 11px; }
  .game-status-row { align-items: flex-start; font-size: 0.88rem; }
  .phase-badge { min-width: 74px; min-height: 29px; padding-inline: 8px; font-size: 0.67rem; }
  .spotlight-stage { padding: 9px; }
  .spotlight-grid { gap: 8px; }
  .spotlight-pad { aspect-ratio: 1; padding: 7px; }
  .portrait { border-width: 3px; }
  .dialog-actions { flex-direction: column; }
}

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