/* Modern Academic Arcade Theme */
:root {
  --bg-dark: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.92);
  --panel-border: #334155;
  --accent-gold: #f59e0b;
  --accent-teal: #14b8a6;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 1280px;
  max-height: 800px;
  background: #090d16;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.8);
  border-radius: 12px;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

/* Enable pointer events on interactive UI elements */
.screen, #hud, .modal-content {
  pointer-events: auto;
}

/* HUD Styling */
#hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 20px;
  z-index: 20;
}

.hud-item {
  font-size: 0.95rem;
  font-weight: 600;
}

.hud-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  margin-right: 4px;
}

#hud-score {
  color: var(--accent-gold);
  font-size: 1.2rem;
}

#hud-combo {
  color: var(--accent-teal);
  font-size: 1.1rem;
}

.icon-btn {
  background: none;
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* Screens */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* Hero & General Cards */
.hero-box, .case-card, .matrix-card {
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 30px;
  max-width: 820px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  animation: fadeIn 0.3s ease-out;
}

.hero-box {
  text-align: center;
}

.badge {
  display: inline-block;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.4);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

h1 {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, #f59e0b, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.subtitle {
  color: var(--accent-teal);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.description {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Mode Selection Buttons */
.mode-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.mode-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-btn:hover {
  border-color: var(--accent-teal);
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(20, 184, 166, 0.25);
  background: rgba(30, 41, 59, 0.9);
}

.mode-icon {
  font-size: 1.8rem;
}

.mode-title {
  color: var(--text-main);
  font-weight: 700;
  font-size: 1rem;
}

.mode-desc {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.instructions-footer {
  font-size: 0.85rem;
  color: var(--accent-gold);
  border-top: 1px solid var(--panel-border);
  padding-top: 14px;
}

/* Case Challenge Cards */
.case-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.tag {
  background: var(--accent-purple);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-transform: uppercase;
}

.case-number {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

#case-title {
  font-size: 1.35rem;
  margin-bottom: 12px;
  color: #ffffff;
}

.case-context-box {
  background: rgba(15, 23, 42, 0.6);
  border-left: 4px solid var(--accent-blue);
  padding: 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.question-prompt {
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 16px;
  font-size: 1rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.opt-btn {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: 8px;
  text-align: left;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.opt-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent-blue);
  padding-left: 20px;
}

.opt-btn .opt-badge {
  background: rgba(255,255,255,0.1);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Modals */
.modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 20px;
}

.modal-content {
  background: #1e293b;
  border: 2px solid var(--accent-teal);
  border-radius: 16px;
  padding: 24px;
  max-width: 580px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0,0,0,0.7);
  animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-header {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.modal-header.correct { color: var(--accent-green); }
.modal-header.wrong { color: var(--accent-red); }

#modal-explanation {
  font-size: 0.95rem;
  line-height: 1.5;
  color: #e2e8f0;
  margin-bottom: 14px;
}

.pedagogical-tip {
  background: rgba(245, 158, 11, 0.12);
  border: 1px dashed var(--accent-gold);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #fef08a;
  margin-bottom: 18px;
  line-height: 1.4;
}

/* Buttons */
.primary-btn {
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-blue));
  border: none;
  color: white;
  font-weight: 700;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: transform 0.15s, box-shadow 0.15s;
  display: inline-block;
  width: 100%;
  text-align: center;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(20, 184, 166, 0.4);
}

.primary-btn.large {
  font-size: 1.15rem;
  padding: 16px 32px;
}

.secondary-btn {
  background: rgba(51, 65, 85, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.secondary-btn:hover {
  background: rgba(71, 85, 105, 1);
}

/* Matrix Matching Screen */
.matrix-instructions {
  color: var(--text-muted);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.categories-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.target-zone {
  background: rgba(15, 23, 42, 0.7);
  border: 2px dashed var(--panel-border);
  border-radius: 10px;
  padding: 12px;
  min-height: 130px;
  transition: border-color 0.2s;
}

.target-zone.active-zone {
  border-color: var(--accent-gold);
}

.target-title {
  font-weight: 700;
  color: var(--accent-teal);
  font-size: 0.9rem;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.items-pool-box {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 12px;
}

.pool-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.pool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.draggable-item {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--accent-blue);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.draggable-item:hover {
  background: var(--accent-blue);
  transform: scale(1.03);
}

.draggable-item.selected {
  border-color: var(--accent-gold);
  background: var(--accent-gold);
  color: #000;
  font-weight: bold;
}

/* Arcade Preview Cards */
.bins-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.bin-card {
  padding: 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}

.b-diag { background: rgba(59, 130, 246, 0.2); border: 1px solid var(--accent-blue); color: #93c5fd; }
.b-form { background: rgba(20, 184, 166, 0.2); border: 1px solid var(--accent-teal); color: #99f6e4; }
.b-sum { background: rgba(245, 158, 11, 0.2); border: 1px solid var(--accent-gold); color: #fde68a; }

/* Summary Screen */
.trophy-icon { font-size: 3.5rem; margin-bottom: 10px; }

.score-breakdown {
  display: flex;
  justify-content: space-around;
  margin: 20px 0;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--accent-gold);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.pedagogical-certificate {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--accent-purple);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  text-align: left;
}

.pedagogical-certificate h3 {
  color: var(--accent-purple);
  font-size: 1rem;
  margin-bottom: 6px;
}

.pedagogical-certificate p {
  font-size: 0.9rem;
  color: #cbd5e1;
  line-height: 1.4;
}

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

.mt-15 { margin-top: 15px; }
.mt-20 { margin-top: 20px; }
.text-center { text-align: center; }

/* Keyframe Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.85); }
  100% { opacity: 1; transform: scale(1); }
}

@media (max-width: 640px) {
  h1 { font-size: 1.8rem; }
  .hero-box, .case-card, .matrix-card { padding: 18px; }
  .bins-preview { grid-template-columns: 1fr; }
  .score-breakdown { flex-direction: column; gap: 12px; }
  .summary-actions { flex-direction: column; }
}