:root {
  color-scheme: dark;
  --bg: #171613;
  --bg-raised: #211f1a;
  --bg-soft: #29261f;
  --line: #484238;
  --text: #f2eee6;
  --muted: #aaa397;
  --subtle: #777066;
  --accent: #d9a441;
  --accent-hover: #e8b958;
  --accent-ink: #211805;
  --danger: #e27868;
  --success: #72bd99;
  --radius: 12px;
  --shadow: 0 18px 60px rgb(0 0 0 / 28%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, #393224 0, transparent 48rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button,
input,
video {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
[tabindex="-1"]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 72%, white);
  outline-offset: 3px;
}

[tabindex="-1"]:focus {
  outline: none;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 100;
  padding: 10px 14px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 6px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.screen {
  min-height: 100vh;
  animation: appear 280ms ease-out both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.brand__name {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.brand__divider {
  width: 1px;
  height: 18px;
  background: var(--line);
}

.brand__label {
  font-size: 0.67rem;
  letter-spacing: 0.17em;
}

.eyebrow,
.field-label,
.lesson-card__label,
.resume-card__label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.eyebrow--success {
  color: var(--success);
}

.display-title {
  max-width: 100%;
  margin: 0;
  color: var(--accent);
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(3.1rem, 10vw, 6.2rem);
  font-weight: 500;
  letter-spacing: 0.025em;
  line-height: 0.95;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.display-title--small {
  font-size: clamp(3rem, 8vw, 5.2rem);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 22px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 750;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease,
    transform 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:active {
  transform: translateY(0);
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
  transform: none;
}

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

.button--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.button--ghost {
  min-height: 40px;
  color: var(--muted);
  background: transparent;
  border-color: var(--line);
}

.button--ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.button--small {
  min-height: 40px;
  padding: 9px 14px;
  font-size: 0.78rem;
}

.button--wide {
  min-width: min(100%, 290px);
}

.text-input {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.text-input:hover,
.text-input:focus {
  border-color: var(--accent);
}

.text-input::placeholder {
  color: var(--subtle);
}

.text-input--code {
  min-width: 0;
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
}

.form-message {
  min-height: 1.4em;
  margin: 8px 0 10px;
  color: var(--danger);
  font-size: 0.83rem;
  line-height: 1.4;
}

.noscript {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--muted);
}

.landing,
.complete {
  display: grid;
  place-items: center;
  padding: 28px 20px 64px;
}

.landing__content,
.complete__content {
  width: min(100%, 720px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.landing .brand,
.complete .brand {
  margin-bottom: 32px;
}

.radar {
  position: relative;
  width: 116px;
  height: 116px;
  margin-bottom: 24px;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%;
}

.radar__ring,
.radar__core,
.radar__needle {
  position: absolute;
  inset: 50%;
  display: block;
  transform: translate(-50%, -50%);
}

.radar__ring {
  width: 88px;
  height: 88px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 28px color-mix(in srgb, var(--accent) 24%, transparent);
}

.radar__core {
  width: 13px;
  height: 13px;
  background: var(--accent);
  border-radius: 50%;
}

.radar__needle {
  width: 2px;
  height: 38px;
  margin-top: -19px;
  background: linear-gradient(var(--accent), transparent);
  transform-origin: 50% 100%;
  animation: radar 4s linear infinite;
}

.landing .eyebrow {
  margin: 0 0 18px;
}

.landing__intro {
  max-width: 610px;
  margin: 24px 0 30px;
  color: #c9c2b7;
  font-size: clamp(1rem, 2.5vw, 1.12rem);
  line-height: 1.65;
}

.team-form {
  width: min(100%, 360px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin-top: 16px;
}

.team-form .field-label {
  margin-bottom: 12px;
}

.team-form .button {
  align-self: center;
}

.landing__meta {
  margin: 18px 0 0;
  color: var(--subtle);
  font-size: 0.82rem;
}

.ai-note {
  max-width: 480px;
  margin: 30px 0 0;
  color: #716b62;
  font-size: 0.72rem;
  font-style: italic;
  line-height: 1.5;
}

.game,
.reveal {
  padding: 24px 20px 60px;
}

.game-header {
  width: min(100%, 880px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 32px;
}

.game__content,
.reveal__content {
  width: min(100%, 780px);
  margin: 0 auto;
  text-align: center;
}

.progress {
  display: grid;
  grid-template-columns: repeat(var(--scenario-count, 10), 1fr);
  gap: 7px;
  padding: 0;
  margin: 0 0 34px;
  list-style: none;
}

.progress__step {
  height: 6px;
  background: #353129;
  border-radius: 999px;
}

.progress__step--complete {
  background: color-mix(in srgb, var(--accent) 65%, #353129);
}

.progress__step--current {
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 35%, transparent);
}

.game__content > .eyebrow,
.reveal__content > .eyebrow {
  margin: 0 0 10px;
}

.scenario-title {
  margin: 0 auto 24px;
  font-size: clamp(1.65rem, 4vw, 2.55rem);
  line-height: 1.18;
}

.video-frame {
  width: 100%;
  overflow: hidden;
  margin-bottom: 26px;
  background: #050505;
  border: 1px solid #3a362f;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.video-frame video {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: block;
  background: #000;
}

.video-error {
  margin: 0;
  padding: 14px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--bg));
  font-size: 0.85rem;
}

.code-form {
  width: 100%;
}

.code-form > .field-label {
  display: block;
  margin-bottom: 12px;
}

.code-form__controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.code-form__controls--wrong {
  animation: shake 360ms ease;
}

.form-message--code {
  min-height: 1.5rem;
  margin-bottom: 0;
}

.team-chip {
  display: inline-block;
  margin: 18px 0 0;
  color: var(--subtle);
  font-size: 0.76rem;
}

.success-mark,
.complete__mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  color: #102019;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 34px color-mix(in srgb, var(--success) 32%, transparent);
  font-size: 2.1rem;
  font-weight: 900;
}

.lesson-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 30px;
  text-align: left;
}

.lesson-card {
  min-height: 100%;
  padding: clamp(20px, 4vw, 28px);
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.lesson-card--risk {
  border-top: 3px solid var(--danger);
}

.lesson-card--measure {
  border-top: 3px solid var(--success);
}

.lesson-card__label {
  margin: 0 0 12px;
}

.lesson-card--risk .lesson-card__label {
  color: var(--danger);
}

.lesson-card--measure .lesson-card__label {
  color: var(--success);
}

.lesson-card p:last-child {
  margin: 0;
  color: #d1cbc0;
  line-height: 1.65;
}

.reveal__continue {
  margin-top: 28px;
}

.complete__content {
  max-width: 650px;
}

.complete__mark {
  width: 92px;
  height: 92px;
  margin-bottom: 28px;
  font-size: 2.8rem;
}

.complete__message {
  max-width: 590px;
  margin: 24px 0 34px;
  color: #cbc4b9;
  font-size: 1.05rem;
  line-height: 1.7;
}

.offline {
  display: grid;
  place-items: center;
  padding: 28px 20px 64px;
}

.offline__content {
  width: min(100%, 700px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.offline .brand {
  margin-bottom: 46px;
}

.offline .eyebrow {
  margin: 0 0 18px;
}

.offline-signal {
  position: relative;
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  border-radius: 50%;
}

.offline-signal__ring {
  width: 74px;
  height: 74px;
  border: 2px solid var(--muted);
  border-radius: 50%;
  box-shadow: 0 0 28px rgb(170 163 151 / 12%);
}

.offline-signal__bar {
  position: absolute;
  width: 3px;
  height: 88px;
  background: var(--danger);
  border-radius: 999px;
  box-shadow: 0 0 14px rgb(226 120 104 / 28%);
  transform: rotate(45deg);
}

.offline__message {
  max-width: 590px;
  margin: 26px 0 14px;
  color: #cbc4b9;
  font-size: clamp(1rem, 2.5vw, 1.1rem);
  line-height: 1.7;
}

.offline__hint {
  margin: 0 0 28px;
  color: var(--subtle);
  font-size: 0.82rem;
}

.admin-shell {
  min-height: 100vh;
  padding: 24px 20px 60px;
}

.admin-header {
  width: min(100%, 760px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 42px;
}

.admin-card {
  width: min(100%, 560px);
  min-height: 410px;
  padding: clamp(26px, 6vw, 48px);
  margin: 0 auto;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-card .eyebrow {
  margin: 0 0 12px;
}

.admin-title {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  line-height: 1.15;
}

.admin-intro {
  margin: 16px 0 28px;
  color: var(--muted);
  line-height: 1.65;
}

.admin-login {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.admin-login .field-label {
  margin-bottom: 10px;
}

.admin-login .button {
  align-self: flex-start;
}

.site-status {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  margin: 28px 0 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.site-status__dot {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  background: var(--subtle);
  border-radius: 50%;
}

.site-status--open {
  border-color: color-mix(in srgb, var(--success) 60%, var(--line));
}

.site-status--open .site-status__dot {
  background: var(--success);
  box-shadow: 0 0 16px rgb(114 189 153 / 45%);
}

.site-status--closed {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
}

.site-status--closed .site-status__dot {
  background: var(--danger);
  box-shadow: 0 0 16px rgb(226 120 104 / 38%);
}

.site-status__label,
.site-status__meta {
  display: block;
}

.site-status__label {
  font-weight: 750;
}

.site-status__meta {
  min-height: 1.2em;
  margin-top: 3px;
  color: var(--subtle);
  font-size: 0.76rem;
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.button--open {
  color: #102019;
  background: var(--success);
}

.button--open:hover:not(:disabled) {
  background: color-mix(in srgb, var(--success) 85%, white);
}

.button--close {
  color: #27100d;
  background: var(--danger);
}

.button--close:hover:not(:disabled) {
  background: color-mix(in srgb, var(--danger) 85%, white);
}

.admin-feedback {
  min-height: 1.5em;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-feedback--success {
  color: var(--success);
}

.admin-feedback--error {
  color: var(--danger);
}

.admin-note {
  padding-top: 20px;
  margin: 20px 0 18px;
  color: var(--subtle);
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  line-height: 1.55;
}

.admin-loading {
  min-height: 300px;
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--muted);
}

.admin-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

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

@keyframes appear {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

@keyframes radar {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@media (max-width: 660px) {
  .display-title {
    font-size: clamp(2.65rem, 13vw, 3.35rem);
    line-height: 1;
  }

  .brand__label,
  .brand__divider {
    display: none;
  }

  .game-header {
    margin-bottom: 24px;
  }

  .progress {
    gap: 4px;
    margin-bottom: 26px;
  }

  .code-form__controls,
  .lesson-grid,
  .admin-actions {
    grid-template-columns: 1fr;
  }

  .code-form__controls .button {
    width: 100%;
  }

  .admin-header {
    align-items: flex-start;
  }

  .admin-header .brand__label,
  .admin-header .brand__divider {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
