:root {
  --ink: #07111e;
  --ink-deep: #030812;
  --ink-soft: #0d2033;
  --bone: #e9e0ce;
  --bone-dim: #a9b2b5;
  --jade: #58d7b7;
  --jade-deep: #1d7567;
  --cinnabar: #d94d3f;
  --cinnabar-deep: #7d2626;
  --amber: #e8b55c;
  --line: rgba(233, 224, 206, 0.18);
  --glass: rgba(8, 20, 33, 0.72);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  --display: "STKaiti", "KaiTi", "Noto Serif SC", "Songti SC", serif;
  --body: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --data: "DIN Alternate", "SFMono-Regular", "Cascadia Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink-deep);
  color: var(--bone);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 4px;
}

.game-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  isolation: isolate;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.grain,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grain {
  opacity: 0.18;
  mix-blend-mode: soft-light;
  background-image:
    repeating-radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.09) 0 1px, transparent 1px 4px),
    repeating-radial-gradient(circle at 70% 80%, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 5px);
  background-size: 7px 7px, 11px 11px;
}

.vignette {
  background:
    radial-gradient(circle at 50% 45%, transparent 34%, rgba(2, 7, 15, 0.24) 72%, rgba(2, 7, 15, 0.78) 100%),
    linear-gradient(180deg, rgba(2, 7, 15, 0.34), transparent 28%, transparent 70%, rgba(2, 7, 15, 0.38));
}

.hud {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  gap: 18px;
  align-items: start;
  padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) 0 calc(18px + env(safe-area-inset-left));
  pointer-events: none;
}

.hud-side {
  min-width: 0;
  padding: 10px 12px 9px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 20, 33, 0.86), rgba(8, 20, 33, 0.36));
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.16);
}

.enemy-hud {
  text-align: right;
}

.hud-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--bone);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.enemy-hud .hud-name {
  justify-content: flex-end;
}

.hud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

.player-dot {
  color: var(--jade);
  background: var(--jade);
}

.enemy-dot {
  color: var(--cinnabar);
  background: var(--cinnabar);
}

.health-track {
  height: 9px;
  margin-top: 8px;
  overflow: hidden;
  border: 1px solid rgba(233, 224, 206, 0.16);
  background: rgba(0, 0, 0, 0.36);
}

.health-fill {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--jade-deep), var(--jade));
  box-shadow: 0 0 16px rgba(88, 215, 183, 0.42);
  transition: width 160ms ease-out;
}

.health-fill.enemy {
  background: linear-gradient(90deg, var(--cinnabar-deep), var(--cinnabar));
  box-shadow: 0 0 16px rgba(217, 77, 63, 0.4);
}

.hud-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
  color: var(--bone-dim);
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.enemy-hud .hud-meta {
  justify-content: flex-end;
}

.match-clock {
  min-width: 154px;
  padding: 8px 18px 10px;
  text-align: center;
  border: 1px solid rgba(232, 181, 92, 0.28);
  background: radial-gradient(circle at 50% 0%, rgba(232, 181, 92, 0.18), rgba(8, 20, 33, 0.82) 64%);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22);
}

.phase-label {
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
}

.timer {
  margin-top: 2px;
  color: var(--bone);
  font-family: var(--data);
  font-size: clamp(24px, 3vw, 34px);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.phase-pips {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
}

.phase-pips i {
  width: 22px;
  height: 2px;
  background: rgba(233, 224, 206, 0.18);
}

.phase-pips i.active {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(232, 181, 92, 0.56);
}

.state-compass {
  position: absolute;
  z-index: 4;
  top: calc(96px + env(safe-area-inset-top));
  right: calc(20px + env(safe-area-inset-right));
  width: 198px;
  padding: 12px;
  border: 1px solid rgba(217, 77, 63, 0.22);
  background: linear-gradient(180deg, rgba(20, 18, 28, 0.82), rgba(8, 20, 33, 0.5));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.compass-title {
  color: var(--bone-dim);
  font-size: 10px;
  letter-spacing: 0.28em;
  text-align: center;
}

.compass-ring {
  position: relative;
  width: 172px;
  height: 172px;
  margin: 8px auto 7px;
}

.compass-ring canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.compass-core {
  position: absolute;
  inset: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(233, 224, 206, 0.14);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(217, 77, 63, 0.16), rgba(7, 17, 30, 0.9) 68%);
  color: var(--bone);
  font-family: var(--display);
  font-size: 38px;
  text-shadow: 0 0 18px rgba(217, 77, 63, 0.44);
  transition: color 220ms ease, text-shadow 220ms ease;
}

.state-legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  color: var(--bone-dim);
  font-size: 10px;
}

.state-legend span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 3px;
  border-bottom: 1px solid rgba(233, 224, 206, 0.08);
}

.state-legend b {
  color: var(--bone);
  font-family: var(--data);
  font-weight: 600;
}

.legend.confidence::before,
.legend.pressure::before,
.legend.vigilance::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  content: "";
  border-radius: 50%;
  vertical-align: 1px;
}

.legend.confidence::before { background: var(--jade); }
.legend.pressure::before { background: var(--cinnabar); }
.legend.vigilance::before { background: var(--amber); }

.dialogue-bubble {
  position: absolute;
  z-index: 5;
  top: 35%;
  right: clamp(24px, 22vw, 270px);
  max-width: 270px;
  padding: 10px 14px;
  border-left: 2px solid var(--cinnabar);
  background: rgba(13, 22, 35, 0.84);
  color: var(--bone);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
}

.dialogue-bubble.show {
  opacity: 1;
  transform: translateY(0);
}

.phase-banner {
  position: absolute;
  z-index: 6;
  top: 42%;
  left: 50%;
  width: min(420px, calc(100vw - 48px));
  padding: 16px 22px 15px;
  text-align: center;
  border-top: 1px solid rgba(232, 181, 92, 0.52);
  border-bottom: 1px solid rgba(232, 181, 92, 0.52);
  background: linear-gradient(90deg, transparent, rgba(8, 20, 33, 0.82) 18%, rgba(8, 20, 33, 0.82) 82%, transparent);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 280ms ease, transform 280ms ease;
  pointer-events: none;
}

.phase-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.phase-banner span {
  display: block;
  color: var(--amber);
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0.18em;
}

.phase-banner small {
  display: block;
  margin-top: 5px;
  color: var(--bone-dim);
  font-size: 12px;
  letter-spacing: 0.12em;
}

.event-feed {
  position: absolute;
  z-index: 4;
  top: calc(180px + env(safe-area-inset-top));
  left: calc(22px + env(safe-area-inset-left));
  width: min(250px, 30vw);
  color: rgba(233, 224, 206, 0.68);
  font-size: 11px;
  line-height: 1.6;
  pointer-events: none;
}

.event-feed p {
  margin: 0 0 4px;
  animation: feed-in 220ms ease-out both;
}

.event-feed p::before {
  margin-right: 7px;
  color: var(--amber);
  content: "·";
}

.controls {
  position: absolute;
  z-index: 7;
  right: calc(26px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: calc(26px + env(safe-area-inset-left));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.joystick {
  position: relative;
  width: 148px;
  height: 148px;
  border: 1px solid rgba(233, 224, 206, 0.22);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(88, 215, 183, 0.1), rgba(8, 20, 33, 0.28) 62%, transparent 63%);
  box-shadow: inset 0 0 24px rgba(88, 215, 183, 0.08);
  pointer-events: auto;
  touch-action: none;
}

.joystick-ring {
  position: absolute;
  inset: 22px;
  border: 1px dashed rgba(88, 215, 183, 0.25);
  border-radius: 50%;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(88, 215, 183, 0.66);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(233, 224, 206, 0.24), rgba(29, 117, 103, 0.62));
  box-shadow: 0 0 24px rgba(88, 215, 183, 0.24);
  transform: translate(-50%, -50%);
}

.joystick-hint {
  position: absolute;
  bottom: -22px;
  left: 50%;
  color: var(--bone-dim);
  font-size: 10px;
  letter-spacing: 0.24em;
  transform: translateX(-50%);
}

.skill-cluster {
  display: grid;
  grid-template-columns: repeat(2, 76px);
  gap: 12px 14px;
  align-items: end;
  pointer-events: auto;
}

.skill-btn {
  position: relative;
  width: 76px;
  height: 76px;
  border: 1px solid rgba(233, 224, 206, 0.28);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 26%, rgba(233, 224, 206, 0.17), rgba(13, 32, 51, 0.88) 58%, rgba(4, 11, 21, 0.94));
  color: var(--bone);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, opacity 120ms ease;
  -webkit-user-select: none;
  user-select: none;
}

.skill-btn span,
.skill-btn small {
  display: block;
}

.skill-btn span {
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: 0.08em;
}

.skill-btn small {
  margin-top: 3px;
  color: var(--bone-dim);
  font-family: var(--data);
  font-size: 10px;
}

.skill-btn:active {
  transform: scale(0.94);
}

.skill-btn:disabled {
  cursor: default;
  opacity: 0.82;
}

.skill-btn.basic {
  border-color: rgba(88, 215, 183, 0.38);
}

.skill-btn.ult {
  border-color: rgba(232, 181, 92, 0.48);
  background: radial-gradient(circle at 35% 26%, rgba(232, 181, 92, 0.22), rgba(50, 31, 24, 0.9) 60%, rgba(12, 10, 17, 0.94));
}

.skill-btn.locked {
  opacity: 0.4;
  filter: grayscale(0.75);
}

.skill-btn.cooling {
  opacity: 0.56;
}

.skill-btn.flash {
  border-color: var(--amber);
  box-shadow: 0 0 28px rgba(232, 181, 92, 0.38);
}

.start-overlay,
.result-overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(88, 215, 183, 0.12), transparent 34%),
    linear-gradient(180deg, rgba(3, 8, 18, 0.72), rgba(3, 8, 18, 0.94));
  backdrop-filter: blur(8px);
}

.start-overlay[hidden],
.result-overlay[hidden] {
  display: none;
}

.start-card,
.result-card {
  width: min(580px, 100%);
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgba(233, 224, 206, 0.18);
  background:
    linear-gradient(135deg, rgba(232, 181, 92, 0.08), transparent 26%),
    linear-gradient(315deg, rgba(217, 77, 63, 0.1), transparent 36%),
    rgba(7, 17, 30, 0.9);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.48);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.start-card h1,
.result-card h2 {
  margin: 0;
  color: var(--bone);
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.start-card h1 {
  font-size: clamp(44px, 10vw, 78px);
  line-height: 0.95;
}

.start-card h1 span {
  color: var(--cinnabar);
  padding: 0 4px;
}

.start-copy,
.result-card > p {
  max-width: 44ch;
  margin: 20px 0 0;
  color: var(--bone-dim);
  font-size: 15px;
  line-height: 1.8;
}

.start-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 28px;
}

.start-rules span {
  padding: 7px 10px;
  border: 1px solid rgba(88, 215, 183, 0.25);
  color: var(--jade);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.start-card button,
.result-card button {
  min-width: 180px;
  padding: 13px 22px;
  border: 1px solid rgba(232, 181, 92, 0.62);
  background: linear-gradient(135deg, rgba(232, 181, 92, 0.22), rgba(217, 77, 63, 0.14));
  color: var(--bone);
  font-weight: 700;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.start-card button:hover,
.result-card button:hover {
  transform: translateY(-2px);
  background: linear-gradient(135deg, rgba(232, 181, 92, 0.32), rgba(217, 77, 63, 0.2));
}

.start-note {
  margin: 14px 0 0;
  color: rgba(169, 178, 181, 0.72);
  font-size: 11px;
}

.result-card h2 {
  font-size: clamp(36px, 8vw, 58px);
  color: var(--amber);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0 28px;
}

.result-stats div {
  padding: 12px 10px;
  border-top: 1px solid rgba(233, 224, 206, 0.16);
  background: rgba(233, 224, 206, 0.04);
}

.result-stats strong,
.result-stats span {
  display: block;
}

.result-stats strong {
  color: var(--bone);
  font-family: var(--data);
  font-size: 20px;
}

.result-stats span {
  margin-top: 4px;
  color: var(--bone-dim);
  font-size: 10px;
}

.sound-toggle {
  position: absolute;
  z-index: 8;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  padding: 6px 9px;
  border: 1px solid rgba(233, 224, 206, 0.16);
  background: rgba(8, 20, 33, 0.62);
  color: var(--bone-dim);
  font-size: 10px;
  letter-spacing: 0.08em;
  cursor: pointer;
  transform: translateX(-50%);
}

.pause-hint {
  position: absolute;
  z-index: 30;
  top: 50%;
  left: 50%;
  display: none;
  padding: 12px 18px;
  border: 1px solid rgba(232, 181, 92, 0.42);
  background: rgba(8, 20, 33, 0.9);
  color: var(--bone);
  font-size: 12px;
  letter-spacing: 0.16em;
  transform: translate(-50%, -50%);
}

.pause-hint.show {
  display: block;
}

@keyframes feed-in {
  from { opacity: 0; transform: translateX(-5px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 860px) {
  .hud {
    grid-template-columns: minmax(110px, 1fr) auto minmax(110px, 1fr);
    gap: 8px;
    padding-right: calc(10px + env(safe-area-inset-right));
    padding-left: calc(10px + env(safe-area-inset-left));
  }

  .hud-side {
    padding: 8px 9px;
  }

  .hud-name {
    font-size: 11px;
  }

  .hud-meta {
    font-size: 9px;
  }

  .match-clock {
    min-width: 112px;
    padding: 6px 10px 8px;
  }

  .phase-label {
    font-size: 9px;
  }

  .state-compass {
    top: calc(86px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    width: 164px;
    padding: 9px;
  }

  .compass-ring {
    width: 144px;
    height: 144px;
  }

  .compass-core {
    inset: 35px;
    font-size: 31px;
  }

  .dialogue-bubble {
    top: 28%;
    right: 18px;
    max-width: 210px;
    font-size: 13px;
  }

  .event-feed {
    top: calc(150px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    width: 160px;
    font-size: 10px;
  }

  .controls {
    right: calc(14px + env(safe-area-inset-right));
    bottom: calc(15px + env(safe-area-inset-bottom));
    left: calc(14px + env(safe-area-inset-left));
  }

  .joystick {
    width: 122px;
    height: 122px;
  }

  .joystick-knob {
    width: 46px;
    height: 46px;
  }

  .skill-cluster {
    grid-template-columns: repeat(2, 64px);
    gap: 9px 10px;
  }

  .skill-btn {
    width: 64px;
    height: 64px;
  }

  .skill-btn span {
    font-size: 14px;
  }

  .skill-btn small {
    font-size: 9px;
  }
}

@media (max-width: 560px) and (orientation: portrait) {
  .state-compass {
    top: calc(78px + env(safe-area-inset-top));
    width: 138px;
  }

  .compass-ring {
    width: 118px;
    height: 118px;
  }

  .compass-core {
    inset: 29px;
    font-size: 25px;
  }

  .state-legend {
    font-size: 9px;
  }

  .event-feed {
    display: none;
  }

  .dialogue-bubble {
    top: 25%;
    right: 12px;
    max-width: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}



