/* Escape Room 3D – Sunlit Tropical Temple Courtyard Design System */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@500;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Space+Grotesk:wght@600;700&display=swap');

:root {
  --bg-sandstone: #F3E6CC;
  --bg-parchment: #FFFDF7;
  --bg-stone-soft: #EFE0C1;
  --bg-jade-deep: #164E48;
  --bg-jade-mid: #1F7A6E;
  --border-stone: #D7C19A;
  --border-terracotta: #E06D32;
  --text-primary: #1F2933;
  --text-secondary: #52606D;
  --accent-terracotta: #E06D32;
  --accent-terracotta-dark: #C2531B;
  --accent-jade: #1F7A6E;
  --accent-emerald: #15803D;
  --accent-gold: #D97706;
  --accent-rose: #DC2626;
  --font-display: 'Space Grotesk', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background-color: var(--bg-sandstone);
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Slim 48px Jade Temple Topbar */
.bunker-topbar {
  height: 48px;
  background: var(--bg-jade-deep);
  border-bottom: 3px solid var(--accent-terracotta);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  color: #FFFDF7;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  color: #FFFDF7;
}

.brand-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 6px;
  background: rgba(224, 109, 50, 0.24);
  color: #FDE68A;
  border: 1px solid #F29D52;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #CBD5E1;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover, .nav-link.active {
  background: rgba(255, 253, 247, 0.14);
  color: #FFFFFF;
}

.nav-link.active {
  background: var(--accent-terracotta);
  color: #FFFFFF;
}

/* Tactile Stone Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-primary {
  background: var(--accent-terracotta);
  color: #FFFFFF;
  border-color: var(--accent-terracotta-dark);
}

.btn-primary:hover:not(:disabled) {
  background: #EC7B40;
}

.btn-emerald {
  background: var(--bg-jade-mid);
  color: #FFFFFF;
  border-color: var(--bg-jade-deep);
}

.btn-emerald:hover:not(:disabled) {
  background: #269183;
}

.btn-amber {
  background: #EAB308;
  color: #1F2933;
  border-color: #CA8A04;
}

.btn-danger {
  background: var(--accent-rose);
  color: #FFFFFF;
  border-color: #B91C1C;
}

.btn-secondary {
  background: var(--bg-stone-soft);
  color: var(--text-primary);
  border-color: var(--border-stone);
}

.btn-secondary:hover:not(:disabled) {
  background: #E5D1AA;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.input-field, .select-field, .textarea-field {
  width: 100%;
  background: #FFFFFF;
  border: 2px solid var(--border-stone);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s;
}

.input-field:focus, .select-field:focus, .textarea-field:focus {
  border-color: var(--bg-jade-mid);
}

.mono {
  font-family: var(--font-mono);
}

/* Landing Gateway */
.gateway-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 64px;
}

.gateway-hero {
  background: var(--bg-parchment);
  border: 2px solid var(--border-stone);
  border-top: 6px solid var(--accent-terracotta);
  border-radius: var(--radius-lg);
  padding: 34px 38px;
  margin-bottom: 26px;
  box-shadow: 0 10px 25px rgba(107, 79, 43, 0.08);
}

.sector-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--bg-jade-deep);
  background: #DDF3EE;
  border: 1px solid #88C9BE;
  padding: 4px 12px;
  border-radius: 7px;
  margin-bottom: 12px;
}

.gateway-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 3.2vw, 2.65rem);
  line-height: 1.18;
  margin-bottom: 12px;
  color: #16302B;
}

.gateway-hero p {
  color: var(--text-secondary);
  font-size: 1.02rem;
  max-width: 820px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

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

.role-card {
  background: var(--bg-parchment);
  border: 2px solid var(--border-stone);
  border-radius: var(--radius-lg);
  padding: 26px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 8px 20px rgba(107, 79, 43, 0.06);
  transition: border-color 0.18s, transform 0.18s;
}

.role-card:hover {
  border-color: var(--accent-terracotta);
  transform: translateY(-2px);
}

.role-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: #FDECE2;
  border: 2px solid #F4B998;
  color: var(--accent-terracotta);
}

.role-card h2 {
  font-family: var(--font-display);
  font-size: 1.28rem;
  margin-bottom: 8px;
  color: #16302B;
}

.role-card p {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.role-meta {
  list-style: none;
  margin-bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.role-meta li::before {
  content: "▸ ";
  color: var(--bg-jade-mid);
  font-weight: 800;
}

/* Display Split-Stage Layout (0% Overlap) */
body.display-page {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.display-page.is-fullscreen .bunker-topbar {
  display: none !important;
}

.display-split {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.stage-viewport {
  position: relative;
  flex: 1 1 58%;
  min-height: 240px;
  background: #A9D8F0;
  overflow: hidden;
}

#arena-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Corner HUD for 2 Teams (Temple Stone Cards) */
.hud-corner {
  position: absolute;
  top: 12px;
  z-index: 12;
  background: rgba(255, 253, 247, 0.92);
  border: 2px solid var(--accent-terracotta);
  border-radius: 12px;
  padding: 8px 14px;
  min-width: 190px;
  box-shadow: 0 4px 14px rgba(22, 78, 72, 0.16);
}

.hud-corner.left {
  left: 14px;
}

.hud-corner.right {
  right: 14px;
  text-align: right;
}

.hud-team-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  color: #16302B;
}

.hud-corner.right .hud-team-title {
  justify-content: flex-end;
}

.team-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  border: 1.5px solid rgba(0, 0, 0, 0.25);
}

.hud-team-pct {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 800;
  margin-top: 2px;
  color: var(--bg-jade-deep);
}

/* Compact Multi-Team HUD Ribbon (3-6 Teams, Zero Clipping, No Bars) */
#hud-multi-teams {
  position: absolute;
  top: 10px;
  left: 14px;
  right: 14px;
  z-index: 12;
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  pointer-events: none;
}

.multi-pill {
  background: rgba(255, 253, 247, 0.94);
  border: 2px solid var(--bg-jade-mid);
  border-radius: 999px;
  padding: 5px 13px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #16302B;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
}

.multi-pill-score {
  font-family: var(--font-mono);
  color: var(--accent-terracotta-dark);
}

/* Stage Toolbar Overlay */
.stage-controls {
  position: absolute;
  bottom: 10px;
  right: 14px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-status-pill {
  position: absolute;
  bottom: 10px;
  left: 14px;
  z-index: 15;
  background: rgba(22, 78, 72, 0.92);
  border: 1.5px solid #F29D52;
  border-radius: 8px;
  padding: 5px 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: #FFFDF7;
}

.pulse-audio {
  animation: pulseGlow 1.3s infinite;
  border-color: var(--accent-terracotta) !important;
  background: #FFFBEB !important;
  color: #B45309 !important;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 109, 50, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(224, 109, 50, 0); }
}

/* Question Panel Below 3D Stage */
#q-panel {
  flex: 0 0 auto;
  max-height: 44vh;
  background: var(--bg-parchment);
  border-top: 4px solid var(--bg-jade-mid);
  padding: 14px 22px 16px;
  overflow-y: auto;
  transition: filter 0.25s;
}

#q-panel.blurred {
  filter: blur(7px);
  pointer-events: none;
  user-select: none;
}

.q-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.q-meta-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-topic {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 6px;
  background: #DDF3EE;
  color: var(--bg-jade-deep);
  border: 1px solid #88C9BE;
}

.badge-timer {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  background: #FDECE2;
  border: 1.5px solid var(--accent-terracotta);
  color: var(--accent-terracotta-dark);
}

.q-prompt-text {
  font-size: clamp(1rem, 1.5vw, 1.22rem);
  font-weight: 700;
  color: #16302B;
  margin-bottom: 10px;
  white-space: pre-line;
}

.q-options-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (max-width: 760px) {
  .q-options-grid {
    grid-template-columns: 1fr;
  }
}

.q-opt-box {
  background: var(--bg-stone-soft);
  border: 1.5px solid var(--border-stone);
  border-radius: 9px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: #1F2933;
}

.q-opt-box.is-correct {
  background: #DCFCE7;
  border-color: #16A34A;
  color: #14532D;
}

.opt-letter {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.82rem;
  background: var(--bg-jade-deep);
  color: #FFFFFF;
  flex-shrink: 0;
}

/* Quick Play Compact Row */
.qp-teams-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.qp-team-row {
  background: var(--bg-stone-soft);
  border: 1.5px solid var(--border-stone);
  border-radius: 9px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.qp-key-btn {
  min-width: 34px;
  height: 32px;
  border-radius: 6px;
  border: 1.5px solid var(--border-stone);
  background: #FFFFFF;
  color: #1F2933;
  font-family: var(--font-mono);
  font-weight: 800;
  cursor: pointer;
}

.qp-key-btn.picked-right {
  background: #16A34A;
  color: #FFFFFF;
  border-color: #15803D;
}

.qp-key-btn.picked-wrong {
  background: #DC2626;
  color: #FFFFFF;
  border-color: #B91C1C;
}

/* Countdown & Winner Overlays */
.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(22, 48, 43, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.stage-overlay.active {
  display: flex;
}

.countdown-num {
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 9vw, 6.5rem);
  font-weight: 800;
  color: #FDE68A;
  letter-spacing: 0.04em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

.winner-card {
  background: rgba(255, 253, 247, 0.96);
  border: 3px solid var(--accent-terracotta);
  border-radius: 16px;
  padding: 22px 26px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

.standing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-stone-soft);
  border: 1px solid var(--border-stone);
  margin-top: 6px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Student Mobile-First Page (/play) */
.play-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.bunker-card {
  background: var(--bg-parchment);
  border: 2px solid var(--border-stone);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 6px 18px rgba(107, 79, 43, 0.06);
}

.team-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.team-select-btn {
  padding: 12px;
  border-radius: 10px;
  border: 2px solid var(--border-stone);
  background: var(--bg-stone-soft);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.team-select-btn.selected {
  background: #FFFBEB;
}

.play-option-btn {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 10px;
  border: 2px solid var(--border-stone);
  background: var(--bg-stone-soft);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}

.play-option-btn.selected {
  border-color: var(--accent-terracotta);
  background: #FDECE2;
}

.alert-banner {
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 10px;
}

.alert-success {
  background: #DCFCE7;
  border: 1.5px solid #16A34A;
  color: #14532D;
}

.alert-partial {
  background: #FEF3C7;
  border: 1.5px solid #D97706;
  color: #78350F;
}

.alert-danger {
  background: #FEE2E2;
  border: 1.5px solid #DC2626;
  color: #7F1D1D;
}

/* Admin Full-Width Dashboard (/admin) */
.admin-content {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 24px 48px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border-stone);
  padding-bottom: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-tab-btn {
  padding: 9px 16px;
  border-radius: 9px;
  background: var(--bg-parchment);
  border: 2px solid var(--border-stone);
  color: var(--text-secondary);
  font-weight: 700;
  cursor: pointer;
}

.admin-tab-btn.active {
  background: var(--bg-jade-deep);
  color: #FFFFFF;
  border-color: var(--bg-jade-deep);
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .admin-grid-2 {
    grid-template-columns: 1fr;
  }
}

.progress-track {
  width: 100%;
  height: 12px;
  background: #E2D2B5;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-stone);
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.35s ease;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th, .data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-stone);
  text-align: left;
}

.data-table th {
  background: var(--bg-jade-deep);
  color: #FFFFFF;
  font-weight: 700;
}

.opt-badge-a { background: #1D4ED8; color: #FFFFFF; }
.opt-badge-b { background: #B91C1C; color: #FFFFFF; }
.opt-badge-c { background: #047857; color: #FFFFFF; }
.opt-badge-d { background: #B45309; color: #FFFFFF; }

@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }
  .bunker-topbar, .admin-tabs, .no-print {
    display: none !important;
  }
  .bunker-card {
    background: #FFFFFF !important;
    border: 1px solid #CBD5E1 !important;
    color: #000000 !important;
    box-shadow: none !important;
  }
  .data-table th {
    background: #164E48 !important;
    color: #FFFFFF !important;
  }
}
