/* ============================================================
   GESTURE RUN — ARIA Design System
   Palette: Warm white · Saffron orange · Ink
   Typography: Sora · DM Mono · Instrument Serif
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=DM+Mono:wght@400;500&family=Instrument+Serif:ital@0;1&display=swap');

:root {
  --bg:           #FAFAF8;
  --bg-2:         #F5F4F0;
  --bg-3:         #EDEAE3;
  --bg-4:         #E2DED6;
  --surface:      #FFFFFF;
  --border:       #E8E5DF;
  --border-2:     #D5D0C8;
  --saffron:      #F97316;
  --saffron-d:    #C2590C;
  --saffron-h:    #EA6C0A;
  --saffron-l:    #FFF3E8;
  --saffron-glow: rgba(249,115,22,.22);
  --saffron-xl:   rgba(249,115,22,.07);
  --ink:          #0D0D0B;
  --ink-2:        #2D2C28;
  --ink-3:        #4A4745;
  --dim:          #8C8885;
  --dim-2:        #B8B4AE;
  --jade:         #16A34A;
  --jade-l:       rgba(22,163,74,.1);
  --rose:         #DC2626;
  --rose-l:       rgba(220,38,38,.1);
  --ff:       'Sora', system-ui, sans-serif;
  --ff-mono:  'DM Mono', 'Courier New', monospace;
  --ff-serif: 'Instrument Serif', Georgia, serif;
  --r-sm:   6px;
  --r:      12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-pill: 100px;
  --shadow-sm: 0 1px 4px rgba(13,13,11,.06);
  --shadow:    0 4px 16px rgba(13,13,11,.07), 0 2px 6px rgba(13,13,11,.04);
  --shadow-md: 0 8px 28px rgba(13,13,11,.09), 0 4px 10px rgba(13,13,11,.05);
  --shadow-lg: 0 20px 56px rgba(13,13,11,.12), 0 8px 18px rgba(13,13,11,.07);
  --ease:   cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ff);
  overflow: hidden;
  width: 100vw; height: 100vh;
  display: flex; align-items: center; justify-content: center;
}

/* ── LOADING ───────────────────────────────────────────────── */
#loading-screen {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.loading-content { text-align: center; }
.logo-text {
  font-family: var(--ff-serif);
  font-size: 3.4rem; font-weight: 400; font-style: italic;
  color: var(--ink); letter-spacing: .04em;
}
.logo-text span { color: var(--saffron); }
.loading-bar-wrap {
  width: 280px; height: 3px;
  background: var(--border-2); border-radius: 2px;
  margin: 1.8rem auto 1rem; overflow: hidden;
}
.loading-bar {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--saffron), var(--saffron-d));
  border-radius: 2px; transition: width .3s ease;
  box-shadow: 0 0 8px var(--saffron-glow);
}
.loading-status {
  font-family: var(--ff-mono);
  font-size: .72rem; color: var(--dim); letter-spacing: .08em;
}

/* ── CALIBRATION ───────────────────────────────────────────── */
#calibration-screen {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.calib-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-xl); padding: 2rem 2.5rem; text-align: center;
  max-width: 520px; width: 100%; box-shadow: var(--shadow-lg);
}
.calib-title {
  font-family: var(--ff-serif); font-size: 1.9rem; font-style: italic;
  color: var(--ink); letter-spacing: .02em; margin-bottom: .5rem;
}
.calib-title span { color: var(--saffron); }
.calib-step { font-size: .82rem; color: var(--dim); margin-bottom: 1.2rem; line-height: 1.5; }
.calib-visual {
  position: relative; width: 320px; height: 240px;
  margin: 0 auto 1.2rem; border-radius: var(--r-lg);
  overflow: hidden; border: 1.5px solid var(--border-2);
  background: var(--bg-3); box-shadow: var(--shadow-sm);
}
.calib-visual video, .calib-visual canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
#calib-canvas { z-index: 2; }
.calib-progress { display: flex; gap: .55rem; justify-content: center; margin-bottom: .85rem; }
.calib-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border-2); transition: background .3s, box-shadow .3s;
}
.calib-dot.active { background: var(--saffron); box-shadow: 0 0 8px var(--saffron-glow); }
.calib-dot.done { background: var(--jade); box-shadow: 0 0 8px rgba(22,163,74,.3); }
.calib-countdown {
  font-family: var(--ff-mono); font-size: .95rem; color: var(--saffron-d);
  min-height: 1.5rem; margin-bottom: 1rem; letter-spacing: .04em;
}
.calib-btn {
  font-family: var(--ff); font-size: .84rem; font-weight: 700;
  padding: .68rem 2.2rem; background: var(--saffron);
  border: none; color: white; border-radius: var(--r-pill);
  cursor: pointer; letter-spacing: .04em; transition: all .2s var(--ease);
  box-shadow: 0 3px 14px var(--saffron-glow);
}
.calib-btn:hover { background: var(--saffron-h); transform: translateY(-1px); box-shadow: 0 5px 20px var(--saffron-glow); }
.calib-btn:active { transform: scale(.96); }
.calib-btn:disabled { background: var(--bg-3); color: var(--dim); box-shadow: none; cursor: not-allowed; transform: none; }

/* ── GAME SCREEN ───────────────────────────────────────────── */
#game-screen {
  position: relative; width: 900px; height: 500px;
  border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  background: var(--bg);
}
#game-canvas { display: block; }

/* ── HUD ───────────────────────────────────────────────────── */
.hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: .75rem 1rem;
  background: linear-gradient(to bottom, rgba(250,250,248,.96) 0%, rgba(250,250,248,0) 100%);
  pointer-events: none; z-index: 10;
}
.hud-left { display: flex; gap: 1.4rem; }
.score-block { display: flex; flex-direction: column; gap: .04rem; }
.hud-label {
  font-family: var(--ff-mono); font-size: .55rem; color: var(--dim);
  letter-spacing: .14em; text-transform: uppercase;
}
.hud-value {
  font-family: var(--ff-mono); font-size: 1.1rem; font-weight: 500;
  color: var(--ink); letter-spacing: .04em;
}
.gesture-indicator {
  font-family: var(--ff-mono); font-size: .72rem; font-weight: 500;
  padding: .28rem .85rem; border-radius: var(--r-pill);
  background: var(--saffron-l); border: 1.5px solid rgba(249,115,22,.25);
  color: var(--saffron-d); letter-spacing: .08em;
  min-width: 110px; text-align: center;
  box-shadow: 0 1px 6px var(--saffron-xl);
}

/* ── AI PANEL ──────────────────────────────────────────────── */
.ai-panel {
  position: absolute; top: 10px; right: 10px;
  width: 164px; background: var(--surface);
  border: 1px solid var(--border-2); border-radius: var(--r-lg);
  overflow: hidden; z-index: 20; box-shadow: var(--shadow-md);
}
.ai-header {
  display: flex; align-items: center; gap: .4rem;
  padding: .35rem .65rem; background: var(--saffron-l);
  border-bottom: 1px solid rgba(249,115,22,.15);
  font-family: var(--ff-mono); font-size: .6rem;
  letter-spacing: .12em; color: var(--saffron-d);
}
.ai-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--saffron); box-shadow: 0 0 5px var(--saffron-glow);
  animation: aria-dot-pulse 1.6s ease-in-out infinite;
}
@keyframes aria-dot-pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:.5; transform:scale(.82); }
}
.cam-wrap { position: relative; width: 164px; height: 123px; background: var(--bg-3); }
.cam-wrap video, .cam-wrap canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
#pose-canvas { z-index: 2; }
.ai-info { padding: .42rem .65rem; background: var(--bg-2); border-top: 1px solid var(--border); }
.ai-row {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--ff-mono); font-size: .6rem; line-height: 1.8;
}
.ai-lbl { color: var(--dim); letter-spacing: .06em; }
.ai-val { color: var(--saffron-d); font-weight: 500; }

/* ── DEBUG PANEL ───────────────────────────────────────────── */
.debug-panel {
  position: absolute; bottom: 10px; left: 10px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r); padding: .55rem .8rem;
  font-family: var(--ff-mono); font-size: .6rem; color: var(--dim-2);
  line-height: 1.85; z-index: 20; min-width: 170px;
  display: none; box-shadow: var(--shadow);
}
.debug-panel.visible { display: block; }
.debug-title {
  font-family: var(--ff-mono); color: var(--saffron-d); font-size: .62rem;
  letter-spacing: .12em; margin-bottom: .35rem; text-transform: uppercase;
}
.debug-toggle {
  position: absolute; bottom: 10px; left: 10px; z-index: 21;
  font-family: var(--ff-mono); font-size: .58rem; padding: .22rem .52rem;
  background: var(--surface); border: 1.5px solid var(--border-2);
  color: var(--dim); border-radius: var(--r-sm); cursor: pointer;
  letter-spacing: .1em; transition: all .18s;
}
.debug-toggle:hover { border-color: var(--saffron); color: var(--saffron-d); background: var(--saffron-l); }

/* ── GAME OVER ─────────────────────────────────────────────── */
#gameover-overlay {
  position: absolute; inset: 0;
  background: rgba(250,250,248,.88); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; animation: go-fade-in .3s ease both;
}
@keyframes go-fade-in { from{opacity:0} to{opacity:1} }
.go-panel {
  text-align: center; padding: 2.5rem 3rem;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: go-scale-in .35s var(--spring) both;
}
@keyframes go-scale-in { from{transform:scale(.9);opacity:0} to{transform:scale(1);opacity:1} }
.go-title {
  font-family: var(--ff-serif); font-size: 2.6rem; font-style: italic;
  color: var(--ink); letter-spacing: .02em; margin-bottom: .25rem;
}
.go-title span { color: var(--saffron); }
.go-subtitle {
  font-family: var(--ff-mono); font-size: .65rem; color: var(--dim);
  letter-spacing: .14em; text-transform: uppercase; margin-bottom: 1.5rem;
}
.go-scores {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--r); padding: .9rem 1.2rem; margin-bottom: 1.4rem;
}
.go-row {
  display: flex; justify-content: space-between; align-items: center; gap: 3rem;
  padding: .18rem 0;
}
.go-row:not(:last-child) { border-bottom: 1px solid var(--border); padding-bottom: .42rem; margin-bottom: .42rem; }
.go-row span:first-child {
  font-family: var(--ff-mono); font-size: .68rem;
  color: var(--dim); letter-spacing: .1em; text-transform: uppercase;
}
.go-row span:last-child {
  font-family: var(--ff-mono); font-size: 1.05rem; font-weight: 500; color: var(--saffron-d);
}
.go-hint { font-size: .78rem; color: var(--dim); margin-bottom: 1.1rem; }
kbd {
  background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 5px;
  padding: .12rem .38rem; font-family: var(--ff-mono); color: var(--ink-3); font-size: .72rem;
}
.go-actions { display: flex; gap: .6rem; justify-content: center; }
.go-btn {
  font-family: var(--ff); font-size: .8rem; font-weight: 600;
  padding: .55rem 1.5rem; border-radius: var(--r-pill);
  cursor: pointer; letter-spacing: .02em; transition: all .2s var(--ease);
}
/* Primary = saffron fill, secondary = outline */
#go-restart-btn {
  background: var(--saffron); border: none; color: white;
  box-shadow: 0 3px 14px var(--saffron-glow); margin-left: .4rem;
}
#go-restart-btn:hover { background: var(--saffron-h); transform: translateY(-1px); }

/* ── UTILITY ───────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Subtle dot-grid texture on game background */
#game-screen::before {
  content: '';
  position: absolute; inset: 0; z-index: 1;
  background-image: radial-gradient(circle, rgba(13,13,11,.05) 1px, transparent 1px);
  background-size: 22px 22px;
  pointer-events: none;
}
