:root {
  --bg-top: #1b0f09;
  --bg-bottom: #050302;
  --panel: rgba(19, 8, 4, 0.82);
  --panel-border: rgba(255, 208, 138, 0.2);
  --text-main: #fff2d5;
  --text-soft: #f1c88a;
  --accent: #ee5a1e;
  --accent-2: #ffcf4b;
  --lane-count: 3;
  --phone-ratio: 0.5627990431;
  --display-font: "Herculanum", "Copperplate", "AppleMyungjo", "Georgia",
    serif;
  --button-font: var(--display-font);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--display-font);
  color: var(--text-main);
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 10px;
  overflow: hidden;
  letter-spacing: 0.02em;
  background:
    radial-gradient(circle at top, rgba(255, 185, 90, 0.25), transparent 32%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 200, 122, 0.08), transparent 18%),
    radial-gradient(circle at 82% 12%, rgba(255, 143, 56, 0.08), transparent 20%),
    radial-gradient(circle at 50% 100%, rgba(255, 104, 46, 0.1), transparent 26%);
  pointer-events: none;
}

body[data-theme="rush"] {
  --accent: #ff7f2f;
  --accent-2: #ffd869;
}

body[data-theme="night"] {
  --accent: #ff5d37;
  --accent-2: #ffb75d;
  --text-soft: #ffd6a3;
}

.app-shell {
  width: min(calc((100dvh - 20px) * var(--phone-ratio)), calc(100vw - 20px), 430px);
  aspect-ratio: 941 / 1672;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 32px;
  border: 1px solid rgba(255, 216, 164, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)),
    rgba(15, 6, 3, 0.22);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.hero {
  display: grid;
  gap: 0.22rem;
  padding: 0.8rem 1rem 0.35rem;
  position: relative;
  z-index: 2;
}

body.is-playing .hero {
  display: none;
}

.eyebrow,
.panel-kicker,
.mode-tag,
.badge,
.hud-label {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.68rem;
  color: var(--text-soft);
}

.hero h1,
.panel h2,
.result-card h2,
.howto h3,
.mode-card strong {
  margin: 0;
  font-family: var(--button-font);
  line-height: 0.92;
}

.hero h1 {
  font-size: 2.5rem;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}

.lede {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-soft);
  max-width: 34ch;
}

.layout {
  display: grid;
  flex: 1;
  min-height: 0;
  padding: 0.5rem;
}

body.is-playing .layout {
  padding-top: 0.25rem;
}

.layout > .panel {
  grid-area: 1 / 1;
}

.panel,
.result-card {
  border-radius: 28px;
  overflow: hidden;
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

.panel-menu {
  padding: 1rem;
  justify-content: flex-end;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(17, 7, 3, 0.22), rgba(17, 7, 3, 0.82)),
    url("assets/start-bg.png") center / cover no-repeat;
}

.panel-menu::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), transparent 26%),
    linear-gradient(180deg, transparent 42%, rgba(9, 4, 2, 0.72));
  pointer-events: none;
}

.panel-menu > * {
  position: relative;
  z-index: 1;
}

.menu-start-card {
  margin-top: auto;
  padding: 1.1rem 1rem 1rem;
  border-radius: 1.65rem;
  background:
    linear-gradient(180deg, rgba(70, 31, 12, 0.86), rgba(22, 9, 4, 0.88)),
    rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 208, 138, 0.18);
  box-shadow:
    inset 0 1px 0 rgba(255, 228, 182, 0.16),
    0 18px 36px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.menu-start-card h1 {
  margin: 0;
  font-family: var(--display-font);
  font-size: 3rem;
  line-height: 0.9;
  text-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

.menu-copy {
  margin: 0.85rem 0 1rem;
  font-size: 0.9rem;
  line-height: 1.48;
  color: #ffe0af;
}

.start-button {
  width: 100%;
  padding: 1rem 1.15rem;
  font-size: 1rem;
}

.tutorial-popover {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.1rem;
  background: rgba(10, 4, 2, 0.18);
  z-index: 4;
}

.speech-bubble {
  position: relative;
  width: min(100%, 18.5rem);
  margin: 0 auto 26%;
  padding: 1rem 1rem 1.05rem;
  border-radius: 1.5rem 1.5rem 1.5rem 0.55rem;
  background:
    linear-gradient(180deg, rgba(84, 37, 15, 0.94), rgba(28, 10, 4, 0.96)),
    rgba(24, 10, 4, 0.9);
  border: 1px solid rgba(255, 208, 138, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 186, 0.16),
    0 20px 40px rgba(0, 0, 0, 0.34);
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 1.4rem;
  bottom: -0.48rem;
  width: 1rem;
  height: 1rem;
  border-right: 1px solid rgba(255, 208, 138, 0.24);
  border-bottom: 1px solid rgba(255, 208, 138, 0.24);
  background: rgba(34, 12, 4, 0.96);
  transform: rotate(45deg);
}

.bubble-kicker {
  margin: 0 0 0.45rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.7rem;
  color: var(--text-soft);
}

.bubble-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.42;
  color: #fff0cf;
}

.tutorial-button {
  margin-top: 0.95rem;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.badge {
  padding: 0.55rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 152, 0.2);
  background: rgba(24, 10, 4, 0.7);
  backdrop-filter: blur(8px);
}

.mode-grid {
  display: grid;
  gap: 0.75rem;
  margin: 0.95rem 0 0.9rem;
}

.mode-card,
.lane-button,
.primary-button,
.secondary-button {
  appearance: none;
  border: 0;
  color: inherit;
  cursor: pointer;
}

.mode-card {
  display: grid;
  gap: 0.45rem;
  text-align: left;
  padding: 0.95rem 1rem;
  border-radius: 1.3rem;
  background:
    linear-gradient(180deg, rgba(84, 37, 15, 0.84), rgba(31, 11, 4, 0.84)),
    rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 201, 126, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 227, 177, 0.14);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.mode-card:hover,
.mode-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(255, 215, 140, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 227, 177, 0.18),
    0 20px 36px rgba(0, 0, 0, 0.28);
}

.mode-card strong {
  font-size: 1.3rem;
}

.mode-card span:last-child,
.howto p {
  color: #ffdba9;
}

.howto {
  display: grid;
  gap: 0.48rem;
  padding: 0.85rem 0.9rem;
  border-radius: 1.2rem;
  background: rgba(24, 10, 4, 0.72);
  border: 1px solid rgba(255, 208, 138, 0.16);
  backdrop-filter: blur(8px);
}

.howto p {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
}

.panel-game {
  padding: 0.85rem 0.8rem 0.8rem;
  background:
    linear-gradient(180deg, rgba(10, 4, 2, 0.3), rgba(10, 4, 2, 0.18)),
    url("assets/track-bg.png") center / cover no-repeat;
}

.panel-game::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.25), transparent 22%),
    linear-gradient(180deg, transparent 58%, rgba(0, 0, 0, 0.12));
  pointer-events: none;
}

.panel-game > * {
  position: relative;
  z-index: 1;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.hud-card {
  display: grid;
  gap: 0.16rem;
  padding: 0.58rem 0.45rem 0.52rem;
  text-align: center;
  border-radius: 1rem;
  background: rgba(23, 10, 4, 0.72);
  border: 1px solid rgba(255, 210, 145, 0.16);
  backdrop-filter: blur(10px);
}

.hud-card strong {
  font-family: var(--button-font);
  font-size: 1.5rem;
}

.arena-frame {
  position: relative;
  flex: 1;
  min-height: 0;
}

.lane-labels {
  display: none;
}

.arena {
  position: absolute;
  inset: 0;
  overflow: hidden;
  min-height: 0;
}

.arena::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 26%;
  z-index: 260;
  pointer-events: none;
  background:
    linear-gradient(
      180deg,
      rgba(19, 8, 4, 0.98) 0%,
      rgba(19, 8, 4, 0.96) 34%,
      rgba(19, 8, 4, 0.74) 58%,
      rgba(19, 8, 4, 0) 100%
    );
}

.danger-line {
  display: none;
}

.zombie {
  position: absolute;
  width: 64px;
  height: 64px;
  overflow: visible;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transform: var(--piece-transform, translate(0, 0));
  transform-origin: center;
  transition:
    transform 120ms ease-out,
    filter 120ms ease-out,
    opacity 120ms ease-out;
  filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45));
  will-change: transform;
}

.zombie::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 26%;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 214, 130, 0.5), transparent 22%),
    radial-gradient(circle at 68% 72%, rgba(255, 126, 54, 0.42), transparent 28%),
    radial-gradient(circle at 50% 52%, rgba(44, 13, 4, 0.62), rgba(12, 5, 2, 0.12));
  mix-blend-mode: multiply;
  transition: opacity 120ms ease-out;
}

.zombie.hit {
  pointer-events: none;
  animation: vanish 180ms ease forwards;
}

.zombie.charred {
  filter:
    drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45))
    sepia(0.42)
    saturate(1.06)
    brightness(0.88)
    contrast(1.06);
}

.zombie.charred::after {
  opacity: 0.38;
}

.zombie.lunge {
  animation: lunge 220ms ease;
}

.zombie.burned {
  animation: burn-jump 420ms cubic-bezier(0.22, 0.8, 0.22, 1);
}

.zombie.burned::after {
  opacity: 1;
  animation: burn-overlay 420ms ease-out;
}

.controls {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  grid-template-columns: repeat(var(--lane-count), minmax(0, 1fr));
  gap: var(--control-gap, 0.55rem);
  align-items: end;
  z-index: 3;
}

.lane-button {
  position: relative;
  width: var(--control-size, 78%);
  max-width: 100%;
  aspect-ratio: 1;
  justify-self: center;
  align-self: end;
  min-height: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  border-radius: 50%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.lane-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.lane-button::before,
.lane-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition:
    opacity 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.lane-button::before {
  inset: 13%;
  background:
    radial-gradient(
      circle,
      rgba(255, 191, 104, 0.72) 0%,
      rgba(255, 132, 39, 0.42) 34%,
      rgba(255, 132, 39, 0.1) 58%,
      transparent 72%
    );
  opacity: 0;
  transform: scale(0.74);
}

.lane-button::after {
  inset: 8%;
  border: 2px solid rgba(255, 206, 118, 0.16);
  box-shadow:
    inset 0 0 0 1px rgba(255, 206, 118, 0.08),
    0 0 0 rgba(255, 185, 86, 0);
  transform: scale(0.9);
  background: radial-gradient(circle, rgba(255, 176, 74, 0.02), transparent 66%);
  opacity: 0;
}

.lane-button:hover::before,
.lane-button:focus-visible::before,
.lane-button.active::before {
  opacity: 1;
  transform: scale(1);
}

.lane-button:hover::after,
.lane-button:focus-visible::after,
.lane-button.active::after {
  opacity: 1;
  transform: scale(1);
  box-shadow:
    0 0 0 2px rgba(255, 205, 112, 0.18),
    0 0 26px rgba(255, 155, 57, 0.48);
}

.lane-button.active {
  transform: scale(0.97);
}

.lane-button.active::before {
  animation: tap-core 220ms ease-out;
}

.lane-button.active::after {
  animation: tap-ring 220ms ease-out;
}

.lane-button.misfire {
  animation: misfire 260ms ease;
}

.lane-button.misfire::after {
  opacity: 1;
  transform: scale(1.03);
  box-shadow:
    0 0 0 2px rgba(255, 117, 88, 0.26),
    0 0 22px rgba(255, 117, 88, 0.6);
}

.lane-button small {
  position: absolute;
  top: -1.85rem;
  left: 50%;
  transform: translateX(-50%);
  min-width: 1.85rem;
  padding: 0.22rem 0.38rem;
  border-radius: 999px;
  background: rgba(24, 10, 4, 0.8);
  border: 1px solid rgba(255, 211, 142, 0.16);
  color: #fff0d1;
  font-family: var(--display-font);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.status-row,
.overlay-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.status-row {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  top: 4.35rem;
  z-index: 3;
}

.status-text {
  margin: 0;
  flex: 1;
  text-align: center;
  font-size: 0.76rem;
  line-height: 1.35;
  color: #ffe9bc;
  padding: 0.72rem 0.88rem;
  border-radius: 999px;
  background: rgba(24, 10, 4, 0.78);
  border: 1px solid rgba(255, 210, 145, 0.16);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.22);
}

.primary-button,
.secondary-button {
  border-radius: 999px;
  padding: 0.76rem 0.95rem;
  font-family: var(--button-font);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-button {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: #311708;
  box-shadow: inset 0 1px 0 rgba(255, 242, 188, 0.42);
}

.secondary-button {
  background: rgba(24, 10, 4, 0.78);
  border: 1px solid rgba(255, 208, 138, 0.16);
  color: var(--text-main);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.8rem;
  background:
    linear-gradient(180deg, rgba(8, 4, 2, 0.28), rgba(8, 4, 2, 0.74)),
    url("assets/end-bg.png") center / cover no-repeat;
  border-radius: inherit;
}

.overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(8, 4, 2, 0.28);
  backdrop-filter: blur(8px);
}

.result-card {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 1.05rem;
  background: rgba(22, 9, 4, 0.84);
  border: 1px solid rgba(255, 210, 145, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1.15rem 0;
}

.result-grid div {
  padding: 0.95rem;
  border-radius: 1.1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 210, 145, 0.1);
}

.result-grid strong {
  display: block;
  margin-top: 0.22rem;
  font-family: var(--button-font);
  font-size: 1.85rem;
}

.hidden {
  display: none !important;
}

@keyframes vanish {
  from {
    opacity: 1;
    transform: var(--piece-transform) scale(1) rotate(0deg);
  }

  to {
    opacity: 0;
    transform: var(--piece-transform) scale(0.72) rotate(-10deg);
  }
}

@keyframes pulse {
  from {
    filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45)) brightness(1);
  }

  to {
    filter:
      drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45))
      drop-shadow(0 0 18px rgba(255, 196, 108, 0.72))
      brightness(1.14);
  }
}

@keyframes lunge {
  0% {
    transform: var(--piece-transform) scale(1);
  }

  45% {
    transform: var(--piece-transform) scale(1.08);
  }

  100% {
    transform: var(--piece-transform) scale(1);
  }
}

@keyframes burn-jump {
  0% {
    transform: var(--piece-transform) translateY(0) scale(1) rotate(0deg);
    filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45)) brightness(1);
  }

  14% {
    transform: var(--piece-transform) translateY(-8px) translateX(-4px) scale(1.03)
      rotate(-4deg);
  }

  28% {
    transform: var(--piece-transform) translateY(-18px) translateX(5px) scale(1.08)
      rotate(4deg);
    filter:
      drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45))
      drop-shadow(0 0 14px rgba(255, 117, 64, 0.36))
      sepia(0.6)
      saturate(1.22)
      brightness(0.82)
      contrast(1.08);
  }

  44% {
    transform: var(--piece-transform) translateY(-9px) translateX(-5px) scale(1.04)
      rotate(-3deg);
  }

  62% {
    transform: var(--piece-transform) translateY(-4px) translateX(4px) scale(1.01)
      rotate(2deg);
  }

  78% {
    transform: var(--piece-transform) translateY(-1px) translateX(-3px) scale(0.99)
      rotate(-1deg);
    filter:
      drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45))
      drop-shadow(0 0 10px rgba(255, 136, 62, 0.26))
      sepia(0.38)
      saturate(1.08)
      brightness(0.9)
      contrast(1.04);
  }

  100% {
    transform: var(--piece-transform) translateY(0) scale(1) rotate(0deg);
    filter: drop-shadow(0 16px 20px rgba(0, 0, 0, 0.45)) brightness(1);
  }
}

@keyframes burn-overlay {
  0% {
    opacity: 0;
  }

  24% {
    opacity: 0.92;
  }

  68% {
    opacity: 0.62;
  }

  100% {
    opacity: 0;
  }
}

@keyframes misfire {
  0%,
  100% {
    transform: translateX(0);
  }

  35% {
    transform: translateX(-5px);
  }

  70% {
    transform: translateX(5px);
  }
}

@keyframes tap-core {
  0% {
    opacity: 0.15;
    transform: scale(0.68);
  }

  45% {
    opacity: 1;
    transform: scale(1);
  }

  100% {
    opacity: 0.22;
    transform: scale(0.86);
  }
}

@keyframes tap-ring {
  0% {
    opacity: 0.14;
    transform: scale(0.76);
  }

  55% {
    opacity: 1;
    transform: scale(1.04);
  }

  100% {
    opacity: 0.26;
    transform: scale(0.92);
  }
}

@media (max-width: 760px) {
  body {
    padding: 6px;
  }

  .app-shell {
    width: min(calc((100dvh - 12px) * var(--phone-ratio)), calc(100vw - 12px), 430px);
    border-radius: 26px;
  }
}

@media (max-height: 760px) {
  .menu-start-card h1 {
    font-size: 2.65rem;
  }

  .hud-card strong {
    font-size: 1.32rem;
  }

  .lane-button small {
    top: -1.62rem;
  }

  .status-row {
    top: 3.95rem;
  }

  .speech-bubble {
    margin-bottom: 20%;
  }
}
