:root {
  color-scheme: light;
  --paper: #f6f0df;
  --ink: #171717;
  --pink: #ff3e88;
  --acid: #ccff00;
  --cyan: #00d7ff;
  --red: #ff463c;
  --muted: #a79f8b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
  background: #0e0e0e;
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", sans-serif;
}

body {
  min-height: 100dvh;
  color: var(--ink);
  overflow: hidden;
  touch-action: none;
  background-color: #0b0b0b;
  background-image:
    linear-gradient(90deg, rgba(255, 62, 136, .08) 1px, transparent 1px),
    linear-gradient(rgba(204, 255, 0, .06) 1px, transparent 1px);
  background-size: 26px 26px;
}

button { font: inherit; }

button:focus-visible {
  outline: 4px solid var(--cyan);
  outline-offset: 3px;
}

.game-shell {
  width: min(100%, 480px);
  height: 100dvh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--paper);
  border-inline: 3px solid var(--ink);
  box-shadow: 0 0 60px rgba(0, 0, 0, .8);
  overflow: hidden;
}

.masthead {
  min-height: 54px;
  padding: max(7px, env(safe-area-inset-top)) 10px 7px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 3px solid var(--acid);
}

.brand-lockup { line-height: .82; transform: skew(-4deg); }
.brand-lockup .eyebrow { display: block; color: var(--acid); font: 700 7px/1.2 Arial, sans-serif; letter-spacing: .19em; margin-bottom: 3px; }
.brand-lockup strong { font-size: clamp(23px, 7vw, 30px); letter-spacing: -.045em; }
.header-actions { display: flex; gap: 5px; }

.icon-button {
  min-height: 34px;
  padding: 4px 7px;
  border: 2px solid var(--paper);
  background: transparent;
  color: var(--paper);
  font: 900 9px/1 Arial, sans-serif;
  letter-spacing: .06em;
}

.icon-button:active { background: var(--pink); color: var(--ink); }

.hud {
  height: 49px;
  display: grid;
  grid-template-columns: .68fr 1.18fr .62fr 1.18fr;
  border-bottom: 3px solid var(--ink);
  background: var(--paper);
}

.hud-cell {
  min-width: 0;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 2px solid var(--ink);
}

.hud-cell:last-child { border-right: 0; text-align: right; }
.hud-cell span { font: 900 7px/1 Arial, sans-serif; letter-spacing: .12em; }
.hud-cell strong { font-size: 16px; line-height: 1; }
.dignity-cell { position: relative; }
.dignity-cell strong { position: absolute; right: 7px; top: 5px; font-size: 10px; }
.score-cell { position: relative; padding-bottom: 13px; }
.score-cell small { position: absolute; right: 7px; bottom: 3px; color: #a50f4b; font: 900 7px/1 Arial, sans-serif; letter-spacing: .06em; }
.timer-cell { padding-inline: 4px; text-align: center; }
.timer-cell strong { color: #a50f4b; font-size: 18px; }
.timer-cell.danger { background: var(--red); color: #fff; animation: clock-pulse .5s steps(2) infinite; }
.timer-cell.danger strong { color: #fff; }

@keyframes clock-pulse {
  50% { background: var(--paper); color: var(--red); }
}

.meter {
  height: 12px;
  margin-top: 4px;
  overflow: hidden;
  border: 2px solid var(--ink);
  background: var(--ink);
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--acid);
  transition: width .15s linear, background .2s;
}

.stage-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #303736;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  background: #303736;
  touch-action: none;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
}

[hidden] { display: none !important; }

.start-screen {
  overflow: hidden;
  background-color: var(--paper);
  background-image:
    linear-gradient(155deg, transparent 0 45%, rgba(0, 215, 255, .18) 45% 49%, transparent 49%),
    radial-gradient(circle at 25% 25%, var(--acid) 0 2px, transparent 2.5px);
  background-size: auto, 13px 13px;
}

.start-screen::before {
  content: "";
  position: absolute;
  inset: auto -20% 14% 28%;
  height: 34%;
  z-index: 0;
  background: var(--pink);
  transform: rotate(-9deg);
  border-block: 4px solid var(--ink);
}

.age-stamp {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: -38px;
  width: 150px;
  padding: 5px;
  text-align: center;
  transform: rotate(34deg);
  border-block: 2px solid var(--ink);
  background: var(--acid);
  font: 900 8px/1 Arial, sans-serif;
  letter-spacing: .06em;
}

.start-copy {
  position: absolute;
  z-index: 3;
  top: 5%;
  left: 5%;
  width: 57%;
  transform: rotate(-2deg);
}

.kicker {
  margin: 0 0 5px;
  font: 900 9px/1 Arial, sans-serif;
  letter-spacing: .17em;
  color: #8d0d40;
}

.start-copy h1 {
  margin: 0;
  font-size: clamp(46px, 14vw, 72px);
  line-height: .72;
  letter-spacing: -.065em;
  text-shadow: 4px 4px 0 var(--cyan);
}

.start-copy h1 em { color: var(--pink); font-style: normal; text-shadow: 4px 4px 0 var(--ink); }
.start-copy > p:last-child { max-width: 190px; margin: 14px 0 0; font: 800 12px/1.25 Arial, sans-serif; text-transform: uppercase; }

.hero-character {
  position: absolute;
  z-index: 2;
  width: min(73%, 330px);
  height: 84%;
  right: -16%;
  bottom: 5%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(8px 9px 0 rgba(0, 0, 0, .9));
  pointer-events: none;
}

.start-actions {
  position: absolute;
  z-index: 5;
  left: 5%;
  right: 5%;
  bottom: max(3%, var(--safe-bottom));
}

.player-setup {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 4px 8px;
  margin: 0 0 9px;
  padding: 7px 9px;
  border: 3px solid var(--ink);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--cyan);
  transform: rotate(.6deg);
}

.player-setup span { font-size: 13px; white-space: nowrap; }
.player-setup input {
  min-width: 0;
  width: 100%;
  padding: 6px 8px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: 900 15px/1 Arial, sans-serif;
  text-transform: uppercase;
}
.player-setup input.invalid { border-color: var(--red); background: #ffe0dc; }
.player-setup small {
  grid-column: 1 / -1;
  font: 800 7px/1.1 Arial, sans-serif;
  letter-spacing: .04em;
}

.main-button {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  background: var(--acid);
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  font-size: clamp(20px, 6vw, 28px);
  line-height: .95;
  letter-spacing: -.025em;
  transform: skew(-3deg);
}

.main-button:active { transform: translate(4px, 4px) skew(-3deg); box-shadow: 1px 1px 0 var(--ink); }

.text-button {
  display: block;
  margin: 13px auto 0;
  padding: 3px;
  border: 0;
  border-bottom: 2px solid currentColor;
  background: transparent;
  color: inherit;
  font: 900 10px/1 Arial, sans-serif;
  letter-spacing: .06em;
}

.start-links { display: flex; justify-content: center; gap: 24px; }
.start-links .text-button { margin-inline: 0; }

.how-panel {
  position: absolute;
  z-index: 7;
  left: 5%;
  right: 5%;
  bottom: 17%;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  background: var(--cyan);
  box-shadow: 5px 5px 0 var(--ink);
  font: 800 12px/1.35 Arial, sans-serif;
  text-transform: uppercase;
}

.message-screen {
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(9, 9, 9, .82);
  backdrop-filter: blur(4px);
}

.message-card {
  width: 100%;
  padding: 22px 20px 20px;
  border: 4px solid var(--ink);
  background: var(--paper);
  box-shadow: 9px 9px 0 var(--pink);
  transform: rotate(-1deg);
}

.message-card h2 {
  margin: 5px 0 10px;
  color: var(--ink);
  font-size: clamp(34px, 11vw, 56px);
  line-height: .82;
  letter-spacing: -.05em;
}

.message-card > p:not(.kicker) { margin: 0 0 18px; font: 800 14px/1.35 Arial, sans-serif; text-transform: uppercase; }
.message-card .main-button { font-size: 21px; }

.message-stats {
  margin: 0 0 16px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 2px solid var(--ink);
  background: var(--acid);
  font: 900 12px/1.2 Arial, sans-serif;
}

.message-stats b { display: block; font-size: 22px; }

.pause-screen {
  z-index: 25;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 215, 255, .88);
}

.pause-card { width: 100%; text-align: center; transform: rotate(1deg); }
.pause-card > span { display: block; font: 900 11px/1 Arial, sans-serif; letter-spacing: .2em; }
.pause-card > strong { display: block; margin: 8px 0 24px; font-size: 46px; line-height: .82; }

.leaderboard-screen {
  z-index: 28;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(9, 9, 9, .88);
  backdrop-filter: blur(4px);
}

.leaderboard-card {
  width: 100%;
  max-height: 96%;
  overflow: auto;
  padding: 18px 16px 16px;
  border: 4px solid var(--ink);
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--cyan);
  transform: rotate(-.5deg);
}

.leaderboard-card h2 { margin: 5px 0 7px; font-size: clamp(32px, 10vw, 48px); line-height: .82; letter-spacing: -.045em; }
.leaderboard-note { margin: 0 0 12px; font: 800 10px/1.25 Arial, sans-serif; text-transform: uppercase; }
.leaderboard-list { margin: 0 0 14px; padding: 0; list-style: none; border: 3px solid var(--ink); }
.leaderboard-list li {
  min-height: 47px;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 1px 7px;
  border-bottom: 2px solid var(--ink);
  background: #fff;
  font-family: Arial, sans-serif;
}
.leaderboard-list li:nth-child(odd) { background: #efffb7; }
.leaderboard-list li:last-child { border-bottom: 0; }
.leaderboard-list li > b { grid-row: 1 / 3; color: #a50f4b; font-size: 16px; }
.leaderboard-list li > strong { min-width: 0; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-list li > small { grid-column: 2; font-size: 7px; font-weight: 800; letter-spacing: .04em; }
.leaderboard-list li > span { grid-column: 3; grid-row: 1 / 3; font-weight: 900; font-size: 16px; }
.leaderboard-list .leaderboard-empty { display: block; padding: 18px 10px; text-align: center; font-weight: 900; }
.leaderboard-card .main-button { min-height: 46px; font-size: 20px; }

.touch-controls {
  position: absolute;
  z-index: 10;
  left: 13px;
  right: 13px;
  bottom: calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: row-reverse;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.joystick {
  position: relative;
  width: 104px;
  height: 104px;
  border: 3px solid rgba(23, 23, 23, .85);
  border-radius: 50%;
  background: rgba(246, 240, 223, .74);
  box-shadow: inset 0 0 0 9px rgba(255, 62, 136, .22);
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

.joystick:active { cursor: grabbing; }

.joystick::before,
.joystick::after { content: ""; position: absolute; inset: 50% 10px auto; border-top: 1px solid rgba(23, 23, 23, .25); }
.joystick::after { transform: rotate(90deg); }

.joystick small {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -15px;
  text-align: center;
  font: 900 7px/1 Arial, sans-serif;
  letter-spacing: .08em;
}

.joystick-nub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 47px;
  height: 47px;
  margin: -23.5px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--pink);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, .7);
  transform: translate(0, 0);
}

.dash-button {
  width: 82px;
  height: 82px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--acid);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  pointer-events: auto;
  touch-action: manipulation;
}

.dash-button b { display: block; font-size: 21px; line-height: .9; }
.dash-button span { font: 900 7px/1 Arial, sans-serif; letter-spacing: .08em; }
.dash-button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.dash-button[disabled] { background: #aaa38f; color: #5e594e; }

.taunt-banner {
  position: absolute;
  z-index: 12;
  top: 12px;
  left: 50%;
  width: min(88%, 360px);
  padding: 8px 12px;
  transform: translateX(-50%) rotate(-1deg);
  border: 3px solid var(--ink);
  background: var(--pink);
  box-shadow: 4px 4px 0 var(--ink);
  text-align: center;
  font-size: clamp(15px, 4.6vw, 21px);
  line-height: .95;
  animation: heckle .2s steps(2) both;
}

@keyframes heckle {
  0% { transform: translateX(-50%) translateY(-16px) rotate(3deg) scale(.92); }
  100% { transform: translateX(-50%) translateY(0) rotate(-1deg) scale(1); }
}

.footer-strip {
  min-height: calc(29px + var(--safe-bottom));
  padding: 7px 9px calc(7px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 3px solid var(--ink);
  background: var(--pink);
  font: 900 8px/1 Arial, sans-serif;
  letter-spacing: .04em;
}

.footer-strip b { color: #fff; }

@media (min-width: 600px) {
  body { padding: 18px 0; }
  .game-shell { height: calc(100dvh - 36px); border: 3px solid var(--ink); }
}

@media (max-height: 650px) {
  .masthead { min-height: 44px; }
  .hud { height: 43px; }
  .brand-lockup strong { font-size: 21px; }
  .start-copy { top: 3%; }
  .start-copy h1 { font-size: 42px; }
  .start-copy > p:last-child { display: none; }
  .player-setup { margin-bottom: 6px; padding-block: 5px; }
  .player-setup small { display: none; }
  .joystick { width: 88px; height: 88px; }
  .dash-button { width: 72px; height: 72px; }
  .touch-controls { bottom: calc(20px + var(--safe-bottom)); }
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls { opacity: .72; }
  button:hover { filter: brightness(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
