:root {
  --blue: #0b2c8a;
  --deep: #061b58;
  --gold: #f9c74f;
  --ink: #172033;
  --muted: #64748b;
  --line: #dbe2ef;
  --green: #2a9d8f;
  --red: #e76f51;
  --bg: #f8fafc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
}

button {
  position: relative;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.loading {
  color: transparent;
  pointer-events: none;
}

button.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.primary,
.toggle-on {
  background: var(--green);
}

.secondary {
  background: #334155;
}

.light {
  background: #e2e8f0;
  color: var(--ink);
}

.danger,
.incorrect {
  background: var(--red);
}

.correct {
  background: var(--green);
}

.hidden {
  display: none !important;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(248, 250, 252, 0.92);
}

.page-loader::before {
  content: "";
  width: 72px;
  height: 72px;
  border: 7px solid rgba(11, 44, 138, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

.setup-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.setup-panel {
  width: min(880px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.setup-panel h1 {
  margin: 0 0 6px;
}

.lede,
.note {
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.setup-actions,
.topbar-actions,
.score-actions,
.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.setup-actions {
  margin-top: 14px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 1.3fr) minmax(320px, 0.7fr);
  gap: 16px;
  padding: 16px;
}

.main-panel,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.board {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  gap: 8px;
}

.cell {
  min-height: 70px;
  display: grid;
  place-items: center;
  padding: 8px;
  border: 0;
  border-radius: 6px;
  text-align: center;
  font-weight: 900;
}

.header-cell {
  min-height: 54px;
  background: var(--deep);
  color: #fff;
  font-size: 14px;
}

.question-cell {
  background: var(--blue);
  color: var(--gold);
  font-size: 26px;
}

.question-cell.active {
  outline: 4px solid var(--gold);
  outline-offset: -4px;
}

.question-cell.done {
  background: #9ca3af;
  color: #e5e7eb;
  text-decoration: line-through;
}

.question-stage {
  display: grid;
  gap: 12px;
}

.question-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.question-title {
  font-size: 20px;
  font-weight: 900;
}

.question-tools {
  display: flex;
  gap: 10px;
  align-items: center;
}

.timer-ring {
  --progress: 100%;
  width: 88px;
  height: 88px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--progress), #e2e8f0 0);
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.timer-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #fff;
}

.timer-ring.time-low {
  background: conic-gradient(var(--red) var(--progress), #e2e8f0 0);
}

.timer-ring span {
  position: relative;
  z-index: 1;
}

.slide-image-wrap {
  min-height: 360px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  overflow: hidden;
}

.slide-image {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
}

.active-question {
  margin-bottom: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #fff7d6;
  color: #533f04;
  font-weight: 900;
}

.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.setting-title {
  font-size: 13px;
  font-weight: 900;
}

.setting-copy,
.status {
  color: var(--muted);
  font-size: 12px;
}

.setting-input {
  width: 80px;
  font-weight: 900;
}

.teams {
  display: grid;
  gap: 10px;
}

.score-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.team-name-input {
  min-height: 38px;
  font-size: 20px;
  font-weight: 900;
}

.score {
  margin: 8px 0 10px;
  color: var(--blue);
  font-size: 34px;
  font-weight: 900;
}

.score-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.score-actions.locked {
  opacity: 0.45;
}

.attempt-note {
  margin-top: 6px;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.skipped-log {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.skipped-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #533f04;
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.45);
}

.modal {
  width: min(430px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.25);
}

.modal h2 {
  margin: 10px 0 8px;
}

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

.modal-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto;
  border-radius: 50%;
  background: #fff7d6;
  color: var(--gold);
  font-size: 34px;
}

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