@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=Orbitron:wght@600;700;800&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-1: #0f1723;
  --bg-2: #13212f;
  --bg-3: #1b3040;
  --card: rgba(10, 18, 29, 0.82);
  --card-strong: rgba(7, 14, 23, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --line-soft: rgba(255, 255, 255, 0.08);
  --text: #eff8ff;
  --muted: #a6b9c7;
  --accent: #f4b860;
  --accent-2: #6de0d0;
  --good: #56d084;
  --bad: #ff7f87;
  --warn: #ffd57a;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  color: var(--text);
  font-family: 'Chakra Petch', 'Trebuchet MS', sans-serif;
  background:
    radial-gradient(circle at 20% -10%, rgba(244, 184, 96, 0.23), transparent 40%),
    radial-gradient(circle at 80% 0%, rgba(109, 224, 208, 0.18), transparent 44%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 26px 26px;
  opacity: 0.35;
}

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

h1 {
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.03em;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  margin-bottom: 10px;
}

h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.3rem;
  letter-spacing: 0.03em;
}

h3 {
  font-size: 1.04rem;
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}

.center-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 20px 45px rgba(3, 7, 14, 0.45);
  backdrop-filter: blur(7px);
}

.vault-card {
  max-width: 560px;
}

.login-card {
  width: 100%;
}

.vault-header {
  background: linear-gradient(120deg, rgba(11, 20, 34, 0.95), rgba(12, 29, 46, 0.9));
  border: 1px solid var(--line);
}

.header {
  border-radius: 24px;
  padding: 24px;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.header p,
.header .muted {
  color: #cce0ee;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: var(--accent-2);
  margin-bottom: 8px;
  font-size: 0.86rem;
}

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

.grid {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: 310px 1fr;
}

.grid-teacher {
  grid-template-columns: 360px 1fr;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.stat {
  min-width: 130px;
  text-align: center;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 12px;
}

.stat strong {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  line-height: 1;
  margin-bottom: 4px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  color: var(--text);
  font: inherit;
  background: rgba(7, 18, 31, 0.7);
}

input::placeholder {
  color: #9eb1c0;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  color: #14100b;
  background: linear-gradient(120deg, #f4b860, #f3d57a);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn.secondary {
  color: #d7ebf7;
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--line);
}

.btn.danger {
  color: #ffe5e5;
  background: rgba(185, 45, 56, 0.5);
  border-color: rgba(255, 165, 165, 0.4);
}

.btn.ghost {
  color: #cde0ec;
  background: transparent;
  border-color: var(--line);
}

.full {
  width: 100%;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.space-between {
  justify-content: space-between;
}

.small {
  font-size: 0.88rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(109, 224, 208, 0.18);
  border: 1px solid rgba(109, 224, 208, 0.45);
  color: #d5fff8;
  font-size: 0.86rem;
  font-weight: 700;
}

.notice {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}

.notice.warn {
  color: #fff2d0;
  background: rgba(117, 88, 19, 0.45);
  border-color: rgba(255, 213, 122, 0.45);
}

.notice.error {
  color: #ffe3e7;
  background: rgba(111, 19, 35, 0.56);
  border-color: rgba(255, 127, 135, 0.6);
}

.notice.success {
  color: #d8ffe5;
  background: rgba(21, 104, 57, 0.52);
  border-color: rgba(86, 208, 132, 0.6);
}

.feedback-banner {
  animation: reveal-banner 0.35s ease;
}

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

pre {
  overflow-x: auto;
  background: var(--card-strong);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  padding: 16px;
  color: #d4eef8;
  font-family: 'JetBrains Mono', Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.48;
}

.challenge-list {
  display: grid;
  gap: 10px;
}

.challenge-btn {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.challenge-btn.active {
  border-color: rgba(244, 184, 96, 0.8);
  background: rgba(244, 184, 96, 0.2);
}

.challenge-btn.done {
  border-color: rgba(86, 208, 132, 0.7);
}

.progress-panel,
.curriculum-panel {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.meter {
  margin-top: 8px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.meter > div {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f4b860, #6de0d0);
  transition: width 0.28s ease;
}

.curriculum-list {
  max-height: 220px;
  overflow: auto;
  padding-right: 4px;
}

.topic-item {
  font-size: 0.9rem;
  padding: 8px;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
}

.question {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.options {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.option.selected {
  border-color: rgba(109, 224, 208, 0.74);
  background: rgba(109, 224, 208, 0.17);
}

.option:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.feedback {
  font-weight: 700;
}

.feedback.ok {
  color: var(--good);
}

.feedback.bad {
  color: var(--bad);
}

.hint-panel {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: none;
  margin-bottom: 16px;
}

.minigame-panel {
  margin-bottom: 16px;
  border-color: rgba(244, 184, 96, 0.35);
}

.mini-block {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
}

.mini-block h4 {
  margin: 0 0 6px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.96rem;
  letter-spacing: 0.03em;
}

.wire-target {
  margin-top: 8px;
  margin-bottom: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.05);
  display: inline-block;
}

.wire-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.wire-btn,
.relay-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  font: inherit;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.wire-btn.on {
  border-color: rgba(86, 208, 132, 0.65);
  background: rgba(86, 208, 132, 0.2);
}

.wire-btn.off {
  border-color: rgba(255, 127, 135, 0.45);
  background: rgba(255, 127, 135, 0.16);
}

.relay-pad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.relay-btn {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
}

.wire-btn:disabled,
.relay-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mini-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(3, 9, 16, 0.7);
  display: grid;
  place-items: center;
  padding: 16px;
}

.mini-modal-card {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(244, 184, 96, 0.45);
  background: rgba(8, 15, 25, 0.96);
  padding: 16px;
  box-shadow: 0 25px 55px rgba(0, 0, 0, 0.45);
}

.feedback-card textarea,
.feedback-card input {
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  font: inherit;
  background: rgba(7, 18, 31, 0.7);
}

.feedback-card textarea {
  resize: vertical;
  min-height: 84px;
}

.slide-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.slide-tile {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 68px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-family: 'Orbitron', sans-serif;
  font-size: 1.2rem;
  cursor: pointer;
}

.slide-tile.empty {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.02);
  cursor: default;
}

.terminal-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.terminal-cmd {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: #d6ffe8;
  background: rgba(86, 208, 132, 0.1);
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
}

.terminal-cmd:disabled,
.slide-tile:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px;
  margin-top: 8px;
  color: #d9eaf5;
}

.score-row {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.rank {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: 'Orbitron', sans-serif;
  background: rgba(244, 184, 96, 0.26);
  border: 1px solid rgba(244, 184, 96, 0.65);
  color: #ffe6be;
}

.big-score {
  font-family: 'Orbitron', sans-serif;
  font-size: 2rem;
  text-align: right;
}

.final-word {
  text-align: center;
  margin: 18px 0;
  font-family: 'Orbitron', sans-serif;
  font-weight: 800;
  letter-spacing: 0.15em;
  font-size: clamp(2.4rem, 9vw, 6.5rem);
  color: #ffda9f;
  text-shadow: 0 0 20px rgba(255, 212, 132, 0.42);
}

.event-feed {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

/* ═══════════════════════════════════════════════════════════
   BUNKER ESCAPE MAP - CANVAS RENDERED
   ═══════════════════════════════════════════════════════════ */

.challenge-map {
  position: relative;
  display: grid;
  place-items: center;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #14181c;
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.5),
    0 12px 32px rgba(0, 0, 0, 0.4);
  padding: 14px;
  overflow: auto;
  min-height: 340px;
  max-height: 600px;
}

.map-empty {
  color: var(--muted);
  font-style: italic;
  padding: 30px;
}

.bunker-canvas {
  display: block;
  image-rendering: auto;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.map-legend {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
}

.legend-empty {
  color: var(--muted);
  font-size: 0.86rem;
  font-style: italic;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 600;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--team-color);
  box-shadow:
    0 0 8px color-mix(in srgb, var(--team-color) 55%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.35);
}

.legend-name {
  color: #e7eef5;
}

.challenge-map::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.challenge-map::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
}

.challenge-map::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
}

.challenge-map::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.event-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  align-items: center;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
}

.event-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  color: #b0c3d1;
}

.event-row.answer-correct,
.event-row.team-escaped {
  border-color: rgba(86, 208, 132, 0.6);
}

.event-row.answer-wrong {
  border-color: rgba(255, 127, 135, 0.6);
}

.hidden {
  display: none !important;
}

body.flash-correct {
  animation: flash-good 0.45s ease;
}

body.flash-wrong {
  animation: flash-bad 0.45s ease;
}

body.pulse-good {
  animation: flash-good 0.45s ease;
}

body.pulse-bad {
  animation: flash-bad 0.45s ease;
}

@keyframes flash-good {
  0% { box-shadow: inset 0 0 0 0 rgba(86, 208, 132, 0); }
  30% { box-shadow: inset 0 0 0 100vmax rgba(86, 208, 132, 0.13); }
  100% { box-shadow: inset 0 0 0 0 rgba(86, 208, 132, 0); }
}

@keyframes flash-bad {
  0% { box-shadow: inset 0 0 0 0 rgba(255, 127, 135, 0); }
  30% { box-shadow: inset 0 0 0 100vmax rgba(255, 127, 135, 0.12); }
  100% { box-shadow: inset 0 0 0 0 rgba(255, 127, 135, 0); }
}

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

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .container {
    padding: 16px;
  }
}
