:root {
  --bg-deep: #050818;
  --accent: #ff6a3d;
  --accent2: #3dd6ff;
  --shield: #3dd6ff;
  --magnet: #ff4dd8;
  --slow: #9b6bff;
  --x2: #ffd23d;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: #fff;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #101838 0%, #050818 70%);
}

#game {
  display: block;
  background: transparent;
  touch-action: none;
  border-radius: 0;
}

#hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 20px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

#hud-score {
  font-size: clamp(28px, 6vw, 42px);
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
  letter-spacing: 1px;
  flex: 1;
}

#hud-combo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--x2);
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
  opacity: 0;
  transition: opacity .15s;
}
#hud-combo.show { opacity: 1; }

#hud-best {
  font-size: 13px;
  font-weight: 600;
  color: #9fb0d9;
  background: rgba(255,255,255,.08);
  padding: 6px 10px;
  border-radius: 999px;
  margin-top: 4px;
}
#hud-best-val { color: #fff; }

#pause-btn {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  z-index: 5;
  display: none;
}
#pause-btn.show { display: block; }

#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 20, 0.55);
  backdrop-filter: blur(6px);
  z-index: 10;
  padding: 16px;
}
#overlay.hidden { display: none; }

.panel {
  width: min(380px, 92vw);
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #12183a 0%, #0a0e26 100%);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px;
  padding: 24px 22px 28px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.panel.hidden { display: none; }

#logo {
  width: 84px;
  height: 84px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 6px 24px rgba(255,106,61,.35);
}

h1 {
  margin: 14px 0 4px;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: .5px;
}
h1 span { color: var(--accent); }

h2 { margin: 0 0 16px; font-size: 24px; }

.tag {
  margin: 0 0 18px;
  color: #a9b4d6;
  font-size: 14px;
}

.btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin: 8px 0;
  border-radius: 14px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }

.btn.primary {
  background: linear-gradient(135deg, #ff6a3d, #ff3d7a);
  color: #fff;
  box-shadow: 0 8px 22px rgba(255,61,90,.35);
}

.btn.ghost {
  background: rgba(255,255,255,.08);
  color: #d8def0;
}

.howto {
  font-size: 13px;
  color: #8b96bd;
  margin: 10px 0 16px;
}

.key {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,.12);
  font-weight: 700;
  color: #fff;
  margin: 0 2px;
}

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 12px;
  color: #b9c2e0;
  text-align: left;
  margin: 6px 4px 16px;
}
.legend div { display: flex; align-items: center; gap: 6px; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.dot.shield { background: var(--shield); color: var(--shield); }
.dot.magnet { background: var(--magnet); color: var(--magnet); }
.dot.slow { background: var(--slow); color: var(--slow); }
.dot.x2 { background: var(--x2); color: var(--x2); }

.best-line {
  margin: 4px 0 0;
  font-size: 13px;
  color: #8b96bd;
}
.best-line b { color: #fff; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: 15px;
  color: #c3cbe6;
}
.stat-row b { color: #fff; font-size: 17px; }
.stat-row.best { border-bottom: none; }
#go-newbest-row { color: var(--x2); display: none; }
#go-newbest-row.show { display: flex; }

@media (max-height: 480px) {
  .panel { padding: 16px 18px 20px; }
  #logo { width: 56px; height: 56px; margin-bottom: 4px; }
  h1 { font-size: 22px; margin: 8px 0 2px; }
  .tag { margin-bottom: 10px; }
  .legend { display: none; }
}
