/* ════════════════════════════════════════════════════════════
   AIRROLL TRAINER  –  Shared Styles
   ════════════════════════════════════════════════════════════ */

:root {
  --bg:          #0b0b0e;
  --surface:     #14141a;
  --surface-2:   #1c1c25;
  --border:      rgba(255,255,255,0.07);
  --border-2:    rgba(255,255,255,0.12);
  --text:        #e4e4ef;
  --text-muted:  #72728a;
  --text-faint:  #40404f;
  --accent:      #f97316;
  --correct:     #22c55e;
  --correct-bg:  rgba(34,197,94,0.12);
  --correct-bdr: rgba(34,197,94,0.35);
  --wrong:       #ef4444;
  --wrong-bg:    rgba(239,68,68,0.12);
  --wrong-bdr:   rgba(239,68,68,0.35);
  --font-display: 'Cabinet Grotesk', system-ui, sans-serif;
  --font-body:    'Satoshi', system-ui, sans-serif;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;
  --ease:        180ms cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: none; }

body {
  font-family: var(--font-body), sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}
.logo {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--accent);
  white-space: nowrap;
}
.logo span { color: var(--text-muted); font-weight: 500; }
.logo-wrap { display: flex; flex-direction: column; gap: 3px; }
.mode-badge {
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(249,115,22,0.12);
  border: 1px solid rgba(249,115,22,0.25);
  border-radius: var(--radius-full);
  padding: 2px 7px;
  align-self: flex-start;
}

.stats { display: flex; gap: 6px; }
.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  text-align: center;
  min-width: 44px;
}
.stat-val {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}
.stat-val.accent { color: var(--accent); }
.stat-lbl {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── Main (swipe zone) ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 16px 10px;
  gap: 12px;
  overflow: hidden;
  position: relative;
}

/* ── GIF Frame ── */
.gif-frame {
  position: relative;
  width: 100%;
  max-width: min(400px, 68vmin);
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: box-shadow 0.15s ease;
}
.gif-frame.flash-correct { box-shadow: 0 0 0 3px var(--correct), 0 0 32px rgba(34,197,94,0.18); }
.gif-frame.flash-wrong   { box-shadow: 0 0 0 3px var(--wrong),   0 0 32px rgba(239,68,68,0.18); }

#gifVideo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  position: absolute;
  inset: 0;
  z-index: 1;
}
.loading {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 1;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-txt { font-size: 11px; color: var(--text-muted); }

.placeholder {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 1;
  padding: 20px;
  text-align: center;
}
.placeholder-dir  { font-size: clamp(56px,13vmin,96px); line-height: 1; filter: drop-shadow(0 0 20px rgba(249,115,22,0.4)); }
.placeholder-name {
  font-family: var(--font-display);
  font-size: clamp(12px,2.8vmin,15px);
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
}
.placeholder-note { font-size: 11px; color: var(--text-faint); max-width: 22ch; }

.fade-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  border-radius: var(--radius-xl);
  transition: opacity 0.25s ease;
}
.fade-overlay.show { opacity: 1; }

.feedback-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
}
.feedback-bubble {
  font-family: var(--font-display);
  font-size: clamp(20px,5vmin,36px);
  font-weight: 900;
  letter-spacing: -0.02em;
  padding: 10px 22px;
  border-radius: var(--radius-lg);
  opacity: 0;
  transform: scale(0.75) translateY(8px);
  transition: opacity 0.15s ease, transform 0.2s cubic-bezier(0.34,1.56,0.64,1);
  backdrop-filter: blur(8px);
  text-align: center;
}
.feedback-bubble.correct {
  color: var(--correct);
  background: var(--correct-bg);
  border: 2px solid var(--correct-bdr);
}
.feedback-bubble.wrong {
  color: var(--wrong);
  background: var(--wrong-bg);
  border: 2px solid var(--wrong-bdr);
  font-size: clamp(13px,3.2vmin,20px);
}
.feedback-bubble.in { opacity: 1; transform: scale(1) translateY(0); }

/* ── Controls / D-Pad ── */
.controls { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; }
.attempts { display: flex; gap: 6px; align-items: center; }
.dots-label { font-size: 10px; color: var(--text-faint); font-weight: 600; letter-spacing: 0.06em; margin-right: 2px; }
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1.5px solid var(--border-2);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.dot.hit { background: var(--wrong); border-color: var(--wrong); transform: scale(1.2); }

.dpad-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows:    repeat(3, 40px);
  gap: 3px;
}
.dk {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--ease), border-color var(--ease), color var(--ease), box-shadow var(--ease), transform 0.1s ease;
  touch-action: manipulation;
}
.dk.center {
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  background: var(--surface-2);
  cursor: default;
}
.dk:not(.center):hover   { background: rgba(249,115,22,0.08); border-color: rgba(249,115,22,0.3); color: var(--accent); }
.dk.held                 { background: rgba(249,115,22,0.15); border-color: var(--accent); color: var(--accent); }
.dk.lit-correct { background: var(--correct); border-color: var(--correct); color: white; box-shadow: 0 0 14px rgba(34,197,94,0.45);  transform: scale(1.08); }
.dk.lit-wrong   { background: var(--wrong);   border-color: var(--wrong);   color: white; box-shadow: 0 0 14px rgba(239,68,68,0.45);   transform: scale(1.08); }

.kb-hint {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px 10px;
}
.kb-col { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10px; color: var(--text-faint); }
.kb-key {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  padding: 2px 5px;
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-muted);
  line-height: 1.4;
}
.kb-key.pair { display: flex; gap: 2px; }
.kb-plus { font-size: 9px; color: var(--text-faint); }

.gp-badge { font-size: 10px; color: var(--correct); font-weight: 600; letter-spacing: 0.05em; opacity: 0; transition: opacity 0.3s; }
.gp-badge.show { opacity: 1; }

/* ── Footer ── */
.bottom-bar {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 16px max(10px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.stop-btn {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 10px 28px;
  width: 100%;
  max-width: 320px;
  background: rgba(239,68,68,0.10);
  border: 1px solid rgba(239,68,68,0.28);
  border-radius: var(--radius-full);
  color: var(--wrong);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--ease), border-color var(--ease), transform 0.1s;
  touch-action: manipulation;
}
.stop-btn:hover  { background: rgba(239,68,68,0.18); border-color: rgba(239,68,68,0.5); }
.stop-btn:active { transform: scale(0.97); }

.fallback-note { font-size: 10px; color: var(--text-faint); text-align: center; display: none; line-height: 1.4; }

/* ── Results Overlay ── */
.results-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.16,1,0.3,1);
  pointer-events: none;
}
.results-overlay.show { opacity: 1; transform: translateY(0); pointer-events: auto; }

.results-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}
.results-title { font-family: var(--font-display); font-size: 16px; font-weight: 900; letter-spacing: 0.06em; color: var(--text); }
.results-summary-text { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.restart-btn {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 8px 16px;
  background: rgba(249,115,22,0.12);
  border: 1px solid rgba(249,115,22,0.3);
  border-radius: var(--radius-full);
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--ease), border-color var(--ease), transform 0.1s;
  touch-action: manipulation;
}
.restart-btn:hover  { background: rgba(249,115,22,0.22); }
.restart-btn:active { transform: scale(0.96); }

.results-overall {
  margin: 12px 16px 0;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}
.overall-stat { text-align: center; flex: 1; }
.overall-val  { font-family: var(--font-display); font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; }
.overall-lbl  { font-size: 10px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 3px; }
.overall-div  { width: 1px; height: 36px; background: var(--border-2); flex-shrink: 0; }

.results-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}
.results-scroll::-webkit-scrollbar       { width: 4px; }
.results-scroll::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.results-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 6px 0 2px;
  margin-top: 2px;
}
.result-row {
  border-radius: var(--radius-md);
  border: 1px solid var(--row-border, rgba(255,255,255,0.08));
  background: var(--row-bg, var(--surface));
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 5px 12px;
  align-items: center;
}
.row-name    { font-family: var(--font-display); font-weight: 800; color: var(--row-color, var(--text)); letter-spacing: -0.01em; line-height: 1.1; }
.row-pct     { font-family: var(--font-display); font-weight: 900; color: var(--row-color, var(--text)); text-align: right; line-height: 1; font-variant-numeric: tabular-nums; }
.row-bar-wrap { height: 5px; background: var(--surface-2); border-radius: var(--radius-full); overflow: hidden; }
.row-bar-fill { height: 100%; border-radius: var(--radius-full); background: var(--row-color, var(--text-muted)); transition: width 0.6s cubic-bezier(0.16,1,0.3,1); }
.row-counts  { font-size: 11px; color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.results-empty      { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--text-muted); text-align: center; padding: 32px; }
.results-empty-icon { font-size: 40px; opacity: 0.4; }
.results-empty-txt  { font-size: 14px; }

/* ── Personal Bests (arcade) ── */
.results-pb {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.pb-eyebrow {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-faint); margin-bottom: 8px; text-align: center;
}
.pb-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
}
.pb-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 6px; text-align: center;
  transition: border-color 0.2s, background 0.2s;
}
.pb-item.pb-new {
  background: rgba(249,115,22,0.08);
  border-color: rgba(249,115,22,0.4);
}
.pb-val {
  font-family: var(--font-display); font-size: 16px; font-weight: 900;
  color: var(--text); line-height: 1;
}
.pb-item.pb-new .pb-val { color: var(--accent); }
.pb-key {
  font-size: 10px; color: var(--text-faint); margin-top: 4px;
  font-weight: 600; letter-spacing: 0.04em;
}

/* ── Menu button (back to main menu) ── */
.menu-btn-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.menu-legal {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-size: 10px;
  color: var(--text-faint);
}
.menu-legal a {
  color: var(--text-faint);
  text-decoration: none;
  transition: color 0.15s;
}
.menu-legal a:hover { color: var(--text-muted); }
.menu-legal-sep { opacity: 0.4; }
.menu-btn {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 10px 28px;
  width: 100%;
  max-width: 320px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform 0.1s;
  touch-action: manipulation;
}
.menu-btn:hover  { background: rgba(255,255,255,0.11); border-color: rgba(255,255,255,0.30); color: var(--text); }
.menu-btn:active { transform: scale(0.97); }

/* ── Countdown / Stopwatch strip (arcade + time + unlimited) ── */
.countdown-strip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.countdown-label { font-size: 9px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.countdown-time {
  font-family: var(--font-display); font-size: 18px; font-weight: 900;
  font-variant-numeric: tabular-nums; color: var(--accent); letter-spacing: 0.04em; min-width: 36px;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }
.countdown-time.warn { color: var(--wrong); animation: blink 0.9s ease infinite; }
.countdown-bar-outer { flex: 1; height: 4px; background: var(--surface); border-radius: var(--radius-full); overflow: hidden; }
.countdown-bar-inner { height: 100%; background: var(--accent); border-radius: var(--radius-full); transition: width 1s linear, background 0.4s; }
.countdown-bar-inner.warn { background: var(--wrong); }

/* ── Level badge (header) ── */
.level-badge {
  font-family: var(--font-display);
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: #a855f7;
  background: rgba(168,85,247,0.10);
  border: 1px solid rgba(168,85,247,0.28);
  padding: 2px 6px; border-radius: var(--radius-full);
  align-self: flex-start;
}

/* ── Pro badge + portal button (header) ── */
.pro-badge {
  font-family: var(--font-display);
  font-size: 9px; font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: #fff; background: var(--accent);
  padding: 2px 6px; border-radius: var(--radius-full);
  align-self: flex-start;
}
.pro-portal-btn {
  font-size: 10px; color: var(--text-faint);
  background: none; border: none; padding: 0;
  cursor: pointer; text-align: left;
  transition: color var(--ease);
  font-family: var(--font-body);
}
.pro-portal-btn:hover { color: var(--text-muted); }

/* ── Paywall / Pro gate overlay ── */
.paywall-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(11,11,14,0.92);
  display: none; align-items: center; justify-content: center;
  padding: 24px 20px;
  backdrop-filter: blur(6px);
  opacity: 0; transition: opacity 0.3s ease;
  pointer-events: none;
}
.paywall-overlay.show { opacity: 1; pointer-events: auto; }

.paywall-card {
  width: 100%; max-width: 360px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius-xl); padding: 32px 24px 28px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  transform: translateY(16px); transition: transform 0.35s cubic-bezier(0.16,1,0.3,1);
}
.paywall-overlay.show .paywall-card { transform: translateY(0); }

.paywall-icon { font-size: 40px; line-height: 1; }
.paywall-title {
  font-family: var(--font-display); font-size: 20px; font-weight: 900;
  letter-spacing: 0.04em; color: var(--text); text-align: center; line-height: 1.2;
}
.paywall-sub { font-size: 13px; color: var(--text-muted); text-align: center; line-height: 1.5; margin-top: -6px; width: 100%; }
.paywall-divider { width: 100%; height: 1px; background: var(--border); }
.paywall-pro-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.paywall-features {
  list-style: none; display: flex; flex-direction: column; gap: 8px; width: 100%;
}
.paywall-features li {
  font-size: 13px; color: var(--text); display: flex; align-items: center; gap: 10px;
}
.paywall-features li::before {
  content: '✓';
  font-family: var(--font-display); font-weight: 900;
  color: var(--correct); font-size: 14px; flex-shrink: 0;
}
.paywall-cta {
  font-family: var(--font-display); font-size: 15px; font-weight: 900;
  letter-spacing: 0.04em; padding: 14px 28px; width: 100%;
  background: var(--accent); border: none;
  border-radius: var(--radius-full); color: white;
  cursor: pointer; transition: opacity 0.15s, transform 0.1s;
  touch-action: manipulation; text-decoration: none;
  display: flex; align-items: center; justify-content: center;
}
.paywall-cta:hover  { opacity: 0.88; }
.paywall-cta:active { transform: scale(0.97); }
.paywall-cta:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.paywall-tomorrow {
  font-size: 11px; color: var(--text-faint); text-align: center; width: 100%;
}
.paywall-menu {
  font-size: 12px; color: var(--text-muted); text-decoration: none;
  transition: color var(--ease);
}
.paywall-menu:hover { color: var(--text); }

/* ── Landscape compact layout ── */
@media (max-height: 560px) and (orientation: landscape) {
  .main       { flex-direction: row; padding: 6px 16px; gap: 10px; }
  .gif-frame  { max-width: min(180px, 40vh); }
  .controls   { flex-direction: row; gap: 12px; }
  .kb-hint    { display: none; }
  .bottom-bar { flex-direction: row; justify-content: center; gap: 16px; padding: 6px 16px; }
  .stop-btn   { width: auto; padding: 8px 22px; }
}
