:root {
  --bg-color: #0f111a;
  --panel-bg: #1a1d2d;
  --panel-border: #2a2f45;
  --text-main: #f0f3ff;
  --text-muted: #8c96ba;
  --accent-cyan: #00e5ff;
  --accent-pink: #ff2a8d;
  --accent-gold: #ffb703;
  --accent-green: #00e676;
  --road-bg: #141724;
  --road-border: #2e3650;
  --lane-line: rgba(255, 255, 255, 0.25);
  --heart-color: #ff3366;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  padding: 10px;
}

#game-wrapper {
  width: 100%;
  max-width: 480px;
  height: 95vh;
  max-height: 860px;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 229, 255, 0.1);
  overflow: hidden;
  position: relative;
}

/* ================= Top HUD ================= */
#game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(180deg, #1f2438 0%, #171a2b 100%);
  border-bottom: 2px solid var(--panel-border);
  z-index: 10;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.hud-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.speed-val {
  color: var(--accent-cyan);
  font-weight: 900;
  transition: color 0.3s, transform 0.2s;
}

.speed-val.tier-2 {
  color: #00E676;
}

.speed-val.tier-3 {
  color: #FFEA00;
}

.speed-val.tier-4 {
  color: #FF9100;
}

.speed-val.tier-5 {
  color: #FF1744;
  text-shadow: 0 0 8px rgba(255, 23, 68, 0.6);
}

.speed-pulse {
  animation: speedPulse 0.4s ease-out;
}

@keyframes speedPulse {
  0% { transform: scale(1.4); }
  100% { transform: scale(1); }
}

#lives-container {
  display: flex;
  gap: 4px;
  font-size: 1.1rem;
}

.heart {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  display: inline-block;
}

.heart.lost {
  opacity: 0.25;
  filter: grayscale(1);
  transform: scale(0.8);
}

.heart.animate-loss {
  animation: heartPop 0.4s ease-out;
}

@keyframes heartPop {
  0% { transform: scale(1.4); }
  50% { transform: scale(0.7); }
  100% { transform: scale(0.8); }
}

/* Target Shape Badge */
.target-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

#target-preview-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.target-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

#target-shape-name {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

#target-color-name {
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.9;
}

/* ================= Mission Objective Banner ================= */
#mission-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(14, 18, 30, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  z-index: 9;
}

.step-badge {
  background: var(--accent-cyan);
  color: #0b132b;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

#mission-text {
  color: #d1d9ec;
}

#mission-text strong {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ================= Canvas & Game Field ================= */
#canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--road-bg);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Flash on hit / damage */
#screen-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease-out;
  z-index: 5;
}

#screen-flash.damage {
  background: radial-gradient(circle, rgba(255, 50, 50, 0.4) 0%, rgba(255, 0, 0, 0.6) 100%);
  opacity: 1;
}

#screen-flash.success {
  background: radial-gradient(circle, rgba(0, 230, 118, 0.25) 0%, rgba(0, 230, 118, 0.5) 100%);
  opacity: 1;
}

/* ================= Floating Morph Banner ================= */
.morph-banner {
  position: absolute;
  top: 25%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.95), rgba(255, 42, 141, 0.95));
  color: #fff;
  padding: 14px 24px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 229, 255, 0.6);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  z-index: 20;
}

.morph-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.morph-title {
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

#morph-desc {
  font-size: 0.85rem;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* ================= Overlays & Modals ================= */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 13, 22, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 30;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #191e30;
  border: 2px solid #2e3857;
  border-radius: 18px;
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.logo-icon {
  font-size: 2.5rem;
  color: var(--accent-cyan);
  text-shadow: 0 0 20px var(--accent-cyan);
  margin-bottom: 4px;
}

.game-title {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  margin-bottom: 2px;
}

.game-subtitle {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  font-weight: 600;
  margin-bottom: 16px;
}

.instructions-card {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  margin-bottom: 18px;
}

.instructions-card h3 {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.instructions-card ul {
  list-style: none;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #c9d2ec;
}

.instructions-card li {
  margin-bottom: 6px;
}

.action-btn {
  background: linear-gradient(135deg, #00e5ff 0%, #0088ff 100%);
  color: #051026;
  border: none;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 12px 28px;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 229, 255, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 229, 255, 0.6);
}

.action-btn:active {
  transform: translateY(1px);
}

.controls-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 12px;
}

/* Game Over Card */
.gameover-title {
  color: #ff3366;
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-shadow: 0 0 15px rgba(255, 51, 102, 0.4);
  margin-bottom: 16px;
}

.gameover-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.stat-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

/* ================= Bottom Touch Controls ================= */
#touch-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #141724;
  border-top: 2px solid var(--panel-border);
  gap: 10px;
  z-index: 10;
}

.touch-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #232a40;
  color: #fff;
  border: 1px solid #364163;
  padding: 12px 10px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.1s, transform 0.1s;
}

.touch-btn:active {
  background: #00e5ff;
  color: #000;
  transform: scale(0.96);
}

.touch-lane-hint {
  font-size: 0.6rem;
  font-weight: 700;
  color: #5d6b91;
  text-align: center;
  max-width: 80px;
  line-height: 1.2;
}

@media (max-height: 650px) {
  #game-wrapper {
    height: 98vh;
  }
  .touch-btn {
    padding: 8px;
  }
}
