@import "https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Rajdhani:wght@500;700&display=swap";
:root {
  --bg-deep: #05030a;
  --ui-gold: #f7c96f;
  --ui-font: "Rajdhani", sans-serif;
  --pixel-font: "Press Start 2P", cursive;
  --neon-pink: #ff4b9f;
  --ui-scale: 1vmin;
  --font-h1: clamp(1.8rem, 13vw, 5rem);
  --font-btn: clamp(1rem, 3.5vmin, 1.8rem);
}
body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-deep);
  overflow: hidden;
  touch-action: none;
  font-family: var(--ui-font);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  overflow: hidden;
}
@supports (height: 100dvh) {
  #game-container {
    height: 100dvh;
  }
}
#ambient-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  filter: blur(20px) brightness(0.75) saturate(1.2);
  transform: scale(1.45);
  transform-origin: center;
  transition: background-image 0.5s ease-in-out;
}
#ambient-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background-color: #fff;
  opacity: 0;
  transition: opacity 0.1s linear;
}
#game-container:has(.menu-screen:not(.hidden)) #ambient-bg {
  filter: blur(20px) brightness(0.2) saturate(0.5);
}
.game-aspect-container {
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 100px #000c;
  background: transparent;
  --hud-scale: 1;
}
.menu-scale-root {
  --menu-scale: 1;
}
.game-aspect-container > * {
  pointer-events: auto;
}
canvas {
  image-rendering: pixelated;
  display: block;
  outline: none;
  border: none;
  background-color: #000;
  width: 100%;
  height: 100%;
  z-index: 5;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  pointer-events: none;
}
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.hud-group {
  position: absolute;
  top: 3%;
  width: auto;
  min-width: calc(7rem * var(--hud-scale));
  max-width: 30%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(2px * var(--hud-scale));
  background: #00000059;
  padding: calc(0.7rem * var(--hud-scale)) calc(0.9rem * var(--hud-scale));
  border-radius: calc(12px * var(--hud-scale));
  border: 1px solid rgba(247, 201, 111, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 6px #0000001a;
  box-sizing: border-box;
}
:root {
  --hud-base-label: 0.9rem;
  --hud-base-value: 1.6rem;
}
.game-aspect-container {
  --hud-scale: 1;
}
#blocksGroup {
  left: 3%;
  text-align: left;
  align-items: flex-start;
  transform: none;
  min-width: calc(4.6rem * var(--hud-scale));
  padding: calc(0.7rem * var(--hud-scale)) calc(0.72rem * var(--hud-scale));
}
#heightGroup {
  left: 50%;
  right: auto;
  transform: translate(-50%);
  text-align: center;
  align-items: center;
  min-width: calc(7.35rem * var(--hud-scale));
}
#heightGroup.triple-digit {
  width: 31%;
}
.scatter-hud {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  font-family: var(--pixel-font);
  width: 100%;
}
.scatter-hud.active {
  display: flex;
}
.scatter-divider {
  height: 1px;
  width: 100%;
  background: #fffc;
}
.scatter-label {
  font-family: var(--ui-font);
  font-size: clamp(0.55rem, calc(0.7rem * var(--hud-scale)), 1rem);
  letter-spacing: 1.6px;
  color: #2ff55a;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
  margin-bottom: 0;
  line-height: 1;
}
.scatter-count {
  font-size: clamp(0.9rem, calc(1.2rem * var(--hud-scale)), 1.9rem);
  color: #2ff55a;
  text-shadow: 1px 1px 0 #000;
  line-height: 1;
}
.pierce-hud {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  font-family: var(--pixel-font);
  width: 100%;
}
.pierce-hud.active {
  display: flex;
}
.pierce-divider {
  height: 1px;
  width: 100%;
  background: #ff7878e6;
}
.pierce-label {
  font-family: var(--ui-font);
  font-size: clamp(0.55rem, calc(0.7rem * var(--hud-scale)), 1rem);
  letter-spacing: 1.6px;
  color: #f66;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
  margin-bottom: 0;
  line-height: 1;
}
.pierce-count {
  font-size: clamp(0.9rem, calc(1.2rem * var(--hud-scale)), 1.9rem);
  color: #f66;
  text-shadow: 1px 1px 0 #000;
  line-height: 1;
}
.score-label {
  font-size: clamp(
    0.65rem,
    calc(var(--hud-base-label) * var(--hud-scale)),
    1.3rem
  );
  color: #eee;
  letter-spacing: 1.2px;
  line-height: 1;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 2px;
}
.score-val {
  font-size: clamp(
    1rem,
    calc(var(--hud-base-value) * var(--hud-scale)),
    2.4rem
  );
  font-weight: 700;
  color: #fff;
  font-family: var(--pixel-font);
  text-shadow: 2px 2px 0 #000;
  line-height: 1;
}
#pauseHudBtn {
  display: none;
}
#debugExitBtn {
  position: absolute;
  top: 15%;
  right: 3%;
  background: #dc143cb3;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--ui-font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 101;
  box-shadow: 0 4px 6px #0000004d;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#debugExitBtn:hover {
  background: #f24;
  border-color: #fff;
}
#biome-display {
  position: absolute;
  top: calc(20% + 50px);
  width: 100%;
  text-align: center;
  font-family: var(--pixel-font);
  font-size: 1.5rem;
  color: var(--ui-gold);
  text-shadow: -1px 0 0 #000, 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000,
    0 0 10px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 1s;
  pointer-events: none;
  z-index: 20;
}
.menu-screen {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #05030aeb;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: auto;
  z-index: 100;
  gap: 1.5vh;
}
.menu-panel {
  width: clamp(300px, 90vw, 640px);
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 18px * var(--menu-scale), 28px);
  padding: clamp(16px, 24px * var(--menu-scale), 40px);
  box-sizing: border-box;
}
.menu-title {
  font-family: var(--pixel-font);
  text-align: center;
  line-height: 1.05;
  margin: 0;
  font-size: clamp(2.4rem, calc(3.6rem * var(--menu-scale)), 5rem);
}
.menu-title--summit {
  color: #00e5ff;
  text-shadow: 0 0 12px rgba(0, 229, 255, 0.75), 2px 2px 0 rgba(0, 0, 0, 0.6);
  font-size: clamp(2.16rem, calc(3.24rem * var(--menu-scale)), 4.5rem);
  text-align: center;
}
.menu-title--main {
  color: #fff;
  text-shadow: 4px 4px 0px var(--neon-pink);
}
.menu-title--danger {
  color: #f55;
  text-shadow: 3px 3px 0 #500;
}
.menu-subtitle {
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: clamp(0.9rem, calc(1.1rem * var(--menu-scale)), 1.4rem);
}
.menu-subtitle--muted {
  color: #aaa;
  font-family: var(--pixel-font);
}
.menu-metric {
  margin: 0;
  text-align: center;
  color: var(--ui-gold);
  font-size: clamp(1rem, calc(1.3rem * var(--menu-scale)), 1.6rem);
}
.menu-screen .btn {
  font-size: clamp(0.9rem, calc(1.1rem * var(--menu-scale)), 1.3rem);
  padding: clamp(10px, 12px * var(--menu-scale), 16px)
    clamp(22px, 26px * var(--menu-scale), 32px);
}
#victoryMenu .btn {
  padding: clamp(11px, 13.2px * var(--menu-scale), 18px)
    clamp(22px, 26px * var(--menu-scale), 32px);
}
@media (orientation: landscape) {
  #blocksGroup {
    transform: scale(0.9);
  }
  #heightGroup {
    transform: translate(-50%) scale(0.9);
  }
  #victoryMenu .btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
@media (min-aspect-ratio: 13/6) {
  .controls-hint .key-icon {
    font-size: clamp(0.56rem, 1.4875vmin, 0.74rem) !important;
  }
  #blocksGroup {
    transform: scale(0.81);
  }
  #heightGroup {
    transform: translate(-50%) scale(0.81);
  }
}
.menu-panel--debug {
  width: clamp(320px, 92vw, 860px);
  max-height: min(80vh, 640px);
  gap: clamp(12px, 2vh * var(--menu-scale), 28px);
  padding: clamp(18px, 3vh * var(--menu-scale), 32px);
}
#debugMenu .menu-title {
  font-size: clamp(1.8rem, calc(2.6rem * var(--menu-scale)), 3.6rem);
  text-shadow: 3px 3px 0 var(--neon-pink);
  animation: none;
}
#debugMenu .btn {
  width: 100%;
  text-align: center;
}
.debug-toggle {
  margin-bottom: clamp(6px, 1vh * var(--menu-scale), 12px);
  border-color: #666;
  box-shadow: none;
  background: #00000059;
}
.debug-toggle:not(.is-active):hover {
  background: #ffffff14;
  color: #fff;
}
.debug-toggle.is-active {
  border-color: var(--ui-gold);
  box-shadow: 0 0 12px #f7c96f99;
  background: #f7c96f1f;
}
.debug-grid {
  width: 100%;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow-y: auto;
  padding: 8px;
  box-sizing: border-box;
}
.btn-danger {
  border-color: #f55;
  color: #fff;
}
.menu-panel--main {
  width: clamp(320px, 90vw, 720px);
}
.menu-panel--gameover {
  width: clamp(320px, 90vw, 640px);
}
.hidden {
  display: none !important;
}
@keyframes pulseTitle {
  0%,
  to {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}
h1 {
  font-family: var(--pixel-font);
  font-size: var(--font-h1);
  text-align: center;
  line-height: 1.155;
  color: #fff;
  text-shadow: 4px 4px 0px var(--neon-pink);
  margin-bottom: 2vh;
  width: 100%;
  animation: pulseTitle 2s infinite ease-in-out;
}
#gameOverMenu h1 {
  animation: none;
  line-height: 1.1;
  margin-bottom: 0;
  width: 100%;
}
.safe-area-container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: clamp(320px, 80vmin, 520px);
  max-height: calc(100vh - 30px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
#mainMenu h1 {
  width: 100%;
  margin-bottom: 4vh;
  font-size: clamp(2.5rem, 12vmin, 5rem);
  line-height: 1.1;
}
#menuHighScore {
  color: var(--ui-gold);
  font-family: var(--pixel-font);
  font-size: clamp(1rem, 3vmin, 1.4rem);
  text-shadow: 2px 2px 0 #000;
  margin-bottom: 4vh;
}
#mainMenu #startBtn {
  width: 35%;
  min-width: 160px;
  max-width: 260px;
  height: clamp(48px, 8vh, 56px);
  margin: 10px 0 15px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.instruction-card {
  width: 100%;
  overflow-y: auto;
  color: #ccc;
  font-size: clamp(0.8rem, 2.5vmin, 1rem);
  line-height: 1.35;
  background: #00000080;
  padding: 15px;
  border-radius: 8px;
  box-sizing: border-box;
  margin: 0;
  flex-shrink: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 10px;
  text-align: center;
}
.instruction-card p {
  margin: 0;
}
@media (orientation: portrait) {
  .safe-area-container {
    top: 45%;
  }
  #mainMenu h1 {
    font-size: clamp(2.1rem, 10.2vmin, 4.25rem);
  }
  .instruction-card {
    width: 100%;
  }
}
@media (orientation: landscape) {
  .safe-area-container {
    top: 50%;
    width: clamp(425px, 55vw, 765px);
    max-height: calc(100vh - 30px);
  }
  #mainMenu h1 {
    font-size: clamp(2rem, 10vmin, 4rem);
  }
  #menuHighScore {
    font-size: clamp(0.85rem, 2.55vmin, 1.19rem);
  }
  #mainMenu #startBtn {
    height: clamp(55px, 9.2vh, 64px);
  }
  .instruction-card {
    white-space: normal;
    transform: none;
    max-height: none;
    line-height: 1.08;
    gap: 8px;
  }
}
@media (orientation: portrait) {
  #gameOverMenu h1 {
    font-size: clamp(2.35rem, 11.4vmin, 5.7rem);
  }
  .game-over-buttons .btn {
    width: 40%;
  }
  #restartBtn,
  #exitGameOverBtn {
    padding-top: 1.8vh;
    padding-bottom: 1.8vh;
  }
}
@media (orientation: landscape) {
  #gameOverMenu h1 {
    font-size: clamp(2.1rem, 10.2vmin, 5rem);
  }
  #gameOverHeight {
    transform: translateY(-1.2vh);
  }
  .game-over-buttons {
    margin-top: 10px;
  }
  #restartBtn,
  #exitGameOverBtn {
    padding: 2vh 0;
    width: 48%;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
.game-over-panel {
  width: 90%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5vh;
  text-align: center;
}
.game-over-buttons {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 1.5vh;
  align-items: center;
  margin-top: 1vh;
}
.game-over-buttons .btn {
  width: 60%;
  margin: 0.5vh 0;
}
.btn {
  background: transparent;
  border: 3px solid var(--ui-gold);
  color: #fff;
  padding: 1.5vh 3vw;
  font-family: var(--ui-font);
  font-size: var(--font-btn);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.1s;
  margin: 1vh;
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  box-shadow: 0 0 15px #f7c96f4d;
}
.btn:hover {
  background: var(--ui-gold);
  color: #05030a;
  box-shadow: 0 0 25px var(--ui-gold);
  transform: translateY(-2px);
}
@media (max-height: 600px) {
  .menu-screen {
    gap: 1vh;
  }
  h1 {
    margin-bottom: 1vh;
  }
  .btn {
    padding: 1vh 2vw;
    margin: 0.5vh;
  }
  #mainMenu p {
    font-size: 0.8rem !important;
    padding: 0 10px !important;
  }
}
.controls-hint {
  position: absolute;
  left: 50%;
  transform: translate(-50%);
  width: 90%;
  max-width: calc(100% - 20px);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2%;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 25;
}
#mobileHints.controls-hint {
  bottom: 14.75%;
  height: auto;
  align-items: flex-end;
  padding-bottom: 10px;
}
#desktopHints.controls-hint {
  bottom: 7.65%;
  height: 6%;
  align-items: center;
}
.key-icon {
  background: #00000059;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: var(--ui-gold);
  padding: 0.525vh 1.4vw;
  border-radius: 6px;
  font-size: clamp(0.66rem, 1.75vmin, 0.875rem);
  font-family: var(--pixel-font);
  text-align: center;
  white-space: normal;
  line-height: 1.2;
  box-shadow: 0 4px 6px #0003;
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
}
.key-icon:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: -1;
}
@media (orientation: landscape) {
  .controls-hint .key-icon {
    font-size: clamp(0.47rem, 1.25vmin, 0.625rem);
    padding: 0.375vh 1vw;
  }
  #mobileHints.controls-hint {
    bottom: max(10px, 14.75%);
  }
  #desktopHints.controls-hint {
    bottom: max(10px, 6.5%);
  }
}
#touchControls {
  position: absolute;
  bottom: 3%;
  left: 0;
  width: 100%;
  height: 14.75%;
  pointer-events: none;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 3%;
  box-sizing: border-box;
}
#touchControls.hidden {
  display: none !important;
}
#perfHud {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 9999;
  padding: 8px 10px;
  background: #000000b8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  font-family: IBM Plex Mono, SFMono-Regular, monospace;
  font-size: 12px;
  color: #dff6ff;
  line-height: 1.25;
  pointer-events: none;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
#perfHud .perf-row {
  white-space: nowrap;
}
#stageTransition {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 50%, #00000059, #000000a6);
  color: #f7f7ff;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 32;
}
#stageTransition.hidden {
  display: none !important;
}
#stageTransition .stage-transition__label {
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: clamp(20px, 3vw, 34px);
  text-shadow: 0 0 16px rgba(0, 0, 0, 0.8);
}
#loadingOverlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000a6;
  z-index: 9998;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
#loadingOverlay.hidden {
  display: none !important;
}
#loadingOverlay .loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: #12141ce6;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: #f5f7ff;
  font-family: Rajdhani, sans-serif;
  min-width: 180px;
  box-shadow: 0 6px 30px #00000059;
}
#loadingOverlay .loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #f7c96f;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
#loadingOverlay .loading-text {
  font-weight: 700;
  letter-spacing: 0.04em;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.control-pad {
  position: relative;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: auto;
}
.control-pad.active {
  background: transparent;
  transform: none;
}
#movePad .arrow-box {
  width: 48%;
  height: 80%;
  background: #00000038;
  border: 1px solid rgba(248, 200, 113, 0.7);
  box-shadow: none;
  border-radius: 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
#movePad .arrow-box:after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  z-index: -1;
}
#movePad .arrow-box:before {
  content: "";
  width: 0;
  height: 0;
  border-top: 1.5vh solid transparent;
  border-bottom: 1.5vh solid transparent;
}
#movePad .arrow-box.left:before {
  border-right: 2vh solid rgba(255, 255, 255, 0.9);
  margin-left: 4px;
}
#movePad .arrow-box.right:before {
  border-left: 2vh solid rgba(255, 255, 255, 0.9);
  margin-right: 4px;
}
#movePad .arrow-box.active {
  background: #f7c96f40;
  box-shadow: 0 0 16px #f7c96f80;
  border-color: var(--ui-gold);
  transform: scale(0.96);
}
#pauseOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #05030af2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  z-index: 90;
}
#pauseTitle {
  font-family: var(--pixel-font);
  font-size: 3rem;
  margin-bottom: 30px;
  text-shadow: 4px 4px 0 var(--neon-pink);
}
#debugMenu {
  padding: 20px;
  box-sizing: border-box;
}
.debug-grid {
  width: clamp(280px, 90vw, 760px);
  max-height: calc(100vh - 220px);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow: auto;
  padding: 8px;
  box-sizing: border-box;
}
.debug-grid .btn {
  width: 100%;
}
