:root {
  --bg: #0d0e10;
  --panel: #17191d;
  --panel-2: #20242a;
  --ink: #f5f1e8;
  --muted: #aeb2bd;
  --line: #343943;
  --green: #9cff5a;
  --cyan: #38d5e8;
  --amber: #ffbf47;
  --rose: #ff4f81;
  --red: #e64135;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(156, 255, 90, 0.08), transparent 30rem),
    linear-gradient(135deg, #0d0e10 0%, #15171b 50%, #101112 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand h1,
.brand p,
.panel-head h2,
.panel-head p,
.prompt-card h2,
.prompt-card p,
.status-strip p {
  margin: 0;
}

.brand h1 {
  font-size: clamp(1.25rem, 4vw, 2.1rem);
  line-height: 1;
}

.brand p,
.eyebrow,
.game-tab small,
.round-meta,
.player-form span {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

.scoreboard {
  min-width: min(520px, 56vw);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

#scoreList {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#scoreList li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

#scoreList strong {
  color: var(--green);
}

.icon-button,
.ghost-action,
.primary-action,
.choice-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--ink);
  font-weight: 900;
}

.icon-button,
.ghost-action {
  background: transparent;
  border-color: var(--line);
}

.icon-button {
  padding: 0 12px;
}

.primary-action {
  padding: 0 18px;
  background: var(--green);
  color: #10140d;
}

.app-grid {
  min-height: calc(100vh - 126px);
}

.setup-panel,
.table-panel {
  background: rgba(23, 25, 29, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.setup-panel {
  max-width: 580px;
  margin: 9vh auto 0;
  padding: clamp(22px, 5vw, 38px);
}

.panel-head {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.panel-head h2 {
  font-size: clamp(2rem, 8vw, 4rem);
  line-height: 0.95;
}

.player-form {
  display: grid;
  gap: 14px;
}

.player-form label {
  display: grid;
  gap: 7px;
}

.player-form input {
  width: 100%;
  min-height: 52px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #111317;
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
}

.table-panel {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 330px;
  gap: 14px;
  padding: 14px;
}

.game-rail,
.control-panel,
.card-stage {
  min-width: 0;
}

.game-rail {
  display: grid;
  align-content: start;
  gap: 10px;
}

.game-tab {
  display: grid;
  gap: 4px;
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  text-align: left;
}

.game-tab span {
  font-size: 1.05rem;
  font-weight: 950;
}

.game-tab.active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(156, 255, 90, 0.45);
}

.card-stage {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
  gap: 12px;
}

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

.round-meta span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.prompt-card {
  min-height: 360px;
  display: grid;
  align-content: center;
  gap: 18px;
  padding: clamp(20px, 6vw, 48px);
  border-radius: 8px;
  border: 1px solid rgba(245, 241, 232, 0.14);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #14161a;
}

.prompt-kicker {
  color: var(--amber);
  font-weight: 950;
  text-transform: uppercase;
}

.prompt-card h2 {
  max-width: 16ch;
  font-size: clamp(2rem, 7vw, 5.2rem);
  line-height: 0.97;
}

.timer {
  display: grid;
  grid-template-columns: 1fr 52px;
  align-items: center;
  gap: 10px;
}

.timer-bar {
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: #2b2f37;
}

.timer-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 160ms linear, background 160ms linear;
}

.timer strong {
  text-align: right;
  color: var(--green);
}

.control-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.status-strip {
  min-height: 62px;
  padding: 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #101216;
}

.status-strip p {
  color: var(--ink);
  font-weight: 850;
}

.controls {
  display: grid;
  align-content: start;
  gap: 10px;
}

.control-group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.control-group h3,
.control-group p {
  margin: 0;
}

.control-group h3 {
  font-size: 1rem;
}

.control-group p {
  color: var(--muted);
}

.choice-grid {
  display: grid;
  gap: 8px;
}

.choice-grid.two {
  grid-template-columns: 1fr 1fr;
}

.choice-button {
  padding: 12px;
  background: #252a32;
  border-color: var(--line);
  text-align: left;
}

.choice-button[data-tone="good"] {
  border-color: rgba(156, 255, 90, 0.5);
}

.choice-button[data-tone="warn"] {
  border-color: rgba(255, 191, 71, 0.5);
}

.choice-button[data-tone="bad"] {
  border-color: rgba(255, 79, 129, 0.55);
}

.utility-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.result-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.icon-button.is-off {
  color: var(--muted);
  border-color: var(--line);
  opacity: 0.7;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  margin-right: 8px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  vertical-align: middle;
}

.choice-button kbd {
  margin-right: 10px;
}

.ghost-action kbd,
.primary-action kbd {
  margin-left: 8px;
  margin-right: 0;
}

.primary-action kbd {
  background: rgba(0, 0, 0, 0.18);
  border-color: rgba(0, 0, 0, 0.2);
  color: #10140d;
}

.defender-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink) !important;
  font-weight: 800;
}

.judge-line {
  color: var(--muted) !important;
}

.side-tag {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 950;
  flex-shrink: 0;
}

.side-tag.tag-a {
  background: rgba(56, 213, 232, 0.18);
  color: var(--cyan);
  border: 1px solid rgba(56, 213, 232, 0.5);
}

.side-tag.tag-b {
  background: rgba(255, 191, 71, 0.16);
  color: var(--amber);
  border: 1px solid rgba(255, 191, 71, 0.5);
}

.prompt-card.is-fresh {
  animation: card-in 360ms cubic-bezier(0.18, 0.9, 0.28, 1.2);
}

@keyframes card-in {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.timer.danger strong {
  animation: timer-pulse 1s ease-in-out infinite;
}

.timer.expired {
  animation: timer-shake 360ms ease;
}

@keyframes timer-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.18);
    opacity: 0.7;
  }
}

@keyframes timer-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

#scoreList li.bumped {
  animation: score-pop 460ms cubic-bezier(0.18, 0.9, 0.28, 1.4);
}

#scoreList li.bumped strong {
  color: var(--amber);
}

@keyframes score-pop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.22);
    border-color: var(--amber);
  }
  100% {
    transform: scale(1);
  }
}

.heat-flash {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  pointer-events: none;
  z-index: 30;
  background: radial-gradient(circle at center, rgba(255, 79, 129, 0.22), rgba(13, 14, 16, 0) 60%);
}

.heat-flash.show {
  display: grid;
  animation: heat-fade 1100ms ease forwards;
}

.heat-flash span {
  font-size: clamp(3rem, 18vw, 11rem);
  font-weight: 950;
  letter-spacing: -0.02em;
  color: var(--rose);
  text-shadow: 0 0 40px rgba(255, 79, 129, 0.6);
  animation: heat-zoom 1100ms cubic-bezier(0.18, 0.9, 0.28, 1.2) forwards;
}

@keyframes heat-fade {
  0% {
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes heat-zoom {
  0% {
    transform: scale(0.6) rotate(-4deg);
  }
  40% {
    transform: scale(1.06) rotate(-2deg);
  }
  100% {
    transform: scale(1.12) rotate(-2deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .prompt-card.is-fresh,
  .timer.danger strong,
  .timer.expired,
  #scoreList li.bumped,
  .heat-flash.show,
  .heat-flash span {
    animation: none !important;
  }
}

.hidden {
  display: none !important;
}

.pass-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.88);
  z-index: 20;
}

.pass-screen > div {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: center;
}

.pass-screen h2 {
  margin: 0;
  font-size: clamp(2rem, 10vw, 4rem);
  line-height: 0.95;
}

@media (max-width: 960px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .scoreboard {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
  }

  #scoreList {
    justify-content: flex-start;
  }

  .table-panel {
    grid-template-columns: 1fr;
  }

  .game-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .card-stage {
    grid-template-rows: auto minmax(300px, auto) auto;
  }

  .prompt-card {
    min-height: 300px;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 12px 0;
  }

  .game-rail {
    grid-template-columns: 1fr;
  }

  .prompt-card h2 {
    max-width: 100%;
  }

  .choice-grid.two,
  .utility-row {
    grid-template-columns: 1fr;
  }
}
