:root {
  color-scheme: dark;
  --ink: #eef9ff;
  --muted: #9cb8c7;
  --soft: #102b3b;
  --panel: rgba(7, 22, 34, 0.94);
  --panel-strong: rgba(13, 38, 52, 0.96);
  --line: rgba(123, 211, 234, 0.24);
  --navy: #061522;
  --teal: #16d8c7;
  --gold: #f3bd4d;
  --green: #6df0a6;
  --red: #ff6f73;
  --green-soft: rgba(109, 240, 166, 0.13);
  --red-soft: rgba(255, 111, 115, 0.14);
  --gold-soft: rgba(243, 189, 77, 0.15);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(22, 216, 199, 0.20), transparent 30%),
    radial-gradient(circle at 88% 10%, rgba(243, 189, 77, 0.18), transparent 28%),
    linear-gradient(90deg, rgba(123, 211, 234, 0.045) 1px, transparent 1px),
    linear-gradient(0deg, rgba(123, 211, 234, 0.04) 1px, transparent 1px),
    #04111c;
  background-size: auto, auto, 34px 34px, 34px 34px, auto;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), transparent 2px),
    linear-gradient(120deg, transparent 0 45%, rgba(22, 216, 199, 0.08) 46% 47%, transparent 48% 100%);
  background-size: 100% 7px, 210px 210px;
  opacity: 0.36;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

p {
  line-height: 1.55;
}

.page-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.app-header {
  margin-bottom: 18px;
  border-radius: 8px;
  background:
    radial-gradient(circle at 88% 0%, rgba(243, 189, 77, 0.24), transparent 30%),
    linear-gradient(110deg, rgba(6, 21, 34, 0.98), rgba(9, 43, 58, 0.86)),
    repeating-linear-gradient(135deg, rgba(22, 216, 199, 0.13) 0 1px, transparent 1px 18px),
    var(--navy);
  color: #ffffff;
  box-shadow: var(--shadow);
  border: 1px solid rgba(123, 211, 234, 0.24);
  border-bottom: 6px solid var(--gold);
  position: relative;
  overflow: hidden;
}

.app-header::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: -36px;
  width: 170px;
  height: 170px;
  border: 2px dashed rgba(22, 216, 199, 0.28);
  border-radius: 50%;
  box-shadow: 0 0 38px rgba(22, 216, 199, 0.16);
  pointer-events: none;
}

.app-header-inner {
  min-height: 116px;
  padding: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.brand-link,
.brand-lockup {
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(203, 244, 240, 0.92));
  color: var(--navy);
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: 0 0 0 4px rgba(22, 216, 199, 0.12), 0 0 28px rgba(22, 216, 199, 0.26);
}

.header-title {
  display: grid;
  gap: 5px;
}

.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.app-header .eyebrow,
.brand-subtitle {
  color: #dfecef;
}

.app-title {
  font-size: clamp(1.6rem, 4vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.app-subtitle {
  max-width: 720px;
  color: #e7f0f2;
}

.header-actions,
.actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ui-icon {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
  display: inline-block;
  color: currentColor;
  vertical-align: -0.16em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.icon-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.hud-cell .icon-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.button,
.button-secondary,
.button-ghost {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--navy);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  text-decoration: none;
  font-weight: 700;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.icon-button {
  min-width: 42px;
  min-height: 42px;
  padding-inline: 12px;
}

.help-button {
  border-color: rgba(243, 189, 77, 0.52);
  color: var(--gold);
}

.button {
  background: linear-gradient(180deg, #178b91, #0a5b68);
  color: #ffffff;
  border-color: rgba(22, 216, 199, 0.60);
  box-shadow: 0 0 0 1px rgba(22, 216, 199, 0.16), 0 12px 28px rgba(0, 0, 0, 0.24);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border-color: rgba(123, 211, 234, 0.32);
}

.button-ghost {
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.42);
}

.button:disabled {
  opacity: 0.55;
}

.button:hover,
.button-secondary:hover,
.button-ghost:hover,
.button:focus-visible,
.button-secondary:focus-visible,
.button-ghost:focus-visible {
  transform: translateY(-1px);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(243, 189, 77, 0.26), 0 14px 30px rgba(0, 0, 0, 0.30);
}

.button-ghost[aria-pressed="true"] {
  border-color: rgba(255, 255, 255, 0.75);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.soft-panel {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 76px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.25rem;
  line-height: 1.1;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chip,
.tag {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
  padding: 6px 9px;
  font-size: 0.86rem;
  font-weight: 700;
}

.tag.gold {
  background: var(--gold-soft);
  color: #725014;
  border-color: rgba(182, 129, 34, 0.35);
}

.tag.green {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(31, 122, 79, 0.28);
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(180, 59, 59, 0.28);
}

.how-grid,
.tutorial-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.how-card,
.tutorial-step {
  min-height: 100px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  padding: 12px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
}

.how-card .ui-icon,
.tutorial-step .ui-icon {
  width: 34px;
  height: 34px;
  color: var(--gold);
  filter: drop-shadow(0 0 16px rgba(243, 189, 77, 0.22));
}

.how-card strong,
.tutorial-step strong {
  font-size: 0.95rem;
  line-height: 1.15;
}

.how-card span,
.tutorial-step span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: 20px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(22, 216, 199, 0.20), transparent 28%),
    rgba(2, 9, 15, 0.84);
}

.tutorial-overlay.hidden {
  display: none !important;
}

.tutorial-card {
  width: min(760px, 100%);
  border-radius: 12px;
  border: 1px solid rgba(123, 211, 234, 0.34);
  background:
    linear-gradient(145deg, rgba(7, 22, 34, 0.98), rgba(12, 42, 56, 0.98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.52);
  padding: 22px;
  display: grid;
  gap: 16px;
}

.tutorial-card h2 {
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  line-height: 1;
}

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

.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.badge-medal {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--gold), #9a6815);
  color: #071622;
  box-shadow: 0 0 28px rgba(243, 189, 77, 0.28);
}

.badge-medal .ui-icon {
  width: 24px;
  height: 24px;
}

.progress-track {
  height: 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  transition: width 180ms ease;
}

.hidden {
  display: none !important;
}

.fx-burst,
.fx-celebrate {
  pointer-events: none;
  position: fixed;
  z-index: 50;
}

.fx-burst {
  width: 1px;
  height: 1px;
}

.fx-burst span {
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold);
  animation: fx-pop 560ms ease-out forwards;
  transform: rotate(var(--angle)) translateX(0);
}

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

.fx-burst.wrong span {
  background: var(--red);
}

.fx-celebrate {
  inset: 0;
  overflow: hidden;
}

.fx-celebrate span {
  position: absolute;
  top: 12px;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  background: var(--gold);
  animation: fx-fall 980ms ease-in forwards;
}

.fx-celebrate span:nth-child(3n) {
  background: var(--teal);
}

.fx-celebrate span:nth-child(4n) {
  background: var(--green);
}

@keyframes fx-pop {
  0% {
    opacity: 1;
    transform: rotate(var(--angle)) translateX(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translateX(var(--distance)) scale(0.15);
  }
}

@keyframes fx-fall {
  0% {
    opacity: 1;
    transform: translateY(-24px) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translateY(var(--fall)) rotate(220deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-burst,
  .fx-celebrate {
    display: none;
  }
}

.result-card {
  padding: 24px;
  display: grid;
  gap: 12px;
}

.result-score {
  color: var(--gold);
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1;
  font-weight: 700;
  text-shadow: 0 0 26px rgba(243, 189, 77, 0.24);
}

.result-status {
  width: fit-content;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(31, 122, 79, 0.28);
  border-radius: 8px;
  padding: 7px 10px;
  font-weight: 700;
}

.result-status.review {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(180, 59, 59, 0.28);
}

@media (max-width: 960px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 10px;
  }

  .app-header-inner {
    padding: 18px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .actions,
  .toolbar,
  .button,
  .button-secondary,
  .button-ghost {
    width: 100%;
  }

  .how-grid,
  .tutorial-steps {
    grid-template-columns: 1fr;
  }

  .tutorial-card {
    padding: 16px;
  }
}
