/* EDGE-Infinity UI — dark, mobile-first (v1.3.0) */

:root {
  --bg: #0e0e12;
  --bg2: #1a1a22;
  --card: #22222c;
  --text: #f0f0f5;
  --muted: #9a9aaa;
  --accent: #ffcc00;
  --go: #2ecc71;
  --stop: #e74c3c;
  --finish: #27ae60;
  --deny: #c0392b;
  --bar-track: #333344;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

#mainwrapper {
  min-height: 100vh;
  background-color: var(--bg);
  background-size: cover;
  background-position: center;
  padding: 12px 14px calc(72px + var(--safe-bottom));
  box-sizing: border-box;
}

/* Age gate */
#ageGate {
  max-width: 480px;
  margin: 10vh auto 0;
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
}
#ageGate h1 {
  font-size: 1.35rem;
  margin: 0 0 12px;
  color: var(--accent);
}
#ageGate p { color: var(--muted); line-height: 1.6; }
.age-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.age-actions button {
  flex: 1;
  min-width: 120px;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}
#btnAgeYes { background: var(--go); color: #111; font-weight: 600; }
#btnAgeNo { background: #444; color: var(--text); }

/* Choose panel */
#choose {
  max-width: 560px;
  margin: 0 auto;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 16px 28px;
}
#choose h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  color: var(--accent);
}
#choose .instructions {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
}
#choose .instructions ul { padding-left: 1.2em; }
#choose .form-group { margin-bottom: 14px; }
#choose .control-label {
  display: block;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}
#choose select,
#choose .bootstrap-select > .dropdown-toggle {
  width: 100% !important;
  background: var(--bg2) !important;
  color: var(--text) !important;
  border: 1px solid #3a3a4a !important;
  border-radius: 8px !important;
}
#submit {
  width: 100%;
  padding: 14px;
  background: var(--accent) !important;
  color: #111 !important;
  border: none !important;
  border-radius: 10px !important;
  font-weight: 700;
  font-size: 1.05rem;
}

#bootStatus {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 8px;
}

/* Game */
#gamewrapper {
  max-width: 640px;
  margin: 0 auto;
}

#message {
  background: rgba(26, 26, 34, 0.92);
  border-radius: var(--radius);
  padding: 16px 14px;
  min-height: 4.5em;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-line;
  border-left: 4px solid var(--accent);
  font-size: 1.05rem;
}
#mainwrapper.go #message { border-left-color: var(--go); }
#mainwrapper.stop #message { border-left-color: var(--stop); }
#mainwrapper.finish #message { border-left-color: var(--finish); }
#mainwrapper.cancel #message { border-left-color: var(--deny); }

/* Timer + session progress */
#timerPanel {
  margin: 14px 0 10px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
}
#timerRow {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}
#timerRow span.val { color: var(--text); }
#sessionBar {
  margin-top: 10px;
  height: 8px;
  background: var(--bar-track);
  border-radius: 4px;
  overflow: hidden;
}
#sessionBar .bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #f1c40f, #e67e22);
  transition: width 0.2s linear;
}

/* Phase dots */
#phaseRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 6px;
  gap: 8px;
}
#phaseLabel {
  font-size: 0.85rem;
  color: var(--muted);
}
#phaseDots { display: flex; gap: 8px; }
#phaseDots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #444;
}
#phaseDots .dot.active { background: var(--accent); box-shadow: 0 0 0 3px rgba(255,204,0,.25); }
#phaseDots .dot.done { background: var(--go); }

/* Instruction progress bars */
#progress {
  margin-top: 12px;
}
#progress .jerkbar,
#progress .cumbar {
  position: relative;
  height: 28px;
  background: var(--bar-track);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}
#progress .jerkbar .bar {
  height: 100%;
  width: 0%;
  background: var(--go);
  transition: width 0.1s linear;
}
#progress .cumbar .bar {
  height: 100%;
  width: 0%;
  background: var(--finish);
  transition: width 0.1s linear;
}
#progress .text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

#cumSoon #speed {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 8px;
  min-height: 1.4em;
}

#cooldownTip {
  display: none;
  margin-top: 12px;
  padding: 12px;
  background: #2a2218;
  border: 1px solid #6b5a30;
  border-radius: 8px;
  color: #f0e0b0;
  font-size: 0.9rem;
}

/* Emergency stop — fixed, reachable thumb zone */
#btnEmergency {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(14px + var(--safe-bottom));
  z-index: 1000;
  min-width: 200px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--deny);
  border: 2px solid #ff6b6b;
  border-radius: 999px;
  box-shadow: 0 4px 20px rgba(192, 57, 43, 0.45);
  cursor: pointer;
}
#btnEmergency:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#btnEmergency:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

#flash { display: none !important; }

/* Mobile tweaks */
@media (max-width: 480px) {
  #message { font-size: 1rem; padding: 14px 12px; }
  #timerRow { font-size: 0.85rem; }
  #choose h2 { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  #sessionBar .bar,
  #progress .bar { transition: none; }
}
