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

:root {
  --bg:       #0d0d0d;
  --surface:  #1a1a1a;
  --card:     #222;
  --accent:   #ff4500;
  --accent2:  #ff8c00;
  --green:    #00e676;
  --blue:     #1e88e5;
  --red:      #ff1744;
  --text:     #f0f0f0;
  --muted:    #777;
  --r:        16px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ── Audio gate ──────────────────────────── */
#audio-gate {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s;
}
#audio-gate.hidden { opacity: 0; pointer-events: none; }

.gate-inner {
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 32px 24px; text-align: center;
}
.gate-emoji  { font-size: 4rem; }
.gate-title  { font-size: 2rem; font-weight: 900; color: var(--accent); letter-spacing: -1px; }
.gate-sub    { font-size: .8rem; color: var(--muted); margin-bottom: 24px; }

#btn-arm {
  padding: 20px 48px; border-radius: 60px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 1.1rem; font-weight: 900;
  letter-spacing: 2px; cursor: pointer;
  box-shadow: 0 0 40px rgba(255,69,0,.5);
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%,100% { box-shadow: 0 0 40px rgba(255,69,0,.5); }
  50%      { box-shadow: 0 0 70px rgba(255,69,0,.9); }
}
.gate-note { font-size: .72rem; color: #444; margin-top: 12px; max-width: 240px; line-height: 1.5; }

/* ── Screens ─────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 24px 18px env(safe-area-inset-bottom, 16px);
  overflow-y: auto;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.screen.active { opacity: 1; pointer-events: all; }

/* ── Setup screen ────────────────────────── */
#screen-setup { gap: 16px; padding-top: 36px; }

.logo      { font-size: 2.6rem; }
.app-title {
  font-size: 1.6rem; font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.app-sub   { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }

.card {
  width: 100%; max-width: 420px;
  background: var(--card); border-radius: var(--r); padding: 16px 18px;
}
.card-title {
  font-size: .65rem; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.card-note { font-size: .75rem; color: #555; line-height: 1.5; margin-top: 10px; }

/* ── Activity selector ───────────────────── */
.activity-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 4px;
}
.btn-activity {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px; border-radius: 12px;
  border: 2px solid #333; background: transparent;
  color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.btn-activity.active {
  border-color: var(--accent);
  background: rgba(255,69,0,.1);
  color: var(--text);
}
.act-emoji { font-size: 1.6rem; }
.act-name  { font-size: .72rem; font-weight: 700; letter-spacing: .5px; }

/* ── Color legend ────────────────────────── */
.color-legend {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; margin-top: 12px;
}
.color-legend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: var(--surface); border-radius: 8px;
}
.legend-swatch {
  width: 16px; height: 16px; border-radius: 4px; flex-shrink: 0;
}
.legend-label {
  font-size: .72rem; font-weight: 700; color: var(--text);
}
.legend-desc { font-weight: 400; color: var(--muted); }

/* ── Stepper ─────────────────────────────── */
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper label { flex: 1; font-size: .9rem; color: var(--muted); }
.stepper-val  { font-size: 1.4rem; font-weight: 900; min-width: 40px; text-align: center; }
.stepper-unit { font-size: .72rem; color: var(--muted); min-width: 32px; }
.btn-step {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--accent); background: transparent;
  color: var(--accent); font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.btn-step:active { background: var(--accent); color: #fff; }

/* ── Toggle switch ───────────────────────── */
.toggle-row   { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-info  { flex: 1; }
.toggle-label { font-size: .9rem; font-weight: 700; color: var(--text); }
.toggle-sub   { font-size: .72rem; color: var(--muted); margin-top: 2px; }

.toggle-switch { position: relative; width: 48px; height: 28px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-knob {
  position: absolute; inset: 0; border-radius: 28px;
  background: #333; cursor: pointer; transition: background .2s;
}
.toggle-knob::before {
  content: ''; position: absolute;
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; top: 4px; left: 4px;
  transition: transform .2s;
}
.toggle-switch input:checked + .toggle-knob { background: var(--accent); }
.toggle-switch input:checked + .toggle-knob::before { transform: translateX(20px); }

/* Cardio burst */
.cardio-burst { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cardio-burst.hidden { display: none; }
.burst-emoji  { font-size: 3.5rem; }
.burst-name   { font-size: 1.1rem; font-weight: 900; color: var(--green); letter-spacing: 2px; }
.burst-count  { font-size: 4rem; font-weight: 900; color: var(--green); line-height: 1; }

/* Language toggle */
.lang-row { display: flex; gap: 10px; margin-bottom: 10px; }
.btn-lang {
  flex: 1; padding: 10px; border-radius: 10px;
  border: 2px solid #333; background: transparent;
  color: var(--muted); font-size: .9rem; font-weight: 700; cursor: pointer;
  transition: all .15s;
}
.btn-lang.active { border-color: var(--accent); color: var(--accent); background: rgba(255,69,0,.1); }

/* Movement/combo grid */
.combo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.combo-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--surface); border-radius: 10px;
}
.combo-num  { font-size: 1.3rem; font-weight: 900; color: var(--accent); min-width: 20px; }
.combo-name { font-size: .8rem; font-weight: 700; }
.combo-desc { font-size: .65rem; color: var(--muted); }

.why-text { font-size: .82rem; color: var(--muted); line-height: 1.65; }
.why-text strong { color: var(--accent2); }

.btn-start {
  width: 100%; max-width: 420px;
  padding: 18px; border-radius: var(--r); border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 1.15rem; font-weight: 900;
  letter-spacing: 1px; cursor: pointer;
  box-shadow: 0 0 28px rgba(255,69,0,.4);
  transition: transform .1s;
}
.btn-start:active { transform: scale(.97); }

/* ── Training screen ─────────────────────── */
#screen-train { padding: 0; justify-content: stretch; }

/* Full-screen color flash — peripheral vision layer */
#color-flash {
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  /* transition set dynamically in JS */
}

.train-layout {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
}

/* HUD */
.train-header {
  display: flex; align-items: center; justify-content: space-around;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid #2a2a2a;
  flex-shrink: 0;
}
.hud-item  { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-label { font-size: .58rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.hud-val   { font-size: 1.15rem; font-weight: 900; }
.hud-val.accent { color: var(--accent); }

/* Phase banner */
.phase-banner {
  text-align: center; padding: 6px;
  font-size: .72rem; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase;
  background: var(--accent); color: #fff;
  flex-shrink: 0; transition: background .4s;
}
.phase-banner.rest { background: var(--blue); }

/* Stage */
.train-stage {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px; padding: 20px;
}

.announced-label {
  font-size: .6rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: 2px;
}

.announced-number {
  font-size: 9rem; font-weight: 900; line-height: 1;
  color: var(--text);
  text-shadow: 0 0 80px rgba(255,69,0,.7);
  min-height: 120px;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .5s, transform .5s;
}
.announced-number.faded { opacity: 0; transform: scale(.8); }

/* Hint box */
.hint-box {
  background: var(--card); border-radius: 14px;
  padding: 12px 22px; text-align: center;
  min-width: 220px; border: 1px solid #2a2a2a;
  transition: opacity .25s;
}
.hint-box.hidden { opacity: 0; pointer-events: none; }
.hint-now-label  {
  font-size: .58rem; color: var(--accent);
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 4px;
}
.hint-combo-num  { font-size: 2.8rem; font-weight: 900; color: var(--accent); line-height: 1; }
.hint-combo-name { font-size: 1rem; font-weight: 700; }
.hint-combo-desc { font-size: .7rem; color: var(--muted); margin-top: 2px; }

/* Color hint section */
.hint-color-section { margin-top: 8px; }
.hint-color-section.hidden { display: none; }
.hint-divider {
  border-top: 1px solid #333; margin: 8px 0;
}
.hint-color-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 6px;
}
.hint-color-swatch {
  width: 28px; height: 28px; border-radius: 8px;
  border: 2px solid rgba(255,255,255,.1);
}
.hint-color-mod {
  font-size: 1.1rem; font-weight: 900; color: var(--text);
}

/* Beat dots */
.beat-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.beat-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #2a2a2a; transition: background .1s, transform .1s;
}
.beat-dot.active { background: var(--accent); transform: scale(1.6); }

/* Footer */
.train-footer {
  padding: 12px 16px env(safe-area-inset-bottom, 12px);
  display: flex; gap: 10px;
  background: var(--surface); border-top: 1px solid #2a2a2a;
  flex-shrink: 0;
}
.btn-ctrl {
  flex: 1; padding: 12px 8px;
  border-radius: 12px; border: 1px solid #333;
  background: var(--card); color: var(--text);
  font-size: .8rem; font-weight: 700; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  transition: background .12s;
}
.btn-ctrl:active  { background: #333; }
.btn-ctrl .ctrl-icon { font-size: 1.1rem; }
.btn-ctrl.hint-on { border-color: var(--accent); color: var(--accent); }
.btn-ctrl.danger  { border-color: var(--red);    color: var(--red); }

/* ── Rest overlay ────────────────────────── */
.rest-overlay {
  position: absolute; inset: 0;
  background: rgba(13,13,13,.96);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  opacity: 0; pointer-events: none;
  transition: opacity .35s;
  z-index: 10;
}
.rest-overlay.show { opacity: 1; pointer-events: all; }

.rest-label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 2px; }
.rest-big   { font-size: 6rem; font-weight: 900; color: var(--blue); line-height: 1; }
.rest-next  { font-size: .78rem; color: #444; margin-top: 4px; }

/* Assessment */
.assess-block { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0; }
.assess-stream-label {
  font-size: .65rem; color: var(--accent); font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
}
.assess-row   { display: flex; gap: 8px; }
.hidden { display: none !important; }

.btn-assess {
  padding: 11px 16px; border-radius: 40px; border: none;
  font-size: .82rem; font-weight: 800; cursor: pointer;
  transition: transform .1s, opacity .2s;
}
.btn-assess:active { transform: scale(.94); }
.btn-assess.easy { background: rgba(0,230,118,.15);  color: var(--green);   border: 2px solid var(--green); }
.btn-assess.ok   { background: rgba(255,140,0,.15);  color: var(--accent2); border: 2px solid var(--accent2); }
.btn-assess.hard { background: rgba(255,23,68,.15);  color: var(--red);     border: 2px solid var(--red); }
.btn-assess.used { opacity: .35; pointer-events: none; }

/* N suggestion */
.n-suggest { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 2px 0; }
.n-suggest.hidden { display: none; }
.n-suggest-text { font-size: .85rem; color: var(--text); font-weight: 700; text-align: center; max-width: 260px; line-height: 1.4; }
.n-suggest-row  { display: flex; gap: 8px; }

/* ── Results screen ──────────────────────── */
#screen-results { gap: 18px; padding-top: 40px; }

.result-title {
  font-size: 1.8rem; font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.stat-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 10px; width: 100%; max-width: 420px;
}
.stat-card { background: var(--card); border-radius: var(--r); padding: 14px 10px; text-align: center; }
.stat-val   { font-size: 2.1rem; font-weight: 900; color: var(--accent); }
.stat-label { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

.round-history { width: 100%; max-width: 420px; background: var(--card); border-radius: var(--r); padding: 18px; }
.round-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #2a2a2a; font-size: .85rem;
  flex-wrap: wrap; gap: 6px;
}
.round-row:last-child { border-bottom: none; }
.feel-badge {
  font-size: .72rem; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; letter-spacing: .5px;
}
.feel-badge.easy { background: rgba(0,230,118,.15); color: var(--green); }
.feel-badge.ok   { background: rgba(255,140,0,.15);  color: var(--accent2); }
.feel-badge.hard { background: rgba(255,23,68,.15);  color: var(--red); }
.feel-badge.none { background: #2a2a2a; color: #555; }

.btn-again {
  width: 100%; max-width: 420px; padding: 16px;
  border-radius: var(--r); border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff; font-size: 1.05rem; font-weight: 900; cursor: pointer;
}
.btn-home {
  width: 100%; max-width: 420px; padding: 14px;
  border-radius: var(--r); border: 1px solid #333;
  background: transparent; color: var(--muted);
  font-size: .95rem; font-weight: 600; cursor: pointer;
}

/* ── Toast ───────────────────────────────── */
.toast {
  position: fixed; top: -80px; left: 50%; transform: translateX(-50%);
  background: var(--accent2); color: #000;
  font-size: .85rem; font-weight: 800;
  padding: 12px 24px; border-radius: 40px;
  z-index: 200; transition: top .4s cubic-bezier(.175,.885,.32,1.275);
  white-space: nowrap;
}
.toast.show { top: 14px; }

/* ── Animations ──────────────────────────── */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-5px); }
  80%      { transform: translateX(5px); }
}
.shake { animation: shake .35s ease; }
