:root {
  --bg: #f3efe3;
  --panel: rgba(255, 251, 243, 0.94);
  --panel-strong: #fff9ec;
  --ink: #172033;
  --muted: #596277;
  --border: rgba(23, 32, 51, 0.12);
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #c2410c;
  --danger-strong: #9a3412;
  --smaller: #b45309;
  --same: #0f766e;
  --bigger: #1d4ed8;
  --shadow: 0 18px 40px rgba(23, 32, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(180, 83, 9, 0.14), transparent 26%),
    linear-gradient(180deg, #f9f4e7 0%, #efe6d0 100%);
}

button,
input,
select {
  font: inherit;
}

.app-page {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.landing-page,
.student-page {
  max-width: 760px;
}

.landing-card,
.panel-card,
.student-shell,
.admin-shell {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.landing-card,
.student-shell,
.admin-shell {
  padding: 28px;
}

.student-shell,
.admin-shell {
  display: grid;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 2.8vw, 2rem);
}

h3 {
  margin-bottom: 8px;
}

.hero-copy,
.helper-copy,
.success-copy,
.error-copy {
  color: var(--muted);
  line-height: 1.55;
}

.success-copy {
  color: var(--accent-strong);
}

.error-copy {
  color: #b91c1c;
}

.landing-form,
.cpu-form {
  display: grid;
  gap: 16px;
}

.tutorial-card {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
}

.tutorial-list {
  display: grid;
  gap: 12px;
}

.tutorial-step {
  padding: 14px 16px;
  border-radius: 18px;
  background: white;
  border: 1px solid var(--border);
}

.tutorial-step strong {
  display: block;
  margin-bottom: 6px;
}

.tutorial-step p {
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 8px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fffdf6;
  color: var(--ink);
}

.primary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.primary-button {
  background: var(--accent);
  color: white;
}

.ghost-button {
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-strong);
}

.danger-button {
  background: rgba(194, 65, 12, 0.12);
  color: var(--danger-strong);
}

.compact-button {
  padding: 9px 14px;
}

.ghost-link {
  color: var(--accent-strong);
  text-decoration: none;
}

.student-hero,
.admin-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.student-stats,
.admin-hero-actions,
.student-result-grid,
.settings-row,
.action-row,
.admin-grid {
  display: grid;
  gap: 14px;
}

.student-stats {
  grid-template-columns: repeat(2, minmax(130px, 1fr));
}

.admin-hero-actions {
  grid-template-columns: repeat(3, minmax(120px, auto));
  align-items: center;
}

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

.panel-card {
  padding: 22px;
  background: var(--panel-strong);
}

.panel-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.pill-note {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(23, 32, 51, 0.08);
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  background: white;
  border: 1px solid var(--border);
}

.truth-stat.truth-bigger {
  border-color: rgba(29, 78, 216, 0.25);
}

.truth-stat.truth-smaller {
  border-color: rgba(180, 83, 9, 0.3);
}

.truth-stat.truth-same {
  border-color: rgba(15, 118, 110, 0.25);
}

.ball-grid {
  --ball-size: 112px;
  position: relative;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(var(--ball-count), minmax(72px, 1fr));
  align-items: start;
  padding: 24px 0 10px;
}

.ball-grid::before {
  content: "";
  position: absolute;
  left: 9%;
  right: 9%;
  top: calc(24px + (var(--ball-size) / 2) - 5px);
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(23, 32, 51, 0.14), rgba(23, 32, 51, 0.24), rgba(23, 32, 51, 0.14));
}

.ball-grid-compact {
  --ball-size: 86px;
  gap: 10px;
  padding-top: 18px;
}

.ball-grid-compact::before {
  top: calc(18px + (var(--ball-size) / 2) - 4px);
  height: 8px;
}

.ball-slot {
  position: relative;
  display: grid;
  justify-items: center;
}

.ball-choice {
  position: relative;
  z-index: 1;
  width: min(100%, var(--ball-size));
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  gap: 6px;
  padding: 14px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.76) 35%, rgba(232, 224, 202, 0.96) 100%);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 18px 34px rgba(23, 32, 51, 0.12), inset 0 -12px 18px rgba(23, 32, 51, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

button.ball-choice {
  cursor: pointer;
}

button.ball-choice:hover {
  transform: translateY(-4px) scale(1.02);
}

.ball-choice-position {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ball-choice strong {
  font-size: clamp(1.55rem, 3vw, 2.1rem);
  line-height: 1;
}

.ball-choice-selected {
  border-color: rgba(15, 118, 110, 0.38);
  box-shadow: 0 20px 36px rgba(15, 118, 110, 0.18), inset 0 0 0 4px rgba(15, 118, 110, 0.18);
}

.ball-choice-bigger {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.96), rgba(229, 238, 255, 0.92) 36%, rgba(191, 219, 254, 0.94) 100%);
  border-color: rgba(29, 78, 216, 0.28);
}

.ball-choice-smaller {
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.96), rgba(255, 239, 220, 0.94) 36%, rgba(253, 230, 138, 0.92) 100%);
  border-color: rgba(180, 83, 9, 0.28);
}

.ball-choice-destroyed {
  border-style: dashed;
  animation: destroyPulse 820ms ease-in-out 2 both;
}

.ball-choice-destroyed::after {
  content: "×";
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  font-size: 2.8rem;
  line-height: 1;
  color: rgba(194, 65, 12, 0.55);
  pointer-events: none;
}

.ball-choice-final {
  border-color: rgba(15, 118, 110, 0.24);
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.98), rgba(221, 247, 236, 0.94) 36%, rgba(167, 243, 208, 0.92) 100%);
}

.swap-marker {
  position: absolute;
  top: -6px;
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: white;
  box-shadow: 0 8px 16px rgba(23, 32, 51, 0.16);
  animation: markerFloat 500ms ease both;
}

.swap-marker-bigger {
  background: var(--bigger);
}

.swap-marker-smaller {
  background: var(--smaller);
}

.decision-slider-wrap {
  display: grid;
  gap: 12px;
}

.slider-instruction {
  margin-bottom: 0;
  font-weight: 700;
  color: var(--ink);
}

.slider-scale,
.slider-hints {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tone-smaller {
  color: var(--smaller);
}

.tone-same {
  color: var(--same);
}

.tone-bigger {
  color: var(--bigger);
}

.decision-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  cursor: grab;
  height: 20px;
  border-radius: 999px;
  touch-action: pan-x;
  background:
    linear-gradient(
      90deg,
      rgba(180, 83, 9, 0.85) 0%,
      rgba(180, 83, 9, 0.35) 33%,
      rgba(15, 118, 110, 0.5) 33%,
      rgba(15, 118, 110, 0.9) 50%,
      rgba(15, 118, 110, 0.5) 66%,
      rgba(29, 78, 216, 0.35) 66%,
      rgba(29, 78, 216, 0.85) 100%
    );
  outline: none;
}

.decision-slider:active {
  cursor: grabbing;
}

.decision-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid white;
  background: var(--ink);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.2);
  cursor: grab;
}

.decision-slider::-moz-range-thumb {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid white;
  background: var(--ink);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.2);
  cursor: grab;
}

.student-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.saved-choice-card {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.15);
}

.room-strip {
  display: flex;
  gap: 12px;
  overflow-x: auto;
}

.room-chip {
  min-width: 180px;
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: white;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.room-chip-active {
  border-color: rgba(15, 118, 110, 0.35);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.leaderboard-list,
.roster-list,
.error-stack {
  display: grid;
  gap: 10px;
}

.leaderboard-row,
.roster-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  background: white;
  border: 1px solid var(--border);
}

.leaderboard-row-current {
  border-color: rgba(15, 118, 110, 0.32);
  background: rgba(221, 247, 236, 0.78);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.line-input-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.line-input-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: white;
  border: 1px solid var(--border);
}

.line-input-card span {
  text-align: center;
  font-weight: 700;
}

.line-input-card input {
  width: 100%;
  height: 76px;
  padding: 0 12px;
  text-align: center;
  line-height: 76px;
  font-size: clamp(1.75rem, 3vw, 2.35rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

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

.action-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 16px;
}

.reveal-grid,
.market-grid {
  display: grid;
  gap: 16px;
}

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

.market-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.market-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 18px;
  background: white;
  border: 1px solid var(--border);
}

.bid-book-card {
  gap: 8px;
}

.market-copy {
  line-height: 1.45;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.96rem;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(23, 32, 51, 0.08);
  text-align: left;
}

.reveal-story-card,
.optimum-panel {
  margin-top: 18px;
  padding: 20px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
}

.swap-pill-row,
.optimum-grid {
  display: grid;
  gap: 12px;
}

.swap-pill-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.swap-pill {
  padding: 12px 14px;
  border-radius: 18px;
  font-weight: 700;
  line-height: 1.45;
}

.swap-pill-bigger {
  color: #1e40af;
  background: rgba(191, 219, 254, 0.72);
}

.swap-pill-smaller {
  color: #9a3412;
  background: rgba(254, 215, 170, 0.72);
}

.reveal-stage {
  display: grid;
  gap: 10px;
}

.optimum-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.optimum-steps {
  display: grid;
  gap: 12px;
}

.optimum-step-card {
  padding: 14px;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--border);
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  animation: revealStep 560ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(220ms + (var(--step-index) * 180ms));
}

.optimum-step-card-finish {
  background: rgba(221, 247, 236, 0.76);
}

.optimum-step-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.reveal-summary-copy {
  margin-top: 18px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.reveal-sequence-card {
  opacity: 0;
  transform: translateY(22px);
  animation: revealCard 520ms cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  animation-delay: calc(var(--reveal-order, 0) * 150ms);
}

@keyframes revealCard {
  from {
    opacity: 0;
    transform: translateY(22px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes revealStep {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes markerFloat {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes destroyPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(0.94);
  }
}

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

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

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

  .optimum-grid,
  .swap-pill-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-page {
    width: min(100% - 20px, 100%);
    padding: 20px 0 28px;
  }

  .landing-card,
  .student-shell,
  .admin-shell,
  .panel-card {
    padding: 20px;
    border-radius: 22px;
  }

  .line-input-row,
  .reveal-grid,
  .student-stats,
  .settings-row,
  .admin-hero-actions {
    grid-template-columns: 1fr;
  }

  .ball-grid {
    --ball-size: 76px;
    gap: 8px;
    padding-top: 18px;
  }

  .ball-grid::before {
    top: calc(18px + (var(--ball-size) / 2) - 4px);
    left: 8%;
    right: 8%;
    height: 8px;
  }

  .ball-grid-compact {
    --ball-size: 64px;
  }

  .student-actions,
  .leaderboard-row,
  .roster-row,
  .saved-choice-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .market-grid,
  .action-row {
    grid-template-columns: 1fr;
  }
}
