:root {
  --bg: #120818;
  --ink: #fff7ea;
  --muted: rgba(255, 247, 234, 0.72);
  --yellow: #ffe500;
  --pink: #ff3cac;
  --danger: #ff5b3a;
  --line: #1a1020;
  --display: Impact, "Arial Black", Haettenschweiler, sans-serif;
  --body: "Trebuchet MS", "Segoe UI", sans-serif;
  --tempo: 0.9s;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--body);
  font-weight: 700;
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(255, 229, 0, 0.22), transparent 55%),
    radial-gradient(820px 520px at 110% 0%, rgba(255, 60, 172, 0.28), transparent 50%),
    radial-gradient(700px 420px at 50% 120%, rgba(255, 229, 0, 0.08), transparent 45%),
    var(--bg);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 18px 18px;
}

button, input { font: inherit; }

.app {
  width: min(520px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(0.8rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(1.2rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
  position: relative;
}

.app.shake { animation: shake 0.35s linear; }

.top { position: relative; }

.top { display: flex; flex-direction: column; align-items: stretch; }

.icon-btn {
  align-self: flex-end;
  z-index: 2;
  width: 2.75rem;
  height: 2.75rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  font-size: 1.2rem;
}

.hero-mark {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 0.2rem;
}

.hand {
  color: var(--yellow);
  transform-origin: 50% 85%;
  animation: weigh-left var(--tempo) ease-in-out infinite;
}

.hand.right {
  color: var(--pink);
  animation-name: weigh-right;
}

.hand svg { display: block; width: 72px; height: 96px; }
.hand.right svg { transform: scaleX(-1); }

.brand { text-align: center; }

.logo {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(4.4rem, 20vw, 6.4rem);
  font-weight: 400;
  line-height: 0.8;
  letter-spacing: -0.04em;
}

.logo .s { color: var(--yellow); }
.logo .dash { color: white; }
.logo .e { color: var(--pink); }

.sub {
  margin: 0.15rem 0 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 0.92rem;
}

.view { display: none; }
.view.is-on {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  flex: 1;
  min-height: 0;
}

.tape {
  align-self: center;
  margin: 0;
  background: var(--yellow);
  color: var(--line);
  padding: 0.2rem 0.7rem;
  transform: rotate(-2deg);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.25);
  letter-spacing: 0.04em;
}

.rule {
  margin: 0;
  text-align: center;
  font-size: 1.05rem;
  line-height: 1.35;
}

.rule b, .how b { color: var(--yellow); }

.play-btn {
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
  letter-spacing: 0.03em;
  color: var(--line);
  background: var(--yellow);
  border: 4px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 7px 0 var(--line);
  padding: 0.7rem 1.4rem;
  cursor: pointer;
  width: 100%;
}

.play-btn:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--line);
}

.play-btn:disabled { opacity: 0.65; cursor: default; }

.how {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}

.how li {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 0.5rem 0.7rem;
}

.how .n {
  width: 1.8rem;
  height: 1.8rem;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--line);
  font-family: var(--display);
  font-weight: 400;
}

.how li span:last-child { line-height: 1.35; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chips li {
  background: rgba(255, 229, 0, 0.12);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.85rem;
}

.board-block { display: grid; gap: 0.45rem; }

h2 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
}

h2 span {
  color: var(--muted);
  font-family: var(--body);
  font-size: 0.95rem;
  letter-spacing: 0;
}

.board {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.board li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.board li.empty { display: block; color: var(--muted); }

.board li.is-me { outline: 2px solid var(--yellow); }

.pos {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.3rem;
  color: var(--yellow);
}

.board li:nth-child(2) .pos { color: white; }
.board li:nth-child(3) .pos { color: var(--pink); }

.who { display: block; font-weight: 800; }
.when {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.pts {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.35rem;
}

.foot {
  margin-top: auto;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.foot p { margin: 0; }

.texty {
  background: none;
  border: 0;
  color: var(--muted);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 0.35rem;
}

.app.is-playing {
  height: 100dvh;
  overflow: hidden;
  user-select: none;
}

.app.is-playing .icon-btn {
  width: 2.2rem;
  height: 2.2rem;
  margin-bottom: -0.4rem;
}
.app.is-playing .sub,
.app.is-playing .hand { display: none; }
.app.is-playing .logo { font-size: 2.3rem; }
.app.is-playing .hero-mark { grid-template-columns: 1fr; }

.hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.7rem;
  align-items: center;
}

.stat { display: flex; flex-direction: column; align-items: center; min-width: 3.2rem; }
.stat strong {
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.8rem;
  line-height: 0.9;
}
.stat span {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat strong.bump { animation: bump 0.18s ease-out; }

.bar {
  height: 0.7rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.bar div {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--yellow), var(--pink));
  border-radius: inherit;
}

.pips {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  min-height: 1.1rem;
}

.pips i {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  display: block;
}

.pips i.on { background: var(--yellow); }
.pips.max i.on { background: var(--pink); box-shadow: 0 0 0 2px white; }
.pips span {
  margin-left: 0.25rem;
  font-family: var(--display);
  font-weight: 400;
  color: var(--yellow);
  min-width: 1.6rem;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.feedback {
  margin: 0;
  min-height: 1.6rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  letter-spacing: 0.04em;
}

.feedback.good { color: var(--yellow); }
.feedback.bad { color: var(--danger); }
.feedback.miss { color: var(--pink); }

.figure {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(6rem, 34vw, 10rem);
  line-height: 0.85;
  color: white;
  text-shadow: 0.055em 0.055em 0 var(--pink), -0.02em -0.02em 0 var(--yellow);
}

.figure.pop { animation: pop 0.18s ease-out; }

.armed {
  margin: 0.2rem 0 0;
  min-height: 1.3rem;
  color: var(--yellow);
  letter-spacing: 0.04em;
}

.floater {
  position: absolute;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 400;
  font-size: 2rem;
  color: var(--yellow);
  pointer-events: none;
  animation: float-up 0.6s ease-out forwards;
}

.pad {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.key {
  font-family: var(--display);
  font-weight: 400;
  font-size: 4.2rem;
  line-height: 1;
  min-height: 104px;
  border-radius: 28px;
  border: 4px solid var(--line);
  box-shadow: 0 8px 0 var(--line);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.key[data-d="6"] { background: var(--yellow); color: var(--line); }
.key[data-d="7"] { background: var(--pink); color: var(--line); }

.key:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 var(--line);
}

.key.is-lit { outline: 4px solid white; outline-offset: 3px; }

.pad.coach .key { animation: coach 0.55s ease-in-out infinite; }

.pad.wait7 .key[data-d="7"] { outline: 4px solid white; outline-offset: 3px; }

.keys-hint {
  margin: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

#play .texty { align-self: center; }

#result.is-on { position: relative; text-align: center; }

.kicker {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--yellow);
}

.big-score {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(4.2rem, 18vw, 6rem);
  line-height: 0.85;
  color: white;
  text-shadow: 0.06em 0.06em 0 var(--pink), -0.02em -0.02em 0 var(--yellow);
}

.score-label {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.final-stats { margin: 0; }

#saveForm {
  text-align: left;
  display: grid;
  gap: 0.35rem;
}

#saveForm label { font-size: 0.95rem; }

input[type="text"], #name {
  width: 100%;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 0.8rem 1rem;
  border-radius: 16px;
  border: 3px solid var(--line);
  background: var(--ink);
  color: var(--line);
}

.form-error {
  margin: 0;
  min-height: 1.2rem;
  color: var(--danger);
}

.saved-msg {
  margin: 0;
  font-size: 1.15rem;
}

.row-actions { display: grid; gap: 0.2rem; justify-items: center; }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti span {
  position: absolute;
  top: -8%;
  font-family: var(--display);
  font-size: 1.8rem;
  animation: fall 1.05s ease-in forwards;
}

.toast {
  position: fixed;
  z-index: 6;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: min(92vw, 420px);
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.noscript {
  max-width: 28rem;
  margin: 1rem auto;
  text-align: center;
}

:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

::selection { background: var(--yellow); color: var(--line); }

@keyframes weigh-left {
  0%, 100% { transform: translateY(8px) rotate(-10deg); }
  50% { transform: translateY(-8px) rotate(8deg); }
}

@keyframes weigh-right {
  0%, 100% { transform: translateY(-8px) rotate(10deg); }
  50% { transform: translateY(8px) rotate(-8deg); }
}

@keyframes pop {
  0% { transform: scale(0.82); }
  100% { transform: scale(1); }
}

@keyframes bump {
  50% { transform: scale(1.18); }
}

@keyframes coach {
  50% { transform: translateY(-4px); }
}

@keyframes float-up {
  to { transform: translate(-50%, -36px); opacity: 0; }
}

@keyframes fall {
  to { transform: translateY(68vh) rotate(18deg); opacity: 0; }
}

@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}

@media (hover: none) {
  .keys-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hand,
  .floater,
  .confetti span,
  .app.shake,
  .figure.pop,
  .pad.coach .key,
  .stat strong.bump {
    animation: none !important;
  }
}
