:root {
  --ink: #17232a;
  --paper: #fff9ec;
  --accent: #e84f35;
  --accent-dark: #b93624;
  --mint: #79c6a5;
  --gold: #f4c45b;
  --shadow: rgba(19, 27, 31, 0.28);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #1f2f38;
  color: var(--paper);
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}

button {
  border: 0;
  font: inherit;
}

#game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 249, 236, 0.12), transparent 28%),
    linear-gradient(180deg, #284452 0%, #1f2f38 100%);
}

#game-canvas {
  width: 100vw;
  height: 100dvh;
  display: block;
}

.hud {
  position: fixed;
  top: calc(12px + var(--safe-top));
  left: 12px;
  right: 12px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.hud.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hud-pill,
.icon-button,
.sound-button,
.primary-button {
  box-shadow: 0 12px 28px var(--shadow);
}

.hud-pill {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 2px solid rgba(255, 249, 236, 0.72);
  border-radius: 8px;
  background: rgba(23, 35, 42, 0.74);
  backdrop-filter: blur(10px);
  color: var(--paper);
  font-weight: 900;
}

.score-pill img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.lives {
  justify-content: center;
  min-width: 86px;
  color: var(--gold);
  letter-spacing: 2px;
}

.icon-button {
  width: 44px;
  height: 42px;
  border: 2px solid rgba(255, 249, 236, 0.72);
  border-radius: 8px;
  background: rgba(23, 35, 42, 0.74);
  color: var(--paper);
  font-weight: 900;
  pointer-events: auto;
  cursor: pointer;
}

.sound-button {
  position: fixed;
  right: 12px;
  bottom: calc(12px + var(--safe-bottom));
  z-index: 13;
  min-height: 40px;
  padding: 9px 12px;
  border: 2px solid rgba(255, 249, 236, 0.72);
  border-radius: 8px;
  background: rgba(23, 35, 42, 0.78);
  color: var(--paper);
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: calc(28px + var(--safe-top)) 18px calc(26px + var(--safe-bottom));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(18, 29, 36, 0.16), rgba(18, 29, 36, 0.76));
}

.screen-art {
  position: absolute;
  inset: 0;
  background-image: url("assets/splash.png");
  background-size: cover;
  background-position: center;
  transform: scale(1.02);
}

.screen.compact {
  align-items: center;
}

.screen.compact::before {
  background: rgba(18, 29, 36, 0.72);
  backdrop-filter: blur(5px);
}

.screen-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  padding: 22px;
  border: 2px solid rgba(255, 249, 236, 0.72);
  border-radius: 8px;
  background: rgba(23, 35, 42, 0.78);
  box-shadow: 0 20px 50px var(--shadow);
  backdrop-filter: blur(14px);
  text-align: left;
}

.compact .screen-panel {
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--paper);
  line-height: 0.98;
  letter-spacing: 0;
}

h1 {
  max-width: 10ch;
  font-size: clamp(40px, 14vw, 72px);
}

h2 {
  font-size: clamp(34px, 10vw, 56px);
}

.screen-copy,
.best-line {
  color: rgba(255, 249, 236, 0.84);
  font-weight: 650;
  line-height: 1.45;
}

.screen-copy {
  margin: 14px 0 18px;
}

.best-line {
  margin: 12px 0 0;
}

.primary-button {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fffdf7;
  font-weight: 950;
  cursor: pointer;
  transform: translateY(0);
  transition: transform 140ms ease, filter 140ms ease;
}

.primary-button:active,
.icon-button:active,
.sound-button:active {
  transform: translateY(1px) scale(0.99);
}

.primary-button:hover,
.icon-button:hover,
.sound-button:hover {
  filter: brightness(1.06);
}

.touch-zone {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 4;
  width: 50vw;
  pointer-events: none;
}

.touch-zone::after {
  content: "";
  position: absolute;
  top: 46%;
  width: 42px;
  height: 86px;
  opacity: 0;
  border: 2px solid rgba(255, 249, 236, 0.22);
  transition: opacity 160ms ease, transform 160ms ease;
}

#touch-left {
  left: 0;
}

#touch-left::after {
  left: 12px;
  border-right: 0;
  border-radius: 8px 0 0 8px;
}

#touch-right {
  right: 0;
}

#touch-right::after {
  right: 12px;
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

.show-touch #touch-left::after,
.show-touch #touch-right::after {
  opacity: 1;
}

@media (min-width: 720px) {
  .screen {
    align-items: center;
    justify-items: start;
    padding-left: clamp(28px, 7vw, 92px);
  }

  .screen-panel {
    margin-top: 8vh;
  }

  .hud {
    left: 22px;
    right: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
