:root {
  color-scheme: dark;
  --panel: rgba(12, 10, 9, 0.72);
  --line: rgba(255, 255, 255, 0.18);
  --ink: #f7efe2;
  --muted: #bbaea0;
  --blood: #e43d30;
  --amber: #f3b44e;
  --acid: #91d44b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #090807;
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  touch-action: none;
}

button {
  font: inherit;
}

.game-shell {
  position: fixed;
  inset: 0;
  min-width: 320px;
  min-height: 320px;
  background: #090807;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.hud {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2;
  display: flex;
  align-items: stretch;
  gap: 8px;
  pointer-events: none;
}

.meter {
  min-width: 84px;
  height: 50px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(32, 28, 24, 0.84), var(--panel));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(8px);
}

.meter span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.meter strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 22px;
  line-height: 1;
}

.meter.danger strong {
  color: var(--blood);
}

.meter.status {
  min-width: 128px;
  margin-left: auto;
}

.meter.status span {
  color: var(--ink);
  font-size: 13px;
  line-height: 32px;
  white-space: nowrap;
}

.icon-button {
  position: absolute;
  z-index: 4;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(10, 9, 8, 0.72);
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(8px);
}

.icon-button:active,
.fire-button:active,
.result button:active {
  transform: translateY(1px);
}

.mute {
  top: max(72px, calc(env(safe-area-inset-top) + 72px));
  right: max(12px, env(safe-area-inset-right));
}

.mute span {
  position: relative;
  width: 19px;
  height: 17px;
  border-left: 7px solid var(--ink);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.mute span::before {
  content: "";
  position: absolute;
  left: -17px;
  top: -3px;
  width: 8px;
  height: 11px;
  border: 2px solid var(--ink);
  border-right: 0;
}

.mute span::after {
  content: "";
  position: absolute;
  left: 8px;
  top: -5px;
  width: 12px;
  height: 20px;
  border-right: 3px solid var(--amber);
  border-radius: 50%;
}

.mute.is-muted span::after {
  left: 5px;
  top: -3px;
  width: 22px;
  height: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--blood);
  transform: rotate(-42deg);
  transform-origin: center;
}

.touch-controls {
  position: absolute;
  inset: auto max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  pointer-events: none;
}

.right-controls {
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  gap: 14px;
  pointer-events: none;
}

.control-pad,
.fire-button {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.control-pad {
  position: relative;
  width: clamp(112px, 19vw, 156px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.1) 0 2px, transparent 3px),
    radial-gradient(circle at center, rgba(232, 63, 46, 0.18), rgba(15, 14, 13, 0.56) 58%, rgba(15, 14, 13, 0.32));
  box-shadow:
    inset 0 0 28px rgba(255, 255, 255, 0.08),
    0 18px 36px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(8px);
}

.control-pad.look-pad {
  width: clamp(98px, 16vw, 130px);
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.1) 0 2px, transparent 3px),
    radial-gradient(circle at center, rgba(145, 212, 75, 0.16), rgba(15, 14, 13, 0.56) 58%, rgba(15, 14, 13, 0.3));
}

.stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 38%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)),
    rgba(26, 23, 21, 0.74);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.34);
  transform: translate(-50%, -50%);
}

.fire-button {
  position: relative;
  width: clamp(76px, 12vw, 102px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 220, 160, 0.36);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.22), transparent 18%),
    radial-gradient(circle at center, #ec613d 0 39%, #9d231d 40% 70%, rgba(43, 18, 15, 0.72) 71%);
  box-shadow:
    inset 0 -10px 18px rgba(40, 0, 0, 0.36),
    0 18px 34px rgba(0, 0, 0, 0.42);
}

.fire-button span {
  position: absolute;
  inset: 24%;
  border: 3px solid rgba(255, 245, 225, 0.88);
  border-radius: 50%;
}

.fire-button span::before,
.fire-button span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 112%;
  height: 3px;
  background: rgba(255, 245, 225, 0.88);
  transform: translate(-50%, -50%);
}

.fire-button span::after {
  width: 3px;
  height: 112%;
}

.result {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(5, 4, 4, 0.66);
  backdrop-filter: blur(5px);
}

.result.hidden {
  display: none;
}

.result h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(46px, 10vw, 112px);
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow:
    0 4px 0 rgba(94, 16, 13, 0.8),
    0 24px 52px rgba(0, 0, 0, 0.7);
}

.result p {
  margin: 0;
  color: var(--amber);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(15px, 3vw, 22px);
  font-weight: 900;
}

.result button {
  justify-self: center;
  min-width: 156px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 7px;
  background: linear-gradient(180deg, #ef6a3d, #9d231d);
  color: #fff7ec;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.42);
}

@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .touch-controls {
    opacity: 0.38;
    transition: opacity 160ms ease;
  }

  .touch-controls:hover,
  .touch-controls:focus-within {
    opacity: 0.86;
  }
}

@media (max-width: 720px) {
  .hud {
    gap: 6px;
  }

  .meter {
    min-width: 62px;
    height: 44px;
    padding: 7px 8px;
  }

  .meter strong {
    font-size: 18px;
  }

  .meter.status {
    min-width: 98px;
  }

  .meter.status span {
    font-size: 11px;
    line-height: 28px;
  }

  .mute {
    top: max(62px, calc(env(safe-area-inset-top) + 62px));
  }

  .right-controls {
    grid-template-columns: 1fr;
    justify-items: end;
    gap: 10px;
  }

  .control-pad.look-pad {
    width: clamp(88px, 25vw, 112px);
  }
}

@media (max-height: 520px) {
  .control-pad {
    width: clamp(90px, 24vh, 120px);
  }

  .control-pad.look-pad {
    width: clamp(78px, 21vh, 102px);
  }

  .fire-button {
    width: clamp(64px, 18vh, 82px);
  }
}
