* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #10131a;
  color: #f2ecdc;
  font-family: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: none;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 8px;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.65);
}

.hud-block { display: flex; flex-direction: column; gap: 3px; }

.lbl {
  font-size: 9px;
  letter-spacing: 3px;
  color: #8f9aa8;
}

#score {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffc93c;
}

#lives { display: flex; gap: 6px; align-items: center; }

.wlvl {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #b085e8;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.65);
}

.life {
  width: 13px;
  height: 14px;
  background: #ff5252;
  clip-path: polygon(50% 0, 0 100%, 100% 100%);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.6));
}

.bars-block {
  flex: 1;
  max-width: 200px;
  margin-left: auto;
  gap: 2px;
}

.lbl-gap { margin-top: 4px; }

.bar {
  height: 9px;
  border: 2px solid #f2ecdc;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

#shield-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #3f6fd0, #6ea8ff);
  transition: width 0.12s linear;
}

#shield-bar.mid { background: #ffc93c; }

#shield-bar.low {
  background: #ff5252;
  animation: blink 0.5s steps(2) infinite;
}

#fuel-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #1f9e4c, #3ddc64);
  transition: width 0.12s linear;
}

#fuel-bar.mid { background: #ffc93c; }

#fuel-bar.low {
  background: #ff5252;
  animation: blink 0.5s steps(2) infinite;
}

@keyframes blink { 50% { opacity: 0.35; } }

#pause-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 2px solid #f2ecdc;
  background: rgba(255, 255, 255, 0.07);
  color: #f2ecdc;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

#pause-btn:active { background: #ffc93c; color: #10131a; }

#music-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 2px solid #f2ecdc;
  background: rgba(255, 255, 255, 0.07);
  color: #f2ecdc;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

#music-btn:active { background: #ffc93c; color: #10131a; }

#music-btn.muted {
  opacity: 0.4;
  text-decoration: line-through;
}

#boss-bar {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(60%, 320px);
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.65);
}

#boss-bar .lbl { color: #ff5252; }

#boss-bar .bar { border-color: #ff5252; }

#boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #aa2222, #ff5252);
  transition: width 0.1s linear;
}

#controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px calc(16px + env(safe-area-inset-bottom));
}

.cluster { display: flex; gap: 16px; }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(2, 56px);
  gap: 6px;
}

.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }

.ctl.d {
  width: 56px;
  height: 56px;
  font-size: 18px;
  border-width: 2px;
}

.ctl {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 3px solid rgba(242, 236, 220, 0.85);
  background: rgba(255, 255, 255, 0.07);
  color: #f2ecdc;
  font: inherit;
  font-size: 24px;
  cursor: pointer;
}

.ctl.active {
  background: #ffc93c;
  border-color: #ffc93c;
  color: #10131a;
}

#btn-fire {
  width: 94px;
  height: 94px;
  border-color: #ff5252;
  color: #ff5252;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
}

.rcluster {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.ctl.bomb {
  width: 66px;
  height: 66px;
  border-color: #ffc93c;
  color: #ffc93c;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
}

.ctl.bomb.active,
.ctl.bomb:active {
  background: #ffc93c;
  border-color: #ffc93c;
  color: #10131a;
}

.ctl.bomb.empty { opacity: 0.35; }

#btn-fire.active {
  background: #ff5252;
  border-color: #ff5252;
  color: #fff;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px;
  text-align: center;
  background: rgba(10, 13, 19, 0.82);
}

.hidden { display: none; }

.title {
  font-size: clamp(32px, 10vw, 56px);
  font-weight: 700;
  letter-spacing: 8px;
  color: #ffc93c;
  text-shadow: 0 4px 0 #6b4d00, 0 8px 0 rgba(0, 0, 0, 0.5);
  animation: titleglow 1.8s ease-in-out infinite;
}

@keyframes titleglow {
  50% {
    color: #ffe66d;
    text-shadow: 0 4px 0 #6b4d00, 0 8px 0 rgba(0, 0, 0, 0.5), 0 0 26px rgba(255, 201, 60, 0.55);
  }
}

.best-line {
  font-size: 13px;
  letter-spacing: 4px;
  color: #ffc93c;
  margin-top: -8px;
}

.record {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 4px;
  color: #ff5252;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
  animation: blink 0.6s steps(2) infinite;
}

.subtitle {
  font-size: 12px;
  letter-spacing: 6px;
  color: #8f9aa8;
  margin-top: -12px;
}

.btn {
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 16px 38px;
  color: #10131a;
  background: #ffc93c;
  border: none;
  border-radius: 8px;
  box-shadow: 0 5px 0 #6b4d00;
  cursor: pointer;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #6b4d00;
}

#menu .btn { animation: pulse 1.5s ease-in-out infinite; }

@keyframes pulse {
  50% { transform: scale(1.07); }
}

.btn.ghost {
  background: transparent;
  color: #ffc93c;
  border: 2px solid #ffc93c;
  box-shadow: 0 5px 0 rgba(107, 77, 0, 0.45);
  animation: none;
}

.btn.ghost:active {
  background: rgba(255, 201, 60, 0.15);
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(107, 77, 0, 0.45);
}

#crt {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.38) 100%),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.13) 0 1px, transparent 1px 3px);
}

.hint {
  font-size: 11px;
  line-height: 2;
  letter-spacing: 1px;
  color: #8f9aa8;
}

.ver {
  position: fixed;
  right: 14px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 10px;
  letter-spacing: 2px;
  color: #55606c;
}

.stats {
  font-size: 15px;
  letter-spacing: 2px;
  line-height: 2.2;
}

.stats b {
  color: #ffc93c;
  font-size: 22px;
  margin-left: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .title, #menu .btn, .record { animation: none; }
}

@media (min-width: 700px) {
  #controls { padding-left: 48px; padding-right: 48px; }
}
