:root {
  --panel: #111827;
  --text: #e5e7eb;
  --accent: #f59e0b;
  --accent-2: #f97316;
  --page-top: #1e293b;
  --page-bottom: #020617;
  --surface: #0b1220;
  --surface-2: #172033;
  --border: #4b5563;
  --panel-border: #374151;
  --danger: #7f1d1d;
  --danger-text: #fee2e2;
  --success: #34d399;
  --success-2: #16a34a;
  --success-text: #052e16;
}

body[data-theme="light"] {
  --panel: #ffffff;
  --text: #0f172a;
  --accent: #f59e0b;
  --accent-2: #ea580c;
  --page-top: #ffffff;
  --page-bottom: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #cbd5e1;
  --panel-border: #dbe4f1;
  --danger: #b91c1c;
  --danger-text: #fee2e2;
  --success: #22c55e;
  --success-2: #16a34a;
  --success-text: #052e16;
}

body[data-theme="sunset"] {
  --panel: #2a1424;
  --text: #fff1e6;
  --accent: #fb7185;
  --accent-2: #f97316;
  --page-top: #4c1d95;
  --page-bottom: #431407;
  --surface: #351628;
  --surface-2: #47203a;
  --border: #9a6a77;
  --panel-border: #7c3d5e;
  --danger: #9f1239;
  --danger-text: #ffe4e6;
  --success: #fbbf24;
  --success-2: #f59e0b;
  --success-text: #422006;
}

body[data-theme="ocean"] {
  --panel: #082f49;
  --text: #e0f2fe;
  --accent: #38bdf8;
  --accent-2: #06b6d4;
  --page-top: #0f766e;
  --page-bottom: #082f49;
  --surface: #0c3a57;
  --surface-2: #0f4c6e;
  --border: #67a8c8;
  --panel-border: #3d7fa6;
  --danger: #b91c1c;
  --danger-text: #fee2e2;
  --success: #2dd4bf;
  --success-2: #14b8a6;
  --success-text: #042f2e;
}

body[data-theme="forest"] {
  --panel: #1a2e1f;
  --text: #ecfdf5;
  --accent: #84cc16;
  --accent-2: #22c55e;
  --page-top: #365314;
  --page-bottom: #0f172a;
  --surface: #203625;
  --surface-2: #29432f;
  --border: #6e8f70;
  --panel-border: #4d6b51;
  --danger: #991b1b;
  --danger-text: #fee2e2;
  --success: #4ade80;
  --success-2: #22c55e;
  --success-text: #052e16;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: radial-gradient(circle at top, var(--page-top), var(--page-bottom) 60%);
  color: var(--text);
  min-height: 100vh;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
  display: none;
}

#confetti-layer.active {
  display: block;
}

.confetti-piece {
  position: absolute;
  top: -12vh;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  opacity: 0.95;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-12vh) rotate(0deg);
  }

  100% {
    transform: translateY(120vh) rotate(720deg);
  }
}

.site-footer {
  max-width: 1200px;
  margin: 0 auto 1.5rem;
  padding: 0 1rem;
  color: #cbd5e1;
  font-size: 0.95rem;
  text-align: center;
}

.site-footer a {
  color: #fcd34d;
}

.site-footer a:hover {
  color: #fde68a;
}

.panel {
  background: color-mix(in oklab, var(--panel) 90%, black);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none;
}

label {
  display: block;
  margin-top: 0.8rem;
  margin-bottom: 0.3rem;
}

input,
button,
.file-label {
  font: inherit;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

button,
.file-label {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 8px;
  color: #111;
  cursor: pointer;
  font-weight: 700;
  padding: 0.55rem 0.9rem;
  height: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}

button:hover,
.file-label:hover {
  filter: brightness(1.08);
}

.setup-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.app-heading {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  line-height: 1.1;
}

.success {
  background: linear-gradient(180deg, var(--success), var(--success-2));
  color: var(--success-text);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.8rem 0;
}

.setup-actions-row > * {
  flex: 1 1 200px;
}

#load-game-input {
  display: none;
}

.library-panel {
  margin: 0.6rem 0 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.9rem;
}

.library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.library-header h3,
.library-item h4 {
  margin: 0;
}

.library-copy,
.library-meta,
.library-empty {
  color: #cbd5e1;
}

.library-copy {
  margin: 0.5rem 0 0.9rem;
}

.library-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
}

.library-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in oklab, var(--panel) 82%, black);
  padding: 0.85rem;
  display: grid;
  gap: 0.6rem;
}

.library-meta {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
}

.guide-panel {
  display: grid;
  gap: 1rem;
}

.guide-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.guide-intro,
.guide-note {
  margin: 0;
  color: #dbe4f1;
}

.guide-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1rem;
}

.guide-section h2,
.guide-example-card h3 {
  margin-top: 0;
}

.guide-list {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  line-height: 1.5;
}

.guide-list.compact {
  margin-top: 0.5rem;
}

.guide-example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
  margin-top: 0.9rem;
}

.guide-example-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: color-mix(in oklab, var(--panel) 82%, black);
  padding: 0.85rem;
}

.options-panel {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  background: var(--surface);
}

.options-panel h3 {
  margin: 0 0 0.6rem;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.option-row p {
  margin: 0;
  min-width: 170px;
}

.option-row label {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.theme-picker-row {
  align-items: center;
}

.theme-picker-row > label {
  margin: 0;
  min-width: 170px;
}

#theme-picker {
  max-width: 220px;
}

.round-editor {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem;
  margin-bottom: 1rem;
  background: var(--panel);
}

.round-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.round-top h3 {
  margin: 0;
}

.round-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr 120px 44px;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.add-answer-btn {
  margin-top: 0.75rem;
}

.remove-answer-btn,
.remove-round-btn,
.danger {
  background: var(--danger);
  color: var(--danger-text);
}

.move-round-up-btn:disabled,
.move-round-down-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(170px, 220px) 1fr minmax(170px, 220px);
  gap: 0.8rem;
  align-items: start;
}

.center-board {
  min-width: 0;
}

#play-title {
  text-align: center;
}

.round-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.question-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.9rem;
  text-align: center;
  margin: 0.8rem 0;
}

#question-text {
  margin: 0;
}

.question-reveal-prompt {
  display: flex;
  justify-content: center;
}

.question-reveal-btn {
  min-width: min(280px, 100%);
}

#answers-board {
  display: grid;
  gap: 0.5rem;
}

.answer-tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  background: var(--surface);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
}

.answer-hidden {
  letter-spacing: 0.2rem;
  color: #9ca3af;
}

.answer-tile.bonus-revealed {
  border-color: #facc15;
  background: linear-gradient(180deg, #3a2e00, #5a4400);
  box-shadow: 0 0 0 1px #facc15 inset;
}

.answer-controls {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.team-side-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.7rem;
  text-align: center;
}

.team-side-card h4 {
  margin: 0 0 0.5rem;
}

.team-side-card p {
  margin: 0.3rem 0;
}

.team-side-card.empty {
  color: #9ca3af;
}

.strike-stack {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: center;
  color: #ef4444;
  font-size: 3.3rem;
  font-weight: 700;
  min-height: 2rem;
}

.side-strike-btn {
  margin-top: 0.75rem;
  width: 100%;
}

.tiny {
  padding: 0.3rem 0.5rem;
  font-size: 0.85rem;
  min-height: 34px;
  height: 34px;
}

.winner-banner {
  background: #14532d;
  color: #dcfce7;
  border: 1px solid #22c55e;
  border-radius: 10px;
  padding: 0.7rem;
  font-weight: 700;
  text-align: center;
}

.game-result-sub {
  margin-top: 0.35rem;
  font-weight: 500;
}

.bottom-add-row {
  justify-content: center;
}

.endgame-screen {
  min-height: 72vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.endgame-screen #play-title {
  display: none;
}

.endgame-screen #game-result {
  width: min(900px, 92%);
  font-size: 2rem;
  line-height: 1.25;
  padding: 2rem 1.5rem;
  margin: 0 auto 1rem;
}

.endgame-screen .game-result-sub {
  font-size: 1.4rem;
  margin-top: 1rem;
}

@media (max-width: 900px) {
  .play-layout {
    grid-template-columns: 1fr;
  }

  .team-side {
    order: 2;
  }

  .center-board {
    order: 1;
  }
}

@media (max-width: 700px) {
  .setup-top-row {
    justify-content: center;
  }

  .app-heading {
    width: 100%;
    text-align: center;
  }

  .guide-top-row .file-label {
    width: 100%;
  }

  .round-actions {
    width: 100%;
  }

  .round-actions button {
    flex: 1 1 140px;
  }

  .library-header button,
  .library-item button {
    width: 100%;
  }

  .answer-row,
  .answer-tile {
    grid-template-columns: 1fr;
  }
}
