:root {
  --bg: #101012;
  --panel: rgba(250, 247, 235, 0.94);
  --panel-strong: #fffaf0;
  --ink: #181716;
  --muted: #686158;
  --accent: #1f7a4d;
  --accent-strong: #145f3a;
  --danger: #c13d2f;
  --line: rgba(24, 23, 22, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(16, 16, 18, 0.28), rgba(16, 16, 18, 0.44)),
    url("assets/games/background.jpg") center / cover no-repeat fixed;
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.start-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 40px);
  background: rgba(0, 0, 0, 0.26);
}

.start-layout {
  width: min(1060px, 100%);
  display: grid;
  grid-template-columns: minmax(320px, 0.94fr) minmax(420px, 1.06fr);
  gap: 18px;
  align-items: stretch;
}

.intro-panel,
.ranking-panel,
.hud-pill,
.game-menu,
.arena-note {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.intro-panel,
.ranking-panel {
  border-radius: 8px;
  padding: clamp(18px, 3vw, 32px);
}

.intro-panel {
  position: relative;
  padding-bottom: clamp(36px, 4vw, 44px);
}

.game-version {
  position: absolute;
  left: clamp(18px, 3vw, 32px);
  bottom: 12px;
  color: rgba(104, 97, 88, 0.72);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
}

.prototype-mark {
  width: max-content;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  font-size: 14px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

.intro-panel h1 {
  margin-bottom: 12px;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 0.95;
}

.intro-panel p {
  max-width: 34rem;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.45;
}

.start-form {
  margin-top: clamp(22px, 4vw, 42px);
}

.speed-picker {
  display: grid;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.speed-picker legend {
  margin-bottom: 8px;
  padding: 0;
  color: var(--muted);
  font-weight: 700;
}

.speed-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.62);
}

.speed-option {
  min-height: 42px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
}

.speed-option.active {
  color: #fffaf0;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(31, 122, 77, 0.22);
}

.start-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 700;
}

.start-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.start-controls input {
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.start-controls input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.2);
}

.start-controls button {
  padding: 0 22px;
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
}

.start-controls button:hover {
  background: var(--accent-strong);
}

.desktop-exit-button {
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  color: #fffaf0;
  background: var(--danger);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-weight: 900;
}

.desktop-exit-button:hover {
  background: #9f2f25;
}

.start-exit-button {
  margin-top: 10px;
}

.menu-exit-button {
  margin-top: 14px;
}

.ranking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ranking-header h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 34px);
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-size: 22px;
}

.ranking-status {
  min-height: 20px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 14px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel-strong);
}

.ranking-table th,
.ranking-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: clamp(13px, 1.8vw, 16px);
}

.ranking-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.ranking-table td:first-child,
.ranking-table th:first-child {
  width: 44px;
  text-align: center;
}

.ranking-table tr:last-child td {
  border-bottom: 0;
}

.orientation-warning {
  display: none;
  width: min(440px, 100%);
  padding: 26px;
  border-radius: 8px;
  color: #fff;
  text-align: center;
  background: rgba(16, 16, 18, 0.86);
  box-shadow: var(--shadow);
}

.orientation-warning h1 {
  margin-bottom: 10px;
  font-size: 28px;
  line-height: 1.1;
}

.orientation-warning p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.45;
}

.phone-rotate {
  width: 92px;
  height: 92px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
}

.phone-shape {
  width: 42px;
  height: 68px;
  border: 4px solid #fff;
  border-radius: 10px;
  position: relative;
  animation: rotate-phone 1.8s ease-in-out infinite;
}

.phone-shape::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  transform: translateX(-50%);
}

@keyframes rotate-phone {
  0%,
  18% {
    transform: rotate(0deg);
  }
  58%,
  76% {
    transform: rotate(90deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.game-screen {
  min-height: 100vh;
  position: relative;
  display: grid;
  padding: 14px;
  background: rgba(0, 0, 0, 0.26);
  overflow: hidden;
}

.game-topbar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-pill {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  border-radius: 8px;
}

.hud-pill > div,
.game-menu-head > div:not(.menu-tabs) {
  display: grid;
  gap: 3px;
}

.hud-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.hud-pill strong {
  min-width: 68px;
  font-size: 20px;
  line-height: 1;
}

.menu-toggle {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  font-size: 26px;
  font-weight: 800;
}

.menu-entrypoint {
  position: relative;
  display: grid;
  justify-items: center;
}

.menu-upgrade-hint {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 7px;
  border-radius: 999px;
  color: #fffaf0;
  background: var(--accent-strong);
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.game-screen.upgrade-hint-active .menu-upgrade-hint {
  display: block;
  animation: upgrade-hint-label 1200ms ease-in-out infinite;
}

.game-screen.upgrade-hint-active .menu-tab[data-menu-tab="upgrades"] {
  animation: upgrade-hint-pulse 1200ms ease-in-out infinite;
}

.game-screen.upgrade-hint-active .menu-toggle {
  color: #fffaf0;
  background: var(--accent);
  border-color: rgba(255, 255, 255, 0.68);
  animation: menu-toggle-hint-pulse 1050ms ease-in-out infinite;
}

.menu-toggle:hover,
.icon-button:hover,
.share-button:hover,
.donat-button:hover {
  background: #fff;
}

.arena-placeholder {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  border: 2px dashed rgba(255, 255, 255, 0.55);
  border-radius: 8px;
  overflow: hidden;
}

@media (hover: hover) and (pointer: fine) {
  .arena-placeholder.ready,
  .arena-placeholder.ready .target {
    cursor: url("assets/games/cursor.png") 12 12, crosshair;
  }
}

.arena-placeholder.ready {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.24);
}

.blocks-layer,
.targets-layer,
.boss-layer,
.edge-bonus-layer,
.hit-effect-layer,
.boss-alert {
  position: absolute;
  inset: 0;
}

.blocks-layer {
  z-index: 2;
  pointer-events: none;
}

.targets-layer {
  z-index: 1;
}

.boss-layer {
  z-index: 4;
  pointer-events: none;
}

.edge-bonus-layer {
  z-index: 5;
  pointer-events: none;
}

.hit-effect-layer {
  z-index: 6;
  overflow: hidden;
  pointer-events: none;
}

.hit-ripple {
  position: absolute;
  left: var(--hit-x);
  top: var(--hit-y);
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 250, 240, 0.86);
  border-radius: 50%;
  opacity: 0;
  box-shadow:
    0 0 0 1px rgba(124, 45, 18, 0.36),
    0 0 16px rgba(255, 218, 120, 0.24);
  transform: translate(-50%, -50%) scale(0.25);
  animation: hit-ripple 320ms ease-out forwards;
  pointer-events: none;
}

.boss-alert {
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at center, rgba(190, 18, 28, 0.12), rgba(190, 18, 28, 0.32)),
    rgba(190, 18, 28, 0.18);
}

.boss-alert.active {
  animation: boss-alert-pulse 1150ms ease-in-out infinite;
}

.arena-block {
  position: absolute;
  pointer-events: none;
  border: 0;
  padding: 0;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.12)),
    url("assets/games/brick.jpg") center / cover no-repeat;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.16),
    inset 0 -8px 18px rgba(0, 0, 0, 0.22),
    0 10px 20px rgba(0, 0, 0, 0.24);
}

.farm-block {
  cursor: url("assets/games/cursor.png") 12 12, crosshair;
  display: block;
  min-height: 0;
  appearance: none;
  pointer-events: auto;
}

.farm-block::after {
  content: "";
  position: absolute;
  inset: 14%;
  background: url("assets/games/Z.png") center / contain no-repeat;
  opacity: var(--farm-z-opacity, 1);
  filter:
    drop-shadow(0 2px 0 rgba(255, 255, 255, 0.24))
    drop-shadow(0 8px 8px rgba(0, 0, 0, 0.34));
  pointer-events: none;
  transition: opacity 160ms ease;
}

.farm-block.hit::after {
  animation: farm-hit 180ms ease-out;
}

.farm-block.depleted {
  cursor: default;
  pointer-events: none;
}

.farm-block.depleted::after {
  filter: none;
}

.arena-note {
  position: relative;
  z-index: 3;
  max-width: 520px;
  padding: 22px;
  border-radius: 8px;
  text-align: center;
}

.target {
  position: absolute;
  width: var(--target-size);
  height: var(--target-size);
  border: 0;
  padding: 0;
  cursor: pointer;
  pointer-events: none;
  background: url("assets/games/moving-prusak.webp") center / contain no-repeat;
  transform: translate(-50%, -50%) rotate(var(--target-angle));
  transition:
    left 360ms ease-out,
    top 360ms ease-out;
  z-index: 1;
}

.target.active {
  pointer-events: auto;
}

.target.moving {
  transition: none;
}

.target.moving-target {
  background-image: url("assets/games/prusak.webp");
}

.target.preparing {
  transition: none;
}

.target.hiding {
  transition:
    left 300ms ease-in,
    top 300ms ease-in;
}

.hit-mark {
  position: absolute;
  width: var(--hit-size);
  height: var(--hit-size);
  background: url("assets/games/prusak_dead.png") center / contain no-repeat;
  transform: translate(-50%, -50%) rotate(var(--hit-angle));
  pointer-events: none;
  z-index: 1;
  animation: fade-hit-mark 1600ms ease-out forwards;
}

.hit-mark.moving-hit-mark {
  background-image: url("assets/games/moving-prusak_dead.png");
}

.boss {
  position: absolute;
  width: calc(var(--boss-size) * 1.4);
  height: var(--boss-size);
  border: 0;
  padding: 0;
  cursor: url("assets/games/cursor.png") 12 12, crosshair;
  pointer-events: auto;
  background: url("assets/games/boss.webp") center / contain no-repeat;
  transform: translate(-50%, -50%) rotate(var(--boss-angle));
  z-index: 1;
}

.boss.hit {
  filter: brightness(1.35) saturate(1.25);
}

.boss-dead {
  position: absolute;
  width: calc(var(--boss-size) * 1.4);
  height: var(--boss-size);
  pointer-events: none;
  background: url("assets/games/boss_dead.png") center / contain no-repeat;
  transform: translate(-50%, -50%) rotate(var(--boss-angle));
  animation: fade-hit-mark 1800ms ease-out forwards;
}

.special-event {
  position: absolute;
  width: var(--special-event-width);
  height: var(--special-event-height);
  min-height: 0;
  border: 0;
  padding: 0;
  cursor: url("assets/games/cursor.png") 12 12, crosshair;
  pointer-events: auto;
  background: var(--special-event-texture) center / contain no-repeat;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.34));
  transform: translate(-50%, -50%) rotate(var(--special-event-angle));
  z-index: 2;
}

.special-event:hover {
  filter:
    brightness(1.12)
    saturate(1.12)
    drop-shadow(0 8px 12px rgba(0, 0, 0, 0.34));
}

.edge-bonus {
  position: absolute;
  width: var(--edge-bonus-size);
  height: var(--edge-bonus-size);
  min-height: 0;
  border: 0;
  padding: 0;
  cursor: url("assets/games/cursor.png") 12 12, crosshair;
  pointer-events: auto;
  background: var(--edge-bonus-texture) center / contain no-repeat;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.34));
  transition:
    left 360ms ease-out,
    top 360ms ease-out,
    filter 120ms ease;
}

.edge-bonus:active {
  filter:
    drop-shadow(0 6px 8px rgba(0, 0, 0, 0.38))
    brightness(1.2);
}

@keyframes boss-alert-pulse {
  0%,
  100% {
    opacity: 0.16;
  }
  50% {
    opacity: 0.34;
  }
}

@keyframes hit-ripple {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.25);
  }

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

@keyframes upgrade-hint-pulse {
  0%,
  100% {
    box-shadow: var(--shadow);
    filter: brightness(1);
  }
  50% {
    box-shadow:
      0 0 0 3px rgba(31, 122, 77, 0.22),
      0 0 18px rgba(31, 122, 77, 0.52),
      var(--shadow);
    filter: brightness(1.08);
  }
}

@keyframes menu-toggle-hint-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 0 rgba(31, 122, 77, 0),
      var(--shadow);
    filter: brightness(1);
  }
  50% {
    box-shadow:
      0 0 0 4px rgba(255, 250, 240, 0.34),
      0 0 0 8px rgba(31, 122, 77, 0.24),
      0 0 24px rgba(31, 122, 77, 0.72),
      var(--shadow);
    filter: brightness(1.14);
  }
}

@keyframes upgrade-hint-label {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(2px);
  }
}

@keyframes farm-hit {
  0% {
    transform: scale(1);
    filter:
      drop-shadow(0 2px 0 rgba(255, 255, 255, 0.24))
      drop-shadow(0 8px 8px rgba(0, 0, 0, 0.34));
  }
  55% {
    transform: scale(0.84) rotate(-4deg);
    filter:
      drop-shadow(0 2px 0 rgba(255, 255, 255, 0.3))
      drop-shadow(0 4px 4px rgba(0, 0, 0, 0.42))
      brightness(1.24);
  }
  100% {
    transform: scale(1);
    filter:
      drop-shadow(0 2px 0 rgba(255, 255, 255, 0.24))
      drop-shadow(0 8px 8px rgba(0, 0, 0, 0.34));
  }
}

.speech-bubble {
  position: absolute;
  max-width: 190px;
  padding: 6px 8px;
  border: 2px solid #181716;
  border-radius: 8px;
  color: #181716;
  background: #fffaf0;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 14px;
  height: 14px;
  border-right: 2px solid #181716;
  border-bottom: 2px solid #181716;
  background: #fffaf0;
  transform: translateX(-50%) rotate(45deg);
}

.edge-bonus-speech {
  z-index: 6;
}

.speech-bubble.above {
  transform: translate(-50%, -100%);
}

.speech-bubble.below {
  transform: translate(-50%, 0);
}

.speech-bubble.below::after {
  top: -9px;
  bottom: auto;
  transform: translateX(-50%) rotate(45deg);
  border: 0;
  border-left: 2px solid #181716;
  border-top: 2px solid #181716;
}

.speech-bubble.right {
  padding-left: 14px;
  transform: translate(0, -50%);
}

.speech-bubble.left {
  padding-right: 14px;
  transform: translate(-100%, -50%);
}

.speech-bubble.right::after,
.speech-bubble.left::after {
  top: 50%;
  bottom: auto;
  transform: translateY(-50%) rotate(45deg);
}

.speech-bubble.right::after {
  left: -8px;
  border: 0;
  border-left: 2px solid #181716;
  border-bottom: 2px solid #181716;
}

.speech-bubble.left::after {
  left: auto;
  right: -8px;
  border: 0;
  border-right: 2px solid #181716;
  border-top: 2px solid #181716;
}

@keyframes fade-hit-mark {
  0% {
    opacity: 1;
    filter: saturate(1.1);
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    filter: saturate(0.8);
  }
}

.arena-note h2 {
  margin-bottom: 8px;
}

.arena-note p {
  margin-bottom: 0;
  color: var(--muted);
}

.menu-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.3);
}

.share-dock {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 30;
  display: grid;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(250, 247, 235, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.game-screen.menu-open .share-dock {
  display: none;
}

.share-title {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
}

.share-buttons-row,
.donat-buttons-row {
  display: flex;
  gap: 8px;
}

.menu-share-group .share-buttons-row {
  justify-content: space-between;
}

.donat-group .donat-buttons-row {
  justify-content: center;
}

.share-button,
.donat-button {
  width: 42px;
  height: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 6px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 900;
}

.donat-button {
  text-decoration: none;
}

.share-button img,
.donat-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.captive-widget {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 31;
  width: max(calc(var(--captive-size, 44px) * 1.65), 66px);
  height: max(calc(var(--captive-size, 44px) * 1.65), 66px);
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: visible;
  border: 0;
  border-radius: 0;
  color: #fffaf0;
  background: transparent;
  box-shadow: none;
  font-weight: 900;
  isolation: isolate;
}

.captive-widget::before,
.captive-widget::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.captive-widget::before {
  inset: 29% 21% 27%;
  z-index: 0;
  background: url("assets/games/prusak.webp") center / contain no-repeat;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.38));
  transform: rotate(-8deg) scale(1.28);
}

.captive-widget::after {
  inset: 0;
  z-index: 1;
  background: url("assets/games/captive_cage.png") center / contain no-repeat;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.36));
}

.captive-count {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  min-width: 24px;
  min-height: 24px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(139, 30, 45, 0.92);
  border: 1px solid rgba(255, 250, 240, 0.82);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.captive-exchange-hint {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 13px);
  z-index: 3;
  display: none;
  padding: 6px 9px;
  border-radius: 8px;
  color: #fffaf0;
  background: rgba(20, 95, 58, 0.95);
  border: 1px solid rgba(255, 250, 240, 0.78);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26);
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  transform: translateX(-50%);
}

.captive-exchange-hint::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(100% - 1px);
  width: 11px;
  height: 11px;
  background: inherit;
  border-right: 1px solid rgba(255, 250, 240, 0.78);
  border-bottom: 1px solid rgba(255, 250, 240, 0.78);
  transform: translateX(-50%) rotate(45deg);
}

.captive-widget.exchange-hint-active {
  animation: captive-widget-pulse 1200ms ease-in-out infinite;
}

.captive-widget.exchange-hint-active .captive-exchange-hint {
  display: block;
  animation: captive-hint-label 1200ms ease-in-out infinite;
}

.rescue-runner {
  position: fixed;
  --rescue-runner-width: max(calc(var(--captive-size, 44px) * 5.55), 231px);
  --rescue-runner-height: max(calc(var(--captive-size, 44px) * 2.52), 102px);
  left: calc(-1 * var(--rescue-runner-width) - 18px);
  bottom: 16px;
  z-index: 45;
  width: var(--rescue-runner-width);
  height: var(--rescue-runner-height);
  background: url("assets/games/rescue_pickup.png") center / contain no-repeat;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.34));
}

.rescue-runner::before,
.rescue-runner::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.rescue-runner::before {
  left: -13%;
  bottom: -2%;
  z-index: -1;
  width: 52%;
  height: 34%;
  background:
    radial-gradient(circle at 14% 58%, rgba(202, 181, 139, 0.48) 0 15%, transparent 34%),
    radial-gradient(circle at 34% 42%, rgba(178, 155, 112, 0.38) 0 14%, transparent 35%),
    radial-gradient(circle at 57% 62%, rgba(224, 203, 160, 0.32) 0 13%, transparent 34%),
    radial-gradient(circle at 76% 48%, rgba(155, 132, 91, 0.24) 0 12%, transparent 32%);
  filter: blur(1.2px);
  transform: translateX(0) scale(0.86);
}

.rescue-runner::after {
  left: 8%;
  right: 6%;
  bottom: -3%;
  z-index: 1;
  height: 24%;
  background:
    radial-gradient(circle at 22% 50%, rgba(213, 190, 145, 0.34) 0 10%, transparent 25%),
    radial-gradient(circle at 70% 54%, rgba(196, 171, 124, 0.28) 0 9%, transparent 24%);
  filter: blur(0.8px);
}

.rescue-runner.running {
  animation: rescue-run var(--rescue-run-ms, 2600ms) ease-in-out forwards;
}

.rescue-runner.running::before {
  animation: rescue-dust-trail 620ms ease-out infinite;
}

.rescue-runner.running::after {
  animation: rescue-wheel-dust 360ms ease-in-out infinite;
}

.event-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.34);
}

.event-modal-box {
  width: min(360px, 100%);
  padding: 22px;
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.event-modal-box h2 {
  margin-bottom: 14px;
  font-size: 24px;
}

.event-modal-box p {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.45;
}

.event-modal-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.event-modal-actions button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  color: #fffaf0;
  background: var(--accent-strong);
  font-weight: 900;
}

.special-event-modal.has-long-answers .event-modal-box {
  width: min(560px, 100%);
}

.special-event-modal.has-long-answers .event-modal-actions {
  grid-template-columns: repeat(2, max-content);
  justify-content: center;
}

.special-event-modal .event-modal-actions button {
  max-width: calc((100vw - 82px) / 2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-modal-actions button:disabled {
  cursor: wait;
  color: rgba(255, 250, 240, 0.72);
  background: rgba(53, 48, 42, 0.72);
}

.event-modal-actions button:only-child {
  grid-column: 1 / -1;
}

.menu-share-group,
.donat-group {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.start-donat-group {
  margin-top: 18px;
}

.game-loader {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.38);
}

.loader-box {
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 8px;
  color: var(--ink);
  text-align: center;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.loader-box h2 {
  margin-bottom: 8px;
}

.loader-box p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.loader-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border: 5px solid rgba(31, 122, 77, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin-loader 800ms linear infinite;
}

@keyframes spin-loader {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rescue-run {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(100vw + var(--rescue-runner-width) + 36px));
  }
}

@keyframes rescue-dust-trail {
  0% {
    opacity: 0;
    transform: translateX(12%) scale(0.76);
  }
  28% {
    opacity: 0.78;
  }
  100% {
    opacity: 0;
    transform: translateX(-20%) scale(1.38);
  }
}

@keyframes rescue-wheel-dust {
  0%,
  100% {
    opacity: 0.2;
    transform: translateY(0) scaleX(0.96);
  }
  50% {
    opacity: 0.58;
    transform: translateY(-3px) scaleX(1.06);
  }
}

@keyframes captive-widget-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(31, 122, 77, 0));
  }
  50% {
    filter: drop-shadow(0 0 14px rgba(31, 122, 77, 0.86));
  }
}

@keyframes captive-hint-label {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-4px);
  }
}

.game-menu {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 50;
  width: min(380px, 100%);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-radius: 8px 0 0 8px;
  transform: translateX(105%);
  transition: transform 180ms ease;
}

.game-menu.open {
  transform: translateX(0);
}

.game-menu-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.game-menu-head strong {
  font-size: 22px;
}

.menu-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px 0;
}

.menu-tab {
  min-height: 40px;
  padding: 0 8px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.62);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
}

.menu-tabs-mobile {
  display: none;
}

.menu-tab.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.menu-panel {
  display: none;
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.menu-panel.active {
  display: block;
}

.stats-list {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.stats-list div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.stats-list dt {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.stats-list dd {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.sound-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.sound-toggle {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.sound-toggle.active {
  color: #fffaf0;
  background: var(--accent);
  border-color: rgba(255, 250, 240, 0.5);
  box-shadow: 0 0 0 2px rgba(20, 95, 58, 0.16);
}

.sound-toggle:not(.active) {
  opacity: 0.72;
}

.sound-icon {
  width: 20px;
  height: 20px;
  display: block;
  flex: 0 0 auto;
  background: url("assets/sounds/on.png") center / contain no-repeat;
}

.sound-toggle:not(.active) .sound-icon {
  background-image: url("assets/sounds/off.png");
}

.sound-toggle.active .sound-icon {
  background-image: url("assets/sounds/on.png");
}

.empty-menu-state {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.empty-menu-state h2 {
  margin-bottom: 8px;
}

.empty-menu-state p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.upgrades-list {
  display: grid;
  gap: 10px;
}

.upgrade-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.upgrade-card h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.upgrade-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.upgrade-card dl {
  display: grid;
  grid-template-columns: 0.7fr 1fr;
  gap: 6px;
  margin: 0;
}

.upgrade-card dl div {
  padding: 8px;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.58);
}

.upgrade-status {
  padding: 10px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.58);
  font-size: 13px;
  font-weight: 800;
}

.upgrade-card dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.upgrade-card dd {
  margin: 2px 0 0;
  font-weight: 900;
}

.upgrade-card button {
  min-height: 42px;
  border-radius: 8px;
  color: #fffaf0;
  background: var(--accent);
  font-weight: 900;
}

.upgrade-card button:disabled {
  cursor: not-allowed;
  color: rgba(24, 23, 22, 0.62);
  background: rgba(24, 23, 22, 0.12);
  font-size: 13px;
}

.achievements-list {
  display: grid;
  gap: 10px;
}

.achievement-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.achievement-card img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.58);
}

.achievement-card h2 {
  margin-bottom: 4px;
  font-size: 17px;
}

.achievement-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.achievement-toast {
  position: fixed;
  top: calc(14px + var(--toast-offset, 0px));
  left: 14px;
  z-index: 36;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  width: min(330px, calc(100vw - 28px));
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: achievement-toast 4200ms ease forwards;
}

.achievement-toast img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255, 250, 240, 0.58);
}

.achievement-toast span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.achievement-toast strong {
  display: block;
  margin-top: 3px;
  font-size: 17px;
  line-height: 1.15;
}

@keyframes achievement-toast {
  0% {
    opacity: 0;
    transform: translateY(-12px);
  }
  12%,
  82% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-12px);
  }
}

@media (max-width: 860px) {
  .start-layout {
    grid-template-columns: 1fr;
  }

  .intro-panel h1 {
    font-size: 42px;
  }
}

@media (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .start-screen {
    padding: 18px;
  }

  .start-layout {
    display: none;
  }

  .orientation-warning {
    display: block;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .start-screen {
    padding: 10px;
  }

  .start-layout {
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
    gap: 10px;
  }

  .intro-panel,
  .ranking-panel {
    padding: 16px;
  }

  .intro-panel h1 {
    font-size: 40px;
  }

  .intro-panel p {
    font-size: 15px;
  }

  .ranking-table th,
  .ranking-table td {
    padding: 8px;
  }

  .game-screen {
    padding: 10px;
  }

  .game-topbar {
    top: 10px;
    right: 10px;
  }

  .share-dock {
    right: 10px;
    bottom: 10px;
    gap: 6px;
    padding: 6px;
  }

  .captive-widget {
    left: 10px;
    bottom: 10px;
    width: max(calc(var(--captive-size, 38px) * 1.5), 58px);
    height: max(calc(var(--captive-size, 38px) * 1.5), 58px);
  }

  .rescue-runner {
    --rescue-runner-width: 198px;
    --rescue-runner-height: 90px;
    bottom: 12px;
  }

  .share-button,
  .donat-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .hud-pill {
    min-height: 46px;
    padding: 7px 10px;
    gap: 10px;
  }

  .hud-pill strong {
    min-width: 54px;
    font-size: 17px;
  }

  .menu-toggle {
    width: 46px;
    height: 46px;
  }

  .game-menu {
    inset: 0;
    width: auto;
    height: 100vh;
    height: 100dvh;
    padding: 10px;
    border-radius: 0;
    transform: translateY(105%);
  }

  .game-menu.open {
    transform: translateY(0);
  }

  .game-menu-head {
    display: grid;
    grid-template-columns: minmax(64px, 0.34fr) minmax(0, 1fr) 38px;
    gap: 8px;
    min-height: 42px;
    padding: 0 0 8px;
  }

  .game-menu-head .hud-label {
    display: none;
  }

  .game-menu-head strong {
    display: block;
    max-width: 100%;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .menu-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding: 0;
  }

  .menu-tabs-desktop {
    display: none;
  }

  .menu-tabs-mobile {
    display: grid;
  }

  .menu-tab {
    min-height: 34px;
    padding: 0 6px;
    font-size: 11px;
    white-space: nowrap;
  }

  #closeGameMenu {
    width: 38px;
    height: 38px;
    min-height: 38px;
  }

  .menu-panel {
    padding-top: 8px;
  }

  .stats-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 8px;
  }

  .stats-list div,
  .upgrade-card,
  .achievement-card,
  .menu-share-group,
  .donat-group {
    padding: 8px;
  }

  .stats-list div {
    display: grid;
    gap: 4px;
  }

  .stats-list dt {
    font-size: 12px;
  }

  .stats-list dd {
    font-size: 18px;
  }

  .sound-controls {
    gap: 6px;
    margin-bottom: 8px;
  }

  .sound-toggle {
    min-height: 38px;
    padding: 7px 8px;
    font-size: 12px;
  }

  .sound-icon {
    width: 18px;
    height: 18px;
  }

  .menu-share-group,
  .donat-group {
    width: max-content;
    max-width: 100%;
    justify-self: center;
    margin: 10px auto 0;
  }

  .upgrades-list,
  .achievements-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .upgrade-card {
    gap: 5px;
    padding: 6px;
  }

  .upgrade-card h2 {
    margin-bottom: 0;
    font-size: 14px;
    line-height: 1.12;
  }

  .upgrade-card p {
    display: -webkit-box;
    overflow: hidden;
    font-size: 11px;
    line-height: 1.18;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  .upgrade-card dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
  }

  .upgrade-card dl div {
    padding: 5px;
    border-radius: 6px;
  }

  .upgrade-card dt {
    font-size: 9px;
  }

  .upgrade-card dd {
    margin-top: 1px;
    font-size: 13px;
    line-height: 1.08;
  }

  .upgrade-status {
    padding: 6px;
    border-radius: 6px;
    font-size: 11px;
  }

  .upgrade-card button {
    min-height: 32px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 12px;
  }

  .achievement-card {
    align-content: start;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 9px;
  }

  .achievement-card img {
    width: 34px;
    height: 34px;
  }

  .achievement-card h2 {
    font-size: 15px;
  }

  .achievement-card p {
    font-size: 12px;
  }

  .achievement-toast {
    top: calc(10px + var(--toast-offset, 0px));
    left: 10px;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 7px;
    width: min(178px, calc(100vw - 20px));
    padding: 6px;
    border-radius: 7px;
  }

  .achievement-toast img {
    width: 30px;
    height: 30px;
    border-radius: 6px;
  }

  .achievement-toast span {
    font-size: 8px;
  }

  .achievement-toast strong {
    margin-top: 2px;
    font-size: 11px;
  }
}
