:root {
  color-scheme: dark;
  --ink: #effcff;
  --muted: #8ed3df;
  --acid: #dfff6c;
  --coral: #ff776e;
  --cyan: #58edf0;
  --deep: #031522;
  --panel: rgba(3, 29, 45, .76);
  font-family: "Bahnschrift Condensed", "Microsoft YaHei UI", sans-serif;
  background: var(--deep);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 50% 12%, rgba(40, 205, 223, .2), transparent 34%),
    linear-gradient(165deg, #071f31 0%, #020b14 76%);
}

body {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.page-shell {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  position: relative;
}

.game-frame {
  --danger: 0;
  --joystick-accent: var(--cyan);
  position: relative;
  width: min(100vw, calc(100vh * 440 / 952));
  height: min(100vh, calc(100vw * 952 / 440));
  overflow: hidden;
  isolation: isolate;
  background: #06263c;
  box-shadow:
    0 0 0 1px rgba(160, 245, 255, .14),
    0 32px 90px rgba(0, 0, 0, .64),
    inset 0 0 68px rgba(0, 6, 19, calc(.32 + var(--danger) * .28));
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.hud {
  position: absolute;
  z-index: 5;
  top: max(12px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  height: 66px;
  display: grid;
  grid-template-columns: 1.3fr .8fr .8fr;
  gap: 7px;
  padding: 8px 8px 11px;
  border: 1px solid rgba(152, 241, 250, .24);
  border-radius: 13px 13px 8px 8px;
  background:
    linear-gradient(104deg, rgba(3, 35, 52, .88), rgba(5, 70, 82, .64)),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(141, 241, 248, .04) 18px 19px);
  box-shadow: 0 10px 32px rgba(0, 11, 24, .34);
  backdrop-filter: blur(9px);
}

.hud > div:not(.progress-track) {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.stage-block { padding-left: 5px; }
.power-block,
.eaten-block {
  align-items: center;
  border-left: 1px solid rgba(137, 231, 239, .16);
}

.hud span,
.hud i {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  font-weight: 650;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.hud strong {
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -.025em;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.power-block strong { color: var(--acid); font-size: 19px; }
.eaten-block strong { display: flex; gap: 3px; align-items: baseline; }
.eaten-block strong b { font-size: 16px; }
.eaten-block strong i { font-size: 9px; }

.progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  overflow: hidden;
  border-radius: 0 0 8px 8px;
  background: rgba(0, 9, 22, .52);
}

.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--acid));
  box-shadow: 0 0 12px rgba(191, 255, 106, .72);
  transition: width .28s ease;
}

.role-legend {
  position: absolute;
  z-index: 4;
  top: 91px;
  left: 19px;
  right: 19px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  color: rgba(224, 253, 255, .78);
  background: rgba(1, 24, 39, .54);
  backdrop-filter: blur(6px);
}

.role-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .03em;
  white-space: nowrap;
}

.role-legend i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.role-legend .can-eat i { background: var(--acid); box-shadow: 0 0 7px var(--acid); }
.role-legend .danger i { background: var(--coral); box-shadow: 0 0 7px var(--coral); }
.role-legend .gap i { border: 1px dashed var(--cyan); border-radius: 2px; }

.objective-hint {
  position: absolute;
  z-index: 4;
  top: 127px;
  left: 50%;
  width: max-content;
  max-width: 86%;
  padding: 7px 12px 8px;
  border: 1px solid rgba(211, 255, 106, .28);
  border-radius: 9px;
  text-align: center;
  background: rgba(2, 35, 47, .68);
  box-shadow: 0 7px 24px rgba(0, 12, 24, .22);
  transform: translateX(-50%);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.objective-hint span {
  display: block;
  color: var(--acid);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .18em;
}

.objective-hint strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 11px;
  letter-spacing: .025em;
}

.scale-callout {
  position: absolute;
  z-index: 7;
  top: 22%;
  left: 50%;
  width: min(82%, 330px);
  padding: 14px 16px 13px;
  border-top: 1px solid rgba(173, 248, 255, .65);
  border-bottom: 1px solid rgba(173, 248, 255, .22);
  color: var(--ink);
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 18, 35, .9);
  background: linear-gradient(90deg, transparent, rgba(3, 45, 61, .8), transparent);
  transform: translate(-50%, -12px);
  opacity: 0;
  pointer-events: none;
}

.scale-callout.is-visible { animation: callout 2.15s cubic-bezier(.2, .72, .2, 1) both; }
.scale-callout span { display: block; color: var(--cyan); font-size: 10px; letter-spacing: .32em; }
.scale-callout strong { display: block; margin-top: 4px; font-size: 17px; letter-spacing: .04em; }

.touch-hint {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px));
  padding: 9px 15px;
  border: 1px solid rgba(180, 248, 255, .26);
  border-radius: 999px;
  color: rgba(238, 255, 255, .88);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  background: rgba(2, 28, 43, .68);
  box-shadow: 0 7px 28px rgba(0, 7, 18, .32);
  transform: translateX(-50%);
  transition: opacity .45s ease, transform .45s ease;
  pointer-events: none;
  white-space: nowrap;
}

.touch-hint.is-hidden { opacity: 0; transform: translate(-50%, 10px); }

.result-screen {
  position: absolute;
  z-index: 12;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 38px 26px;
  color: var(--ink);
  text-align: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(12, 86, 99, .36), transparent 38%),
    rgba(1, 13, 25, .88);
  backdrop-filter: blur(12px);
}

.result-screen[hidden] { display: none; }
.eyebrow { margin: 0 0 8px; color: var(--coral); font-size: 11px; font-weight: 800; letter-spacing: .32em; }
.result-screen h1 { margin: 0; font-size: clamp(31px, 9vw, 43px); line-height: 1; letter-spacing: -.055em; }
.result-screen > p:nth-of-type(2) { max-width: 310px; margin: 16px 0 22px; color: #b9dce2; font-size: 13px; line-height: 1.65; }

.result-stats {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 0;
}

.result-stats div {
  padding: 12px 4px;
  border: 1px solid rgba(148, 233, 240, .18);
  border-radius: 10px;
  background: rgba(4, 57, 69, .38);
}

.result-stats dt { color: var(--muted); font-size: 9px; letter-spacing: .06em; }
.result-stats dd { margin: 3px 0 0; color: var(--acid); font-size: 16px; font-weight: 900; }
.reload-note { margin: 22px 0 0 !important; color: rgba(179, 221, 226, .66) !important; font-size: 10px !important; letter-spacing: .1em; }

.edge-frame,
.vignette {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.edge-frame {
  border: 1px solid rgba(161, 240, 247, .16);
  box-shadow: inset 0 0 0 8px rgba(1, 13, 26, .12), inset 0 0 50px rgba(0, 8, 24, .24);
}

.vignette {
  z-index: 9;
  box-shadow:
    inset 0 0 92px rgba(0, 8, 24, .24),
    inset 0 0 45px rgba(255, 70, 60, calc(var(--danger) * .34));
  transition: box-shadow .12s linear;
}

.desktop-note {
  position: fixed;
  bottom: 14px;
  left: calc(50% + min(50vw, calc(50vh * 440 / 952)) + 24px);
  margin: 0;
  color: rgba(151, 204, 212, .5);
  font-size: 10px;
  letter-spacing: .08em;
  white-space: nowrap;
}

@keyframes callout {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(.96); }
  13%, 70% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(1.02); }
}

@media (max-aspect-ratio: 440 / 952) {
  .game-frame { width: 100vw; height: calc(100vw * 952 / 440); }
}

@media (min-aspect-ratio: 440 / 952) {
  .game-frame { width: calc(100vh * 440 / 952); height: 100vh; }
}

@media (max-width: 700px) { .desktop-note { display: none; } }

@media (pointer: coarse) and (max-width: 700px) {
  .touch-hint { bottom: max(147px, calc(env(safe-area-inset-bottom) + 137px)); }
}

@media (max-height: 720px) {
  .hud { top: 8px; left: 10px; right: 10px; transform: scale(.94); transform-origin: top center; }
  .role-legend { top: 80px; left: 12px; right: 12px; }
  .objective-hint { top: 113px; }
  .touch-hint { bottom: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .scale-callout.is-visible { animation-duration: .01ms; }
  .touch-hint,
  .progress-track i { transition: none; }
}
