:root {
  --red: #ff3347; --orange: #ff8a14; --yellow: #ffd01f; --green: #38d94a; --cyan: #25c9ff; --blue: #3f6bff; --purple: #a848ff; --pink: #ff4fb8;
  --dim: #9a9aa3;
  --fat: "Lilita One", "Arial Rounded MT Bold", "Arial Black", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: #000; color: #fff; font-family: var(--body); font-weight: 700; overscroll-behavior: none; color-scheme: dark; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #fff; outline-offset: 3px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

#game { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.hud { position: fixed; z-index: 2; inset: 0 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: max(8px, env(safe-area-inset-top)) clamp(12px, 3vw, 32px) 6px; pointer-events: none; }
.side { display: flex; gap: 8px; align-items: center; min-width: 0; }
.side.r { justify-content: flex-end; }
.lnk { pointer-events: auto; padding: 10px 8px; border: 0; background: none; color: var(--dim); font: inherit; font-size: 15px; text-decoration: none; white-space: nowrap; cursor: pointer; transition: color .2s; }
.lnk:hover { color: #fff; }
.lnk.armed { color: var(--red); }
.points { display: grid; grid-template-columns: minmax(96px, 1fr) auto minmax(96px, 1fr); grid-template-areas: "best score combo"; align-items: center; gap: 22px; text-align: center; font-size: 18px; line-height: 24px; }
.score { grid-area: score; font-family: var(--fat); font-size: clamp(40px, 7vh, 64px); line-height: 1; min-width: 3ch; }
.score.hit { animation: hit .35s ease-out; }
@keyframes hit { 30% { transform: scale(1.3); } 60% { transform: scale(.96); } }
.combo.hit { animation: hit .45s ease-out; display: inline-block; }
.best { grid-area: best; justify-self: end; display: inline-flex; align-items: center; gap: 7px; color: var(--yellow); }
.best svg { width: 19px; }
.best.new { animation: hit .5s ease-out 2; }
.combo { grid-area: combo; justify-self: start; font-family: var(--fat); font-weight: 400; font-size: 21px; color: var(--cyan); }
.combo.risk { color: var(--orange); }

/* ── shouts ── */
.shout { position: fixed; z-index: 3; inset: 0; pointer-events: none; overflow: hidden; font-family: var(--fat); text-align: center; line-height: .9; }
.shout > * { position: absolute; transform: translate(-50%, -50%); white-space: nowrap; will-change: transform, opacity; }
.shout i { font-style: normal; display: block; paint-order: stroke fill; -webkit-text-stroke: .13em #000; }
.praise i { font-size: calc(var(--u) * 1.06); filter: drop-shadow(0 0 .35em currentColor); animation: praise 1.25s cubic-bezier(.2, 1.5, .4, 1) both; }
.slam i { filter: drop-shadow(0 0 .3em rgba(255, 255, 255, .35)); animation: slam 1.5s cubic-bezier(.2, 1.3, .35, 1) both; }
.slam .w { font-size: calc(var(--u) * 1.2); }
.slam .n { font-size: calc(var(--u) * (1.8 + var(--k) * .11)); animation-delay: .06s; animation-name: slamn; filter: drop-shadow(0 0 .25em #ffb300); }
.pts i { font-size: calc(var(--u) * .74); animation: pts 1.1s ease-out both; }
.clear i { font-size: calc(var(--u) * 1.35); animation: slam 2s cubic-bezier(.2, 1.3, .35, 1) both; background: linear-gradient(90deg, var(--red), var(--orange), var(--yellow), var(--green), var(--cyan), var(--purple)); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 0; filter: drop-shadow(0 4px 0 #000) drop-shadow(0 0 14px #000); }
@keyframes praise { 0% { transform: scale(.1) rotate(-14deg); opacity: 0; } 25% { transform: scale(1.12) rotate(-5deg); opacity: 1; } 75% { transform: scale(1) rotate(-5deg); opacity: 1; } 100% { transform: scale(1.06) translateY(-.5em) rotate(-5deg); opacity: 0; } }
@keyframes slam { 0% { transform: scale(3.4); opacity: 0; } 18% { transform: scale(.86); opacity: 1; } 28% { transform: scale(1.06); } 36%, 78% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
@keyframes slamn { 0% { transform: scale(4.2) rotate(-12deg); opacity: 0; } 16% { transform: scale(.8) rotate(4deg); opacity: 1; } 26% { transform: scale(1.12) rotate(-3deg); } 34% { transform: scale(.97) rotate(1deg); } 42%, 78% { transform: scale(1) rotate(0); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }
@keyframes pts { 0% { transform: scale(.4); opacity: 0; } 18% { transform: scale(1.15); opacity: 1; } 65% { opacity: 1; } 100% { transform: translateY(-.7em); opacity: 0; } }
.edge { position: fixed; z-index: 3; inset: 0; pointer-events: none; opacity: 0; box-shadow: inset 0 0 14vmin 3vmin var(--e, #fff); }
.edge.on { animation: edge .8s ease-out; }
@keyframes edge { 12% { opacity: calc(.85 * var(--eo, 1)); } 100% { opacity: 0; } }

/* ── game over ── */
.over { position: fixed; z-index: 4; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 20px; text-align: center; background: rgba(0, 0, 0, .86); animation: fade .35s both; }
@keyframes fade { from { opacity: 0; } }
.over h1 { font-family: var(--fat); font-weight: 400; font-size: clamp(34px, 6vw, 58px); }
.over .big { font-family: var(--fat); font-weight: 400; font-size: clamp(70px, 14vw, 140px); line-height: 1; color: var(--yellow); }
.over .note { color: #d0d0d6; font-size: 18px; margin-bottom: 18px; }
.again { padding: 16px 40px 18px; border: 0; border-radius: 14px; background: var(--green); color: #04230a; font-family: var(--fat); font-size: 27px; cursor: pointer; box-shadow: 0 6px 0 #1b8a2a; transition: transform .1s, box-shadow .1s, background .2s; }
.again:hover { background: #5cec6c; }
.again:active { transform: translateY(5px); box-shadow: 0 1px 0 #1b8a2a; }

@media (max-width: 900px) and (min-height: 480px) {
  .points { grid-template-columns: auto auto; grid-template-areas: "score score" "best combo"; justify-content: center; gap: 0 14px; font-size: 16px; }
  .points:has(.combo:empty) { grid-template-areas: "score" "best"; grid-template-columns: auto; }
  .points:has(.combo:empty) .best { justify-self: center; }
  .combo { font-size: 17px; }
  .combo:empty { display: none; }
}
@media (max-width: 900px) and (max-height: 479px) { .points { gap: 10px; font-size: 14px; grid-template-columns: minmax(70px, 1fr) auto minmax(70px, 1fr); } .combo { font-size: 15px; } .score { font-size: 34px; } }
@media (max-width: 620px) {
  .lnk { font-size: 13px; padding: 10px 4px; }
  .side { gap: 2px; }
  .side.r { flex-direction: column; align-items: flex-end; gap: 0; }
  .side.r .lnk { padding: 5px 4px; }
  .hud { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .shout i { animation-timing-function: ease; animation-name: plain !important; }
  .score.hit, .best.new, .edge.on, .combo.hit { animation: none; }
  @keyframes plain { 0%, 100% { opacity: 0; } 15%, 80% { opacity: 1; } }
}
