:root {
  color-scheme: dark;
  --ink: #070a0d;
  --panel: #111820;
  --line: #344452;
  --chalk: #dfe7e2;
  --acid: #f6d322;
  --army: #8ca738;
  --hot: #ef4e45;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  overflow: hidden;
  background: #000;
  color: var(--chalk);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

button { font: inherit; }

.page-shell {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
}

.game-shell {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  background: #143e51;
  touch-action: none;
  user-select: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hud-actions {
  position: absolute;
  top: 12px;
  right: 13px;
  z-index: 9;
  display: flex;
  gap: 10px;
}

.hud-action {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--acid);
  font: 900 44px/.8 Consolas, monospace;
  filter: drop-shadow(2px 2px 0 #544914);
  cursor: pointer;
}

.hud-action:hover, .hud-action:focus-visible { color: #fff39b; outline: 2px solid #fff39b; }
.hud-action[aria-pressed="true"] { color: #7e8a91; border-color: #60707b; text-decoration: line-through; }
.hud-action:disabled { opacity: .3; cursor: default; }

.pixel-speaker {
  position: relative;
  display: block;
  width: 30px;
  height: 28px;
}

.pixel-speaker::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 10px;
  width: 8px;
  height: 10px;
  background: currentColor;
  box-shadow: 7px -5px 0 1px currentColor, 7px 5px 0 1px currentColor;
}

.pixel-speaker::after {
  content: "))";
  position: absolute;
  left: 14px;
  top: 1px;
  font: 900 23px/1 Consolas, monospace;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: #06111bc2;
  backdrop-filter: blur(2px);
}

.game-overlay[hidden] { display: none; }

.game-overlay__panel {
  width: min(520px, 75%);
  padding: clamp(20px, 4vw, 46px);
  text-align: center;
  border: 2px solid #778692;
  background: #0c141de8;
  box-shadow: 9px 9px 0 #0008;
  clip-path: polygon(13px 0, 100% 0, 100% calc(100% - 13px), calc(100% - 13px) 100%, 0 100%, 0 13px);
}

.game-overlay h2 {
  margin: 10px 0 8px;
  color: white;
  font-size: clamp(26px, 5vw, 58px);
  line-height: 1;
  text-shadow: 5px 5px 0 #000;
}

.game-overlay p { margin: 0 auto 24px; max-width: 400px; color: #afbac2; font-size: clamp(12px, 1.5vw, 16px); }

.pixel-action {
  min-width: 160px;
  border: 0;
  padding: 13px 26px;
  background: var(--acid);
  color: #10120f;
  font-weight: 900;
  box-shadow: 6px 6px 0 #000;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.pixel-action:hover { filter: brightness(1.13); transform: translateY(-2px); }
.pixel-action:disabled { opacity: .55; cursor: wait; transform: none; filter: grayscale(.45); }

.rotate-hint {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  place-content: center;
  text-align: center;
  background: #081017f2;
}

.rotate-hint__phone {
  width: 30px;
  height: 52px;
  margin: 0 auto 12px;
  border: 3px solid var(--acid);
  border-radius: 5px;
  animation: rotate-phone 1.6s ease-in-out infinite;
}

.rotate-hint strong { display: block; font-size: 18px; }
.rotate-hint small { display: block; margin-top: 5px; color: #8f9ba5; }

.touch-controls { position: absolute; inset: 0; z-index: 8; display: none; pointer-events: none; }
.touch-controls__move, .touch-controls__action { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; gap: 12px; }
.touch-controls__move { left: max(18px, env(safe-area-inset-left)); }
.touch-controls__action { right: max(18px, env(safe-area-inset-right)); align-items: end; }
.touch-key { width: 64px; height: 64px; border: 2px solid #fff7; border-radius: 4px; background: #071018a8; color: #fff; font-weight: 900; pointer-events: auto; }
.touch-key span { display: block; font-size: 11px; }
.touch-key b { color: var(--acid); font: 800 18px Consolas, monospace; }
.touch-key.is-pressed { transform: translateY(3px); background: #f6d322c9; color: #111; }
.touch-key--jump { width: 74px; height: 74px; }
.touch-key--bomb[data-unavailable="true"] { opacity: .35; filter: grayscale(1); }

@keyframes rotate-phone { 50% { transform: rotate(90deg); } }

@media (hover: none), (pointer: coarse) {
  .touch-controls { display: block; }
  .hud-actions { top: max(7px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
  .hud-action { width: 42px; height: 38px; }
}

@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint { display: grid; }
}
