:root {
  --ink: #f9f8ff;
  --night: #080b2b;
  --glass: rgba(10, 13, 43, 0.68);
  --glass-strong: rgba(7, 10, 35, 0.82);
  --line: rgba(255, 255, 255, 0.24);
  --sun: #ffe37d;
  --sky: #9cecff;
  --shadow: 0 20px 60px rgba(1, 3, 22, 0.48);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night);
}

body,
button,
a {
  font-family:
    ui-rounded,
    "SF Pro Rounded",
    "PingFang SC",
    "Hiragino Sans GB",
    "Microsoft YaHei",
    system-ui,
    sans-serif;
}

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

button {
  color: inherit;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 4px solid var(--sun);
  outline-offset: 4px;
}

.fireworks-game {
  width: 100vw;
  min-height: 100vh;
  min-height: 100dvh;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.scene-picker {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden auto;
  padding:
    max(20px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  color: var(--ink);
  background:
    radial-gradient(circle at 52% -12%, rgba(107, 91, 255, 0.54), transparent 42%),
    radial-gradient(circle at 8% 78%, rgba(47, 161, 205, 0.28), transparent 34%),
    linear-gradient(162deg, #141747 0%, #11133b 52%, #071e38 100%);
  touch-action: pan-y;
}

.scene-picker::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(circle at 8% 17%, #fff 0 1px, transparent 1.7px),
    radial-gradient(circle at 22% 9%, #fff 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 34% 23%, #fff 0 1px, transparent 1.7px),
    radial-gradient(circle at 64% 12%, #fff 0 1.2px, transparent 1.8px),
    radial-gradient(circle at 79% 26%, #fff 0 1px, transparent 1.7px),
    radial-gradient(circle at 92% 10%, #fff 0 1.2px, transparent 1.8px);
}

.picker-glow {
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(28px);
  pointer-events: none;
}

.picker-glow--one {
  top: -180px;
  right: -70px;
  background: rgba(255, 128, 151, 0.24);
}

.picker-glow--two {
  bottom: -190px;
  left: -100px;
  background: rgba(80, 228, 205, 0.2);
}

.picker-copy,
.scene-grid,
.picker-tip {
  position: relative;
  z-index: 1;
}

.picker-copy {
  width: min(1160px, 100%);
  margin: 0 auto clamp(24px, 4vh, 42px);
  text-align: center;
}

.home-link {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 112px;
  min-height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #fff;
  background: var(--glass);
  box-shadow: 0 10px 26px rgba(2, 5, 26, 0.28);
  font-size: 15px;
  font-weight: 900;
  text-decoration: none;
  backdrop-filter: blur(16px) saturate(130%);
  touch-action: manipulation;
  transition: background 180ms ease-out, transform 180ms ease-out;
}

.home-link:active {
  transform: scale(0.97);
  background: var(--glass-strong);
}

.eyebrow {
  margin: 7px 0 6px;
  color: var(--sky);
  font-size: clamp(11px, 2vw, 14px);
  font-weight: 900;
  letter-spacing: 0.16em;
}

.picker-copy h1 {
  margin: 0;
  font-size: clamp(43px, 8vw, 80px);
  line-height: 1;
  letter-spacing: -0.055em;
  text-shadow: 0 6px 30px rgba(113, 194, 255, 0.32);
}

.picker-copy > p:last-child {
  margin: 14px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(16px, 2.5vw, 22px);
  font-weight: 800;
  line-height: 1.5;
}

.scene-grid {
  width: min(1160px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(14px, 2vw, 22px);
}

.scene-card {
  position: relative;
  min-height: clamp(245px, 38vh, 390px);
  overflow: hidden;
  padding: 0;
  border: 3px solid rgba(255, 255, 255, 0.88);
  border-radius: 28px;
  color: #fff;
  background: #1b2556;
  box-shadow:
    0 8px 0 rgba(4, 7, 31, 0.72),
    var(--shadow);
  text-align: left;
  touch-action: manipulation;
  transition: transform 180ms ease-out, box-shadow 180ms ease-out, border-color 180ms ease-out;
}

.scene-card::after {
  content: "";
  position: absolute;
  inset: 34% 0 0;
  background: linear-gradient(180deg, transparent, rgba(4, 7, 27, 0.94));
  pointer-events: none;
}

.scene-card:active {
  transform: translateY(5px) scale(0.985);
  box-shadow:
    0 3px 0 rgba(4, 7, 31, 0.72),
    0 12px 30px rgba(2, 4, 22, 0.34);
}

@media (hover: hover) {
  .scene-card:hover {
    transform: translateY(-5px);
    border-color: #fff5bd;
    box-shadow:
      0 12px 0 rgba(4, 7, 31, 0.68),
      0 30px 70px rgba(1, 3, 20, 0.54);
  }
}

.scene-preview,
.scene-preview img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-preview img {
  object-fit: cover;
  transition: transform 500ms ease-out;
}

@media (hover: hover) {
  .scene-card:hover .scene-preview img {
    transform: scale(1.035);
  }
}

.scene-card--forest .scene-preview img {
  object-position: 50% 50%;
}

.scene-card--home .scene-preview img {
  object-position: 50% 40%;
}

.scene-card--castle .scene-preview img {
  object-position: 50% 62%;
}

.scene-name,
.scene-hint {
  position: absolute;
  z-index: 2;
  left: 20px;
  right: 16px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.68);
}

.scene-name {
  bottom: 49px;
  font-size: clamp(25px, 3vw, 36px);
  font-weight: 1000;
  line-height: 1.05;
}

.scene-hint {
  bottom: 20px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  font-weight: 850;
}

.picker-tip {
  margin: clamp(22px, 4vh, 38px) auto 0;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
}

.play-screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow: hidden;
  background: var(--night);
  isolation: isolate;
}

[data-screen="play"] .scene-picker {
  display: none;
}

[data-screen="play"] .play-screen {
  display: block;
}

.scene-background,
.scene-background img,
.scene-grade,
.effects-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.scene-background {
  z-index: 0;
  background: #080b2b;
}

.scene-background img {
  object-fit: cover;
}

.scene-grade {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(1, 2, 15, 0.08), transparent 50%, rgba(1, 2, 15, 0.12)),
    radial-gradient(ellipse at center, transparent 56%, rgba(1, 2, 18, 0.2) 100%);
}

.effects-canvas {
  z-index: 2;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: absolute;
  z-index: 10;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  left: max(14px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
}

.hud-button {
  min-width: 94px;
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: #fff;
  background: var(--glass);
  box-shadow: 0 10px 28px rgba(2, 4, 25, 0.3);
  font-size: 15px;
  font-weight: 950;
  text-decoration: none;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(16px) saturate(135%);
  pointer-events: auto;
  touch-action: manipulation;
  transition: background 170ms ease-out, transform 170ms ease-out;
}

.hud-button:active {
  transform: scale(0.96);
  background: var(--glass-strong);
}

.hud > .hud-button:first-child {
  justify-self: start;
}

.scene-button {
  min-width: 132px;
  flex-direction: column;
  line-height: 1.05;
}

.scene-button small {
  margin-top: 4px;
  color: var(--sky);
  font-size: 11px;
  font-weight: 850;
}

.sound-button {
  justify-self: end;
  gap: 9px;
}

.sound-button strong {
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #0d1834;
  background: #aaf1cc;
  font-size: 12px;
  text-align: center;
}

.sound-button[aria-pressed="false"] strong {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

.window-hint {
  position: absolute;
  z-index: 9;
  left: 50%;
  bottom: max(104px, calc(env(safe-area-inset-bottom) + 92px));
  max-width: calc(100vw - 36px);
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #fff;
  background: rgba(78, 35, 50, 0.76);
  box-shadow: 0 10px 30px rgba(1, 3, 20, 0.3);
  font-size: 14px;
  font-weight: 900;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  pointer-events: none;
}

.window-hint.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 900px) {
  .scene-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scene-card {
    min-height: clamp(230px, 34vh, 330px);
  }
}

@media (max-width: 600px) {
  .scene-picker {
    padding-top: max(18px, env(safe-area-inset-top));
  }

  .picker-copy {
    padding-top: 58px;
    margin-bottom: 24px;
  }

  .home-link {
    min-width: 104px;
    min-height: 48px;
  }

  .picker-copy h1 {
    font-size: clamp(42px, 15vw, 64px);
  }

  .scene-grid {
    gap: 14px;
  }

  .scene-card {
    min-height: 235px;
    border-radius: 23px;
  }

  .scene-name {
    left: 16px;
    bottom: 45px;
    font-size: 25px;
  }

  .scene-hint {
    left: 16px;
    bottom: 18px;
    font-size: 12px;
  }

  .hud {
    gap: 8px;
  }

  .hud-button {
    min-width: 74px;
    min-height: 50px;
    padding: 0 12px;
    border-radius: 16px;
    font-size: 13px;
  }

  .scene-button {
    min-width: 110px;
  }

  .sound-button {
    gap: 5px;
  }

}

@media (max-width: 430px) {
  .scene-grid {
    grid-template-columns: 1fr;
  }

  .scene-card {
    min-height: 220px;
  }

  .picker-copy > p:last-child {
    font-size: 16px;
  }

  .hud-button > span:first-child:not(#scene-title),
  .sound-button > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .sound-button {
    min-width: 54px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .scene-picker {
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .picker-copy {
    margin-bottom: 16px;
  }

  .picker-copy h1 {
    font-size: 45px;
  }

  .picker-copy > p:last-child,
  .eyebrow,
  .picker-tip {
    display: none;
  }

  .scene-card {
    min-height: 190px;
  }

}

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