/* ============================================================
   CODESHOT — Design System
   Theme: Ultra Minimal Monochrome
   Fonts: JetBrains Mono (code) + Inter (UI)
   ============================================================ */

/* ----------------------------------------------------------
   CSS Variables
   ---------------------------------------------------------- */
:root {
  --bg:           #020617; /* Slate 950 - Deepest Midnight */
  --surface:      #0f172a; /* Slate 900 - Card Surface */
  --surface-2:    #1e293b; /* Slate 800 */
  --surface-3:    #334155; /* Slate 700 */
  --border:       #334155;
  --border-2:     #475569; /* Slate 600 */

  --text-primary:   #f8fafc; /* Slate 50 */
  --text-secondary: #cbd5e1; /* Slate 300 */
  --text-muted:     #94a3b8; /* Slate 400 */

  --accent:       #6366f1; /* Indigo 500 */
  --accent-dim:   rgba(99, 102, 241, 0.15);
  --accent-hover: #818cf8; /* Indigo 400 */

  --green:        #10b981; /* Emerald 500 */
  --green-dim:    rgba(16, 185, 129, 0.10);
  --red:          #f43f5e; /* Rose 500 */
  --red-dim:      rgba(244, 63, 94, 0.10);

  --font-mono:  'JetBrains Mono', Consolas, Monaco, monospace;
  --font-ui:    'Inter', system-ui, -apple-system, sans-serif;

  --radius:     6px;
  --radius-lg:  12px;

  --transition: 150ms ease;
}

/* ----------------------------------------------------------
   Reset & Base
   ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; }

body {
  background: radial-gradient(circle at 50% 0%, #1e293b 0%, var(--bg) 80%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-ui);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  width: 100%;
}

body.center-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

a { color: var(--text-primary); text-decoration: underline; text-underline-offset: 4px; transition: var(--transition); }
a:hover { color: var(--text-secondary); }

img, video, canvas { max-width: 100%; height: auto; }

/* ----------------------------------------------------------
   Layout
   ---------------------------------------------------------- */
.app {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------
   Header
   ---------------------------------------------------------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 32px 0;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 40px;
}

.logo {
  display: block;
  font-family: var(--font-ui);
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.header h1 { font-size: 0; line-height: 0; margin: 0; padding: 0; }
.logo span { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.streak-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  cursor: default;
}

.btn-login {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-login:hover { background: var(--surface-2); }

.user-email {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ----------------------------------------------------------
   Question Card & Content
   ---------------------------------------------------------- */
.question-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.meta-date { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.meta-sep { color: var(--border); }
.badge { font-family: var(--font-mono); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--border); color: var(--text-secondary); background: transparent; }

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 20px 40px -20px rgba(0,0,0,0.5);
}

.question-text {
  padding: 24px 28px 0;
  font-size: 16px;
  color: var(--text-primary);
  line-height: 1.6;
}

.code-block {
  margin: 20px 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-bar { display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.2); }
.code-dot { width: 10px; height: 10px; border-radius: 50%; background: #3f3f46; }
.code-dot:nth-child(1) { background: #ef4444; }
.code-dot:nth-child(2) { background: #eab308; }
.code-dot:nth-child(3) { background: #22c55e; }
.code-lang { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-left: auto; }

.code-block pre {
  padding: 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: #e4e4e7;
  background: transparent !important;
}

/* Prism Overrides */
.code-block pre[class*="language-"] { margin: 0; padding: 24px; background: transparent !important; border: none; box-shadow: none; }
.code-block code[class*="language-"] { font-family: var(--font-mono); font-size: 13px; text-shadow: none; }

/* Custom scrollbar for code */
.code-block pre::-webkit-scrollbar { height: 4px; }
.code-block pre::-webkit-scrollbar-track { background: var(--surface-2); }
.code-block pre::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.options { display: flex; flex-direction: column; gap: 12px; padding: 0 28px 28px; }
.option { display: flex; align-items: flex-start; gap: 16px; padding: 16px 20px; background: transparent; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: var(--transition); text-align: left; width: 100%; }
.option:hover:not(:disabled) { border-color: var(--border-2); background: var(--surface-2); }
.option-key { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 4px; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.option-text { font-size: 15px; color: var(--text-secondary); font-family: var(--font-mono); }

.option.correct { border-color: var(--green); background: var(--green-dim); }
.option.correct .option-key { background: var(--green); color: #000; border-color: var(--green); }
.option.wrong { border-color: var(--red); background: var(--red-dim); }
.option.wrong .option-key { background: var(--red); color: #fff; border-color: var(--red); }

/* ----------------------------------------------------------
   Panels & UI
   ---------------------------------------------------------- */
.timer-bar { height: 2px; background: var(--surface-2); overflow: hidden; margin-bottom: 24px; }
.timer-fill { height: 100%; background: var(--text-primary); width: 100%; transition: width 1s linear; }

.result-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 28px; margin-bottom: 20px; display: none; }
.result-panel.show { display: block; animation: slideUp 300ms ease; }
.result-verdict { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; font-family: var(--font-mono); margin-bottom: 12px; }
.result-verdict.correct { color: var(--green); }
.result-explanation { font-size: 15px; color: var(--text-secondary); line-height: 1.7; border-top: 1px solid var(--border); padding-top: 16px; margin-top: 4px; }

.result-stats { display: flex; gap: 32px; margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--border); }
.result-stat { display: flex; flex-direction: column; gap: 4px; }
.result-stat-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); font-family: var(--font-mono); }
.result-stat-value { font-size: 18px; font-weight: 600; font-family: var(--font-mono); }

.streak-display { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px 28px; margin-bottom: 20px; display: none; align-items: center; justify-content: space-between; }
.streak-display.show { display: flex; animation: slideUp 300ms ease 100ms both; }
.streak-number { font-family: var(--font-mono); font-size: 32px; font-weight: 600; }

.share-section { display: none; margin-bottom: 24px; }
.share-section.show { display: block; animation: slideUp 300ms ease 200ms both; }

.share-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 28px; text-align: center; }
.share-card label { display: block; font-size: 11px; text-transform: uppercase; color: var(--text-muted); font-family: var(--font-mono); margin-bottom: 20px; }
.share-preview { background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; font-family: var(--font-mono); font-size: 13px; text-align: left; margin-bottom: 20px; }
.share-actions { display: flex; gap: 12px; justify-content: center; }

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 10px 24px;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  text-decoration: none;
}

.share-btn:hover { background: var(--surface-3); border-color: var(--text-muted); }

.share-btn.share-download {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.share-btn.share-download:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.share-btn svg { width: 14px; height: 14px; }

/* ----------------------------------------------------------
   Leaderboard, Archive, Achievements
   ---------------------------------------------------------- */
.leader-grid { display: flex; flex-direction: column; gap: 12px; margin-top: 24px; }
.leader-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: flex; align-items: center; gap: 20px; transition: var(--transition); }
.leader-row:hover { border-color: var(--accent); background: var(--surface-2); }
.leader-rank { font-family: var(--font-mono); font-size: 14px; color: var(--text-muted); width: 32px; flex-shrink: 0; }
.leader-info { flex: 1; min-width: 0; }
.leader-name { font-family: var(--font-mono); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.leader-score { display: flex; align-items: center; gap: 24px; flex-shrink: 0; }
.score-item { display: flex; flex-direction: column; align-items: flex-end; }
.score-val { font-family: var(--font-mono); font-size: 18px; font-weight: 600; }
.score-lbl { font-size: 10px; text-transform: uppercase; color: var(--text-muted); }
.top-1 { background: linear-gradient(to right, var(--surface), var(--accent-dim)); border-color: var(--accent); }
.top-1 .leader-rank { color: var(--accent); font-weight: 700; }
.my-rank-indicator { background: var(--accent); color: #fff; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-left: 8px; font-weight: 600; }

.stats-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 40px; margin-top: 24px; }
.stat-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; text-align: center; }
.stat-val { display: block; font-family: var(--font-mono); font-size: 24px; font-weight: 700; }
.stat-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); margin-top: 4px; }

.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 20px; }
.badge-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px 16px; text-align: center; opacity: 0.4; filter: grayscale(1); }
.badge-card.unlocked { opacity: 1; filter: grayscale(0); border-color: var(--accent); background: radial-gradient(circle at 50% 0%, var(--accent-dim) 0%, var(--surface) 100%); }

.heatmap-wrap { margin-bottom: 48px; }
.heatmap-title { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.heatmap-grid { display: grid; grid-template-columns: repeat(15, 1fr); gap: 6px; }
.heatmap-day { aspect-ratio: 1; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--border); }
.heatmap-day.played-wrong { background: var(--red-dim); }
.heatmap-day.played-correct { background: var(--green); border-color: var(--green); }

.archive-list { display: flex; flex-direction: column; gap: 16px; margin-top: 32px; }
.archive-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 12px; transition: var(--transition); }
.archive-card:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ----------------------------------------------------------
   Footer & Modals
   ---------------------------------------------------------- */
.footer { margin-top: auto; padding: 48px 0 32px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 20px; }
.footer-top, .footer-bottom { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.footer-nav { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-muted); }
.footer-link { color: var(--text-muted); text-decoration: none; }
.footer-link:hover { color: var(--text-primary); }
.next-shot-timer { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); background: var(--surface-2); padding: 4px 10px; border-radius: 4px; border: 1px solid var(--border); }
.footer-bottom { padding-top: 20px; border-top: 1px solid rgba(255,255,255,0.03); font-size: 12px; color: var(--text-muted); }

.modal-overlay { 
  position: fixed; inset: 0; 
  background: rgba(0,0,0,0.7); 
  backdrop-filter: blur(12px); 
  display: none; 
  align-items: center; 
  justify-content: center; 
  z-index: 1000; 
  animation: fadeIn 300ms ease;
}
.modal-overlay.show { display: flex; }

.modal { 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: var(--radius-lg); 
  padding: 48px 40px; 
  width: 100%; 
  max-width: 420px; 
  position: relative; 
  box-shadow: 0 40px 80px -20px rgba(0,0,0,0.8), 0 0 0 1px var(--border);
  animation: modalEnter 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-title { font-size: 20px; font-weight: 700; color: #fff; margin-bottom: 8px; text-align: center; letter-spacing: -0.5px; }
.modal-sub { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 32px; text-align: center; }

.input-group { display: flex; flex-direction: column; gap: 12px; }
.input-field {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: #fff;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 15px;
  transition: var(--transition);
  width: 100%;
}
.input-field:focus { outline: none; border-color: var(--accent); background: var(--surface-3); box-shadow: 0 0 0 4px var(--accent-dim); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 14px;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-close {
  position: absolute; top: 20px; right: 20px;
  background: transparent; border: none; color: var(--text-muted);
  font-size: 24px; cursor: pointer; transition: var(--transition);
}
.btn-close:hover { color: #fff; }

.form-note { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 20px; font-family: var(--font-mono); }

.alert { margin-bottom: 24px; padding: 12px 16px; border-radius: var(--radius); font-size: 13px; display: none; }
.alert.show { display: block; animation: slideUp 300ms ease; }
.alert-error { background: var(--red-dim); color: var(--red); border: 1px solid rgba(244, 63, 94, 0.2); }
.alert-success { background: var(--green-dim); color: var(--green); border: 1px solid rgba(16, 185, 129, 0.2); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalEnter { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ----------------------------------------------------------
   RESPONSIVE (The Bottom Block)
   ---------------------------------------------------------- */
@media (max-width: 680px) {
  .app { padding: 0 20px; }
  .header { padding: 24px 0; margin-bottom: 32px; }
  
  .question-text { padding: 20px 20px 0; }
  .code-block { margin: 16px 20px; }
  .options { padding: 0 20px 20px; }
  
  .result-panel { padding: 20px; }
  .streak-display { padding: 20px; }
  .share-card { padding: 20px; }
  
  .heatmap-grid { grid-template-columns: repeat(10, 1fr); }
  .stats-summary { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 500px) {
  .header { flex-direction: column; align-items: center; gap: 16px; text-align: center; }
  .header-right { justify-content: center; width: 100%; }
  
  .question-text { padding: 20px 16px 0; font-size: 15px; }
  .code-block { margin: 16px 0; border-radius: 0; border-left: none; border-right: none; }
  .code-block pre { padding: 16px; font-size: 12px; }
  
  .options { padding: 0 16px 20px; }
  .option { padding: 12px 14px; gap: 12px; }
  .option-text { font-size: 14px; }
  
  .result-panel { padding: 20px 16px; }
  .result-stats { gap: 20px; flex-wrap: wrap; }
  .result-stat-value { font-size: 16px; }
  
  .streak-display { flex-direction: column; gap: 12px; text-align: center; }
  .header-right { flex-wrap: wrap; justify-content: center; gap: 12px; width: 100%; }
  .user-email { font-size: 11px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-link { font-size: 12px !important; margin: 0 !important; }
  
  .footer-top, .footer-bottom { flex-direction: column; text-align: center; }
  .footer-nav { justify-content: center; flex-wrap: wrap; }
  
  .stats-summary { grid-template-columns: 1fr; }
  .leader-score { gap: 12px; }
  .score-val { font-size: 15px; }
  .leader-row { gap: 12px; padding: 12px; }

  .question-meta { flex-wrap: wrap; gap: 10px; align-items: center; }
  .meta-sep { display: none; }
  .meta-date { font-size: 10px; width: auto; }
  .badge { font-size: 9px; padding: 2px 6px; }

  .modal { padding: 32px 20px; }
}

/* ----------------------------------------------------------
   Visual Share Card Hidden Template
   ---------------------------------------------------------- */
.vsc {
  width: 600px;
  height: 600px;
  background: #020617;
  border: 1px solid var(--border-2);
  padding: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  font-family: var(--font-ui);
}
.vsc-header { display: flex; justify-content: space-between; align-items: center; }
.vsc-logo { font-size: 32px; font-weight: 700; color: #fff; }
.vsc-logo span { color: var(--accent); }
.vsc-streak-badge { background: var(--surface-3); color: #fff; padding: 8px 18px; border-radius: 30px; font-family: var(--font-mono); font-size: 16px; font-weight: 600; border: 1px solid var(--border); }

.vsc-main { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.vsc-verdict { font-family: var(--font-mono); font-size: 24px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 2px; margin-bottom: 24px; }
.vsc-stats-row { display: flex; gap: 60px; width: 100%; justify-content: center; align-items: flex-end; }
.vsc-stat-entry { display: flex; flex-direction: column; align-items: center; }
.vsc-stat-label { font-size: 14px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; letter-spacing: 2px; font-family: var(--font-mono); }
.vsc-stat-value { font-size: 48px; font-weight: 700; color: #fff; font-family: var(--font-mono); line-height: 1; }
.vsc-stat-entry.highlight { position: relative; }
.vsc-stat-entry.highlight .vsc-stat-value { font-size: 84px; color: var(--accent); letter-spacing: -2px; }

.vsc-challenge { font-family: var(--font-mono); font-size: 18px; color: var(--text-secondary); margin-bottom: 32px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius); width: 80%; margin-left: auto; margin-right: auto; }

.vsc-footer { border-top: 1px solid var(--border); padding-top: 32px; }
.vsc-tagline { font-size: 16px; color: var(--text-muted); margin-bottom: 6px; }
.vsc-url { font-size: 22px; font-weight: 700; color: #fff; letter-spacing: 1px; }

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