:root {
  --bg: #05050a;
  --bg2: #0a0a14;
  --card: #0f0f1e;
  --card2: #141428;
  --accent: #ff6b00;
  --accent2: #ff9500;
  --accent3: #ffcc00;
  --cyan: #00d4ff;
  --green: #00ff88;
  --purple: #8b5cf6;
  --red: #ff4444;
  --text: #f0f0ff;
  --text2: #9090b0;
  --border: rgba(255,255,255,0.07);
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-container {
  width: 100%;
  max-width: 420px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  position: relative;
  background: linear-gradient(180deg, #07070f 0%, #05050a 100%);
}

/* HEADER */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0,0,0,0.5);
  border-bottom: 1px solid var(--border);
  height: 52px;
  flex-shrink: 0;
}
.back-btn {
  color: var(--text2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all 0.2s;
}
.back-btn:hover { color: var(--accent); border-color: rgba(255,107,0,0.3); }
.game-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.game-emoji { font-size: 22px; }
.game-name {
  font-family: 'Teko', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}
.header-score {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.hs-label { font-size: 10px; color: var(--text2); letter-spacing: 1px; text-transform: uppercase; }
.hs-val {
  font-family: 'Orbitron', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

/* STATS BAR */
.stats-bar {
  display: flex;
  justify-content: space-around;
  padding: 8px 16px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.si-label { font-size: 10px; color: var(--text2); letter-spacing: 1px; text-transform: uppercase; }
.si-val { font-size: 14px; font-weight: 700; }
.rank-val { font-size: 12px; }

/* GAME AREA */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* FEEDBACK */
.feedback-msg {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent2);
  text-align: center;
  min-height: 24px;
  letter-spacing: 0.5px;
}

/* CONTROLS */
.controls-area {
  padding: 12px 16px;
  background: rgba(0,0,0,0.4);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ctrl-state { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ctrl-state.hidden { display: none !important; }
.ctrl-hint { font-size: 13px; color: var(--text2); text-align: center; line-height: 1.4; }
.ctrl-hint2 { font-size: 12px; color: var(--text2); text-align: center; opacity: 0.7; }

.btn-game-primary {
  width: 100%;
  max-width: 320px;
  padding: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 16px;
  color: #000;
  font-family: 'Teko', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 30px rgba(255,107,0,0.4);
  -webkit-tap-highlight-color: transparent;
}
.btn-game-primary:active {
  transform: scale(0.96);
  box-shadow: 0 0 50px rgba(255,107,0,0.7);
}

.btn-game-stop {
  width: 100%;
  max-width: 320px;
  padding: 20px;
  background: linear-gradient(135deg, #ff4444, #ff0000);
  border: none;
  border-radius: 16px;
  color: #fff;
  font-family: 'Teko', sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 0 30px rgba(255,68,68,0.5);
  animation: stopPulse 1s ease-in-out infinite;
}
@keyframes stopPulse {
  0%,100% { box-shadow: 0 0 30px rgba(255,68,68,0.5); }
  50% { box-shadow: 0 0 60px rgba(255,68,68,0.9); }
}
.btn-game-stop:active { transform: scale(0.94); }

.btn-game-secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text2);
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 24px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-game-secondary:active { opacity: 0.7; }

/* RISK METER */
.risk-meter {
  width: 100%;
  max-width: 320px;
  margin-bottom: 4px;
}
.rm-label { font-size: 10px; color: var(--text2); letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px; }
.rm-bar {
  height: 8px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.rm-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00ff88, #ffcc00);
  border-radius: 4px;
  transition: width 0.08s, background 0.3s;
}

/* RESULT CARD */
.result-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  width: 100%;
  max-width: 320px;
  text-align: center;
}
.rc-mult {
  font-family: 'Orbitron', sans-serif;
  font-size: 42px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}
.rc-msg { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.rc-improvement { font-size: 13px; margin-bottom: 4px; }
.rc-compare { font-size: 13px; color: var(--purple); }

/* VS OTHERS */
.vs-others {
  padding: 8px 16px;
  background: rgba(139,92,246,0.08);
  border-top: 1px solid rgba(139,92,246,0.15);
  flex-shrink: 0;
}
.vo-text { font-size: 13px; font-weight: 700; color: var(--purple); text-align: center; }

/* PROGRESS */
.progress-section {
  padding: 8px 16px 12px;
  flex-shrink: 0;
}
.ps-label { font-size: 10px; color: var(--text2); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }
.ps-bar {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}
.ps-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* CANVAS GAME */
.game-canvas {
  border-radius: 12px;
  touch-action: none;
  display: block;
}

/* SCREEN FLASH */
@keyframes flashRed {
  0%,100% { background: linear-gradient(180deg, #07070f, #05050a); }
  50% { background: linear-gradient(180deg, #1a0505, #05050a); }
}
.game-container.flash-red { animation: flashRed 0.3s ease; }

@keyframes flashGreen {
  0%,100% { background: linear-gradient(180deg, #07070f, #05050a); }
  50% { background: linear-gradient(180deg, #051a08, #05050a); }
}
.game-container.flash-green { animation: flashGreen 0.3s ease; }
