:root {
  --bg-dark: #0a1114;
  --glass: rgba(16, 26, 30, 0.78);
  --glass-strong: rgba(13, 21, 25, 0.92);
  --surface-card: rgba(24, 38, 44, 0.72);
  --border: rgba(254, 215, 170, 0.2);
  --border-accent: rgba(45, 212, 191, 0.45);
  --text: #fafaf9;
  --text-muted: #a8b8c0;
  --teal: #14b8a6;
  --teal-light: #2dd4bf;
  --emerald: #059669;
  --coral: #f97316;
  --coral-light: #fb923c;
  --gold: #fbbf24;
  --rose: #f43f5e;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  touch-action: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

.hidden {
  display: none !important;
}

/* Crisp Inline SVG Icons */
.ui-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ui-icon-sm {
  width: 15px;
  height: 15px;
}

.ui-icon-lg {
  width: 22px;
  height: 22px;
}

.icon-gold { color: var(--gold); }
.icon-teal { color: var(--teal-light); }
.icon-coral { color: var(--coral-light); }

/* Screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
}

.screen button,
.screen .interactive {
  pointer-events: auto;
}

/* Pills & Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  padding: 8px 13px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.32);
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.top-actions {
  display: flex;
  gap: 8px;
}

/* Home Hero */
.home-hero {
  text-align: center;
  margin-top: 10px;
  pointer-events: none;
}

.game-title {
  margin: 0;
  font-size: clamp(32px, 8.8vw, 44px);
  font-weight: 900;
  letter-spacing: 2px;
  background: linear-gradient(180deg, #fff7ed 0%, #fdba74 52%, #f97316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 16px rgba(249, 115, 22, 0.35));
}

.game-subtitle {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #99f6e4;
  text-transform: uppercase;
}

/* Home Bottom Stack */
.home-bottom {
  display: flex;
  flex-direction: column;
  gap: 11px;
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}

.bonus-card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--glass);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-radius: 16px;
  padding: 11px 13px;
}

.bonus-info {
  min-width: 0;
}

.bonus-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.bonus-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.ad-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fef3c7;
  color: #7c2d12;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 5px;
  line-height: 1.1;
}

.btn-ad-bonus {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #ea580c, #f97316);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.4);
}

.btn-ad-bonus:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-play-main {
  width: 100%;
  border: 1px solid rgba(94, 234, 212, 0.4);
  border-radius: 16px;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1.6px;
  color: #ffffff;
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 55%, #14b8a6 100%);
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.42);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.btn-play-main:active {
  transform: scale(0.97);
}

.nav-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.nav-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 4px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.nav-btn:active {
  transform: scale(0.95);
}

.nav-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--coral);
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* HUD */
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-distance {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  color: #fff7ed;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

.hud-sub-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #e7e5e4;
}

.hud-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hud-biome-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(13, 21, 25, 0.75);
  border: 1px solid var(--border-accent);
  color: #99f6e4;
  width: fit-content;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.speed-gauge {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(13, 21, 25, 0.78);
  border: 3px solid var(--coral-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.speed-val {
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  color: #fff7ed;
}

.speed-unit {
  font-size: 9px;
  font-weight: 800;
  color: var(--text-muted);
  margin-top: 2px;
}

.boost-wrap {
  width: 148px;
  height: 8px;
  border-radius: 999px;
  background: rgba(13, 21, 25, 0.78);
  border: 1px solid var(--border);
  overflow: hidden;
}

.boost-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #14b8a6, #f97316);
  transition: width 0.08s linear;
}

/* Biome / Ring floating banner */
.biome-banner {
  position: fixed;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  padding: 9px 18px;
  border-radius: 12px;
  background: rgba(13, 21, 25, 0.9);
  border: 1px solid var(--border-accent);
  font-size: 14px;
  font-weight: 800;
  color: #fff7ed;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

/* On-screen flight controls */
.hud-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.dpad-cluster {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(2, 50px);
  gap: 6px;
}

.ctrl-btn {
  border-radius: 14px;
  border: 1px solid rgba(254, 215, 170, 0.24);
  background: rgba(13, 21, 25, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fafaf9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ctrl-btn.pressed,
.ctrl-btn:active {
  background: rgba(20, 184, 166, 0.55);
  transform: scale(0.94);
}

.ctrl-up { grid-column: 2; grid-row: 1; }
.ctrl-left { grid-column: 1; grid-row: 2; }
.ctrl-down { grid-column: 2; grid-row: 2; }
.ctrl-right { grid-column: 3; grid-row: 2; }

.boost-btn {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(254, 215, 170, 0.7);
  background: linear-gradient(135deg, #ea580c, #c2410c);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 6px 20px rgba(234, 88, 12, 0.45);
  cursor: pointer;
}

.boost-btn.pressed,
.boost-btn:active {
  transform: scale(0.92);
  filter: brightness(1.15);
}

/* Game Over Screen */
.gameover-screen {
  background: rgba(8, 14, 17, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

.go-card {
  width: 100%;
  max-width: 380px;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.go-title {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
  color: var(--coral-light);
  letter-spacing: 0.8px;
}

.go-summary {
  margin: 6px 0 2px;
  font-size: 24px;
  font-weight: 900;
  color: #ffffff;
}

.go-biome {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal-light);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.go-new-best {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.18);
  border: 1px solid rgba(45, 212, 191, 0.55);
  color: #99f6e4;
  font-size: 12px;
  font-weight: 800;
}

.go-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 18px;
}

.go-stat {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 6px;
}

.go-stat-label {
  font-size: 11px;
  color: var(--text-muted);
}

.go-stat-val {
  font-size: 15px;
  font-weight: 800;
  margin-top: 3px;
}

.go-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-full {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.btn-full:active {
  transform: scale(0.97);
}

.btn-revive {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  color: #ffffff;
}

.btn-double {
  background: linear-gradient(135deg, #ea580c, #f97316);
  color: #ffffff;
}

.btn-again {
  background: linear-gradient(135deg, #14b8a6, #059669);
  color: #ffffff;
}

.btn-secondary {
  background: rgba(30, 48, 54, 0.85);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(6, 11, 14, 0.84);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--glass-strong);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-close-modal {
  border: 1px solid var(--border);
  background: var(--surface-card);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.section-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--teal-light);
  margin: 14px 0 8px;
}

/* Shop Grid */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.shop-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.shop-card.is-equipped {
  border-color: var(--teal-light);
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.25);
}

.skin-orb {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset -4px -4px 10px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.35);
}

.shop-card-name {
  font-size: 14px;
  font-weight: 800;
}

.shop-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 10px;
}

.shop-action-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, #0d9488, #14b8a6);
  color: #ffffff;
}

.btn-muted {
  background: rgba(39, 57, 64, 0.72);
  color: #cbd5e1;
}

.upgrade-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 9px;
}

.upgrade-head {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
}

.upgrade-icon-box {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(20, 184, 166, 0.16);
  border: 1px solid rgba(45, 212, 191, 0.35);
  color: var(--teal-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.upgrade-name {
  font-size: 14px;
  font-weight: 800;
}

.upgrade-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Missions */
.mission-card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 10px;
}

.mission-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.mission-title {
  font-size: 14px;
  font-weight: 800;
}

.mission-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mission-reward {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mission-bar-wrap {
  height: 7px;
  border-radius: 999px;
  background: rgba(10, 17, 20, 0.85);
  margin: 9px 0;
  overflow: hidden;
}

.mission-bar {
  height: 100%;
  background: linear-gradient(90deg, #14b8a6, #fb923c);
}

.mission-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mission-progress {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
}

.mission-btn {
  border: none;
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

/* Ads Info & Rules Tables */
.info-box {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 13px;
  margin-bottom: 11px;
  font-size: 13px;
  line-height: 1.5;
  color: #e7e5e4;
}

.info-box h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--coral-light);
  display: flex;
  align-items: center;
  gap: 7px;
}

.ads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0 12px;
}

.ads-table th,
.ads-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid rgba(254, 215, 170, 0.16);
  vertical-align: top;
}

.ads-table th {
  color: var(--teal-light);
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.promise-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.promise-list li {
  margin-bottom: 7px;
  padding-left: 20px;
  position: relative;
}

.promise-list li::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 5px;
  width: 8px;
  height: 5px;
  border-left: 2px solid var(--teal-light);
  border-bottom: 2px solid var(--teal-light);
  transform: rotate(-45deg);
}

.rules-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.rules-list li {
  margin-bottom: 6px;
}

/* Demo Ad Overlay */
.demo-ad-box {
  width: 100%;
  max-width: 340px;
  background: #0d1519;
  border: 1px solid rgba(251, 146, 60, 0.5);
  border-radius: 18px;
  padding: 20px;
  text-align: center;
}

.demo-ad-timer {
  font-size: 40px;
  font-weight: 900;
  color: var(--coral-light);
  margin: 10px 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(13, 21, 25, 0.96);
  border: 1px solid var(--border-accent);
  color: #fafaf9;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-width: 90vw;
  text-align: center;
}
