:root {
  color-scheme: dark;
  --bg: #05070b;
  --panel: rgba(8, 13, 24, 0.8);
  --panel-strong: rgba(7, 10, 20, 0.94);
  --line: rgba(113, 224, 255, 0.3);
  --line-hot: #68e7ff;
  --gold: #ffd84a;
  --green: #67f08b;
  --pink: #ff5f9f;
  --violet: #9d7cff;
  --red: #ff4c5f;
  --bifly-cyan: #55edf0;
  --bifly-navy: #06164f;
  --bifly-pink: #ff77d6;
  --ink: #f7fbff;
  --muted: #93a6bd;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --display-font: "Fredoka", "Assistant", "Noto Sans Hebrew", Arial, sans-serif;
  --body-font: "Assistant", "Noto Sans Hebrew", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.7)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 80px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 80px),
    #05070b;
  color: var(--ink);
  font-family: var(--body-font);
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.game-shell {
  --shell-padding: clamp(8px, 1.4vw, 18px);
  --stage-width: min(
    calc(100vw - var(--shell-padding) - var(--shell-padding)),
    1180px,
    calc((100dvh - 132px - var(--shell-padding) - var(--shell-padding)) * 1.3333)
  );
  --joystick-size: 112px;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: center;
  gap: clamp(6px, 1.1dvh, 10px);
  padding: var(--shell-padding);
}

.stage {
  position: relative;
  width: var(--stage-width);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  touch-action: none;
  border: 1px solid rgba(104, 231, 255, 0.24);
  background: #02040a;
  box-shadow:
    var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 0 70px rgba(10, 55, 96, 0.35);
}

.stage-hit {
  animation: stageHit 460ms ease;
}

#game-static-canvas,
#game-static-collectibles-canvas,
#game-compositor-collectibles,
#game-compositor-actors,
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#game-static-canvas,
#game-static-collectibles-canvas,
#game-compositor-collectibles,
#game-compositor-actors {
  background: transparent;
  pointer-events: none;
  transform-origin: 0 0;
  visibility: hidden;
}

#game-compositor-collectibles,
#game-compositor-actors {
  z-index: 2;
  overflow: hidden;
  contain: layout paint style;
}

#game-compositor-collectibles {
  z-index: 1;
  overflow: visible;
  backface-visibility: hidden;
  will-change: transform;
}

.game-compositor-collectible {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff8bc;
  background: #ffe45f;
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 0 4px rgba(255, 242, 153, 0.95), 0 0 9px rgba(255, 216, 74, 0.55);
  font: 900 13px/1 system-ui, sans-serif;
}

.game-compositor-collectible--standard,
.game-compositor-collectible--bonus {
  background: radial-gradient(circle at 38% 32%, #fffde0 0 24%, #e9ef79 33%, #96b34b 57%, #486e35 74%, #233b2b 100%);
  border-color: rgba(255, 251, 202, 0.88);
  box-shadow: 0 0 4px rgba(255, 250, 184, 0.92), 0 0 9px rgba(204, 231, 92, 0.52);
}

.game-compositor-collectible--bonus-letter {
  border-radius: 7px;
  color: #6b4314;
  background: linear-gradient(145deg, #fff7b2, #ffd84a);
  border-color: #fffce0;
}

.game-compositor-collectible--ice-gem {
  border: 0;
  border-radius: 0;
  clip-path: polygon(50% 0, 91% 50%, 50% 100%, 9% 50%);
  background: conic-gradient(from 0deg, #a6f5ff 0 25%, #168ecb 25% 50%, #4bbdec 50% 75%, #edfeff 75% 100%);
  box-shadow: none;
}

.game-compositor-collectible--bonus-key {
  color: #6f4400;
  background: #ffd84a;
}

.game-compositor-collectible--power,
.game-compositor-collectible--boss-core {
  color: #fff;
  background: #6ee7ff;
  border-color: #eaffff;
  box-shadow: 0 0 5px rgba(255, 255, 255, 0.95), 0 0 12px rgba(104, 231, 255, 0.7);
}

.game-compositor-actor {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  object-fit: contain;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.game-compositor-actor--boss {
  background-repeat: no-repeat;
  image-rendering: auto;
}

.game-compositor-chest {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  pointer-events: none;
  user-select: none;
  transform-origin: 50% 62%;
  backface-visibility: hidden;
  will-change: transform;
  z-index: 4;
}

.game-compositor-chest::before,
.game-compositor-chest::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.game-compositor-chest::before {
  left: 18%;
  right: 18%;
  bottom: 2%;
  height: 18%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.52);
  filter: blur(2px);
}

.game-compositor-chest::after {
  inset: -20%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 230, 112, 0.42), rgba(255, 186, 45, 0.16) 46%, rgba(255, 216, 74, 0) 72%);
  opacity: 0;
}

.game-compositor-chest.is-ready::after {
  opacity: 0.72;
}

.game-compositor-chest.is-opened::after {
  opacity: 0.9;
}

.game-compositor-chest-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: 50% 62%;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.game-compositor-chest-image--closed {
  z-index: 2;
}

.game-compositor-chest-image--open {
  z-index: 3;
  opacity: 0;
}

.game-compositor-reward {
  --reward-color: #ffd84a;
  --reward-accent: #fff7c6;
  position: absolute;
  left: 50%;
  top: clamp(52px, 10%, 78px);
  z-index: 12;
  display: none;
  align-items: center;
  gap: 12px;
  width: min(350px, calc(100% - 28px));
  min-height: 88px;
  padding: 10px 14px;
  direction: rtl;
  color: #f7fbff;
  background: linear-gradient(180deg, rgba(10, 20, 44, 0.97), rgba(2, 5, 14, 0.98));
  border: 2px solid var(--reward-color);
  border-radius: 20px;
  box-shadow:
    0 0 24px rgba(255, 216, 74, 0.42),
    0 12px 26px rgba(0, 0, 0, 0.5),
    inset 0 -7px 0 rgba(0, 0, 0, 0.2);
  pointer-events: none;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

.game-compositor-reward::after {
  content: "";
  position: absolute;
  inset: auto 8% 7px;
  height: 5px;
  border-radius: 999px;
  background: var(--reward-color);
  box-shadow: 0 0 12px var(--reward-color);
  opacity: 0.34;
}

.game-compositor-reward-icon {
  display: grid;
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  place-items: center;
  color: var(--reward-color);
  background: rgba(14, 29, 57, 0.96);
  border: 2px solid var(--reward-accent);
  border-radius: 18px;
  box-shadow: 0 0 18px rgba(255, 216, 74, 0.4);
}

.game-compositor-reward-icon .ui-icon {
  width: 38px;
  height: 38px;
  filter: drop-shadow(0 0 7px var(--reward-color));
}

.game-compositor-reward-copy {
  display: grid;
  flex: 1 1 auto;
  gap: 1px;
  min-width: 0;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.78);
}

.game-compositor-reward-title,
.game-compositor-reward-label,
.game-compositor-reward-detail {
  display: block;
}

.game-compositor-reward-title {
  color: var(--reward-accent);
  font: 800 15px/1.1 Assistant, system-ui, sans-serif;
}

.game-compositor-reward-label {
  color: var(--reward-color);
  font: 900 25px/1.12 Assistant, system-ui, sans-serif;
  text-shadow: 0 0 12px currentColor;
}

.game-compositor-reward-detail {
  color: #f7fbff;
  font: 800 13px/1.15 Assistant, system-ui, sans-serif;
}

.game-compositor-gate {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255, 235, 126, 0.96);
  border-radius: 50%;
  color: #fff7c6;
  background: rgba(79, 44, 48, 0.88);
  box-shadow: 0 0 12px rgba(255, 176, 80, 0.48);
  font: 900 22px/1 system-ui, sans-serif;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

#game-static-collectibles-canvas {
  background: transparent;
}

#game-canvas {
  background: #02040a;
}

html.low-memory-compositor-active #game-static-canvas,
html.low-memory-compositor-active #game-static-collectibles-canvas,
html.low-memory-compositor-active #game-compositor-collectibles,
html.low-memory-compositor-active #game-compositor-actors {
  visibility: visible;
}

html.android-low-memory-runtime.low-memory-compositor-active #game-static-canvas,
html.android-low-memory-runtime.low-memory-compositor-active #game-static-collectibles-canvas {
  backface-visibility: hidden;
  will-change: transform;
}

html.low-memory-compositor-active #game-canvas {
  display: none !important;
}

.hud {
  position: relative;
  width: var(--stage-width);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 25%) auto;
  align-items: start;
  gap: 12px;
  z-index: 5;
  pointer-events: none;
}

.hud-group {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

.hud-group-main {
  flex-wrap: wrap;
}

.metric {
  min-width: 82px;
  padding: 8px 10px 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(2, 6, 14, 0.68);
  box-shadow: inset 0 0 18px rgba(104, 231, 255, 0.08);
  backdrop-filter: blur(8px);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.1;
  margin-bottom: 4px;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: clamp(16px, 2.2vw, 22px);
  line-height: 1;
  white-space: nowrap;
}

.metric-muted {
  color: var(--muted);
  font-size: 0.78em;
  padding-inline-start: 2px;
}

.metric-progress strong,
.mission-progress {
  direction: ltr;
  unicode-bidi: isolate;
}

.metric-lives strong {
  color: var(--red);
  letter-spacing: 0;
}

.metric-world {
  min-width: 96px;
}

.metric-world strong {
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-mission {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  min-width: 0;
  flex: 0 0 auto;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

.metric-mission strong {
  overflow: hidden;
  color: var(--gold);
  font-size: clamp(13px, 1.7vw, 17px);
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-progress {
  display: block;
  margin-top: 5px;
  color: var(--line-hot);
  font-size: 12px;
  line-height: 1;
}

.metric-pulse {
  animation: metricPulse 440ms ease;
}

.life-hit {
  animation: lifeHit 520ms ease;
}

.progress-wrap {
  height: 12px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.45);
  box-shadow: 0 0 26px rgba(104, 231, 255, 0.18);
}

.progress-pulse {
  animation: progressPulse 520ms ease;
}

#progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold), var(--pink));
  box-shadow: 0 0 20px rgba(255, 216, 74, 0.55);
  transition: width 240ms ease;
}

.hud-actions {
  justify-content: flex-end;
  pointer-events: auto;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(2, 6, 14, 0.72);
  cursor: pointer;
  box-shadow: inset 0 0 18px rgba(104, 231, 255, 0.08);
}

.icon-button:hover,
.icon-button:focus-visible {
  outline: none;
  border-color: rgba(104, 231, 255, 0.7);
  box-shadow:
    0 0 0 3px rgba(104, 231, 255, 0.18),
    inset 0 0 18px rgba(104, 231, 255, 0.12);
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 14;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: clamp(10px, 2vmin, 24px);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0.76)),
    rgba(2, 5, 12, 0.62);
  backdrop-filter: blur(6px);
}

.dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 12;
  width: min(300px, calc(100% - 48px));
  display: block;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.dialog[hidden],
.screen[hidden] {
  display: none;
}

.dialog-inner,
.screen-panel {
  position: relative;
  isolation: isolate;
  border: 1px solid rgba(104, 231, 255, 0.42);
  background:
    linear-gradient(180deg, rgba(10, 16, 32, 0.96), rgba(5, 7, 17, 0.98)),
    var(--panel-strong);
  box-shadow:
    0 24px 90px rgba(0, 0, 0, 0.66),
    0 0 0 4px rgba(104, 231, 255, 0.04),
    inset 0 0 44px rgba(104, 231, 255, 0.08);
  text-align: center;
}

.dialog-inner::before,
.screen-panel::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: -1;
  border: 1px solid rgba(255, 216, 74, 0.18);
  pointer-events: none;
}

.screen-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, transparent 0 9px, rgba(104, 231, 255, 0.08) 9px 10px, transparent 10px 100%),
    linear-gradient(0deg, transparent 0 9px, rgba(255, 216, 74, 0.07) 9px 10px, transparent 10px 100%);
  background-size: 40px 40px;
  opacity: 0.34;
  pointer-events: none;
}

.dialog-inner {
  width: 100%;
  padding: clamp(12px, 2vw, 18px);
}

.start-layout {
  position: relative;
  isolation: isolate;
  width: min(980px, 94vw);
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(300px, 40%) minmax(440px, 60%);
  align-items: stretch;
  justify-content: center;
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(104, 231, 255, 0.42);
  background:
    linear-gradient(135deg, rgba(12, 18, 39, 0.98), rgba(4, 7, 18, 0.99)),
    var(--panel-strong);
  box-shadow:
    0 28px 100px rgba(0, 0, 0, 0.72),
    0 0 0 4px rgba(104, 231, 255, 0.04),
    0 0 60px rgba(102, 66, 255, 0.12),
    inset 0 0 50px rgba(104, 231, 255, 0.06);
  direction: ltr;
}

.start-layout::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: 3;
  border: 1px solid rgba(255, 216, 74, 0.14);
  pointer-events: none;
}

.start-layout .screen-panel {
  width: 100%;
  max-height: min(88dvh, 780px);
  padding: clamp(20px, 2.5vmin, 30px);
  border: 0;
  background:
    linear-gradient(90deg, rgba(5, 8, 20, 0.82), rgba(5, 8, 20, 0.98) 16%),
    transparent;
  box-shadow: none;
  direction: rtl;
  scrollbar-gutter: stable;
}

.start-layout .screen-panel::before {
  display: none;
}

.start-layout .screen-panel::after {
  opacity: 0.2;
}

.start-poster-frame {
  position: relative;
  width: 100%;
  min-height: 100%;
  max-height: min(88dvh, 780px);
  aspect-ratio: auto;
  margin: 0;
  overflow: hidden;
  background: #050318;
  box-shadow: inset -24px 0 40px rgba(3, 5, 15, 0.5);
}

.start-poster-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 64%, rgba(5, 8, 20, 0.72) 88%, #050814 100%),
    linear-gradient(180deg, rgba(4, 3, 22, 0.04), transparent 72%, rgba(4, 3, 22, 0.32));
  box-shadow: inset 0 0 36px rgba(8, 3, 42, 0.18);
  pointer-events: none;
}

.start-poster {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.screen-panel {
  width: min(520px, 92%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(18px, 3vmin, 30px);
  scrollbar-gutter: stable;
}

.dialog-kicker,
.eyebrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid rgba(104, 231, 255, 0.42);
  color: var(--line-hot);
  background: rgba(104, 231, 255, 0.1);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
  box-shadow: inset 0 0 16px rgba(104, 231, 255, 0.08);
}

.dialog h1,
.screen h1 {
  margin: 16px 0 18px;
  color: var(--gold);
  font-family: var(--display-font);
  font-weight: 700;
  font-size: clamp(36px, 7vw, 66px);
  line-height: 1;
  text-shadow: 0 0 24px rgba(255, 216, 74, 0.42);
}

.dialog h1 {
  direction: ltr;
  unicode-bidi: bidi-override;
  font-size: clamp(30px, 4.8vw, 42px);
}

.question-timer {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 74px;
  margin-top: 10px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 216, 74, 0.36);
  background: rgba(255, 216, 74, 0.08);
  color: var(--gold);
  font-size: 14px;
  line-height: 1;
}

.question-timer[hidden] {
  display: none;
}

.question-timer strong {
  min-width: 2ch;
  font-size: 20px;
  line-height: 1;
  text-align: center;
}

.question-timer-low {
  border-color: rgba(255, 76, 95, 0.65);
  background: rgba(255, 76, 95, 0.14);
  color: var(--red);
}

.screen h1 {
  margin-top: 10px;
  font-size: clamp(34px, 6vw, 56px);
  letter-spacing: 0;
}

#start-screen h1 {
  color: #9af8fb;
  text-shadow:
    0 0 24px rgba(85, 237, 240, 0.5),
    0 0 44px rgba(255, 119, 214, 0.16);
}

.start-graphic {
  position: relative;
  display: grid;
  grid-template-columns: 58px repeat(3, 12px) 46px 46px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 74px;
  margin: 10px auto 4px;
  overflow: hidden;
  border-block: 1px solid rgba(104, 231, 255, 0.16);
}

.start-graphic::before {
  content: "×";
  position: absolute;
  inset-inline-start: 38px;
  top: 50%;
  color: rgba(255, 216, 74, 0.44);
  font-family: var(--display-font);
  font-size: 34px;
  transform: translateY(-52%);
}

.start-graphic::after {
  content: "12";
  position: absolute;
  inset-inline-end: 32px;
  top: 50%;
  color: rgba(103, 240, 139, 0.44);
  font-family: var(--display-font);
  font-size: 24px;
  transform: translateY(-48%);
}

.start-graphic-player {
  width: 54px;
  height: 54px;
  background: url("assets/bifly-player.png") center / contain no-repeat;
  filter:
    drop-shadow(0 0 10px rgba(85, 237, 240, 0.58))
    drop-shadow(0 0 14px rgba(255, 119, 214, 0.2));
}

.start-graphic-player::before,
.start-graphic-player::after {
  content: none;
}

.start-graphic-collectible {
  width: 9px;
  height: 9px;
  background: #f7fbff;
  box-shadow: 0 0 12px rgba(247, 251, 255, 0.66);
  transform: rotate(45deg);
}

.start-graphic-enemy {
  width: 46px;
  height: 46px;
  background: url("assets/dark-enemy.png") center / contain no-repeat;
  filter:
    drop-shadow(0 0 9px rgba(131, 91, 255, 0.72))
    drop-shadow(0 0 15px rgba(77, 40, 190, 0.38));
}

.start-graphic-enemy::before,
.start-graphic-enemy::after {
  content: none;
}

.start-graphic-enemy-b {
  opacity: 0.78;
  transform: scale(0.88);
  filter:
    drop-shadow(0 0 8px rgba(85, 237, 240, 0.52))
    drop-shadow(0 0 13px rgba(77, 40, 190, 0.34));
}

#answer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  direction: ltr;
}

#answer-input {
  min-width: 0;
  height: 48px;
  border: 1px solid rgba(104, 231, 255, 0.44);
  background: rgba(0, 0, 0, 0.42);
  color: var(--ink);
  text-align: center;
  font-size: 24px;
  outline: none;
}

#answer-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 216, 74, 0.18);
}

#submit-answer,
.primary-button {
  min-height: 48px;
  border: 1px solid rgba(247, 251, 255, 0.16);
  background: linear-gradient(135deg, #13c985, #86f76f);
  color: #031009;
  cursor: pointer;
  font-family: var(--display-font);
  font-weight: 700;
  padding: 0 16px;
  box-shadow:
    0 12px 34px rgba(19, 201, 133, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

#submit-answer:hover,
#submit-answer:focus-visible,
.primary-button:hover,
.primary-button:focus-visible {
  outline: none;
  filter: brightness(1.08);
  box-shadow:
    0 0 0 3px rgba(103, 240, 139, 0.2),
    0 16px 42px rgba(19, 201, 133, 0.3);
}

#question-feedback {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--muted);
}

.screen-visible {
  display: grid;
}

.screen-panel {
  border-color: rgba(104, 231, 255, 0.34);
}

.screen-panel p {
  margin: 0;
}

.screen-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 22px;
}

.screen-stats span {
  min-width: 104px;
  padding: 9px 12px;
  border: 1px solid rgba(104, 231, 255, 0.2);
  background: rgba(104, 231, 255, 0.055);
  color: var(--muted);
  box-shadow: inset 0 0 18px rgba(104, 231, 255, 0.05);
}

.screen-stats strong {
  color: var(--ink);
}

.name-form {
  display: grid;
  gap: 10px;
  margin-top: 4px;
}

.name-form label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

#player-name-input {
  width: 100%;
  height: 54px;
  border: 1px solid rgba(104, 231, 255, 0.5);
  background: rgba(0, 0, 0, 0.5);
  color: var(--ink);
  text-align: center;
  font-family: var(--display-font);
  font-size: 24px;
  outline: none;
  box-shadow:
    inset 0 0 18px rgba(104, 231, 255, 0.08),
    0 10px 26px rgba(0, 0, 0, 0.22);
}

#player-name-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 216, 74, 0.18);
}

.form-note {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
}

.difficulty-field {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.difficulty-field legend {
  display: block;
  width: 100%;
  padding: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 0 10px rgba(104, 231, 255, 0.28);
  transform: translateY(-3px);
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.difficulty-options label {
  min-width: 0;
}

.difficulty-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.difficulty-options span {
  display: grid;
  min-height: 42px;
  place-items: center;
  padding: 0 7px;
  border: 1px solid rgba(104, 231, 255, 0.32);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.025));
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
  box-shadow: inset 0 0 16px rgba(104, 231, 255, 0.04);
}

.difficulty-options input:checked + span {
  border-color: rgba(255, 216, 74, 0.82);
  background:
    linear-gradient(180deg, rgba(255, 216, 74, 0.22), rgba(255, 216, 74, 0.08));
  color: var(--gold);
  box-shadow:
    0 0 0 2px rgba(255, 216, 74, 0.08),
    inset 0 0 20px rgba(255, 216, 74, 0.12);
}

.difficulty-options input:focus-visible + span {
  outline: 2px solid rgba(104, 231, 255, 0.72);
  outline-offset: 2px;
}

.time-limit-setting {
  display: grid;
  justify-items: center;
  gap: 7px;
  margin: 2px 0 4px;
}

.time-limit-title {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
}

.time-limit-toggle {
  position: relative;
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  border: 1px solid rgba(104, 231, 255, 0.34);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(104, 231, 255, 0.16), rgba(2, 6, 14, 0.76) 68%),
    rgba(255, 255, 255, 0.04);
  cursor: pointer;
  box-shadow:
    inset 0 0 18px rgba(104, 231, 255, 0.1),
    0 12px 28px rgba(0, 0, 0, 0.34);
}

.time-limit-toggle:hover,
.time-limit-toggle:focus-visible {
  outline: none;
  border-color: rgba(255, 216, 74, 0.78);
  box-shadow:
    0 0 0 3px rgba(255, 216, 74, 0.14),
    inset 0 0 18px rgba(255, 216, 74, 0.12),
    0 14px 32px rgba(0, 0, 0, 0.4);
}

.time-limit-toggle[aria-pressed="true"] {
  border-color: rgba(255, 216, 74, 0.86);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 216, 74, 0.24), rgba(2, 6, 14, 0.78) 68%),
    rgba(255, 216, 74, 0.08);
}

.clock-icon {
  position: relative;
  width: 28px;
  height: 28px;
  border: 3px solid currentColor;
  border-radius: 50%;
  color: var(--line-hot);
}

.time-limit-toggle[aria-pressed="true"] .clock-icon {
  color: var(--gold);
}

.clock-icon::before,
.clock-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 3px;
  background: currentColor;
  border-radius: 999px;
  transform-origin: bottom center;
}

.clock-icon::before {
  height: 9px;
  transform: translateX(-50%) rotate(0deg);
}

.clock-icon::after {
  height: 7px;
  transform: translateX(-50%) rotate(115deg);
}

.time-limit-state {
  min-height: 17px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
}

.time-limit-toggle[aria-pressed="true"] + .time-limit-state {
  color: var(--gold);
}

.winner-trophy {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(150px, 22vmin, 210px);
  height: clamp(166px, 24vmin, 236px);
  margin: 0 0 8px;
  isolation: isolate;
  perspective: 800px;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.34)) drop-shadow(0 0 22px rgba(255, 216, 74, 0.44));
}

.winner-trophy[hidden] {
  display: none !important;
}

.trophy-stage-glow,
.trophy-ground-shadow {
  position: absolute;
  inset-inline: 8%;
  border-radius: 50%;
  pointer-events: none;
}

.trophy-stage-glow {
  inset-block-start: 5%;
  height: 58%;
  z-index: -2;
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 237, 142, 0.44), rgba(255, 216, 74, 0.14) 42%, transparent 72%),
    radial-gradient(circle at 50% 60%, rgba(85, 255, 214, 0.2), transparent 66%);
  filter: blur(3px);
  animation: trophyAura 2600ms ease-in-out infinite;
}

.trophy-ground-shadow {
  inset-block-end: 1%;
  height: 15%;
  z-index: -1;
  background:
    radial-gradient(ellipse at center, rgba(255, 216, 74, 0.28), rgba(85, 255, 214, 0.11) 42%, transparent 74%);
  filter: blur(5px);
}

.trophy-cup-3d {
  position: absolute;
  inset-block-start: 12%;
  width: 62%;
  height: 42%;
  border: 2px solid rgba(255, 247, 196, 0.72);
  border-radius: 46% 46% 36% 36% / 20% 20% 66% 66%;
  background:
    linear-gradient(112deg, rgba(255, 255, 255, 0.74) 0 9%, transparent 10% 25%, rgba(255, 255, 255, 0.32) 30%, transparent 45%),
    radial-gradient(circle at 30% 22%, #fff9c8 0 12%, transparent 25%),
    linear-gradient(100deg, #6d3300 0%, #df840f 13%, #fff0a4 34%, #ffd84a 52%, #c66f0b 73%, #5b2700 100%);
  box-shadow:
    inset 11px 0 20px rgba(255, 255, 255, 0.18),
    inset -16px -12px 24px rgba(72, 30, 0, 0.46),
    inset 0 -8px 12px rgba(107, 55, 0, 0.34),
    0 12px 24px rgba(0, 0, 0, 0.26);
  transform: rotateX(8deg) translateZ(16px);
}

.trophy-cup-3d::after {
  content: "";
  position: absolute;
  inset: 5% 8% auto;
  height: 36%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent);
  mix-blend-mode: screen;
  pointer-events: none;
}

.trophy-rim {
  position: absolute;
  inset-block-start: -9%;
  inset-inline: -9%;
  height: 22%;
  border: 1px solid rgba(255, 253, 211, 0.8);
  border-radius: 50%;
  background:
    linear-gradient(92deg, #693000 0%, #e99a19 18%, #fff7bd 47%, #f7b52b 72%, #753800 100%);
  box-shadow:
    inset 0 -6px 10px rgba(91, 39, 0, 0.34),
    0 4px 10px rgba(0, 0, 0, 0.24);
}

.trophy-handle {
  position: absolute;
  inset-block-start: 23%;
  width: 34%;
  height: 50%;
  z-index: -1;
  border: clamp(8px, 1.6vmin, 16px) solid #d98712;
  border-block-start-color: #fff0a4;
  border-block-end-color: #71400a;
  border-radius: 50%;
  box-shadow:
    inset 0 0 10px rgba(255, 255, 255, 0.24),
    0 7px 12px rgba(0, 0, 0, 0.24);
}

.trophy-handle-left {
  inset-inline-start: -24%;
  border-inline-end-color: transparent;
  transform: rotate(-8deg);
}

.trophy-handle-right {
  inset-inline-end: -24%;
  border-inline-start-color: transparent;
  transform: rotate(8deg);
}

.trophy-logo-gold {
  position: absolute;
  inset-block-start: 42%;
  left: 50%;
  transform: translate(-50%, -50%) rotateX(4deg);
  direction: rtl;
  color: #5f2c00;
  font-size: clamp(22px, 4.1vmin, 40px);
  font-weight: 1000;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    0 1px 0 rgba(255, 252, 196, 0.72),
    0 3px 8px rgba(90, 38, 0, 0.54);
  background: linear-gradient(180deg, #fff8c8, #ffd84a 46%, #9a5306 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.trophy-shine {
  position: absolute;
  inset-block-start: 4%;
  inset-inline-start: 15%;
  width: 18%;
  height: 72%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), transparent 74%);
  filter: blur(1px);
  opacity: 0.82;
  transform: rotate(14deg);
  animation: trophyShine 2400ms ease-in-out infinite;
}

.trophy-stem-3d {
  position: absolute;
  inset-block-start: 52%;
  width: 16%;
  height: 24%;
  border-radius: 8px 8px 14px 14px;
  background:
    linear-gradient(90deg, #704000, #ffd84a 22%, #fff4af 47%, #c56d09 71%, #4d2200);
  box-shadow:
    inset -8px 0 11px rgba(68, 28, 0, 0.36),
    0 8px 14px rgba(0, 0, 0, 0.26);
}

.trophy-base-3d {
  position: absolute;
  inset-block-start: 71%;
  width: 72%;
  height: 20%;
  display: grid;
  place-items: center;
  padding: 0 10%;
  border: 1px solid rgba(255, 233, 139, 0.7);
  border-radius: 14px 14px 18px 18px;
  background:
    linear-gradient(180deg, rgba(255, 230, 125, 0.96), rgba(187, 95, 10, 0.94) 37%, rgba(75, 34, 8, 0.98) 100%);
  box-shadow:
    inset 0 7px 9px rgba(255, 255, 255, 0.22),
    inset 0 -12px 16px rgba(31, 12, 2, 0.52),
    0 12px 22px rgba(0, 0, 0, 0.34);
}

.trophy-base-3d::before {
  content: "";
  position: absolute;
  inset: 22% 9% 27%;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(30, 12, 3, 0.62), rgba(114, 55, 5, 0.58));
  box-shadow:
    inset 0 2px 3px rgba(0, 0, 0, 0.42),
    0 1px 0 rgba(255, 242, 178, 0.22);
}

.trophy-engraved-name {
  position: relative;
  z-index: 1;
  max-width: 100%;
  overflow: hidden;
  color: #fff2ad;
  font-size: clamp(13px, 2.4vmin, 22px);
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.28),
    0 -1px 0 rgba(47, 18, 0, 0.88);
  white-space: nowrap;
}

.champion-trophy-art {
  width: clamp(220px, 32vmin, 340px);
  height: clamp(220px, 32vmin, 340px);
  overflow: visible;
}

.champion-trophy-image {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  filter:
    drop-shadow(0 18px 22px rgba(0, 0, 0, 0.36))
    drop-shadow(0 0 28px rgba(255, 216, 74, 0.38));
  transform-origin: 50% 64%;
  will-change: transform, filter;
}

.champion-trophy-art::before,
.champion-trophy-art::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.champion-trophy-art::before {
  inset: 7% 9% 10%;
  z-index: 2;
  border-radius: 38% 38% 28% 28%;
  background:
    linear-gradient(105deg, transparent 0 35%, rgba(255, 255, 255, 0.62) 45%, rgba(255, 246, 184, 0.36) 50%, transparent 60% 100%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: translateX(-72%) skewX(-10deg);
}

.champion-trophy-art::after {
  inset: 0;
  z-index: 4;
  background:
    radial-gradient(circle at 74% 25%, rgba(255, 255, 255, 0.96) 0 2px, rgba(255, 216, 74, 0.5) 3px, transparent 9px),
    radial-gradient(circle at 50% 49%, rgba(255, 255, 255, 0.9) 0 2px, rgba(255, 216, 74, 0.42) 3px, transparent 8px),
    radial-gradient(circle at 35% 66%, rgba(255, 255, 255, 0.86) 0 2px, rgba(255, 216, 74, 0.42) 3px, transparent 7px);
  opacity: 0;
}

.champion-trophy-art .trophy-stage-glow {
  inset: 9% 9% auto;
  height: 62%;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 52%, rgba(255, 246, 184, 0.46), rgba(255, 216, 74, 0.16) 38%, transparent 72%),
    radial-gradient(circle at 50% 65%, rgba(85, 255, 214, 0.2), transparent 67%);
}

.champion-trophy-art .trophy-ground-shadow {
  inset-inline: 18%;
  inset-block-end: 3%;
  height: 12%;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.34), transparent 72%);
  filter: blur(5px);
}

.champion-trophy-art .trophy-logo-gold {
  position: absolute;
  top: 30.85%;
  inset-inline-start: auto;
  inset-inline-end: auto;
  left: 50%;
  z-index: 1;
  width: 34%;
  height: 11.2%;
  overflow: visible;
  transform: translateX(-50%);
  transform-origin: center center;
  will-change: transform, filter;
  pointer-events: none;
}

.champion-trophy-art .trophy-logo-plaque {
  fill: url(#trophy-logo-plaque-gradient);
  filter: url(#trophy-logo-plaque-shadow);
  stroke: rgba(255, 237, 139, 0.62);
  stroke-width: 2.6px;
}

.champion-trophy-art .trophy-logo-text {
  fill: #ffdc3f;
  filter:
    drop-shadow(0 2px 1px rgba(74, 31, 0, 0.72))
    drop-shadow(0 0 4px rgba(255, 246, 184, 0.46));
  font-family: Assistant, Arial, sans-serif;
  font-size: 54px;
  font-weight: 900;
  letter-spacing: 0;
  paint-order: stroke fill;
  stroke: rgba(76, 32, 0, 0.62);
  stroke-width: 4px;
}

.champion-trophy-art .trophy-engraved-name {
  position: absolute;
  top: 76.55%;
  left: 50.05%;
  z-index: 1;
  width: 43%;
  max-width: 43%;
  height: 5%;
  display: grid;
  place-items: center;
  transform: translateX(-50%);
  color: #ffe99b;
  font-size: clamp(14px, 2.8vmin, 28px);
  font-weight: 1000;
  line-height: 0.95;
  text-align: center;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.26),
    0 2px 4px rgba(0, 0, 0, 0.68),
    0 -1px 0 rgba(59, 22, 0, 0.9);
  white-space: nowrap;
  will-change: transform, filter;
}

.trophy-share-button {
  position: fixed;
  inset-block-start: calc(env(safe-area-inset-top, 0px) + 14px);
  inset-inline-end: calc(env(safe-area-inset-right, 0px) + 14px);
  z-index: 5;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08)),
    rgba(4, 12, 31, 0.86);
  color: #f8ffff;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.36),
    0 0 18px rgba(85, 255, 214, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  backdrop-filter: blur(10px);
}

.trophy-share-button[hidden] {
  display: none;
}

.trophy-share-button .ui-icon {
  width: 22px;
  height: 22px;
}

.trophy-share-status {
  min-height: 20px;
  color: #dffcff;
  font-weight: 800;
}

.victory-confetti {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.victory-confetti i,
.victory-confetti b,
.victory-confetti em {
  position: absolute;
  pointer-events: none;
}

.victory-confetti i {
  top: -12vh;
  width: var(--confetti-w, 9px);
  height: var(--confetti-h, 18px);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), transparent 42%),
    var(--confetti-color, #ffd84a);
  opacity: 0;
  box-shadow: 0 0 10px color-mix(in srgb, var(--confetti-color, #ffd84a) 55%, transparent);
  transform: translate3d(0, -12vh, 0) rotate(var(--confetti-start-rotate, 0deg));
}

.victory-confetti i[data-shape="circle"] {
  border-radius: 50%;
  height: var(--confetti-w, 9px);
}

.victory-confetti i[data-shape="diamond"] {
  border-radius: 2px;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.victory-confetti i[data-shape="star"] {
  border-radius: 0;
  clip-path: polygon(50% 0, 61% 34%, 98% 35%, 68% 56%, 79% 91%, 50% 70%, 21% 91%, 32% 56%, 2% 35%, 39% 34%);
}

.victory-confetti i[data-shape="ribbon"] {
  width: calc(var(--confetti-w, 9px) * 1.8);
  height: calc(var(--confetti-h, 18px) * 0.42);
  border-radius: 999px;
}

.victory-confetti b {
  left: var(--burst-x, 50%);
  top: var(--burst-y, 24%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  opacity: 0;
  background: var(--burst-color, #ffd84a);
  box-shadow:
    0 -52px 0 -1px var(--burst-color, #ffd84a),
    37px -37px 0 -1px #55ffd6,
    52px 0 0 -1px #ff5fd7,
    37px 37px 0 -1px #fff7c6,
    0 52px 0 -1px #9d7cff,
    -37px 37px 0 -1px #67f08b,
    -52px 0 0 -1px #ffd84a,
    -37px -37px 0 -1px #ff9f1c;
  transform: translate(-50%, -50%) scale(0.1);
}

.victory-confetti em {
  top: -10vh;
  width: 34px;
  height: 26px;
  border: 4px solid var(--confetti-color, #ffd84a);
  border-inline-start-color: transparent;
  border-block-end-color: transparent;
  border-radius: 50%;
  opacity: 0;
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--confetti-color, #ffd84a) 46%, transparent));
  transform: translate3d(0, -12vh, 0) rotate(0deg);
}

.final-trophy-screen .victory-confetti::before,
.final-trophy-screen .victory-confetti::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 18%;
  width: min(76vw, 520px);
  height: min(76vw, 520px);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.35);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 247, 198, 0.9) 0 2px, transparent 3px),
    radial-gradient(circle at 88% 24%, rgba(85, 255, 214, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 74% 84%, rgba(255, 95, 215, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 18% 76%, rgba(255, 216, 74, 0.9) 0 3px, transparent 4px),
    radial-gradient(circle at 11% 32%, rgba(157, 124, 255, 0.9) 0 3px, transparent 4px);
}

.final-trophy-screen .victory-confetti::after {
  top: 28%;
  width: min(86vw, 620px);
  height: min(86vw, 620px);
  animation-delay: 760ms;
}

.final-trophy-screen {
  overflow: hidden;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 216, 74, 0.2), transparent 30%),
    radial-gradient(circle at 18% 42%, rgba(255, 95, 215, 0.2), transparent 28%),
    radial-gradient(circle at 84% 34%, rgba(85, 255, 214, 0.2), transparent 26%),
    linear-gradient(180deg, rgba(4, 8, 24, 0.54), rgba(2, 3, 12, 0.9)),
    #05070b;
  backdrop-filter: blur(4px);
}

.final-trophy-screen .victory-confetti i {
  opacity: var(--confetti-opacity, 0.96);
  animation: victoryConfettiFall var(--confetti-duration, 3.8s) linear var(--confetti-delay, 0s) infinite;
}

.final-trophy-screen .victory-confetti b {
  animation: victoryConfettiBurst 1900ms ease-out var(--burst-delay, 0s) infinite;
}

.final-trophy-screen .victory-confetti em {
  animation: victoryStreamerFall var(--confetti-duration, 5.2s) ease-in var(--confetti-delay, 0s) infinite;
}

.final-trophy-screen .victory-confetti::before,
.final-trophy-screen .victory-confetti::after {
  animation: trophyFireworkRing 2400ms ease-out infinite;
}

.final-trophy-screen .results-panel {
  z-index: 4;
  width: min(900px, calc(100vw - 20px));
  max-height: calc(100dvh - 20px);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(8px, 1.2dvh, 14px);
  padding: clamp(16px, 2.3vmin, 32px);
  overflow: hidden;
  border-color: rgba(255, 216, 74, 0.62);
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.16), transparent 30%),
    linear-gradient(180deg, rgba(18, 22, 56, 0.96), rgba(5, 8, 26, 0.98));
  box-shadow:
    0 24px 90px rgba(0, 0, 0, 0.62),
    0 0 52px rgba(255, 216, 74, 0.22),
    inset 0 0 58px rgba(104, 231, 255, 0.12);
}

.final-trophy-screen .results-panel::before {
  border-color: rgba(255, 216, 74, 0.32);
}

.final-trophy-screen .winner-trophy {
  width: clamp(250px, 34vmin, 360px);
  height: clamp(250px, 34vmin, 360px);
  margin: 0;
  transform-style: preserve-3d;
  animation:
    trophyEntrance 950ms cubic-bezier(0.16, 1, 0.3, 1) both,
    trophyGlow 2600ms ease-in-out 820ms infinite;
  filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.44)) drop-shadow(0 0 32px rgba(255, 216, 74, 0.5));
}

.final-trophy-screen .champion-trophy-image {
  animation: trophyFloat 3600ms ease-in-out 920ms infinite;
}

.final-trophy-screen .champion-trophy-art::before {
  animation: trophySweep 3300ms ease-in-out 520ms infinite;
}

.final-trophy-screen .champion-trophy-art::after {
  animation: trophySparkle 2600ms ease-in-out 360ms infinite;
}

.final-trophy-screen .trophy-cup-3d {
  border-width: 3px;
}

.final-trophy-screen .champion-trophy-art .trophy-logo-gold {
  animation:
    trophyLogoReveal 680ms cubic-bezier(0.16, 1, 0.3, 1) 180ms both,
    trophyLogoPulse 2500ms ease-in-out 950ms infinite;
}

.final-trophy-screen .champion-trophy-art .trophy-engraved-name {
  font-size: clamp(15px, 3vmin, 28px);
  animation:
    engravedNameReveal 620ms cubic-bezier(0.16, 1, 0.3, 1) 280ms both,
    engravedNameGlow 2800ms ease-in-out 1020ms infinite;
}

.final-trophy-screen #end-kicker {
  margin: 0;
  color: #86fff1;
  font-size: clamp(15px, 2.1vmin, 20px);
  text-shadow: 0 0 14px rgba(85, 255, 214, 0.34);
  animation: victoryTextRise 520ms cubic-bezier(0.16, 1, 0.3, 1) 260ms both;
}

.final-trophy-screen #end-title {
  max-width: min(900px, 24ch);
  margin: 0;
  color: #fff7c6;
  font-size: clamp(34px, 7.3vmin, 64px);
  line-height: 0.98;
  text-wrap: balance;
  text-shadow:
    0 5px 0 rgba(94, 48, 0, 0.55),
    0 0 24px rgba(255, 216, 74, 0.34);
  animation: victoryTitlePop 650ms cubic-bezier(0.16, 1, 0.3, 1) 360ms both;
}

.final-trophy-screen #end-copy {
  max-width: min(600px, 90vw);
  color: #eefcff;
  font-size: clamp(17px, 2.7vmin, 24px);
  font-weight: 900;
  line-height: 1.18;
  animation: victoryTextRise 560ms cubic-bezier(0.16, 1, 0.3, 1) 500ms both;
}

.final-trophy-screen .screen-stats {
  margin: 0;
  gap: 7px;
  animation: victoryTextRise 560ms cubic-bezier(0.16, 1, 0.3, 1) 620ms both;
}

.final-trophy-screen .screen-stats span,
.final-trophy-screen .results-grid span {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
}

.final-trophy-screen .results-grid,
.final-trophy-screen .score-breakdown,
.final-trophy-screen #publish-score-panel {
  display: none;
}

.final-trophy-screen .result-actions {
  margin: 4px 0 0;
  animation: victoryTextRise 560ms cubic-bezier(0.16, 1, 0.3, 1) 760ms both;
}

@keyframes trophyEntrance {
  0% {
    opacity: 0;
    transform: translateY(34px) scale(0.62) rotate(-10deg);
  }
  64% {
    opacity: 1;
    transform: translateY(-7px) scale(1.07) rotate(3deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0);
  }
}

@keyframes trophyGlow {
  0%,
  100% {
    filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.44)) drop-shadow(0 0 30px rgba(255, 216, 74, 0.5));
  }
  50% {
    filter: drop-shadow(0 24px 34px rgba(0, 0, 0, 0.44)) drop-shadow(0 0 52px rgba(85, 255, 214, 0.42));
  }
}

@keyframes trophyFloat {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    filter:
      drop-shadow(0 18px 22px rgba(0, 0, 0, 0.36))
      drop-shadow(0 0 28px rgba(255, 216, 74, 0.38));
  }
  50% {
    transform: translate3d(0, -7px, 0) rotate(0.7deg);
    filter:
      drop-shadow(0 23px 26px rgba(0, 0, 0, 0.32))
      drop-shadow(0 0 42px rgba(255, 216, 74, 0.52));
  }
}

@keyframes trophySweep {
  0%,
  28% {
    opacity: 0;
    transform: translateX(-72%) skewX(-10deg);
  }
  42% {
    opacity: 0.82;
  }
  58% {
    opacity: 0;
    transform: translateX(82%) skewX(-10deg);
  }
  100% {
    opacity: 0;
    transform: translateX(82%) skewX(-10deg);
  }
}

@keyframes trophySparkle {
  0%,
  100% {
    opacity: 0.12;
    transform: scale(0.96) rotate(0deg);
    filter: blur(0);
  }
  28% {
    opacity: 0.92;
    transform: scale(1.04) rotate(6deg);
  }
  42% {
    opacity: 0.25;
  }
  68% {
    opacity: 0.72;
    transform: scale(1.02) rotate(-5deg);
  }
}

@keyframes trophyLogoReveal {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.72);
    filter: blur(4px);
  }
  70% {
    opacity: 1;
    transform: translateX(-50%) scale(1.05);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scale(1);
    filter: blur(0);
  }
}

@keyframes trophyLogoPulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(255, 216, 74, 0));
  }
  50% {
    filter: drop-shadow(0 0 10px rgba(255, 246, 184, 0.46));
  }
}

@keyframes engravedNameReveal {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(6px) scale(0.84);
    filter: blur(3px);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes engravedNameGlow {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(255, 216, 74, 0));
  }
  50% {
    filter: drop-shadow(0 0 7px rgba(255, 216, 74, 0.42));
  }
}

@keyframes trophyAura {
  0%,
  100% {
    opacity: 0.72;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes trophyShine {
  0%,
  100% {
    opacity: 0.48;
    transform: translateX(0) rotate(14deg);
  }
  50% {
    opacity: 0.92;
    transform: translateX(55%) rotate(14deg);
  }
}

@keyframes victoryTextRise {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes victoryTitlePop {
  0% {
    opacity: 0;
    transform: translateY(22px) scale(0.9);
    filter: blur(4px);
  }
  68% {
    opacity: 1;
    transform: translateY(-4px) scale(1.04);
    filter: blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes victoryConfettiFall {
  0% {
    transform: translate3d(0, -12vh, 0) rotate(var(--confetti-start-rotate, 0deg));
  }
  52% {
    transform: translate3d(calc(var(--confetti-drift, 18px) * 0.55), 54vh, 0) rotate(calc(var(--confetti-rotate, 680deg) * 0.52));
  }
  100% {
    transform: translate3d(var(--confetti-drift, 18px), 118vh, 0) rotate(var(--confetti-rotate, 680deg));
  }
}

@keyframes victoryConfettiBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.08) rotate(0deg);
  }
  14% {
    opacity: 1;
  }
  62% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(var(--burst-scale, 1)) rotate(28deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(calc(var(--burst-scale, 1) * 1.35)) rotate(54deg);
  }
}

@keyframes victoryStreamerFall {
  0% {
    opacity: 0;
    transform: translate3d(0, -12vh, 0) rotate(0deg);
  }
  12% {
    opacity: 0.88;
  }
  100% {
    opacity: 0.74;
    transform: translate3d(var(--confetti-drift, 18px), 116vh, 0) rotate(var(--streamer-rotate, 520deg));
  }
}

@keyframes trophyFireworkRing {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.28) rotate(0deg);
  }
  18% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.12) rotate(18deg);
  }
}

.primary-button {
  min-width: min(240px, 100%);
  font-size: 18px;
}

.mobile-joystick {
  display: none;
}

.touch-pad {
  display: none !important;
}

@media (max-height: 820px) {
  .screen {
    padding: 12px;
  }

  .screen-panel {
    padding: 16px;
  }

  .start-layout {
    width: min(900px, 96vw);
    grid-template-columns: minmax(250px, 38%) minmax(390px, 62%);
  }

  .start-poster-frame {
    max-height: calc(100dvh - 24px);
  }

  .start-layout .screen-panel {
    max-height: calc(100dvh - 24px);
  }

  .dialog h1,
  .screen h1 {
    margin: 10px 0 12px;
  }

  .screen h1 {
    font-size: clamp(30px, 5.2vw, 48px);
  }

  .start-graphic {
    grid-template-columns: 46px repeat(3, 9px) 36px 36px;
    gap: 9px;
    height: 52px;
    margin: 6px auto 2px;
  }

  .start-graphic::before {
    inset-inline-start: 30px;
    font-size: 25px;
  }

  .start-graphic::after {
    inset-inline-end: 24px;
    font-size: 19px;
  }

  .start-graphic-player {
    width: 42px;
    height: 42px;
  }

  .start-graphic-collectible {
    width: 7px;
    height: 7px;
  }

  .start-graphic-enemy {
    width: 36px;
    height: 36px;
  }

  .screen-stats {
    gap: 6px;
    margin: 10px 0 12px;
  }

  .screen-stats span {
    padding: 7px 9px;
  }

  .name-form,
  .difficulty-field {
    gap: 8px;
  }

  #player-name-input {
    height: 46px;
    font-size: 20px;
  }

  .difficulty-options span {
    min-height: 38px;
  }

  .time-limit-setting {
    gap: 5px;
    margin: 0;
  }

  .time-limit-toggle {
    width: 48px;
    height: 48px;
  }

  .clock-icon {
    width: 24px;
    height: 24px;
  }

  .primary-button {
    min-height: 44px;
  }
}

@media (max-width: 720px), (max-height: 760px) {
  .final-trophy-screen .results-panel {
    gap: 7px;
    padding: 14px 12px;
  }

  .final-trophy-screen .winner-trophy {
    width: clamp(260px, 72vw, 330px);
    height: clamp(260px, 72vw, 330px);
  }

  .final-trophy-screen .champion-trophy-art .trophy-logo-gold {
    font-size: clamp(26px, 7.4vw, 48px);
  }

  .final-trophy-screen .champion-trophy-art .trophy-engraved-name {
    font-size: clamp(15px, 4vw, 23px);
  }

  .final-trophy-screen #end-title {
    max-width: 13ch;
    font-size: clamp(30px, 8.4vw, 48px);
  }

  .final-trophy-screen #end-copy {
    font-size: clamp(15px, 4vw, 19px);
  }

  .final-trophy-screen .screen-stats span {
    min-width: 88px;
    padding: 7px 9px;
  }

  .final-trophy-screen .results-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .final-trophy-screen .results-grid span {
    padding: 6px 8px;
    font-size: 12px;
  }

  .final-trophy-screen .results-grid strong {
    font-size: 15px;
  }

  .trophy-share-button {
    width: 42px;
    height: 42px;
  }
}

@media (max-height: 620px) {
  .hud {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
  }

  .hud-group-main {
    gap: 4px;
  }

  .metric {
    min-width: 58px;
    padding: 4px 6px;
  }

  .metric-world {
    min-width: 68px;
  }

  .metric-label {
    margin-bottom: 3px;
    font-size: 9px;
  }

  .metric strong {
    font-size: 14px;
  }

  .progress-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 0;
  }

  .icon-button {
    width: 30px;
    height: 30px;
  }
}

.joystick-base {
  position: relative;
  width: var(--joystick-size);
  height: var(--joystick-size);
  border: 1px solid rgba(104, 231, 255, 0.34);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 216, 74, 0.13), transparent 29%),
    radial-gradient(circle at 50% 50%, rgba(104, 231, 255, 0.18), rgba(2, 6, 14, 0.78) 68%);
  box-shadow:
    inset 0 0 28px rgba(104, 231, 255, 0.15),
    0 18px 38px rgba(0, 0, 0, 0.42);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.joystick-base::before,
.joystick-base::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 70%;
  height: 1px;
  background: rgba(247, 251, 255, 0.12);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.joystick-base::after {
  width: 1px;
  height: 70%;
}

.joystick-base.is-active {
  border-color: rgba(255, 216, 74, 0.72);
  cursor: grabbing;
  box-shadow:
    inset 0 0 30px rgba(255, 216, 74, 0.13),
    0 0 0 6px rgba(255, 216, 74, 0.08),
    0 18px 38px rgba(0, 0, 0, 0.42);
}

.joystick-knob {
  --knob-x: 0px;
  --knob-y: 0px;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48%;
  height: 48%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff8a5, #ffd84a 42%, #f0a500);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.42),
    0 0 22px rgba(255, 216, 74, 0.45);
  transform: translate(calc(-50% + var(--knob-x)), calc(-50% + var(--knob-y)));
  transition: transform 120ms ease;
  pointer-events: none;
}

@media (hover: none), (pointer: coarse) {
  .mobile-joystick {
    display: grid;
    width: var(--stage-width);
    place-items: center;
    pointer-events: auto;
  }
}

@media (max-width: 760px) {
  html,
  body {
    height: 100dvh;
    overflow: hidden;
  }

  body {
    min-height: 100dvh;
  }

  .game-shell {
    --joystick-size: clamp(92px, 25vw, 116px);
    --stage-width: min(100%, calc((100dvh - 218px - env(safe-area-inset-bottom)) * 1.3333));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    height: 100dvh;
    min-height: 100dvh;
    gap: 8px;
    overflow: hidden;
    padding: max(8px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom));
  }

  .stage {
    width: var(--stage-width);
    flex: 0 0 auto;
    margin-top: 0;
  }

  .hud {
    width: var(--stage-width);
    grid-template-columns: 1fr auto;
    gap: 8px;
    flex: 0 0 auto;
  }

  .hud-group-main {
    gap: 5px;
  }

  .metric {
    min-width: 68px;
    padding: 6px 7px;
  }

  .metric-label {
    font-size: 10px;
  }

  .metric strong {
    font-size: 15px;
  }

  .metric-mission {
    flex-basis: 100%;
    order: 2;
  }

  .metric-mission strong {
    font-size: 13px;
  }

  .progress-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 0;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .screen {
    position: fixed;
    inset: 0;
    overflow-y: auto;
    padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  }

  #start-screen {
    place-items: start center;
  }

  .start-layout {
    width: min(100%, 520px);
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .start-poster-frame {
    width: 100%;
    min-height: 0;
    height: clamp(150px, 24dvh, 210px);
    flex: 0 0 auto;
    aspect-ratio: auto;
    box-shadow: inset 0 -20px 30px rgba(3, 5, 15, 0.48);
  }

  .start-poster-frame::after {
    background:
      linear-gradient(180deg, transparent 48%, rgba(5, 8, 20, 0.78) 86%, #050814 100%),
      linear-gradient(90deg, rgba(4, 3, 22, 0.1), transparent 20% 80%, rgba(4, 3, 22, 0.1));
  }

  .start-poster {
    object-position: center 58%;
  }

  .start-layout .screen-panel {
    width: 100%;
    max-height: none;
    flex: 0 0 auto;
    padding-top: 8px;
    background:
      linear-gradient(180deg, rgba(5, 8, 20, 0.92), rgba(5, 8, 20, 0.99) 18%),
      transparent;
  }

  .dialog {
    position: fixed;
    top: 42%;
    width: min(280px, calc(100% - 24px));
  }

  .screen-panel {
    width: min(340px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
    padding: 14px;
  }

  .screen h1 {
    margin: 10px 0 12px;
    font-size: clamp(26px, 8vw, 38px);
    line-height: 1.05;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .screen-stats {
    gap: 6px;
    margin: 10px 0 12px;
  }

  .screen-stats span {
    min-width: 92px;
    padding: 7px 9px;
  }

  .name-form {
    gap: 8px;
  }

  #player-name-input {
    height: 46px;
    font-size: 20px;
  }

  .primary-button {
    min-height: 44px;
    font-size: 16px;
  }

  .difficulty-options span {
    min-height: 38px;
    font-size: 14px;
  }

  .difficulty-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #answer-form {
    grid-template-columns: 1fr;
  }

  .mobile-joystick {
    display: grid;
    width: 100%;
    min-height: calc(var(--joystick-size) + 12px);
    margin-top: auto;
    padding-top: 6px;
    place-items: center;
    flex: 0 0 auto;
  }

  .joystick-knob {
    transition: transform 80ms ease;
  }
}

@media (max-width: 760px) and (max-height: 560px) {
  .game-shell {
    --joystick-size: 82px;
    --stage-width: min(100%, calc((100dvh - 170px - env(safe-area-inset-bottom)) * 1.3333));
    gap: 6px;
  }

  .metric {
    min-width: 60px;
    padding: 5px 6px;
  }

  .metric-label {
    font-size: 9px;
  }

  .metric strong {
    font-size: 14px;
  }

  .icon-button {
    width: 30px;
    height: 30px;
  }
}

@keyframes metricPulse {
  0% {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 18px rgba(104, 231, 255, 0.08);
  }
  45% {
    border-color: rgba(103, 240, 139, 0.9);
    box-shadow:
      0 0 0 3px rgba(103, 240, 139, 0.18),
      inset 0 0 22px rgba(103, 240, 139, 0.2);
  }
  100% {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 0 18px rgba(104, 231, 255, 0.08);
  }
}

@keyframes progressPulse {
  0% {
    box-shadow: 0 0 26px rgba(104, 231, 255, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(255, 216, 74, 0.18),
      0 0 34px rgba(255, 216, 74, 0.42);
  }
  100% {
    box-shadow: 0 0 26px rgba(104, 231, 255, 0.18);
  }
}

@keyframes lifeHit {
  0%,
  100% {
    border-color: rgba(255, 255, 255, 0.12);
  }
  45% {
    border-color: rgba(255, 76, 95, 0.95);
    box-shadow:
      0 0 0 3px rgba(255, 76, 95, 0.2),
      inset 0 0 24px rgba(255, 76, 95, 0.18);
  }
}

@keyframes stageHit {
  0%,
  100% {
    filter: none;
  }
  45% {
    filter: drop-shadow(0 0 22px rgba(255, 76, 95, 0.48));
  }
}

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


/* Mobile runtime integration */
html[data-game-viewport="phone-portrait"] #game-canvas,
html[data-game-viewport="phone-landscape"] #game-canvas,
html[data-game-viewport="tablet"] #game-canvas {
  will-change: contents;
}

@media (pointer: coarse) {
  .metric,
  .icon-button,
  .dialog-inner,
  .screen-panel,
  .difficulty-options span,
  .primary-button {
    border-radius: 12px;
  }
}
