:root {
  --ink-deep: #1d2a36;
  --ink-soft: #324555;
  --paper: #f7f2e5;
  --paper-soft: #efe5cf;
  --mint: #58b7a4;
  --sun: #f6be58;
  --coral: #ea866f;
  --sky: #7eb8e5;
  --panel: rgba(247, 242, 229, 0.8);
  --panel-line: rgba(29, 42, 54, 0.26);
  --text-main: #1d2a36;
  --font-ui: "VT323", "Noto Sans KR", monospace;
  --font-display: "Press Start 2P", "VT323", monospace;
  --button-bg: linear-gradient(180deg, #fffdf0 0%, #ffe8b8 56%, #efbe6e 100%);
  --button-border: rgba(29, 42, 54, 0.62);
  --button-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.52) inset,
    0 6px 12px rgba(29, 42, 54, 0.16);
  --rank-panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.74) 0%, rgba(255, 245, 226, 0.84) 100%);
  --rank-line: rgba(29, 42, 54, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  font-size: 17px;
}

body {
  margin: 0;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  font-family: var(--font-ui);
  line-height: 1.35;
  color: var(--text-main);
  background:
    radial-gradient(46% 36% at 16% 8%, rgba(126, 184, 229, 0.38), transparent 72%),
    radial-gradient(54% 40% at 88% 14%, rgba(246, 190, 88, 0.34), transparent 76%),
    radial-gradient(60% 44% at 50% 96%, rgba(234, 134, 111, 0.3), transparent 74%),
    linear-gradient(180deg, #f6efe2 0%, #f1e0be 42%, #ecd39a 100%);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.app {
  width: min(95vw, 472px);
  padding: 0.85rem;
}

.game-shell {
  position: relative;
  aspect-ratio: 9 / 16;
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid rgba(29, 42, 54, 0.36);
  box-shadow:
    0 24px 48px rgba(29, 42, 54, 0.24),
    0 0 0 1px rgba(255, 255, 255, 0.56) inset;
  animation: shell-intro 520ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.game-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(44% 30% at 84% 12%, rgba(255, 255, 255, 0.32), transparent 70%),
    radial-gradient(42% 28% at 10% 90%, rgba(255, 255, 255, 0.2), transparent 75%);
  mix-blend-mode: soft-light;
  opacity: 0.62;
}

.game-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(180deg,
      rgba(255, 255, 255, 0.06) 0,
      rgba(255, 255, 255, 0.06) 1px,
      transparent 1px,
      transparent 4px);
  mix-blend-mode: overlay;
  opacity: 0.35;
}

@keyframes shell-intro {
  from {
    transform: translateY(12px) scale(0.985);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
}

.start-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-content: center;
  gap: 0.52rem;
  text-align: center;
  padding: 1.45rem;
  background:
    radial-gradient(56% 40% at 50% 28%, rgba(255, 255, 255, 0.36), transparent 74%),
    linear-gradient(180deg, rgba(247, 242, 229, 0.9), rgba(238, 225, 194, 0.9));
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.start-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.start-overlay.mode-start .end-only {
  display: none;
}

.start-overlay.mode-result .start-only {
  display: none;
}

.start-kicker {
  margin: 0;
  font-size: 1.02rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(29, 42, 54, 0.78);
}

.start-title {
  margin: 0.25rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 3.8vw, 1.18rem);
  line-height: 1.5;
  letter-spacing: 0.04em;
  color: var(--ink-deep);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.end-result {
  margin: 0.1rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(0.8rem, 3.4vw, 1rem);
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}

.end-score {
  margin: 0;
  font-size: 1.06rem;
  letter-spacing: 0.1em;
  color: #258778;
  text-shadow: 0 0 5px rgba(88, 183, 164, 0.34);
}

.end-message {
  margin: 0.1rem auto 0.22rem;
  width: min(100%, 340px);
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(29, 42, 54, 0.2);
  background: rgba(255, 255, 255, 0.7);
  color: rgba(29, 42, 54, 0.92);
  font-size: 0.98rem;
  letter-spacing: 0.02em;
  line-height: 1.24;
  text-align: center;
}

.clear-reward-link {
  width: min(100%, 340px);
  justify-self: center;
  margin: 0 auto 0.14rem;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(29, 42, 54, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78) 0%, rgba(255, 248, 236, 0.8) 100%);
  color: rgba(29, 42, 54, 0.94);
  text-decoration: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.68) inset,
    0 4px 10px rgba(29, 42, 54, 0.1);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.clear-reward-link[hidden] {
  display: none;
}

.clear-reward-link:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 88, 88, 0.5);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 6px 12px rgba(29, 42, 54, 0.14);
}

.clear-reward-link:active {
  transform: translateY(1px);
}

.clear-reward-link:focus-visible {
  outline: 2px solid rgba(29, 42, 54, 0.78);
  outline-offset: 1px;
}

.clear-reward-icon {
  position: relative;
  width: 24px;
  height: 16px;
  border-radius: 5px;
  background: linear-gradient(180deg, #ff5f5f 0%, #ff2f2f 100%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.32) inset,
    0 2px 4px rgba(104, 22, 22, 0.26);
  flex: none;
}

.clear-reward-icon::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 4px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 7px solid #fff;
}

.clear-reward-text {
  display: block;
  flex: 1;
  text-align: left;
  letter-spacing: 0.01em;
  line-height: 1.18;
  font-size: 0.96rem;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.blink {
  animation: blink 1s step-end infinite;
}

.start-help {
  margin: 0;
  justify-self: center;
  width: min(100%, 340px);
  padding: 9px 12px 9px 34px;
  border-radius: 9px;
  border: 1px solid rgba(29, 42, 54, 0.3);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.68) 0%,
    rgba(255, 246, 228, 0.72) 100%
  );
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.74) inset,
    0 6px 12px rgba(29, 42, 54, 0.09);
  text-align: left;
  font-size: 0.98rem;
  line-height: 1.22;
  letter-spacing: 0.015em;
  color: rgba(29, 42, 54, 0.9);
  position: relative;
}

.start-help::before {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(29, 42, 54, 0.72);
  font-size: 0.88rem;
}

.start-help.help-drill::before {
  content: "▶";
}

.start-help.help-clear::before {
  content: "♬";
}

.start-nick {
  margin-top: 0.12rem;
  display: grid;
  gap: 0.2rem;
  justify-items: center;
}

.start-nick-label {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0.08em;
  color: rgba(29, 42, 54, 0.84);
}

.start-nick-input {
  width: min(100%, 220px);
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid rgba(29, 42, 54, 0.34);
  background: rgba(255, 255, 255, 0.92);
  color: #203244;
  text-align: center;
  font: 700 1rem/1 var(--font-ui);
  letter-spacing: 0.04em;
  text-transform: none;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 4px 8px rgba(29, 42, 54, 0.1);
  user-select: text;
  -webkit-user-select: text;
}

.start-nick-input:focus-visible {
  outline: 2px solid rgba(29, 42, 54, 0.74);
  outline-offset: 1px;
}

.start-color {
  margin-top: 0.4rem;
  display: grid;
  gap: 0.38rem;
  justify-items: center;
}

.start-color-label {
  margin: 0;
  font-size: 0.98rem;
  letter-spacing: 0.08em;
  color: rgba(29, 42, 54, 0.84);
}

.start-color-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.color-chip {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid rgba(29, 42, 54, 0.34);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.35) inset,
    0 4px 8px rgba(29, 42, 54, 0.16);
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.color-chip.is-active {
  transform: scale(1.14);
  border-color: rgba(29, 42, 54, 0.75);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.5) inset,
    0 0 0 2px rgba(29, 42, 54, 0.2),
    0 6px 12px rgba(29, 42, 54, 0.22);
}

.color-chip:active {
  transform: scale(1.06);
}

.color-chip:focus-visible {
  outline: 2px solid rgba(29, 42, 54, 0.72);
  outline-offset: 2px;
}

.color-chip.butter {
  background: linear-gradient(145deg, #fff8b9 0%, #ffd978 58%, #ebb54a 100%);
}

.color-chip.mint {
  background: linear-gradient(145deg, #eefff7 0%, #c4f5dd 56%, #86cfb1 100%);
}

.color-chip.peach {
  background: linear-gradient(145deg, #fff0e0 0%, #ffd0ac 54%, #f0a883 100%);
}

.color-chip.lavender {
  background: linear-gradient(145deg, #f4ebff 0%, #dac4ff 56%, #ac92eb 100%);
}

.color-chip.sky {
  background: linear-gradient(145deg, #ebf9ff 0%, #c2eaff 56%, #84caf4 100%);
}

.start-btn {
  margin-top: 0.62rem;
  justify-self: center;
  min-width: 206px;
  border: 2px solid var(--button-border);
  color: var(--ink-deep);
  background: var(--button-bg);
  border-radius: 12px;
  padding: 11px 34px 11px 24px;
  font: 700 1.1rem/1 var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: var(--button-shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease, border-color 120ms ease;
  animation: start-btn-breathe 1.8s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

.start-btn::before {
  content: "";
  position: absolute;
  top: -18px;
  left: -44px;
  width: 34px;
  height: calc(100% + 36px);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 255, 255, 0.44),
    rgba(255, 255, 255, 0)
  );
  transform: rotate(14deg);
  animation: start-btn-shine 1.95s linear infinite;
}

.start-btn::after {
  content: "▶";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-48%);
  font-size: 0.72rem;
  opacity: 0.8;
}

.start-btn:focus-visible {
  outline: 2px solid rgba(29, 42, 54, 0.8);
  outline-offset: 2px;
}

@keyframes start-btn-breathe {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-1px);
    filter: saturate(1.08);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes start-btn-shine {
  0% {
    left: -48px;
  }

  65% {
    left: calc(100% + 20px);
  }

  100% {
    left: calc(100% + 20px);
  }
}

.start-btn:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5) inset, 0 4px 8px rgba(29, 42, 54, 0.16);
}

.save-score-btn {
  min-width: 206px;
  margin-top: 0.3rem;
  background: linear-gradient(180deg, #f6ffe8 0%, #d6f59d 56%, #8ad369 100%);
}

.save-score-btn:disabled {
  opacity: 0.62;
  filter: grayscale(0.2);
}

.start-records {
  width: min(100%, 348px);
  justify-self: center;
  margin-top: 0.34rem;
  padding: 10px;
  border-radius: 12px;
  border: 2px solid rgba(29, 42, 54, 0.3);
  background: var(--rank-panel-bg);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.72) inset,
    0 8px 14px rgba(29, 42, 54, 0.14);
  text-align: left;
  display: grid;
  gap: 8px;
}

.start-records-head {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 0 2px;
}

.start-records-label {
  font-size: 0.96rem;
  letter-spacing: 0.06em;
  color: rgba(29, 42, 54, 0.78);
}

.start-records-my {
  justify-self: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(29, 42, 54, 0.26);
  background: rgba(126, 184, 229, 0.16);
  color: rgba(29, 42, 54, 0.9);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

.start-records-my.pending {
  color: #9a3256;
  border-color: rgba(173, 56, 97, 0.34);
  background: rgba(255, 94, 138, 0.14);
}

.start-records-best {
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  color: #1f6f64;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 3px rgba(88, 183, 164, 0.26);
}

.start-record-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  display: grid;
  gap: 6px;
  max-height: 130px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--rank-line);
  background: rgba(255, 255, 255, 0.54);
}

.start-record-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 8px;
  border: 1px solid rgba(29, 42, 54, 0.1);
  background: rgba(255, 255, 255, 0.78);
  font-size: 1rem;
}

.start-record-item.is-mine {
  border-color: rgba(255, 74, 109, 0.42);
  background: linear-gradient(180deg, rgba(255, 241, 229, 0.94), rgba(255, 226, 234, 0.9));
  box-shadow: 0 0 0 1px rgba(255, 74, 109, 0.2) inset;
}

.start-record-rank {
  min-width: 2.3em;
  text-align: center;
  color: #1f2f3d;
  background: rgba(126, 184, 229, 0.22);
  border: 1px solid rgba(29, 42, 54, 0.2);
  border-radius: 999px;
  padding: 2px 6px;
  font-weight: 700;
}

.start-record-item.is-mine .start-record-rank {
  color: #8f2849;
  background: rgba(255, 74, 109, 0.16);
  border-color: rgba(176, 54, 95, 0.34);
}

.start-record-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(29, 42, 54, 0.96);
  letter-spacing: 0.02em;
  font-weight: 700;
}

.start-record-type {
  letter-spacing: 0.02em;
  font-size: 0.74em;
  border-radius: 999px;
  padding: 1px 7px 2px;
  border: 1px solid currentColor;
  font-weight: 700;
  text-transform: uppercase;
}

.start-record-type.clear {
  color: #1f8b5d;
  background: rgba(83, 207, 143, 0.12);
}

.start-record-type.gameover {
  color: #a94861;
  background: rgba(232, 116, 143, 0.11);
}

.start-record-score {
  color: #1a3042;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 4.8em;
  font-weight: 700;
}

.start-record-item.is-mine .start-record-score {
  color: #8f2849;
}

.start-record-empty {
  list-style: none;
  color: rgba(29, 42, 54, 0.64);
  font-size: 1rem;
  padding: 12px 8px;
  text-align: center;
}

.start-overlay.mode-result .start-records {
  width: min(100%, 392px);
  padding: 12px;
  gap: 10px;
}

.start-overlay.mode-result .start-record-list {
  max-height: 152px;
  min-height: 152px;
}

.start-overlay.mode-result .start-record-item {
  font-size: 1.08rem;
  padding: 7px 8px;
  min-height: 44px;
}

.start-overlay.mode-result .start-record-score {
  min-width: 5.4em;
}

.hud-top {
  position: absolute;
  inset: 10px 10px auto;
  z-index: 3;
  padding: 9px 10px;
  padding-right: 96px;
  border-radius: 10px;
  border: 2px solid var(--panel-line);
  background:
    linear-gradient(180deg, rgba(247, 242, 229, 0.84), rgba(237, 224, 194, 0.8));
  text-transform: uppercase;
  box-shadow:
    0 8px 16px rgba(29, 42, 54, 0.15),
    0 0 0 1px rgba(255, 255, 255, 0.42) inset;
}

.hud-icon-controls {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}

.hud-icon-btn {
  width: 34px;
  height: 34px;
  border: 2px solid var(--button-border);
  border-radius: 10px;
  background: var(--button-bg);
  color: var(--ink-deep);
  font: 700 1.08rem/1 var(--font-ui);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: var(--button-shadow);
}

#pauseBtn::before,
#pauseBtn::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 4px;
  height: 12px;
  border-radius: 1px;
  background: currentColor;
  transition: all 120ms ease;
}

#pauseBtn::before {
  left: 11px;
}

#pauseBtn::after {
  right: 11px;
}

#pauseBtn.paused::before {
  top: 8px;
  left: 12px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 10px solid currentColor;
  border-radius: 0;
  background: transparent;
}

#pauseBtn.paused::after {
  opacity: 0;
}

.hud-icon-btn:active {
  transform: translateY(1px) scale(0.98);
}

.hud-icon-btn.paused {
  border-color: rgba(234, 124, 92, 0.84);
  color: #a45f00;
  background: linear-gradient(180deg, #fff8dd 0%, #ffdca2 54%, #f3ba6f 100%);
}

.hud-title {
  font-family: var(--font-display);
  font-size: 0.62rem;
  line-height: 1.45;
  letter-spacing: 0.1em;
  color: rgba(29, 42, 54, 0.88);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.hud-stats {
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  gap: 0.44rem;
}

.hud-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-label {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  color: rgba(29, 42, 54, 0.78);
}

.hud-value {
  font-weight: bold;
  font-size: 1.28rem;
  font-family: var(--font-ui);
  letter-spacing: 0.03em;
  text-shadow: 0 0 3px currentColor;
  font-variant-numeric: tabular-nums;
}

.neon-mint {
  color: var(--mint);
}

.neon-sun {
  color: var(--sun);
}

.neon-boost {
  color: #8492a1;
  text-shadow: none;
  min-width: 3.2ch;
  text-align: right;
}

.neon-boost.active {
  color: #ff4a6d;
  text-shadow: 0 0 6px rgba(255, 74, 109, 0.55);
}

#lifeLabel {
  display: flex;
  gap: 2px;
}

.pixel-heart {
  display: inline-block;
  width: 14px;
  height: 14px;
  background-color: #ea866f;
  clip-path: polygon(10% 0, 40% 0, 50% 20%, 60% 0, 90% 0, 100% 20%, 100% 40%, 50% 100%, 0 40%, 0 20%);
}

.hud-timebar-wrap {
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-timebar-label {
  font-size: 1rem;
  letter-spacing: 0.08em;
  color: rgba(29, 42, 54, 0.86);
}

.hud-timebar {
  position: relative;
  flex: 1;
  height: 14px;
  border: 2px solid rgba(29, 42, 54, 0.42);
  border-radius: 4px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 252, 243, 0.9), rgba(236, 227, 209, 0.9)),
    repeating-linear-gradient(90deg,
      rgba(29, 42, 54, 0.08) 0,
      rgba(29, 42, 54, 0.08) 2px,
      transparent 2px,
      transparent 6px);
}

.hud-timebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 70%);
}

.hud-timebar-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(1);
  transition: transform 90ms linear;
  background: linear-gradient(90deg, #6ad1bb 0%, #f5c363 45%, #ef946f 75%, #7eb8e5 100%);
}

.hud-timebar-fill::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg,
      rgba(255, 255, 255, 0.22) 0,
      rgba(255, 255, 255, 0.22) 4px,
      transparent 4px,
      transparent 8px);
}

.hud-timebar.off {
  border-color: rgba(96, 112, 127, 0.5);
}

.hud-timebar.off .hud-timebar-fill {
  background: linear-gradient(90deg, #9eaeb9, #7e8f9e);
}

.hud-music {
  margin-top: 6px;
  border: 2px solid var(--button-border);
  background: var(--button-bg);
  color: var(--ink-deep);
  border-radius: 10px;
  padding: 4px 8px;
  font: 700 1rem/1 var(--font-ui);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: var(--button-shadow);
}

.hud-music.off {
  border-color: rgba(96, 112, 127, 0.52);
  color: #617181;
}

.hud-music:active {
  transform: translateY(1px);
}

.judgment {
  position: absolute;
  left: 50%;
  top: 41%;
  transform: translate(-50%, -50%) scale(0.5);
  z-index: 4;
  font-family: "Press Start 2P", "VT323", monospace;
  letter-spacing: 0.07em;
  font-size: clamp(0.98rem, 3.8vw, 1.22rem);
  color: #253547;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7),
    0 0 14px rgba(255, 241, 214, 0.75);
  opacity: 0;
  pointer-events: none;
}

@keyframes bouncePop {
  0% {
    transform: translate(-50%, -50%) scale(0.5) translateY(10px);
    opacity: 0;
  }

  50% {
    transform: translate(-50%, -50%) scale(1.1) translateY(-10px);
    opacity: 1;
  }

  80% {
    transform: translate(-50%, -50%) scale(0.95) translateY(0);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes floatFade {
  0% {
    transform: translate(-50%, -50%) scale(1) translateY(0);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(1) translateY(-30px);
    opacity: 0;
  }
}

.judgment.show {
  animation: bouncePop 200ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards, floatFade 600ms 400ms forwards;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0.05),
      rgba(0, 0, 0, 0.05) 1px,
      transparent 1px,
      transparent 3px);
  animation: scan 8s linear infinite;
  mix-blend-mode: overlay;
}

@keyframes scan {
  from {
    background-position: 0 0;
  }

  to {
    background-position: 0 100vh;
  }
}

@media (max-width: 430px) {
  body {
    display: block;
  }

  .app {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    padding: 0;
  }

  .game-shell {
    border-radius: 0;
    width: 100vw;
    height: 100dvh;
    max-height: none;
    min-height: 100dvh;
    aspect-ratio: auto;
    border: 0;
  }

  .hud-top {
    border-radius: 0 0 10px 10px;
    inset: 0 0 auto;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-bottom: 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: 8px;
    row-gap: 5px;
    align-items: center;
  }

  .hud-icon-controls {
    position: static;
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
  }

  .hud-title {
    grid-column: 1;
    grid-row: 1;
    font-size: 0.56rem;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hud-stats {
    grid-column: 1 / span 2;
    grid-row: 2;
    margin-top: 0;
    gap: 0.32rem 0.58rem;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .hud-timebar-wrap {
    grid-column: 1;
    grid-row: 3;
    margin-top: 0;
    min-width: 0;
  }

  .hud-timebar-label {
    font-size: 0.88rem;
  }

  .hud-music {
    grid-column: 2;
    grid-row: 3;
    margin-top: 0;
    justify-self: end;
    padding: 4px 7px;
    font-size: 0.9rem;
  }

  .start-overlay {
    padding-top: max(1.45rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(1.45rem, env(safe-area-inset-bottom, 0px));
  }

  .start-help {
    width: min(100%, 318px);
    font-size: 1rem;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .clear-reward-link {
    width: min(100%, 318px);
    padding: 7px 9px;
    gap: 8px;
  }

  .clear-reward-text {
    font-size: 0.9rem;
  }

  .start-nick-input {
    width: min(100%, 206px);
    font-size: 0.96rem;
  }

  .start-btn {
    min-width: 188px;
    padding: 11px 32px 11px 23px;
    font-size: 1.04rem;
  }

  .start-records {
    width: min(100%, 304px);
    padding: 8px 9px;
    gap: 5px;
  }

  .start-record-list {
    max-height: 96px;
  }

  .start-record-item {
    font-size: 0.88rem;
  }

  .start-overlay.mode-start .start-records {
    width: min(100%, 336px);
    padding: 8px;
    gap: 6px;
  }

  .start-overlay.mode-start .start-record-list {
    max-height: 132px;
    min-height: 132px;
  }

  .start-overlay.mode-start .start-record-item {
    min-height: 38px;
    font-size: 0.9rem;
  }

  .start-overlay.mode-result .start-records {
    width: min(100%, 100%);
    padding: 10px;
  }

  .start-overlay.mode-result .start-record-list {
    max-height: 140px;
    min-height: 140px;
  }

  .start-overlay.mode-result .start-record-item {
    font-size: 0.98rem;
    min-height: 40px;
  }
}

@media (max-width: 380px),
(max-height: 760px) {
  .hud-top {
    row-gap: 4px;
    padding-bottom: 7px;
  }

  .hud-icon-controls {
    gap: 5px;
  }

  .hud-icon-btn {
    width: 30px;
    height: 30px;
    font-size: 1rem;
  }

  .hud-label {
    font-size: 0.8rem;
  }

  .hud-value {
    font-size: 1.18rem;
  }

  .pixel-heart {
    width: 12px;
    height: 12px;
  }

  .hud-timebar {
    height: 12px;
  }

  .start-help {
    width: min(100%, 300px);
    font-size: 0.94rem;
    padding-left: 31px;
  }

  .clear-reward-link {
    width: min(100%, 300px);
  }

  .clear-reward-text {
    font-size: 0.86rem;
  }

  .start-btn {
    min-width: 172px;
    padding: 10px 30px 10px 21px;
    font-size: 0.98rem;
  }

  .start-nick-label {
    font-size: 0.82rem;
  }

  .start-nick-input {
    width: min(100%, 194px);
    font-size: 0.9rem;
  }

  .start-records {
    width: min(100%, 286px);
    max-height: 104px;
  }

  .start-records-best {
    font-size: 1.06rem;
  }

  .start-record-item {
    font-size: 0.84rem;
    gap: 6px;
  }

  .start-overlay.mode-start .start-record-list {
    max-height: 120px;
    min-height: 120px;
  }

  .start-overlay.mode-start .start-record-item {
    min-height: 34px;
    font-size: 0.86rem;
  }
}

@media (hover: none) and (pointer: coarse) {
  .app {
    width: 100vw;
    height: 100dvh;
    padding: 0;
  }

  .game-shell {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    aspect-ratio: auto;
    border-radius: 0;
  }
}
