:root {
  --bg-deep: #0b0620;
  --bg-mid: #170b34;
  --panel-bg: rgba(18, 12, 40, 0.92);
  --accent-a: #ff6b5b;
  --accent-b: #4fd3ff;
  --text-bright: #f5f3ff;
  --text-dim: #b7aee0;
  --btn-glow: #ffd166;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text-bright);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(circle at 30% 20%, var(--bg-mid), var(--bg-deep) 65%);
  display: flex;
  flex-direction: column;
  touch-action: none;
  user-select: none;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  padding: max(10px, env(safe-area-inset-top)) 16px 0 16px;
  pointer-events: none;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background: rgba(11, 6, 32, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 12px;
  min-width: 84px;
}

.hud-item:last-child {
  align-items: flex-end;
}

.hud-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hud-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.25;
  display: inline-block;
  transform-origin: left center;
}

.hud-item:last-child .hud-value {
  transform-origin: right center;
}

.hud-value.pop {
  animation: scorePop 0.28s ease-out;
}

@keyframes scorePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

.hud-badges {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.hud-combo,
.hud-shield {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.hud-combo {
  color: #1a1030;
  background: linear-gradient(90deg, var(--btn-glow), var(--accent-a));
}

.hud-shield {
  color: #062a33;
  background: linear-gradient(90deg, var(--accent-b), #8ff0ff);
}

.hud-combo.hidden,
.hud-shield.hidden {
  display: none;
}

.recap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 4px 0 16px;
  text-align: left;
}

.recap-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-dim);
}

.recap-row span:last-child {
  color: var(--text-bright);
  font-weight: 700;
}

#game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

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

.overlay.hidden {
  display: none;
}

.panel {
  width: 100%;
  max-width: 420px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 26px 24px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.panel h1 {
  margin: 0 0 6px;
  font-size: 30px;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 14px;
}

.howto {
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 20px;
}

.howto p {
  margin: 6px 0;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-bright);
}

.howto p strong {
  color: var(--accent-b);
}

kbd {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 34px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1a1030;
  background: linear-gradient(90deg, var(--btn-glow), var(--accent-a));
  box-shadow: 0 8px 24px rgba(255, 209, 102, 0.35);
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.result-line {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.result-score {
  margin: 2px 0 4px;
  font-size: 56px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent-b), var(--btn-glow));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.result-sub {
  min-height: 18px;
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--btn-glow);
}

#mis-leaderboard {
  margin: 6px 0 18px;
  min-height: 0;
}

#tip-toast {
  position: absolute;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(11, 6, 32, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-dim);
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#tip-toast.hidden {
  opacity: 0;
}

@media (max-width: 420px) {
  .panel h1 {
    font-size: 26px;
  }
  .result-score {
    font-size: 46px;
  }
  .hud-value {
    font-size: 17px;
  }
}
