:root {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  color: #fff4ff;
  background: #160f2e;
  color-scheme: dark;
  --pink: #ff6b9d;
  --cyan: #5ee7f5;
  --yellow: #ffd75e;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  padding: env(safe-area-inset-top) 12px calc(12px + env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 15% 10%, #3b2167 0, transparent 45%),
    radial-gradient(circle at 90% 0%, #163a59 0, transparent 40%),
    #160f2e;
  text-align: center;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 4px 6px;
}
.top-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.weapon-bar {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(8, 6, 16, .6);
  border: 1px solid rgba(255, 255, 255, .18);
}
.weapon {
  padding: 6px 11px;
  font-size: .78rem;
  color: #cfc2e8;
  background: transparent;
  box-shadow: none;
  border-radius: 999px;
}
.weapon[aria-pressed="true"] {
  color: #1c1233;
  background: linear-gradient(#ffe58a, #ffc93d);
  box-shadow: 0 2px 0 #b67b12;
}
.weapon[data-weapon="jelly"][aria-pressed="true"] { background: linear-gradient(#ffb8d2, #ff6b9d); box-shadow: 0 2px 0 #a62661; }
.weapon[data-weapon="zap"][aria-pressed="true"] { background: linear-gradient(#c9fbff, #5ee7f5); box-shadow: 0 2px 0 #1c7f93; }
.weapon[data-weapon="shoot"][aria-pressed="true"] { background: linear-gradient(#ffe58a, #ffc93d); box-shadow: 0 2px 0 #b67b12; }
h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 14px rgba(255, 107, 157, .75);
}
main { max-width: 980px; margin: 0 auto; }
button {
  font: inherit;
  font-weight: 700;
  color: #1c1233;
  background: linear-gradient(#ffe58a, #ffc93d);
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 0 #b67b12;
}
button:active { transform: translateY(2px); box-shadow: 0 2px 0 #b67b12; }
button:disabled { opacity: .55; }
button:focus-visible { outline: 3px solid #5ee7f5; outline-offset: 3px; }
#sound-button,
.pause-button {
  font-size: .8rem;
  padding: 8px 14px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, .3);
}
.stage {
  position: relative;
  width: 100%;
  height: clamp(340px, calc(100dvh - 190px), 660px);
  border-radius: 22px;
  overflow: hidden;
  background: #0e0a22;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .08);
  touch-action: none;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}
.pause-button:active { transform: translateY(1px); box-shadow: none; }
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(10, 6, 26, .68);
  backdrop-filter: blur(3px);
  transition: opacity .18s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.card {
  width: min(440px, 100%);
  padding: clamp(18px, 3vw, 30px);
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(62, 32, 102, .96), rgba(25, 17, 52, .97));
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}
.eyebrow {
  margin: 0 0 6px;
  font-size: .74rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--cyan);
}
.card h2 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  line-height: 1.05;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 107, 157, .7);
}
.card p { margin: 0 0 12px; line-height: 1.45; color: #e5d9ff; }
.card .controls { font-size: .82rem; color: #b9a8dc; }
.card button { margin-top: 6px; min-width: 150px; }
.hint {
  margin: 10px auto 18px;
  max-width: 720px;
  font-size: .82rem;
  color: #b9a8dc;
  line-height: 1.4;
}
.scores {
  margin: 0 auto 28px;
  max-width: 520px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
}
.scores h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}
#scores-status { margin: 0 0 10px; font-size: .85rem; color: #bfb0e0; min-height: 1.2em; }
#scores-board {
  margin: 0 auto 14px;
  padding-left: 1.6em;
  max-width: 320px;
  text-align: left;
  line-height: 1.75;
  font-variant-numeric: tabular-nums;
}
#scores-board:empty { display: none; }
#scores-board li::marker { color: var(--yellow); font-weight: 700; }
#score-form { margin: 14px 0; }
#score-form-label { margin: 0 0 10px; color: var(--yellow); font-size: .9rem; }
.fields { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .78rem; color: #bfb0e0; text-align: left; }
input {
  font: inherit;
  color: #fff;
  background: rgba(0, 0, 0, .35);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 10px;
  padding: 9px 10px;
  width: 6.5em;
  text-transform: uppercase;
}
.refresh {
  background: transparent;
  color: #d9ccff;
  border: 1px solid rgba(255, 255, 255, .25);
  box-shadow: none;
  font-size: .8rem;
  padding: 8px 16px;
}
.refresh:active { transform: translateY(1px); box-shadow: none; }
@media (max-width: 480px) {
  body { padding-left: 8px; padding-right: 8px; }
  .topbar { padding-top: 6px; }
  h1 { font-size: 1.15rem; }
  .weapon { padding: 6px 9px; font-size: .72rem; }
  .stage { border-radius: 16px; height: clamp(360px, calc(100dvh - 190px), 600px); }
  .hint { font-size: .75rem; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .stage { height: calc(100dvh - 88px); min-height: 280px; }
  .hint { display: none; }
  .topbar { padding: 4px; }
  .overlay { align-items: flex-start; overflow: auto; padding: 10px; }
  .card { padding: 12px 18px; }
  .card h2 { font-size: 1.5rem; margin-bottom: 5px; }
  .card p { font-size: .8rem; line-height: 1.35; margin-bottom: 6px; }
  .card .controls { font-size: .7rem; }
  .card button { padding: 8px 18px; margin-top: 2px; }
  .eyebrow { font-size: .62rem; margin-bottom: 2px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
