:root {
  --bg: #050510;
  --panel: #070b18ee;
  --cyan: #00e8ff;
  --cyan-dim: #1288a8;
  --gold: #ffd200;
  --gold-2: #c9a000;
  --white: #f4f7ff;
  --muted: #8aa0c8;
  --danger: #ff3b7a;
  --ink: #031018;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  color: var(--white);
  font-family: "VT323", "Courier New", monospace;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

#frame {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: #000;
}

#stage {
  position: relative;
  width: min(100vw, 430px);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 0 0 2px #0b1c3a, 0 0 40px #00e8ff22;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#ui { position: absolute; inset: 0; pointer-events: none; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  pointer-events: auto;
  background: linear-gradient(180deg, #02040ccc 0%, #050510ee 100%);
  overflow-y: auto;
}

.screen.hidden, .hidden { display: none !important; }

#screen-ready {
  background: transparent;
  align-items: center;
  padding-top: 12%;
}

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

.hud-score {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-label {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 2px;
  text-shadow: 0 0 8px #ffd20088;
}

#hud-score {
  font-family: "Press Start 2P", monospace;
  font-size: 22px;
  color: #fff;
  text-shadow: 3px 3px 0 #000, 0 0 10px #00e8ff88;
}

.icon-btn {
  pointer-events: auto;
  width: 36px; height: 36px;
  border: 2px solid var(--cyan);
  background: #061018cc;
  color: var(--cyan);
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 0 10px #00e8ff44;
}
.mute-fab {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  right: 12px;
  z-index: 6;
}

.growsoft {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(4px, env(safe-area-inset-bottom));
  z-index: 6;
  text-align: center;
  font-family: "VT323", monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: #ffffff;
  text-decoration: none;
  opacity: 0.7;
  pointer-events: auto;
  padding: 4px;
}
.growsoft:active { opacity: 1; }

.panel {
  width: min(100%, 320px);
  background: var(--panel);
  border: 3px solid var(--cyan);
  box-shadow: 0 0 0 2px #021018, 0 0 24px #00e8ff55, inset 0 0 30px #00e8ff10;
  padding: 18px 16px 16px;
  text-align: center;
}

.portrait {
  width: 118px;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 14px #00e8ff88);
  margin-bottom: 6px;
}
.portrait.sm { width: 86px; }

.eyebrow {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: var(--cyan);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.logo { line-height: 1.05; margin-bottom: 8px; }
.logo-o {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 16px;
  color: #fff;
  text-shadow: 0 0 8px #00e8ff, 3px 3px 0 #041028;
}
.logo-aura {
  display: block;
  font-family: "Press Start 2P", monospace;
  font-size: 34px;
  color: var(--gold);
  text-shadow: 0 0 12px #ffd200aa, 4px 4px 0 #5a3a00;
  transform: rotate(-3deg);
  margin-top: 6px;
}

.tag {
  font-size: 18px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 14px;
}

form { display: grid; gap: 10px; text-align: left; }

label {
  display: grid;
  gap: 4px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--cyan);
}

input {
  width: 100%;
  border: 2px solid var(--cyan-dim);
  background: #030712;
  color: var(--white);
  font-family: "VT323", monospace;
  font-size: 22px;
  padding: 10px 12px;
  outline: none;
  text-transform: uppercase;
}

input:focus { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }

.btn {
  pointer-events: auto;
  width: 100%;
  border: 3px solid var(--cyan);
  background: #071422;
  color: var(--white);
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  padding: 14px 10px;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 4px 0 #034056, 0 0 12px #00e8ff33;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #034056; }
.btn.gold {
  border-color: var(--gold);
  background: linear-gradient(180deg, #ffe566, #d4a200);
  color: #2a1a00;
  box-shadow: 0 4px 0 #7a5a00, 0 0 16px #ffd20055;
  text-shadow: none;
}
.btn.ghost {
  background: transparent;
  border-color: #2a3c5a;
  color: var(--muted);
  box-shadow: none;
  font-size: 9px;
}

.menu-panel .btn { margin-top: 8px; }

.how {
  list-style: none;
  text-align: left;
  font-size: 20px;
  color: var(--white);
  display: grid;
  gap: 8px;
  margin: 12px 0 14px;
}
.how li::before { content: "▸ "; color: var(--gold); }

.hint {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: var(--gold);
  letter-spacing: 1px;
  margin: 8px 0;
}

.ready-card {
  text-align: center;
  animation: pulse 1s steps(2) infinite;
  background: #050510dd;
  border: 2px solid #00e8ff88;
  padding: 12px 14px 10px;
  box-shadow: 0 0 16px #00e8ff33;
}
.ready-kicker {
  font-family: "Press Start 2P", monospace;
  font-size: 11px;
  color: #fff;
  text-shadow: 3px 3px 0 #000, 0 0 10px #00e8ff;
}
.ready-sub {
  margin-top: 8px;
  font-size: 22px;
  color: var(--gold);
}

.over-score-label {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--muted);
  margin-top: 8px;
}
.over-score {
  font-family: "Press Start 2P", monospace;
  font-size: 32px;
  color: var(--gold);
  text-shadow: 0 0 16px #ffd20088, 4px 4px 0 #000;
  margin: 6px 0 2px;
}
.rank-line {
  min-height: 20px;
  font-size: 18px;
  color: var(--cyan);
  margin-bottom: 8px;
}

.vip-box {
  text-align: left;
  border: 2px solid var(--gold);
  background: #120e04cc;
  padding: 10px;
  margin: 4px 0 8px;
  box-shadow: 0 0 14px #ffd20033;
}
.vip-kicker {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--gold);
  letter-spacing: 1px;
  text-align: center;
}
.vip-copy {
  font-size: 18px;
  color: var(--white);
  line-height: 1.15;
  margin: 6px 0 8px;
  text-align: center;
}
.vip-box .btn { margin-top: 8px; }
.vip-box .btn.ghost { margin-top: 4px; }
.vip-ok {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.6;
  color: var(--gold);
  margin: 8px 0;
}

.share-sheet { z-index: 8; }
.share-preview {
  width: min(100%, 240px);
  height: auto;
  margin: 8px auto 6px;
  display: block;
  image-rendering: auto;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 16px #00e8ff44;
  cursor: pointer;
}
.share-caption {
  font-size: 18px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.2;
}
.install-copy {
  font-size: 18px;
  color: var(--muted);
  line-height: 1.25;
  margin: 0 0 12px;
}
.pwa-ios {
  margin-top: 10px;
  text-align: left;
  border: 2px solid #2a3c5a;
  padding: 10px;
}
.pwa-ios .hint { margin-top: 0; }

.share-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.share-row .btn { margin-top: 8px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.tab {
  pointer-events: auto;
  border: 2px solid #2a3c5a;
  background: #061018;
  color: var(--muted);
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  padding: 10px 4px;
  cursor: pointer;
}
.tab.on {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 10px #ffd20044;
}

.rank-list {
  list-style: none;
  max-height: 42vh;
  overflow-y: auto;
  text-align: left;
  margin: 8px 0 10px;
  padding-right: 4px;
}
.rank-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 6px;
  align-items: baseline;
  padding: 7px 4px;
  border-bottom: 1px solid #142038;
  font-size: 18px;
}
.rank-list .pos { color: var(--gold); font-family: "Press Start 2P", monospace; font-size: 8px; }
.rank-list .who { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .who small { display: block; color: var(--muted); font-size: 14px; }
.rank-list .pts { color: var(--cyan); font-family: "Press Start 2P", monospace; font-size: 9px; }
.rank-list li.me { background: #ffd20018; box-shadow: inset 0 0 0 1px #ffd20066; }
.rank-list li.empty { display: block; color: var(--muted); text-align: center; padding: 20px 0; }

.screen-load {
  flex-direction: column;
}
.load-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(260px, 86%);
}
.pixel-load {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  line-height: 1.8;
  color: var(--cyan);
  text-align: center;
  margin: 0;
}
.bar {
  width: 100%;
  height: 14px;
  border: 2px solid var(--cyan);
  background: #030712;
  overflow: hidden;
  box-sizing: border-box;
}
.bar i {
  display: block;
  height: 100%;
  width: 8%;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
}

#rotate {
  display: none;
  position: fixed;
  inset: 0;
  background: #050510;
  z-index: 50;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  line-height: 1.8;
  color: var(--gold);
}

@media (max-height: 640px) {
  .portrait { width: 92px; }
  .logo-aura { font-size: 28px; }
  .panel { padding: 14px 14px 12px; }
}

@media (orientation: landscape) and (max-height: 500px) {
  #rotate { display: flex; }
  #stage { visibility: hidden; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
