:root {
  --ink: #0e1a1f;
  --paper: #e8f0f2;
  --mist: #9bb4bc;
  --line: rgba(14, 26, 31, 0.14);
  --accent: #d9772c;
  --accent-deep: #a85212;
  --good: #1f7a4c;
  --bad: #a33b2c;
  --warn-bg: #fff3d6;
  --error-bg: #fde8e4;
  --panel: rgba(232, 240, 242, 0.88);
  --shadow: 0 18px 50px rgba(8, 20, 24, 0.18);
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-ui: "Outfit", "Segoe UI", Helvetica, Arial, sans-serif;
  --radius: 14px;
  --touch: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--ink);
  background: #0b1519;
  line-height: 1.45;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 15% 10%, rgba(217, 119, 44, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 0%, rgba(60, 140, 150, 0.35), transparent 50%),
    linear-gradient(165deg, #102229 0%, #1a333c 42%, #0c171c 100%);
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image: repeating-linear-gradient(
    -12deg,
    transparent,
    transparent 11px,
    rgba(232, 240, 242, 0.04) 11px,
    rgba(232, 240, 242, 0.04) 12px
  );
}

.top,
.stage,
.foot {
  width: min(560px, calc(100% - 2rem));
  margin-inline: auto;
}

.top {
  padding: 2.4rem 0 0.5rem;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 9vw, 3.6rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  color: var(--paper);
  line-height: 0.95;
}

.meta {
  margin: 0.55rem 0 0;
  color: var(--mist);
  font-size: 0.95rem;
  font-weight: 500;
}

.stage {
  padding: 1.25rem 0 3rem;
}

.banner {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.banner.warn {
  background: var(--warn-bg);
  color: #5a3d00;
}

.banner.error {
  background: var(--error-bg);
  color: #6d2418;
}

.status {
  color: var(--paper);
  font-size: 1.05rem;
}

.game,
.results {
  margin-top: 0.75rem;
  padding: 1.25rem 1.15rem 1.4rem;
  background: var(--panel);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.mode-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(14, 26, 31, 0.55);
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.55);
}

.mode-btn {
  min-height: var(--touch);
  min-width: 5.5rem;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  padding: 0 1rem;
}

.mode-btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

.mode-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.round-label {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.65rem;
  line-height: 1.1;
}

.level-steps {
  display: flex;
  gap: 0.45rem;
  margin: 0 0 1.15rem;
}

.level-step {
  flex: 1;
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.45);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(14, 26, 31, 0.45);
}

.level-step[data-state="current"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.level-step[data-state="done"] {
  background: rgba(31, 122, 76, 0.16);
  border-color: rgba(31, 122, 76, 0.35);
  color: var(--good);
}

.step-badge {
  margin: 0 0 1rem;
  display: inline-block;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: rgba(217, 119, 44, 0.16);
  color: var(--accent-deep);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.level-gate {
  text-align: left;
  padding: 0.35rem 0 0.5rem;
}

.gate-eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(14, 26, 31, 0.5);
}

.gate-title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.1;
}

.gate-copy {
  margin: 0 0 1.25rem;
  color: rgba(14, 26, 31, 0.68);
  max-width: 28rem;
}

.answer-panel {
  margin-top: 0.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.answer-heading {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: 1rem;
}

.play-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.1rem;
}

.play-btn,
.share-btn,
.choice {
  font: inherit;
  cursor: pointer;
}

.play-btn,
.share-btn {
  min-height: var(--touch);
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 0 1.35rem;
  width: fit-content;
  transition: transform 160ms ease, background 160ms ease;
}

.play-btn:hover,
.share-btn:hover {
  background: var(--accent-deep);
}

.play-btn:active,
.share-btn:active,
.choice:active {
  transform: scale(0.98);
}

.play-btn:focus-visible,
.share-btn:focus-visible,
.choice:focus-visible,
.mode-btn:focus-visible {
  outline: 3px solid rgba(217, 119, 44, 0.55);
  outline-offset: 2px;
}

.hint {
  margin: 0;
  color: rgba(14, 26, 31, 0.62);
  font-size: 0.92rem;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.choice {
  min-height: var(--touch);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  padding: 0.7rem 0.8rem;
}

.choice:hover {
  border-color: rgba(14, 26, 31, 0.35);
}

.choice[data-state="correct"] {
  background: rgba(31, 122, 76, 0.14);
  border-color: var(--good);
  color: var(--good);
}

.choice[data-state="wrong"] {
  background: rgba(163, 59, 44, 0.12);
  border-color: var(--bad);
  color: var(--bad);
}

.choice:disabled {
  cursor: default;
}

.grid {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.grid li {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 4px;
  background: rgba(14, 26, 31, 0.12);
}

.grid li.hit {
  background: var(--good);
}

.grid li.miss {
  background: var(--bad);
}

.grid li.current {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.results-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
}

.results-summary {
  margin: 0.4rem 0 1rem;
  color: rgba(14, 26, 31, 0.7);
}

.share-card {
  position: relative;
  overflow: hidden;
  padding: 1.35rem 1.2rem 1.25rem;
  border-radius: 18px;
  color: var(--paper);
  background:
    radial-gradient(ellipse 90% 70% at 0% 0%, rgba(217, 119, 44, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 60% at 100% 10%, rgba(60, 140, 150, 0.4), transparent 50%),
    linear-gradient(160deg, #132830 0%, #1c3a44 48%, #0f1c22 100%);
  box-shadow: 0 16px 40px rgba(8, 20, 24, 0.28);
}

.share-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.14;
  background-image: repeating-linear-gradient(
    -12deg,
    transparent,
    transparent 10px,
    rgba(232, 240, 242, 0.06) 10px,
    rgba(232, 240, 242, 0.06) 11px
  );
}

.share-card-brand {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.85rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.share-card-meta {
  position: relative;
  margin: 0.45rem 0 0;
  color: rgba(232, 240, 242, 0.72);
  font-size: 0.92rem;
  font-weight: 500;
}

.share-card-score {
  position: relative;
  margin: 1.15rem 0 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 10vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.share-card-grid {
  position: relative;
  display: grid;
  gap: 0.55rem;
  margin: 0 0 1.15rem;
}

.share-level-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  align-items: center;
  gap: 0.65rem;
}

.share-level-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(232, 240, 242, 0.62);
}

.share-cells {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.share-cell {
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 5px;
  background: rgba(232, 240, 242, 0.16);
}

.share-cell.hit {
  background: #3dba74;
  box-shadow: 0 0 0 1px rgba(61, 186, 116, 0.35);
}

.share-cell.miss {
  background: #d45a4a;
  box-shadow: 0 0 0 1px rgba(212, 90, 74, 0.35);
}

.share-card-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding-top: 0.95rem;
  border-top: 1px solid rgba(232, 240, 242, 0.14);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(232, 240, 242, 0.55);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
}

.share-actions {
  margin-top: 1.15rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.share-btn.primary {
  background: var(--accent);
  color: #fff;
}

.share-btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
  box-shadow: none;
}

.share-btn.secondary:hover {
  background: rgba(14, 26, 31, 0.06);
  border-color: rgba(14, 26, 31, 0.28);
}

.reveal-details {
  margin-top: 1.15rem;
  border-top: 1px solid var(--line);
  padding-top: 0.85rem;
}

.reveal-details summary {
  cursor: pointer;
  font-weight: 600;
  color: rgba(14, 26, 31, 0.72);
  list-style: none;
}

.reveal-details summary::-webkit-details-marker {
  display: none;
}

.reveal-details summary::before {
  content: "▸ ";
  color: var(--accent);
}

.reveal-details[open] summary::before {
  content: "▾ ";
}

.reveal {
  margin: 0.75rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
  color: rgba(14, 26, 31, 0.78);
  font-size: 0.95rem;
}

.share-row {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.streak-line {
  margin: 1rem 0 0;
  font-weight: 600;
}

.foot {
  padding: 0 0 2.5rem;
  color: var(--mist);
  font-size: 0.9rem;
}

.foot p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .play-btn,
  .share-btn,
  .choice {
    transition: none;
  }

  .play-btn:active,
  .share-btn:active,
  .choice:active {
    transform: none;
  }
}

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