* {
  box-sizing: border-box;
}

:root {
  --ink: #17324d;
  --muted: #5d7287;
  --line: #dfe8ef;
  --button: #067bdc;
  --button-dark: #035ca8;
  --challenge: #7c3aed;
  --danger: #d6364f;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #fff;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  min-height: 100svh;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app {
  width: min(1400px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(10px, 1.4vh, 18px) clamp(12px, 2vw, 28px);
}

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

.logo {
  width: min(48vw, 560px);
  max-height: clamp(62px, 12vh, 112px);
  object-fit: contain;
  object-position: left center;
}

.round-info {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  font-size: clamp(0.88rem, 1.6vw, 1.08rem);
  font-weight: 800;
}

.small-btn,
.quick-btn {
  border: 1px solid #c9d8e5;
  border-radius: 999px;
  padding: 9px 15px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.small-btn:hover,
.quick-btn:hover {
  background: #f3f8fb;
}

.setup-screen {
  min-height: calc(100svh - 110px);
  display: grid;
  place-items: center;
  padding: 12px 0 30px;
}

.setup-card {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: clamp(22px, 4vw, 42px);
  box-shadow: 0 18px 45px rgba(25, 62, 93, 0.12);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--button);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.setup-card h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.setup-copy {
  color: var(--muted);
  line-height: 1.5;
}

.saved-classes {
  display: grid;
  gap: 10px;
  margin: 22px 0;
}

.saved-class {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  background: #f8fbfd;
}

.saved-class strong {
  display: block;
}

.saved-class small {
  color: var(--muted);
}

.play-class-btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 15px;
  background: var(--button);
  color: #fff;
  font-weight: 900;
}

.delete-class-btn {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 800;
}

.empty-message {
  color: var(--muted);
  text-align: center;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  margin: 22px 0;
  font-size: 0.9rem;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.class-form {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 14px;
  align-items: end;
}

.class-form label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid #bfd0dd;
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

.primary-btn {
  border: 0;
  border-radius: 13px;
  padding: 12px 18px;
  background: linear-gradient(135deg, var(--button), #18a2eb);
  color: #fff;
  font-weight: 900;
}

.primary-btn.compact {
  white-space: nowrap;
}

.game-screen {
  height: calc(100svh - 94px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  gap: clamp(7px, 1.1vh, 13px);
}

.prompt {
  text-align: center;
}

.prompt h1 {
  margin: 0;
  font-size: clamp(1.18rem, 2.5vw, 2.15rem);
  line-height: 1.1;
}

.prompt h1 strong {
  color: var(--button);
}

.prompt p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: clamp(0.8rem, 1.35vw, 1rem);
}

.category-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 20px);
}

.category-card {
  position: relative;
  min-width: 0;
  border: 4px solid transparent;
  border-radius: clamp(16px, 2vw, 25px);
  padding: clamp(32px, 3vw, 48px) clamp(12px, 1.8vw, 22px) clamp(13px, 2vw, 24px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-shadow: 0 9px 22px rgba(30, 66, 96, 0.12);
  transition: transform 160ms ease, opacity 160ms ease, border-color 160ms ease;
  overflow: hidden;
}

.category-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255,255,255,.42), transparent 48%);
  pointer-events: none;
}

.card-0 { background: #dff3ff; color: #075d98; }
.card-1 { background: #fff0cc; color: #7b4a00; }
.card-2 { background: #e7f8df; color: #28640d; }
.card-3 { background: #f5e7ff; color: #6d2691; }

.category-card h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 2.05rem);
  line-height: 1.08;
}

.category-card p {
  position: relative;
  z-index: 1;
  margin: clamp(5px, 1vh, 10px) 0 0;
  font-size: clamp(0.74rem, 1.12vw, 0.96rem);
  line-height: 1.25;
}

.points-badge {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  min-width: 58px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  font-weight: 900;
  font-size: clamp(0.72rem, 1vw, 0.9rem);
  box-shadow: 0 3px 10px rgba(0,0,0,.08);
}

.challenge-label {
  position: absolute;
  z-index: 2;
  left: 10px;
  top: 10px;
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--challenge);
  color: #fff;
  font-size: clamp(0.62rem, 0.9vw, 0.78rem);
  font-weight: 900;
  letter-spacing: .035em;
}

.category-card.active {
  transform: translateY(-5px) scale(1.015);
  border-color: #ffce2e;
  box-shadow: 0 13px 28px rgba(30, 66, 96, 0.2);
}

.category-card.dim {
  opacity: .28;
  transform: scale(.97);
}

.action-area {
  text-align: center;
}

.reveal-btn {
  width: min(680px, 100%);
  border: 0;
  border-radius: 16px;
  padding: clamp(12px, 1.7vh, 18px) 24px;
  background: linear-gradient(135deg, var(--button), #18a2eb);
  color: #fff;
  font-size: clamp(1rem, 1.8vw, 1.28rem);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(6, 123, 220, 0.24);
}

.reveal-btn:disabled {
  opacity: .65;
  cursor: default;
}

.status {
  min-height: 17px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: clamp(0.74rem, 1.1vw, 0.92rem);
}

.result-panel,
.score-entry-panel {
  border: 2px solid #cde4f4;
  border-radius: 18px;
  padding: clamp(9px, 1.3vh, 14px) clamp(14px, 2vw, 24px);
  background: #f6fbff;
}

.result-panel {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(18px, 5vw, 60px);
}

.result-kicker {
  color: var(--button);
  font-size: clamp(0.65rem, 0.9vw, 0.8rem);
  font-weight: 900;
  letter-spacing: .09em;
}

.result-panel h2,
.score-entry-panel h2 {
  margin: 2px 0 0;
  font-size: clamp(1.15rem, 2.3vw, 1.9rem);
  line-height: 1.05;
}

.result-panel p,
.score-entry-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: clamp(0.75rem, 1.1vw, 0.92rem);
}

.result-points {
  min-width: 96px;
  text-align: center;
  font-size: clamp(1.1rem, 1.8vw, 1.45rem);
  font-weight: 900;
  color: var(--challenge);
}

.score-entry-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  border-color: #e3d8ff;
  background: #fbf9ff;
}

.score-entry-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-entry-controls input {
  width: 82px;
  text-align: center;
  font-weight: 900;
}

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

  .class-form .primary-btn {
    grid-column: 1 / -1;
  }

  .score-entry-panel {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .score-entry-controls {
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (max-width: 760px), (orientation: portrait) {
  .topbar {
    min-height: 68px;
  }

  .logo {
    width: min(62vw, 480px);
    max-height: 82px;
  }

  .round-info {
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
  }

  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .category-card {
    padding: 31px 10px 10px;
  }

  .category-card h2 {
    font-size: clamp(0.95rem, 4.6vw, 1.45rem);
  }

  .category-card p {
    font-size: clamp(0.68rem, 2.7vw, 0.86rem);
  }

  .class-form {
    grid-template-columns: 1fr;
  }

  .class-form .primary-btn {
    grid-column: auto;
  }
}

@media (max-height: 690px) {
  .app {
    padding-top: 6px;
    padding-bottom: 6px;
  }

  .topbar {
    min-height: 56px;
  }

  .logo {
    max-height: 56px;
  }

  .prompt p {
    display: none;
  }

  .game-screen {
    height: calc(100svh - 62px);
    gap: 5px;
  }

  .category-card {
    padding-top: 28px;
  }

  .result-panel,
  .score-entry-panel {
    padding-top: 7px;
    padding-bottom: 7px;
  }
}
