*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:      #000000;
  --surface: #0a0a0a;
  --border:  #1a1a1a;
  --white:   #ffffff;
  --muted:   #adadad;
  --faint:   #111111;
  --accent:  #e8620a;
  --accent2: #c8a96e;
  --green:   #14b861;
  --danger:  #ff4444;
  --daily:   #7c6fff;
  --cp:      30px;
  --radius:  58px;
}
html, body {
  height: 100%; font-family: 'DM Sans', sans-serif;
  background: var(--bg); color: var(--white);
  -webkit-font-smoothing: antialiased; overscroll-behavior: none;
}
body { display: flex; flex-direction: column; min-height: 100dvh; overflow: hidden; }

/* FULL-SCREEN LAYOUT */
.app-card {
  display: flex; flex-direction: column; flex: 1; min-height: 0;
}

/* HEADER */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px var(--cp); flex-shrink: 0;
}
.wordmark {
  font-family: 'DM Mono', monospace; font-size: 15px; font-weight: 500;
  letter-spacing: -0.02em; color: var(--white); text-transform: lowercase;
  text-decoration: none;
}
.header-right { display: flex; align-items: center; gap: 12px; }
.mode-pill {
  display: none; font-family: 'DM Mono', monospace; font-size: 9px;
  letter-spacing: 0.14em; text-transform: uppercase;
  border: 1px solid; padding: 4px 10px; border-radius: var(--radius);
}
.mode-pill.hard   { color: var(--accent); border-color: var(--accent); }
.mode-pill.daily  { color: var(--daily);  border-color: var(--daily); }
.mode-pill.visible { display: block; }
.header-meta { font-family: 'DM Mono', monospace; font-size: 10px; color: rgba(255,255,255,0.3); letter-spacing: 0.04em; }

/* MAIN */
main { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 0 var(--cp) var(--cp); overflow-y: auto; }

/* SCREENS */
.screen { display: none; flex-direction: column; align-items: center; width: 100%; max-width: 480px; }
.screen.active { display: flex; animation: fadeIn 0.4s ease both; }
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* INTRO */
.intro-eyebrow {
  font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 1.92px;
  text-transform: uppercase; color: rgba(255,255,255,0.35); margin-top: 40px; margin-bottom: 20px;
}
.intro-title {
  font-family: 'DM Sans', sans-serif; font-size: clamp(72px, 20vw, 92px);
  font-weight: 500; letter-spacing: -0.06em; line-height: 0.9;
  text-align: center; color: var(--white); margin-bottom: 20px;
}
.intro-divider { width: 1px; height: 28px; background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.12), transparent); margin-bottom: 18px; }
.intro-sub {
  font-size: 15px; font-weight: 400; color: var(--muted); text-align: center;
  line-height: 1.65; max-width: 280px; margin-bottom: 40px; letter-spacing: -0.01em;
}
.intro-canvas-wrap { width: 100%; margin-bottom: 36px; }
#c-intro { display: block; width: 100%; height: 72px; }

/* DAILY CARD */
.daily-card {
  width: 100%; border: 1px solid rgba(124,111,255,0.25); padding: 18px 20px;
  margin-bottom: 14px; position: relative; overflow: hidden;
  background: rgba(124,111,255,0.04); border-radius: 14px;
}
.daily-card-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.daily-card-label {
  font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--daily);
}
.daily-card-date {
  font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
}
.daily-card-title {
  font-family: 'DM Sans', sans-serif; font-size: 16px; font-weight: 500;
  color: var(--white); letter-spacing: -0.02em; margin-bottom: 4px;
}
.daily-card-sub {
  font-size: 13px; font-weight: 400; color: rgba(255,255,255,0.4);
}
.daily-card-played {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08);
  font-family: 'DM Mono', monospace; font-size: 11px; color: rgba(255,255,255,0.4);
  letter-spacing: 0.06em; display: none;
}
.daily-card-played.visible { display: flex; justify-content: space-between; align-items: center; }
.daily-score-display { color: var(--daily); font-size: 13px; }

.btn-daily {
  width: 100%; font-family: 'DM Mono', monospace; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase; border: none; cursor: pointer;
  padding: 0; height: 56px; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  background: var(--daily); color: #fff; border-radius: var(--radius);
  transition: transform 0.15s ease, opacity 0.15s; margin-bottom: 12px;
}
.btn-daily:hover { transform: scale(1.02); }
.btn-daily:active { transform: scale(0.97); }
.btn-daily:disabled { opacity: 0.35; cursor: default; transform: none; }

/* BUTTONS */
.btn {
  font-family: 'DM Mono', monospace; font-size: 12px; letter-spacing: 0.08em;
  text-transform: uppercase; border: none; cursor: pointer;
  padding: 0 28px; height: 56px; flex: 1; border-radius: var(--radius);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { transform: scale(1.02); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--white); color: #000; }
.btn-ghost { background: transparent; color: var(--muted); border: 2px solid rgba(255,255,255,0.15); }
.btn-ghost:hover { border-color: rgba(255,255,255,0.3); color: var(--white); }
.btn-row { display: flex; gap: 10px; width: 100%; }

/* GAME TOP */
.game-top { width: 100%; padding-top: 20px; padding-bottom: 12px; display: flex; flex-direction: column; gap: 11px; }
.round-header { display: flex; justify-content: space-between; align-items: center; }
.round-label { font-family: 'DM Mono', monospace; font-size: 10px; color: rgba(255,255,255,0.35); letter-spacing: 1.6px; text-transform: uppercase; }
.dots { display: flex; gap: 8px; align-items: center; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.1); transition: background 0.25s, transform 0.25s; }
.dot.done    { background: rgba(255,255,255,0.35); }
.dot.current { background: var(--white); transform: scale(1.35); }
.dot.current.daily-mode { background: var(--daily); }

/* TIMERS */
.timer-wrap { width: 100%; height: 2px; background: rgba(255,255,255,0.06); overflow: hidden; border-radius: 1px; }
.timer-bar  { height: 100%; background: var(--white); width: 100%; border-radius: 1px; }
.draw-timer-wrap { width: 100%; height: 3px; background: rgba(255,255,255,0.06); overflow: hidden; border-radius: 2px; margin-bottom: 2px; }
.draw-timer-bar { height: 100%; width: 100%; background: var(--white); transition: none; border-radius: 2px; }
.draw-timer-bar.urgent { background: var(--danger); }
.draw-timer-bar.daily-mode { background: var(--daily); }
.draw-timer-bar.daily-mode.urgent { background: var(--danger); }

/* INSTRUCTION */
.instruction {
  font-size: 15px; font-weight: 400;
  color: rgba(255,255,255,0.45); text-align: center; padding: 8px 0 4px;
  height: 28px; overflow: hidden; letter-spacing: -0.01em;
}

/* CANVAS */
.canvas-wrap {
  width: 100%; height: 200px; border: 1px solid rgba(255,255,255,0.08); background: var(--surface);
  position: relative; overflow: hidden; border-radius: 12px;
}
.canvas-wrap.daily-border { border-color: rgba(124,111,255,0.2); }
canvas { display: block; width: 100%; touch-action: none; -webkit-user-select: none; user-select: none; background: transparent; }

.hint {
  font-family: 'DM Mono', monospace; font-size: 10px; color: rgba(255,255,255,0.3);
  letter-spacing: 0.1em; text-align: center; padding: 8px 0 10px;
  text-transform: uppercase; transition: opacity 0.2s;
}

/* LEGEND */
.legend { width: 100%; display: flex; gap: 20px; justify-content: center; padding: 8px 0 0; opacity: 0; transition: opacity 0.3s; }
.legend.visible { opacity: 1; }
.legend-item { display: flex; align-items: center; gap: 7px; font-family: 'DM Mono', monospace; font-size: 10px; color: rgba(255,255,255,0.4); letter-spacing: 0.08em; }
.legend-swatch { width: 18px; height: 2px; border-radius: 1px; }

/* TIMEOUT FLASH */
@keyframes flashRed { 0% { background: rgba(255,68,68,0.15); } 100% { background: var(--surface); } }
.canvas-wrap.timeout { animation: flashRed 0.5s ease-out forwards; }

/* RESULTS */
.score-big {
  font-family: 'DM Sans', sans-serif; font-size: clamp(72px, 20vw, 92px);
  font-weight: 500; letter-spacing: -0.05em; line-height: 1; color: var(--white); margin-top: 32px;
}
.score-big.daily-color { color: var(--daily); }
.score-denom { font-family: 'DM Mono', monospace; font-size: 11px; color: rgba(255,255,255,0.3); letter-spacing: 0.12em; text-transform: uppercase; margin: 8px 0 4px; }
.daily-result-label { font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--daily); margin-bottom: 10px; display: none; }
.daily-result-label.visible { display: block; }
.verdict { font-size: 14px; font-weight: 400; color: rgba(255,255,255,0.45); text-align: center; margin-bottom: 28px; letter-spacing: -0.01em; }

/* LEADERBOARD */
.leaderboard-wrap { width: 100%; margin-bottom: 18px; display: none; }
.leaderboard-wrap.visible { display: block; }
.lb-title {
  font-family: 'DM Mono', monospace; font-size: 9px; letter-spacing: 0.18em;
  text-transform: uppercase; color: rgba(255,255,255,0.3); margin-bottom: 10px;
  padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.lb-row {
  display: flex; align-items: center; gap: 10px;
  font-family: 'DM Mono', monospace; font-size: 12px; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04); letter-spacing: 0.02em;
}
.lb-rank { color: rgba(255,255,255,0.3); width: 18px; text-align: right; font-size: 10px; }
.lb-name { color: var(--white); flex: 1; }
.lb-score { color: var(--daily); }
.lb-you     { color: var(--accent2); }
.lb-loading { font-family: 'DM Mono', monospace; font-size: 11px; color: rgba(255,255,255,0.3); letter-spacing: 0.08em; padding: 10px 0; }
.lb-you .lb-name::after { content: ' (you)'; color: rgba(255,255,255,0.3); font-size: 9px; }
.lb-row:first-child .lb-score,
.lb-row:first-child.lb-you { color: var(--green); }

.breakdown { width: 100%; margin-bottom: 20px; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 16px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.r-section  { width: fit-content; }
.r-round-label { font-family: 'DM Mono', monospace; font-size: 9px; color: rgba(255,255,255,0.3); letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 6px; }
.r-row { display: grid; grid-template-columns: 7ch 9ch 14ch 9ch 12ch 40px; align-items: center; column-gap: 10px; font-family: 'DM Mono', monospace; font-size: 11px; letter-spacing: 0.04em; }
.r-label { color: rgba(255,255,255,0.3); white-space: nowrap; overflow: hidden; }
.r-score { white-space: nowrap; }
.r-score.good { color: var(--green); }
.r-score.ok   { color: var(--accent2); }
.r-score.bad  { color: var(--accent); }
.r-score.miss { color: var(--danger); }
.r-detail-len { color: rgba(255,255,255,0.45); font-size: 9px; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; }
.r-detail-ang { color: rgba(255,255,255,0.45); font-size: 9px; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; padding-left: 6px; border-left: 1px solid rgba(255,255,255,0.12); }
.r-detail-pos { color: rgba(255,255,255,0.45); font-size: 9px; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; padding-left: 6px; border-left: 1px solid rgba(255,255,255,0.12); }
.r-bar-wrap { width: 40px; height: 2px; background: rgba(255,255,255,0.06); border-radius: 1px; overflow: hidden; }
.r-bar      { height: 100%; border-radius: 1px; }

.share-btn {
  width: 100%; font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase; text-align: center;
  border: 2px solid rgba(255,255,255,0.15); padding: 0; cursor: pointer; margin-bottom: 12px;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  height: 56px; display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease, border-color 0.15s, color 0.15s; background: transparent;
  border-radius: var(--radius);
}
.share-btn:hover { transform: scale(1.02); border-color: rgba(255,255,255,0.3); color: var(--white); }
.share-btn:active { transform: scale(0.97); }
.share-btn.copied { border-color: var(--green); color: var(--green); }
.share-btn.daily-share { border-color: rgba(124,111,255,0.3); color: var(--daily); }
.share-btn.daily-share:hover { border-color: var(--daily); }

/* NAME INPUT */
.name-input {
  width: 100%; height: 56px; background: var(--faint); border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius); color: var(--white); font-family: 'DM Mono', monospace;
  font-size: 14px; letter-spacing: 0.04em; padding: 0 24px; outline: none;
  transition: border-color 0.15s;
}
.name-input::placeholder { color: rgba(255,255,255,0.25); }
.name-input:focus { border-color: rgba(255,255,255,0.35); }

footer {
  text-align: center; padding: 16px; font-family: 'DM Mono', monospace;
  font-size: 10px; color: rgba(255,255,255,0.2); letter-spacing: 0.08em;
  flex-shrink: 0; text-transform: uppercase;
}
