:root {
  --game-edge: clamp(12px, 2.2vw, 28px);
}

.play-page {
  min-height: 100svh;
  overscroll-behavior: none;
  touch-action: manipulation;
  background:
    radial-gradient(circle at 50% -15%, rgba(200, 255, 96, 0.11), transparent 35rem),
    #090b0f;
}

.play-ambient {
  position: fixed;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.016) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.016) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
  pointer-events: none;
}

.game-header {
  position: sticky;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 72px;
  padding: 10px max(var(--game-edge), env(safe-area-inset-right)) 10px max(var(--game-edge), env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(9, 11, 15, 0.86);
  backdrop-filter: blur(20px);
}

.game-runtime {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.runtime-dot,
.status-light {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(200, 255, 96, 0.7);
}

.game-header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.performance-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.performance-control select {
  min-height: 28px;
  border: 0;
  border-radius: 7px;
  padding: 0 24px 0 8px;
  color: var(--text);
  background: #1a1f28;
  cursor: pointer;
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
}

.performance-control:focus-within {
  border-color: rgba(200, 255, 96, 0.7);
}

.game-tool-button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.045);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.game-tool-button:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.09);
}

.game-tool-button:active {
  transform: translateY(1px);
}

.game-tool-primary {
  border-color: var(--accent);
  color: #101606;
  background: var(--accent);
}

.game-tool-primary:hover {
  border-color: #d7ff8a;
  background: #d7ff8a;
}

.game-main {
  width: min(1440px, 100%);
  margin-inline: auto;
  padding: clamp(26px, 4vw, 54px) var(--game-edge) max(36px, env(safe-area-inset-bottom));
}

.game-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.58fr);
  align-items: end;
  gap: 36px;
  max-width: 1240px;
  margin: 0 auto 24px;
}

.game-intro h1 {
  max-width: none;
  margin: 0;
  font-size: clamp(2.45rem, 5.6vw, 5.5rem);
}

.game-intro > p {
  max-width: 530px;
  margin: 0 0 5px auto;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.25vw, 1.05rem);
  line-height: 1.7;
}

.game-stage {
  position: relative;
  width: min(100%, 1280px);
  aspect-ratio: 16 / 9;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.19);
  border-radius: clamp(16px, 2vw, 26px);
  background: #05070a;
  box-shadow:
    0 34px 100px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(200, 255, 96, 0.045) inset;
  touch-action: none;
}

.game-stage::before {
  position: absolute;
  z-index: 6;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 70px rgba(0, 0, 0, 0.32) inset;
  content: "";
  pointer-events: none;
}

.game-frame {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #05070a;
  touch-action: none;
}

.game-loader {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  color: var(--text);
  background:
    radial-gradient(circle at 50% 42%, rgba(200, 255, 96, 0.1), transparent 28%),
    #090b0f;
  text-align: center;
  transition: opacity 420ms ease, visibility 420ms ease;
}

.game-loader.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.game-loader img {
  width: clamp(58px, 8vw, 96px);
  height: clamp(58px, 8vw, 96px);
  margin-bottom: 25px;
  object-fit: contain;
  filter: drop-shadow(0 0 32px rgba(200, 255, 96, 0.2));
  animation: loader-float 2.4s ease-in-out infinite;
}

.game-loader strong {
  font-size: clamp(1.1rem, 2.2vw, 1.65rem);
}

.game-loader small {
  max-width: 480px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.loader-track {
  width: min(320px, 72%);
  height: 5px;
  margin: 22px 0 15px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.loader-track span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  box-shadow: 0 0 15px rgba(200, 255, 96, 0.45);
  transition: width 500ms ease;
}

@keyframes loader-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.025); }
}

.game-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 1280px);
  margin: 13px auto 0;
  gap: 20px;
  color: var(--faint);
  font-size: 0.72rem;
}

.game-foot p {
  margin: 0;
}

#gameStatus {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

.desktop-hint {
  text-align: right;
}

.controls-help {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  width: min(100%, 1280px);
  margin: 18px auto 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(18, 22, 29, 0.72);
  backdrop-filter: blur(18px);
}

.controls-help[hidden] {
  display: none;
}

.controls-help > div {
  min-width: 0;
  padding: 20px;
}

.controls-help > div + div {
  border-left: 1px solid var(--line);
}

.controls-help p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.controls-help dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.controls-help dl div {
  padding: 9px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.controls-help dt {
  color: var(--faint);
  font-size: 0.58rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.controls-help dd {
  margin-top: 4px;
  color: var(--text);
  font-size: 0.74rem;
}

.rotate-hint {
  display: none;
}

.game-stage:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  border: 0;
  border-radius: 0;
}

@media (pointer: coarse), (max-width: 900px) {
  .game-header {
    min-height: 62px;
    grid-template-columns: 1fr auto;
  }

  .performance-control span {
    display: none;
  }

  .performance-control {
    padding-inline: 6px;
  }

  .game-runtime,
  .game-intro,
  .desktop-hint,
  #helpButton {
    display: none;
  }

  .game-main {
    padding-top: 12px;
  }

  .game-stage {
    border-radius: 17px;
  }

  .game-stage::before {
    border-radius: 17px;
  }

  .game-stage:fullscreen {
    overflow: hidden;
    margin: 0;
    background: #05070a;
  }

  .game-foot {
    justify-content: center;
  }

  .controls-help {
    grid-template-columns: 1fr;
  }

  .controls-help > div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (orientation: portrait) and (pointer: coarse) and (max-width: 700px) {
  .rotate-hint {
    position: absolute;
    z-index: 7;
    right: 10px;
    bottom: 10px;
    display: grid;
    max-width: 190px;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 2px 9px;
    padding: 9px 11px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    color: var(--text);
    background: rgba(9, 11, 15, 0.9);
    backdrop-filter: blur(12px);
  }

  .rotate-icon {
    grid-row: 1 / 3;
    color: var(--accent);
    font-size: 1.35rem;
  }

  .rotate-hint strong {
    font-size: 0.62rem;
  }

  .rotate-hint small {
    color: var(--muted);
    font-size: 0.52rem;
    line-height: 1.3;
  }
}

@media (max-width: 560px) {
  .game-header .brand span,
  #reloadButton {
    display: none;
  }

  .game-header .brand img {
    width: 32px;
    height: 32px;
  }

  .game-tool-button {
    min-height: 36px;
    padding-inline: 12px;
  }

  .performance-control {
    min-height: 36px;
  }

  .game-main {
    padding-inline: 10px;
  }

  .game-loader img {
    margin-bottom: 14px;
  }

  .game-loader .eyebrow {
    display: none;
  }

  .loader-track {
    margin-block: 15px 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-loader img {
    animation: none;
  }
}
