:root {
  --bg: #07111d;
  --bg-elevated: rgba(10, 19, 31, 0.84);
  --panel: rgba(9, 21, 35, 0.82);
  --panel-strong: rgba(8, 17, 28, 0.95);
  --line: rgba(123, 241, 216, 0.22);
  --line-strong: rgba(123, 241, 216, 0.45);
  --text: #e8f5ff;
  --muted: #9bb8c9;
  --accent: #70f5cb;
  --accent-2: #5ad2ff;
  --warning: #ff9d5c;
  --danger: #ff6678;
  --success: #92ff79;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
  --radius: 28px;
  --radius-sm: 18px;
  --touch: 58px;
  --font-display: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono: "SFMono-Regular", "Menlo", "Monaco", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
}

body {
  position: relative;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.backdrop,
.backdrop__orbs,
.backdrop__grid,
.backdrop__noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.backdrop {
  background:
    radial-gradient(circle at 15% 20%, rgba(90, 210, 255, 0.18), transparent 35%),
    radial-gradient(circle at 85% 15%, rgba(112, 245, 203, 0.16), transparent 32%),
    radial-gradient(circle at 40% 100%, rgba(255, 157, 92, 0.1), transparent 35%),
    linear-gradient(180deg, #08111c 0%, #091525 55%, #08121b 100%);
}

.backdrop__orbs {
  background:
    radial-gradient(circle at 20% 30%, rgba(112, 245, 203, 0.18), transparent 18%),
    radial-gradient(circle at 78% 42%, rgba(90, 210, 255, 0.12), transparent 22%),
    radial-gradient(circle at 60% 80%, rgba(255, 102, 120, 0.1), transparent 18%);
  filter: blur(20px);
}

.backdrop__grid {
  background-image:
    linear-gradient(rgba(123, 241, 216, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(123, 241, 216, 0.06) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent 90%);
}

.backdrop__noise {
  opacity: 0.06;
  background-image:
    linear-gradient(transparent 0 48%, rgba(255, 255, 255, 0.6) 49% 50%, transparent 51% 100%);
  background-size: 100% 6px;
  mix-blend-mode: screen;
}

.app-shell {
  position: relative;
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: clamp(18px, 3vw, 28px);
  display: grid;
  gap: 18px;
}

.panel {
  position: relative;
  background: linear-gradient(180deg, rgba(12, 26, 41, 0.88), rgba(8, 18, 30, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(18px, 4vw, 30px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 24%),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.03) 0 2px,
      transparent 2px 8px
    );
  pointer-events: none;
  mix-blend-mode: screen;
}

.hero h1,
.panel h2 {
  margin: 0;
  line-height: 1.05;
}

.hero h1 {
  font-size: clamp(2.4rem, 8vw, 5rem);
  letter-spacing: -0.04em;
}

.eyebrow,
.kicker {
  margin: 0 0 10px;
  color: var(--accent);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.76rem;
  font-weight: 700;
}

.subtitle {
  margin: 10px 0 0;
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: var(--muted);
}

.status-strip {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.status-strip span,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(11, 26, 42, 0.86);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.92rem;
}

.view[hidden] {
  display: none;
}

.panel__intro {
  margin-bottom: 24px;
  max-width: 70ch;
}

.panel__intro p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.panel__intro--compact {
  margin-bottom: 18px;
}

.game-header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
}

.game-header h2 {
  margin-bottom: 8px;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

.badge {
  color: var(--success);
  border-color: rgba(146, 255, 121, 0.35);
  white-space: nowrap;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.95rem;
}

.field input {
  min-height: var(--touch);
  width: 100%;
  padding: 0 18px;
  color: var(--text);
  background: rgba(4, 13, 24, 0.84);
  border: 1px solid var(--line);
  border-radius: 18px;
  outline: none;
  font-size: 1.1rem;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(112, 245, 203, 0.14);
}

.primary-button,
.ghost-button,
.tile-button,
.order-button,
.token-button,
.utility-button {
  min-height: var(--touch);
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.primary-button {
  padding: 0 18px;
  color: #041016;
  font-weight: 800;
  background:
    linear-gradient(135deg, var(--accent) 0%, #b7fff0 52%, var(--accent-2) 100%);
}

.ghost-button,
.utility-button {
  padding: 0 16px;
  color: var(--text);
  background: rgba(9, 22, 34, 0.88);
  border: 1px solid var(--line);
}

.primary-button:active,
.ghost-button:active,
.utility-button:active,
.tile-button:active,
.order-button:active,
.token-button:active {
  transform: scale(0.98);
}

.feedback {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
}

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

.module-progress {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.module-progress__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.module-progress__meta strong {
  color: var(--text);
  font-size: 0.98rem;
}

.module-progress__meta span {
  font-size: 0.88rem;
}

.module-progress__track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(4, 10, 18, 0.94);
  border: 1px solid rgba(123, 241, 216, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.module-progress__fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  box-shadow: 0 0 24px rgba(90, 210, 255, 0.35);
  transition: width 220ms ease, background 220ms ease, box-shadow 220ms ease;
}

.module-progress__track.is-complete {
  border-color: rgba(146, 255, 121, 0.35);
}

.module-progress__fill.is-complete {
  background: linear-gradient(90deg, #54ef85, var(--success));
  box-shadow: 0 0 24px rgba(146, 255, 121, 0.35);
}

.game-stage {
  display: grid;
  gap: 16px;
}

.callout {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(10, 24, 38, 0.82);
  border: 1px solid var(--line);
  color: var(--muted);
}

.callout strong {
  color: var(--text);
}

.tile-grid,
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.tile-button,
.token-button {
  position: relative;
  padding: 16px;
  text-align: left;
  color: var(--text);
  background: rgba(8, 17, 29, 0.94);
  border: 1px solid rgba(123, 241, 216, 0.18);
}

.tile-button strong,
.token-button strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.tile-button span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.tile-button.is-correct {
  border-color: rgba(146, 255, 121, 0.45);
  background: linear-gradient(180deg, rgba(22, 63, 42, 0.88), rgba(13, 30, 23, 0.94));
}

.tile-button.is-wrong,
.order-card.is-shaking,
.token-button.is-wrong {
  animation: shake 420ms ease;
}

.tile-button.is-wrong,
.token-button.is-wrong {
  border-color: rgba(255, 102, 120, 0.65);
}

.sync-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.sync-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.sync-button {
  min-height: 120px;
  padding: 18px 16px;
  text-align: left;
  border-radius: 24px;
  background: rgba(8, 17, 29, 0.94);
  border: 1px solid rgba(123, 241, 216, 0.18);
  color: var(--text);
  transition: transform 140ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.sync-button strong,
.sync-button span {
  display: block;
}

.sync-button strong {
  margin-bottom: 10px;
  font-size: 1.04rem;
}

.sync-button span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.sync-button.is-flashing {
  border-color: rgba(90, 210, 255, 0.55);
  background: linear-gradient(180deg, rgba(16, 59, 82, 0.94), rgba(8, 27, 44, 0.96));
  box-shadow: 0 0 0 1px rgba(90, 210, 255, 0.35), 0 0 28px rgba(90, 210, 255, 0.2);
  transform: translateY(-2px) scale(1.01);
}

.sync-button.is-picked {
  border-color: rgba(146, 255, 121, 0.45);
  background: linear-gradient(180deg, rgba(22, 63, 42, 0.88), rgba(13, 30, 23, 0.94));
}

.sync-button:disabled {
  opacity: 1;
}

.split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.terminal {
  display: grid;
  gap: 12px;
}

.terminal__line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 16px;
  min-height: 78px;
  border-radius: 20px;
  background: rgba(4, 10, 18, 0.95);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
}

.terminal__prompt {
  color: var(--accent);
}

.terminal-slot {
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px dashed rgba(123, 241, 216, 0.28);
  color: var(--muted);
}

.terminal-slot.is-filled {
  color: var(--text);
  border-style: solid;
  border-color: rgba(112, 245, 203, 0.38);
  background: rgba(13, 31, 25, 0.85);
}

.terminal__status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 17, 29, 0.94);
  color: var(--muted);
}

.status-pill strong {
  color: var(--warning);
}

.status-pill.is-safe strong {
  color: var(--success);
}

.token-button.is-used {
  opacity: 0.42;
}

.token-button.is-correct {
  border-color: rgba(146, 255, 121, 0.4);
  background: linear-gradient(180deg, rgba(22, 63, 42, 0.88), rgba(13, 30, 23, 0.94));
}

.victory-view {
  text-align: center;
}

.victory-meter {
  width: min(100%, 620px);
  height: 22px;
  margin: 0 auto 16px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(4, 10, 18, 0.92);
  border: 1px solid var(--line);
}

.victory-meter__bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #b7fff0, var(--accent-2));
  transition: width 260ms ease;
}

.victory-percent {
  margin: 0 0 20px;
  color: var(--accent);
  font-size: clamp(2rem, 6vw, 3.6rem);
  font-weight: 800;
}

.victory-lines {
  display: grid;
  gap: 12px;
  margin: 0 auto 24px;
  width: min(100%, 720px);
}

.victory-line {
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(146, 255, 121, 0.28);
  background: rgba(11, 32, 22, 0.76);
  color: var(--success);
  font-family: var(--font-mono);
  animation: reveal 280ms ease;
}

.boot-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 10, 18, 0.8);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.boot-card {
  width: min(100%, 760px);
}

.boot-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.boot-log {
  min-height: 240px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(4, 10, 18, 0.95);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  display: grid;
  gap: 10px;
}

.boot-line {
  color: var(--accent);
  animation: reveal 220ms ease;
}

.boot-line::before {
  content: "> ";
  color: var(--warning);
}

.kernel-panic {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 102, 120, 0.4);
  background: rgba(58, 13, 24, 0.86);
  color: #ffd1d8;
  animation: reveal 240ms ease;
}

.subtle {
  color: var(--muted);
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 820px) {
  .game-header,
  .boot-card__header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (orientation: landscape) and (min-width: 900px) {
  .app-shell {
    padding-top: 26px;
  }

  .hero {
    display: grid;
    grid-template-columns: 1.3fr auto;
    align-items: end;
    gap: 24px;
  }

  .status-strip {
    justify-content: flex-end;
    margin-top: 0;
  }
}
