* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: #fff;
  user-select: none;
  touch-action: none;
}
#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #000;
}
#game {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto; height: auto;
  cursor: crosshair;
}
#toast {
  position: absolute;
  left: 50%; top: 58%;
  transform: translate(-50%, -50%);
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 0 16px #ff00ea, 0 0 28px #00e5ff;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 5;
}
#toast.show { opacity: 1; }
#popup, #sheet {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55);
  z-index: 6;
  padding: 10px;
  overflow: auto;
}
#popup.hidden, #sheet.hidden, #quit-run.hidden { display: none; }
.popup-card, .panel {
  width: min(920px, 98vw);
  max-height: 100%;
  padding: 16px 16px 12px;
  background: linear-gradient(180deg, #0b1230, #050814);
  border: 2px solid #00e5ff;
  box-shadow: 0 0 40px #00e5ff88, inset 0 0 30px #ff00ea22;
  text-align: center;
  border-radius: 8px;
}
.popup-card { width: min(420px, 92vw); }
.popup-card img, .panel .mark { width: 88px; height: auto; margin-bottom: 4px; }
.popup-card h2, .panel h2 {
  font-size: clamp(20px, 3vh, 32px);
  color: #7ef6ff; letter-spacing: 2px; margin: 4px 0;
}
.popup-card p, .panel .big {
  font-size: clamp(22px, 4.5vh, 48px);
  color: #fff; font-weight: 900; margin: 6px 0 10px;
  text-shadow: 0 0 18px #00e5ff;
}
.panel .sub { color: #b7f7ff; font-size: clamp(14px, 2vh, 18px); margin: 2px 0 8px; line-height: 1.3; }
.panel .note { color: #ffd27a; font-size: 14px; margin-bottom: 8px; }
button, .card {
  cursor: pointer;
  border: 0;
  font-family: inherit;
}
button.go, .popup-card button, .bar button, .modes button, #quit-run {
  padding: 12px 22px;
  min-height: 48px;
  font-size: 18px; font-weight: 800; letter-spacing: 1px;
  color: #001018;
  background: linear-gradient(90deg, #00e5ff, #ff4cf0);
  border-radius: 4px;
  margin: 6px;
}
.textbtn {
  padding: 12px 22px;
  min-height: 48px;
  font-size: 16px; font-weight: 800; letter-spacing: 1px;
  border-radius: 4px;
  margin: 6px;
}
.textbtn.ghost, #quit-run {
  background: transparent;
  color: #7ef6ff;
  border: 2px solid #00e5ff;
}
#quit-run {
  position: absolute;
  z-index: 5;
  margin: 0;
}
.modes { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.modes button { min-width: 160px; }
.panel.upgrade {
  width: min(860px, 98vw);
  height: auto;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px 14px 8px;
}
.upgrade-head, .upgrade-foot { flex: 0 0 auto; }
.upgrade-head h2 { margin: 0; }
.upgrade-head .sub { margin: 0 0 8px; }
.cards {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: stretch;
  justify-content: center;
}
.card {
  flex: 1 1 200px;
  width: auto;
  max-width: 260px;
  min-width: 0;
  min-height: 48px;
  max-height: 200px;
  text-align: left;
  padding: 12px;
  color: #fff;
  background: #070d22;
  border: 2px solid #7ef6ff;
  border-radius: 8px;
}
.card img { width: 42px; height: 42px; object-fit: contain; float: right; }
.card b { display: block; color: #7ef6ff; font-size: 20px; margin-bottom: 6px; letter-spacing: 0.4px; }
.card span { display: block; font-size: 16px; line-height: 1.3; color: #e8fbff; }
@media (min-width: 1400px), (min-height: 900px) {
  .card { max-height: 220px; padding: 16px; }
  .card b { font-size: 28px; }
  .card span { font-size: 22px; }
  .panel.upgrade h2 { font-size: 40px; }
  .panel.upgrade .sub { font-size: 22px; }
}
@media (max-height: 420px) {
  .panel.upgrade { padding: 4px 8px; }
  .card { max-height: 150px; padding: 6px; }
  .card b { font-size: 15px; }
  .card span { font-size: 13px; }
  .card img { width: 28px; height: 28px; }
  button.go, .modes button, .textbtn, #quit-run { margin: 3px; padding: 8px 14px; }
}
.skins { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0 12px; }
.skins button {
  width: 56px; height: 56px; min-height: 48px;
  padding: 4px;
  background: #070d22;
  border: 2px solid #00e5ff;
  border-radius: 6px;
}
.skins img { width: 100%; height: 100%; object-fit: contain; }
.runstats { text-align: left; margin: 8px auto 12px; max-width: 520px; font-size: 16px; line-height: 1.45; }
.runstats p { margin: 8px 0; }
#splash {
  position: fixed; inset: 0;
  background: #000;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 20;
  transition: opacity 0.9s ease;
}
#splash.fade { opacity: 0; pointer-events: none; }
#splash.gone { display: none; }
#splash-logo {
  max-width: min(900px, 86vw);
  max-height: 62vh;
  height: auto;
  filter: drop-shadow(0 0 24px #00e5ff88);
}
#splash-hint {
  margin-top: 28px;
  font-size: 18px;
  letter-spacing: 4px;
  color: #7ef6ff;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}
