:root {
  --ink: #171711;
  --paper: #f2cf45;
  --hot: #ff5c35;
  --cream: #fff5cf;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

body {
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.game-shell {
  width: min(100%, 680px);
  height: 100vh;
  height: 100dvh;
  min-height: 430px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--paper);
  border-inline: 1px solid rgba(255, 245, 207, 0.14);
}

.hud {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 74px;
  padding: 0 20px;
  border-bottom: 3px solid var(--ink);
  background: var(--paper);
}

.wordmark {
  width: max-content;
  color: inherit;
  font-size: 13px;
  font-weight: 900;
  line-height: 0.86;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.wordmark span,
.wordmark b {
  display: block;
}

.wordmark b {
  color: var(--hot);
  font-size: 15px;
}

.streak {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.streak strong {
  font-size: 27px;
  line-height: 1;
  letter-spacing: -0.06em;
}

.sound-toggle {
  justify-self: end;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 8px;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.sound-toggle svg {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound-toggle .sound-off,
.sound-toggle.is-muted .sound-on {
  display: none;
}

.sound-toggle.is-muted .sound-off {
  display: block;
}

.playfield {
  position: relative;
  height: calc(100% - 74px);
  overflow: hidden;
  isolation: isolate;
  background-color: var(--paper);
  background-image: radial-gradient(rgba(23, 23, 17, 0.14) 0.8px, transparent 0.8px);
  background-size: 11px 11px;
}

.playfield::after {
  content: "";
  position: absolute;
  z-index: 12;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(23, 23, 17, 0.2);
}

.playfield::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 111px;
  right: 0;
  left: 0;
  border-top: 2px solid rgba(23, 23, 17, 0.18);
  pointer-events: none;
}

.rods,
.effects {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.rods {
  z-index: 3;
}

.rod {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  place-items: center;
  width: 50px;
  height: 86px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  pointer-events: auto;
  cursor: crosshair;
  opacity: 0.64;
  transition: opacity 80ms ease;
  will-change: transform;
}

.rod.is-released {
  opacity: 1;
}

.rod::before {
  content: "";
  grid-area: 1 / 1;
  width: 24px;
  height: 62px;
  background: var(--ink);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(255, 92, 53, 0.85);
}

.rod-key {
  position: relative;
  z-index: 1;
  display: none;
  grid-area: 1 / 1;
  color: var(--cream);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: -0.02em;
  pointer-events: none;
}

.rod:focus-visible::before {
  outline: 3px solid var(--cream);
  outline-offset: 3px;
}

.rod.is-caught {
  pointer-events: none;
}

.rod.is-caught::before {
  animation: rod-pop 120ms ease-out forwards;
}

.effects {
  z-index: 11;
}

.catch-ring {
  position: absolute;
  width: 24px;
  height: 24px;
  margin: -12px;
  border: 4px solid var(--hot);
  border-radius: 50%;
  animation: ring-pop 180ms ease-out forwards;
}

.catch-ring::before,
.catch-ring::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: var(--ink);
  box-shadow: 23px 1px 0 var(--ink), -18px 15px 0 var(--ink), 3px -22px 0 var(--ink);
}

.catch-ring::before {
  transform: translate(-50%, -50%) rotate(14deg);
}

.catch-ring::after {
  transform: translate(-50%, -50%) rotate(105deg);
}

.progress {
  position: absolute;
  z-index: 15;
  bottom: 18px;
  left: 50%;
  display: flex;
  gap: 8px;
  padding: 8px 11px;
  border: 2px solid var(--ink);
  border-radius: 30px;
  background: var(--paper);
  transform: translateX(-50%);
}

.progress i {
  display: block;
  width: 9px;
  height: 9px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  transition: background 90ms ease, transform 90ms ease;
}

.progress i.is-caught {
  background: var(--hot);
  transform: scale(1.2);
}

.wave-message {
  position: absolute;
  z-index: 14;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  width: max-content;
  padding: 12px 18px;
  color: var(--cream);
  background: var(--hot);
  box-shadow: 6px 6px 0 var(--ink);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -45%) scale(0.88) rotate(-2deg);
}

.wave-message.is-visible {
  animation: message-in 500ms ease both;
}

.wave-message span {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.wave-message strong {
  margin-top: 3px;
  font-size: clamp(25px, 6vw, 40px);
  line-height: 1;
  letter-spacing: -0.06em;
}

.overlay {
  position: absolute;
  z-index: 25;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--paper);
  opacity: 0;
  visibility: hidden;
  transition: opacity 160ms ease, visibility 160ms ease;
}

.overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.title-card {
  display: grid;
  justify-items: center;
  width: min(100%, 430px);
  text-align: center;
}

.title-rods {
  display: flex;
  align-items: flex-end;
  gap: 11px;
  height: 64px;
  margin-bottom: 17px;
}

.title-rods i {
  display: block;
  width: 14px;
  height: 47px;
  background: var(--ink);
  box-shadow: 3px 3px 0 var(--hot);
  animation: title-bob 1.2s ease-in-out infinite alternate;
}

.title-rods i:nth-child(2) {
  height: 61px;
  animation-delay: -0.5s;
}

.title-rods i:nth-child(3) {
  height: 37px;
  animation-delay: -0.9s;
}

.eyebrow {
  margin: 0 0 9px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.22em;
}

h1 {
  margin: 0;
  font-size: clamp(64px, 18vw, 108px);
  font-weight: 950;
  line-height: 0.72;
  letter-spacing: -0.085em;
}

h1 em {
  color: var(--hot);
  font-style: normal;
}

.instruction {
  margin: 32px 0 12px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.best-line {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.best-line strong {
  color: var(--hot);
  font-size: 15px;
}

.start-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 250px);
  min-height: 56px;
  margin-top: 13px;
  padding: 0 12px 0 20px;
  color: var(--cream);
  border: 0;
  border-radius: 0;
  background: var(--ink);
  box-shadow: 6px 6px 0 var(--hot);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.13em;
  cursor: pointer;
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.start-button i {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--ink);
  background: var(--paper);
  font-size: 20px;
  font-style: normal;
}

.start-button:active {
  box-shadow: 2px 2px 0 var(--hot);
  transform: translate(4px, 4px);
}

.start-button:focus-visible,
.sound-toggle:focus-visible,
.wordmark:focus-visible {
  outline: 3px solid var(--hot);
  outline-offset: 4px;
}

.game-shell.is-shaking {
  animation: shake 160ms linear;
}

.playfield.is-miss {
  animation: miss-flash 240ms ease-out;
}

@keyframes rod-pop {
  60% { transform: scale(1.25, 0.35); background: var(--hot); }
  100% { transform: scale(0); opacity: 0; }
}

@keyframes ring-pop {
  from { opacity: 1; transform: scale(0.35); }
  to { opacity: 0; transform: scale(2.4); }
}

@keyframes message-in {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.75) rotate(-2deg); }
  18%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(0.96) rotate(-2deg); }
}

@keyframes title-bob {
  from { transform: translateY(-2px); }
  to { transform: translateY(7px); }
}

@keyframes shake {
  0%, 100% { transform: translate(0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -1px); }
  75% { transform: translate(-2px, -2px); }
}

@keyframes miss-flash {
  0%, 100% { background-color: var(--paper); }
  25% { background-color: var(--hot); }
}

@media (max-height: 600px) {
  .hud { height: 60px; }
  .playfield { height: calc(100% - 60px); }
  .title-rods { display: none; }
  .instruction { margin-top: 25px; }
}

@media (min-width: 700px) {
  .rod-key {
    display: block;
  }
}

@media (hover: hover) {
  .start-button:hover {
    transform: translate(-2px, -2px);
    box-shadow: 8px 8px 0 var(--hot);
  }

  .sound-toggle:hover {
    color: var(--paper);
    background: var(--ink);
  }
}

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