:root {
  --bg: #0a0a0a;
  --bg-elevated: #121414;
  --surface: #1a1c1c;
  --surface-high: #232626;
  --border: rgba(255, 255, 255, 0.1);
  --text: #e2e2e2;
  --text-dim: #9a9a9a;
  --purple: #9d00ff;
  --purple-light: #dfb7ff;
  --cyan: #00f2ff;
  --green: #3ddc84;
  --red: #ff5470;
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

/* Icon-formaten — als classes i.p.v. inline style="", zodat de Content-Security-Policy
   geen 'unsafe-inline' voor style-src nodig heeft. */
.icon-14 { font-size: 14px; }
.icon-16 { font-size: 16px; }
.icon-18 { font-size: 18px; }
.icon-20 { font-size: 20px; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow-x: hidden;
}

.glass-panel {
  background-color: rgba(30, 32, 32, 0.85);
  border: 1px solid var(--border);
}

.accent-cyan { color: var(--cyan); }
.accent-purple { color: var(--purple-light); }

/* ---------- Screens ---------- */
.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 24px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-primary {
  background: var(--purple);
  color: #fff;
  box-shadow: 0 0 0 rgba(157, 0, 255, 0);
}
.btn-primary:hover {
  box-shadow: 0 0 20px rgba(157, 0, 255, 0.5);
  transform: translateY(-2px);
}

.btn-outline-cyan {
  background: transparent;
  border: 2px solid var(--cyan);
  color: var(--cyan);
}
.btn-outline-cyan:hover {
  background: rgba(0, 242, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
  transform: translateY(-2px);
}

.btn-real {
  background: transparent;
  border: 2px solid var(--cyan);
  color: var(--cyan);
  flex: 1;
  padding: 20px;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.btn-real:hover:not(:disabled) {
  background: rgba(0, 242, 255, 0.1);
  box-shadow: 0 0 15px rgba(0, 242, 255, 0.4);
  transform: translateY(-2px);
}

.btn-ai {
  background: var(--purple);
  color: #fff;
  flex: 1;
  padding: 20px;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.btn-ai:hover:not(:disabled) {
  box-shadow: 0 0 15px rgba(157, 0, 255, 0.5);
  transform: translateY(-2px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- Start Screen ---------- */
#start-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(157, 0, 255, 0.12), transparent 60%),
    radial-gradient(ellipse at bottom, rgba(0, 242, 255, 0.08), transparent 60%),
    var(--bg);
}

.start-panel {
  width: 100%;
  max-width: 440px;
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.logo-icon {
  color: var(--cyan);
  font-size: 32px;
  filter: drop-shadow(0 0 8px rgba(0, 242, 255, 0.6));
}
.logo h1 {
  font-size: 2rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin: 0 0 28px;
  line-height: 1.5;
}

#start-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
#start-form label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
#start-form input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
}
#start-form input:focus {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 3px rgba(157, 0, 255, 0.15);
}
#start-form .btn {
  margin-top: 8px;
}

.load-error {
  margin-top: 16px;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(255, 84, 112, 0.1);
  border: 1px solid rgba(255, 84, 112, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.start-meta {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ---------- Game Screen ---------- */
.game-header {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 10, 10, 0.95);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 0 20px rgba(157, 0, 255, 0.1);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.stats {
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
}
.stat-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--purple-light);
}
.stat-dim { color: var(--text-dim); font-weight: 500; }
.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
}

.game-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  gap: 24px;
}

.media-container {
  width: 100%;
  max-width: 800px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  background: var(--surface);
}
.media {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-tag {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: rgba(116, 245, 255, 0.7);
  letter-spacing: 0.05em;
}

.feedback-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.75);
  animation: fade-in 0.2s ease;
}
.feedback-overlay[hidden] {
  display: none;
}
.feedback-overlay.correct .feedback-icon { color: var(--green); }
.feedback-overlay.wrong .feedback-icon { color: var(--red); }
.feedback-icon { font-size: 56px; }
.feedback-text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  padding: 0 16px;
}
.feedback-overlay.correct .feedback-text { color: var(--green); }
.feedback-overlay.wrong .feedback-text { color: var(--red); }
.feedback-explanation {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 480px;
  padding: 0 16px;
}
.feedback-explanation[hidden] {
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.speed-bar {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.speed-bar-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.speed-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.speed-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  box-shadow: 0 0 8px rgba(0, 242, 255, 0.5);
}

.action-buttons {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 640px;
}

.game-footer {
  width: 100%;
  padding: 16px 24px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.progress-info {
  max-width: 1200px;
  margin: 0 auto 8px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}
.progress-track {
  max-width: 1200px;
  margin: 0 auto;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 242, 255, 0.6);
  transition: width 0.4s ease;
}

/* ---------- End Screen ---------- */
.end-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  background:
    radial-gradient(ellipse at top, rgba(157, 0, 255, 0.1), transparent 60%),
    var(--bg);
}

.game-over-title {
  font-size: clamp(2rem, 6vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--purple-light);
  text-shadow: 0 0 20px rgba(223, 183, 255, 0.5);
  margin: 0 0 8px;
  text-align: center;
}
.game-over-sub {
  color: var(--text-dim);
  margin: 0 0 40px;
  text-align: center;
}

.end-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 24px;
  width: 100%;
}

.end-left {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.scorecard-wrapper {
  border-radius: var(--radius);
  padding: 2px;
  background: linear-gradient(135deg, rgba(0, 242, 255, 0.4), rgba(157, 0, 255, 0.4));
  box-shadow: 0 0 25px rgba(0, 242, 255, 0.2);
}

.scorecard {
  position: relative;
  border-radius: calc(var(--radius) - 2px);
  background:
    radial-gradient(circle at 30% 20%, rgba(157, 0, 255, 0.18), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(0, 242, 255, 0.12), transparent 55%),
    #0c0f0f;
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: hidden;
}

.scorecard-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 20px;
}

.scorecard h2 {
  font-size: 1.5rem;
  margin: 0 0 16px;
  word-break: break-word;
}

.scorecard-score-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 8px 0 20px;
}
.scorecard-score-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.scorecard-score {
  font-size: clamp(3rem, 10vw, 4rem);
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(180deg, #fff, #b5b5b5);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.15);
}

.scorecard-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  margin: 4px 0 20px;
}

.scorecard-cta {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--purple-light);
  margin: 0;
  font-size: 0.95rem;
}

.scorecard-fingerprint {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-size: 60px;
  opacity: 0.12;
  pointer-events: none;
}

.end-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.end-buttons .btn { flex: 1; min-width: 200px; }

.end-right {
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.leaderboard-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.leaderboard-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}
.leaderboard-list::-webkit-scrollbar { width: 4px; }
.leaderboard-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.leaderboard-item.current {
  background: rgba(157, 0, 255, 0.15);
  border-color: rgba(157, 0, 255, 0.5);
  box-shadow: 0 0 12px rgba(157, 0, 255, 0.2);
}
.leaderboard-rank {
  font-family: var(--font-mono);
  color: var(--text-dim);
  width: 24px;
  text-align: center;
  margin-right: 12px;
}
.leaderboard-item.current .leaderboard-rank { color: var(--purple-light); font-weight: 700; }
.leaderboard-name-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.leaderboard-name {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaderboard-score {
  font-family: var(--font-mono);
  color: var(--cyan);
  font-weight: 600;
}
.leaderboard-empty {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: center;
  padding: 24px 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .end-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .game-header { padding: 16px; }
  .stats { gap: 10px; }
  .action-buttons { flex-direction: column; }
  .end-main { padding: 32px 16px; }
  .scorecard { padding: 32px 20px; }
  .end-buttons .btn { min-width: 100%; }
}
