:root {
  --bg: #07090d;
  --panel: rgba(18, 24, 34, 0.86);
  --stroke: rgba(120, 160, 210, 0.22);
  --text: #e8eef7;
  --muted: #9aa8bb;
  --cyan: #4fd1ff;
  --gold: #ffd166;
  --danger: #ff5b5b;
  --ok: #4ade80;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
}
.screen.active {
  display: block;
}

/* ---------------- 横屏提示 ---------------- */
#rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #07090d;
  color: var(--text);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#rotate-hint p {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}
#rotate-hint span {
  color: var(--muted);
  font-size: 13px;
}
.rotate-icon {
  font-size: 48px;
  animation: rotate 1.8s ease-in-out infinite;
}
@keyframes rotate {
  0%, 40% { transform: rotate(0deg); }
  70%, 100% { transform: rotate(90deg); }
}
@media (orientation: portrait) {
  #rotate-hint { display: flex; }
}

/* ---------------- 主菜单 ---------------- */
#menu-screen {
  background: radial-gradient(120% 100% at 20% 0%, #16233a 0%, #0a0e15 55%, #06080c 100%);
}
.menu-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(80, 140, 200, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 140, 200, 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 100%);
}
.menu-panel {
  position: relative;
  width: min(880px, 92vw);
  max-height: 94vh;
  margin: 3vh auto;
  padding: 22px 30px 18px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(24, 33, 48, 0.92), rgba(12, 17, 26, 0.95));
  border: 1px solid var(--stroke);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow-y: auto;
}
.title-wrap {
  text-align: center;
  margin-bottom: 14px;
}
.game-title {
  margin: 0;
  font-size: clamp(30px, 5.2vw, 46px);
  letter-spacing: 6px;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff, #7fd8ff 55%, #3aa7d8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 18px rgba(79, 209, 255, 0.25));
}
.game-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 1px;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0 18px;
}
.setting-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.setting-row > label {
  width: 72px;
  flex: 0 0 72px;
  color: var(--muted);
  font-size: 13px;
}
.option-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.opt {
  appearance: none;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s;
  font-family: inherit;
}
.opt:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
.opt.active {
  background: linear-gradient(180deg, rgba(79, 209, 255, 0.28), rgba(79, 209, 255, 0.12));
  border-color: rgba(79, 209, 255, 0.7);
  color: #d9f6ff;
  box-shadow: 0 0 18px rgba(79, 209, 255, 0.22);
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #04212e;
  background: linear-gradient(180deg, #8ce7ff, #35b6e8);
  box-shadow: 0 10px 28px rgba(53, 182, 232, 0.32);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.12s;
}
.btn-primary:active {
  transform: scale(0.985);
}
.btn-ghost {
  padding: 12px 20px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-wide {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  font-size: 14px;
  letter-spacing: 2px;
}

/* ---------- 联机大厅 ---------- */
#lobby-screen {
  background: radial-gradient(120% 100% at 80% 0%, #16233a 0%, #0a0e15 55%, #06080c 100%);
}
.lobby-bg {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(80, 140, 200, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 140, 200, 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(80% 70% at 50% 45%, #000 30%, transparent 100%);
}
.lobby-panel {
  position: relative;
  width: min(920px, 94vw);
  max-height: 94vh;
  margin: 3vh auto;
  padding: 24px 30px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(24, 33, 48, 0.94), rgba(12, 17, 26, 0.96));
  border: 1px solid var(--stroke);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow-y: auto;
}
.lobby-title {
  margin: 0 0 4px;
  font-size: 26px;
  letter-spacing: 3px;
  text-align: center;
}
.lobby-sub {
  margin: 0 0 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.lobby-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.lobby-field label {
  width: 62px;
  flex: 0 0 62px;
  color: var(--muted);
  font-size: 13px;
}
.lobby-field input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  letter-spacing: 1px;
}
.lobby-field input:focus {
  border-color: rgba(79, 209, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(79, 209, 255, 0.12);
}
.lobby-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: rgba(154, 168, 187, 0.7);
  font-size: 12px;
}
.lobby-divider::before,
.lobby-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(120, 160, 210, 0.18);
}
.lobby-error {
  min-height: 18px;
  margin-top: 10px;
  color: #ff8080;
  font-size: 12.5px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.lobby-error.show {
  opacity: 1;
}
.lobby-back {
  display: block;
  margin: 14px auto 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.lobby-back:hover {
  color: var(--text);
}

.lobby-room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(120, 160, 210, 0.14);
}
.lobby-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.room-code {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 8px;
  color: var(--cyan);
  text-shadow: 0 0 24px rgba(79, 209, 255, 0.35);
  font-variant-numeric: tabular-nums;
}
.lobby-cols {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 22px;
  margin-bottom: 18px;
}
.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lobby-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(120, 160, 210, 0.14);
  font-size: 13px;
}
.lobby-player.me {
  border-color: rgba(79, 209, 255, 0.45);
  background: rgba(79, 209, 255, 0.1);
}
.lp-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: 0 0 12px;
}
.lp-name {
  flex: 1;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lp-host {
  font-style: normal;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.18);
  color: var(--gold);
  border: 1px solid rgba(255, 209, 102, 0.4);
  flex: 0 0 auto;
}
.lp-char {
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}

.lobby-chars {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.lobby-char {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s;
}
.lobby-char:hover:not(.taken) {
  background: rgba(255, 255, 255, 0.09);
  transform: translateY(-1px);
}
.c-info {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(120, 160, 210, 0.35);
  background: rgba(8, 12, 18, 0.85);
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  z-index: 2;
}
.c-info:hover {
  color: var(--cyan);
  border-color: rgba(79, 209, 255, 0.6);
}
.lp-down {
  font-style: normal;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 91, 91, 0.16);
  color: #ff9a9a;
  border: 1px solid rgba(255, 91, 91, 0.4);
  flex: 0 0 auto;
}

/* 技能详情弹窗 */
.skill-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 11, 0.62);
  backdrop-filter: blur(5px);
  z-index: 60;
}
.skill-modal.show {
  display: flex;
}
.skill-card {
  width: min(380px, 86vw);
  padding: 24px 22px 20px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(24, 33, 48, 0.98), rgba(10, 15, 22, 0.99));
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.62);
  text-align: center;
}
.sc-name {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 14px;
}
.sc-skill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(79, 209, 255, 0.12);
  border: 1px solid rgba(79, 209, 255, 0.35);
  font-size: 15px;
  font-weight: 800;
  color: #cfeeff;
}
.sc-icon {
  font-size: 18px;
}
.sc-desc {
  margin: 16px 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--muted);
  text-align: left;
}
.sc-meta {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 12px;
  color: rgba(154, 168, 187, 0.9);
  margin-bottom: 18px;
}
#sc-close {
  width: 100%;
  padding: 10px;
}
.lobby-char .c-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
}
.lobby-char .c-name {
  font-size: 13px;
  font-weight: 700;
}
.lobby-char small {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}
.lobby-char.active {
  border-color: rgba(79, 209, 255, 0.8);
  background: rgba(79, 209, 255, 0.16);
  box-shadow: 0 0 20px rgba(79, 209, 255, 0.25);
}
.lobby-char.taken {
  opacity: 0.38;
  cursor: not-allowed;
  filter: grayscale(0.7);
}
.lobby-wait {
  text-align: center;
  padding: 14px;
  color: var(--muted);
  font-size: 14px;
  border-radius: 12px;
  border: 1px dashed rgba(120, 160, 210, 0.3);
}

.lobby-bot-btn {
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  font-size: 13px;
  border-style: dashed;
}
.lp-bot {
  font-style: normal;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(120, 160, 255, 0.16);
  color: #a8c8ff;
  border: 1px solid rgba(120, 160, 255, 0.4);
  flex: 0 0 auto;
}
.lp-kick {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 120, 120, 0.4);
  background: rgba(255, 80, 80, 0.14);
  color: #ff9a9a;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  flex: 0 0 auto;
}
.lobby-player.is-bot {
  border-style: dashed;
}

.controls-hint {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
  color: rgba(154, 168, 187, 0.75);
  font-size: 12px;
}

/* ---------------- 游戏区 ---------------- */
#game-screen {
  background: #05070a;
}
#game-area {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(90% 90% at 50% 40%, #10161f 0%, #05070a 100%);
}
#game-canvas {
  display: block;
  border-radius: 6px;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.8);
}

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hud-topleft {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
#minimap-wrap {
  padding: 4px;
  border-radius: 10px;
  background: rgba(8, 12, 18, 0.72);
  border: 1px solid rgba(120, 160, 210, 0.25);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
}
#minimap {
  display: block;
  border-radius: 6px;
}
.hud-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
#objective {
  padding: 7px 12px;
  border-radius: 9px;
  background: rgba(8, 12, 18, 0.72);
  border: 1px solid rgba(120, 160, 210, 0.2);
  font-size: 12px;
  color: var(--muted);
  backdrop-filter: blur(6px);
}
#objective b {
  color: var(--gold);
  font-size: 14px;
}
#objective.urgent {
  color: #ffd9d9;
  border-color: rgba(255, 91, 91, 0.5);
  animation: pulse 1.1s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 91, 91, 0); }
  50% { box-shadow: 0 0 22px rgba(255, 91, 91, 0.35); }
}

.hud-topright {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}
.hud-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(8, 12, 18, 0.72);
  border: 1px solid rgba(120, 160, 210, 0.2);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(6px);
}
.hud-chip .k {
  font-size: 13px;
}

#status-banner {
  position: absolute;
  top: calc(58px + env(safe-area-inset-top));
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(120, 24, 30, 0.85);
  border: 1px solid rgba(255, 120, 120, 0.45);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.22s;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#status-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#toast {
  position: absolute;
  bottom: 22%;
  left: 50%;
  transform: translate(-50%, 10px);
  padding: 10px 20px;
  border-radius: 12px;
  background: rgba(10, 16, 24, 0.92);
  border: 1px solid rgba(120, 170, 220, 0.28);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.2s;
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#rage-banner {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.86);
  padding: 16px 42px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(198, 34, 34, 0.94), rgba(104, 12, 12, 0.96));
  border: 2px solid rgba(255, 130, 130, 0.75);
  box-shadow: 0 0 50px rgba(255, 60, 60, 0.55);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 22;
  transition: opacity 0.22s, transform 0.22s;
  white-space: nowrap;
}
#rage-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: rageGlow 0.9s ease-in-out infinite;
}
@keyframes rageGlow {
  0%, 100% { box-shadow: 0 0 34px rgba(255, 60, 60, 0.45); }
  50% { box-shadow: 0 0 72px rgba(255, 80, 80, 0.85); }
}
.rage-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}
.rage-sub {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  color: #ffd6d6;
  letter-spacing: 2px;
}

#interact-hint {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translate(-50%, 8px);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 209, 102, 0.14);
  border: 1px solid rgba(255, 209, 102, 0.45);
  color: #ffe6a3;
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transition: all 0.18s;
  white-space: nowrap;
}
#interact-hint.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#stamina-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 9px;
  background: rgba(8, 12, 18, 0.72);
  border: 1px solid rgba(120, 160, 210, 0.2);
  backdrop-filter: blur(6px);
}
.stamina-label {
  font-size: 11px;
  color: var(--muted);
}
#stamina-bar {
  width: 104px;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
#stamina-fill {
  height: 100%;
  width: 100%;
  background: var(--ok);
  border-radius: 999px;
  transition: width 0.1s linear;
}

/* 摇杆 */
#joystick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 55%;
  height: 100%;
  touch-action: none;
}
#joystick-base {
  position: absolute;
  width: 104px;
  height: 104px;
  margin-left: -52px;
  margin-top: -52px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(180, 220, 255, 0.12), rgba(120, 160, 210, 0.05));
  border: 2px solid rgba(140, 190, 240, 0.28);
  opacity: 0;
  transition: opacity 0.14s;
  pointer-events: none;
}
#joystick-base.active {
  opacity: 1;
}
#joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #c6f0ff, #3fa9d8 70%);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), 0 0 20px rgba(79, 209, 255, 0.35);
  transform: translate(-50%, -50%);
}

/* 动作按钮 */
#action-buttons {
  position: absolute;
  right: calc(20px + env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.action-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(140, 190, 240, 0.28);
  background: rgba(14, 22, 32, 0.62);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.1s, background 0.12s;
}
.action-btn span {
  font-size: 22px;
  line-height: 1;
}
.action-btn small {
  font-size: 10px;
  color: var(--muted);
}
.action-btn:active {
  transform: scale(0.93);
  background: rgba(79, 209, 255, 0.2);
}
.action-btn.primary {
  width: 82px;
  height: 82px;
  border-color: rgba(255, 209, 102, 0.6);
  background: rgba(255, 209, 102, 0.16);
  box-shadow: 0 0 26px rgba(255, 209, 102, 0.22);
}
.action-btn.primary small {
  color: #ffe6a3;
}
.action-btn.ghost {
  opacity: 0.5;
}
.action-btn {
  position: relative;
  overflow: hidden;
}
.action-btn > span,
.action-btn > small {
  position: relative;
  z-index: 1;
}
.cd-mask {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: rgba(6, 10, 16, 0.7);
  pointer-events: none;
  transition: height 0.1s linear;
}
.action-btn.ready {
  border-color: rgba(79, 209, 255, 0.7);
  box-shadow: 0 0 22px rgba(79, 209, 255, 0.32);
}
.action-btn.cooling {
  filter: grayscale(0.9);
  border-color: rgba(120, 140, 160, 0.3);
  box-shadow: none;
}
.action-btn.cooling > span {
  opacity: 0.22;
}
.action-btn.cooling > small {
  opacity: 0;
}
.action-btn.spent {
  opacity: 0.4;
  filter: grayscale(1);
}
.cd-num {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 800;
  color: #f1f5f9;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
  z-index: 2;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.action-btn.cooling .cd-num {
  display: flex;
}

/* 人数多时的紧凑选项 */
#opt-students {
  flex: 1;
}
#opt-students .opt {
  padding: 7px 11px;
  min-width: 40px;
}
#opt-character {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  flex: 1;
}
#opt-character .opt {
  padding: 7px 8px;
  font-size: 12.5px;
  text-align: center;
}
.hint-inline {
  font-size: 11px;
  color: rgba(154, 168, 187, 0.82);
  margin-left: 4px;
  white-space: nowrap;
}

#btn-pause,
#btn-audio {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(8, 12, 18, 0.7);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  line-height: 1;
}
#btn-pause {
  right: calc(50% - 46px);
}
#btn-audio {
  right: calc(50% + 12px);
}
#btn-audio.muted {
  color: var(--danger);
  border-color: rgba(255, 91, 91, 0.45);
}

/* ---------------- 解密浮层 ---------------- */
#puzzle-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 11, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  z-index: 30;
}
#puzzle-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
#puzzle-panel {
  width: min(560px, 62vw);
  padding: 16px 20px 20px;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(20, 28, 40, 0.92), rgba(10, 15, 22, 0.95));
  border: 1px solid rgba(255, 209, 102, 0.28);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 209, 102, 0.08);
  backdrop-filter: blur(10px);
}
.puzzle-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
#puzzle-title {
  font-size: 17px;
  font-weight: 800;
}
#puzzle-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}
#puzzle-close {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border-radius: 9px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
#puzzle-warning {
  margin: 12px 0 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 91, 91, 0.1);
  border: 1px solid rgba(255, 91, 91, 0.28);
  color: #ffb3b3;
  font-size: 11.5px;
  line-height: 1.5;
}
#puzzle-warning.bite {
  animation: bite 0.4s;
}
@keyframes bite {
  0% { box-shadow: 0 0 0 rgba(255, 80, 80, 0); }
  40% { box-shadow: 0 0 24px rgba(255, 80, 80, 0.55); }
  100% { box-shadow: 0 0 0 rgba(255, 80, 80, 0); }
}
#noise-track {
  margin-top: 7px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
#noise-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd166, #ff5b5b);
  border-radius: 999px;
}

/* ---------- 谜题通用 ---------- */
.pz-hint {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}
.pz-hint b {
  color: var(--gold);
  letter-spacing: 3px;
  font-size: 16px;
}
.pz-btn {
  display: block;
  margin: 14px auto 0;
  padding: 11px 34px;
  border-radius: 12px;
  border: 1px solid rgba(255, 209, 102, 0.5);
  background: rgba(255, 209, 102, 0.16);
  color: #ffe6a3;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
}
.pz-btn:active {
  transform: scale(0.97);
}

/* 密码转盘 */
.pz-code {
  display: flex;
  justify-content: center;
  gap: 18px;
  padding: 6px 0;
}
.pz-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.pz-arrow {
  width: 62px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.pz-arrow:active {
  background: rgba(79, 209, 255, 0.2);
}
.pz-digit {
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(120, 160, 210, 0.25);
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #cfe6ff;
}
.pz-digit.hit {
  border-color: rgba(74, 222, 128, 0.7);
  color: #8ef0b0;
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.25);
}

/* 记忆 */
.pz-memory {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  width: 240px;
  margin: 0 auto;
}
.pz-pad {
  height: 74px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: var(--c);
  opacity: 0.42;
  cursor: pointer;
  transition: opacity 0.1s, transform 0.1s;
}
.pz-pad.lit {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 0 26px var(--c);
}

/* 节奏 */
.pz-track {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--stroke);
  margin: 18px 0 6px;
  overflow: hidden;
}
.pz-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(74, 222, 128, 0.35);
  border-left: 2px solid rgba(74, 222, 128, 0.9);
  border-right: 2px solid rgba(74, 222, 128, 0.9);
}
.pz-cursor {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 6px;
  border-radius: 3px;
  background: #ffd166;
  box-shadow: 0 0 14px #ffd166;
}
.pz-count {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  font-weight: 700;
}

/* 图案 */
.pz-pattern {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 240px;
  margin: 0 auto;
}
.pz-dot {
  height: 66px;
  border-radius: 12px;
  border: 2px solid rgba(120, 160, 210, 0.25);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.12s;
}
.pz-dot.hint {
  background: rgba(79, 209, 255, 0.5);
  border-color: rgba(160, 235, 255, 0.95);
  box-shadow: 0 0 22px rgba(79, 209, 255, 0.5);
}
.pz-dot.on {
  background: rgba(74, 222, 128, 0.35);
  border-color: rgba(74, 222, 128, 0.85);
}

/* 四位线索转轮 */
.pz-code4 {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 4px 0 2px;
}
.pz-c4col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 84px;
}
.pz-clue {
  min-height: 30px;
  text-align: center;
  font-size: 11px;
  line-height: 1.35;
  color: #ffd166;
  opacity: 0.92;
}
.pz-c4col .pz-digit {
  width: 58px;
  height: 54px;
  font-size: 26px;
}
.pz-c4col .pz-arrow {
  width: 58px;
  height: 29px;
}

/* 接线电路 */
.pz-wires {
  display: flex;
  justify-content: center;
  gap: 96px;
  padding: 8px 0 4px;
  position: relative;
}
.pz-wires::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 12px;
  bottom: 12px;
  width: 2px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, rgba(120, 160, 210, 0.3) 0 6px, transparent 6px 12px);
}
.pz-wcol {
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1;
}
.pz-node {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 2px solid var(--c);
  background: rgba(255, 255, 255, 0.05);
  color: var(--c);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s;
}
.pz-node.sel {
  background: var(--c);
  color: #0b0f16;
  box-shadow: 0 0 22px var(--c);
  transform: scale(1.06);
}
.pz-node.done {
  background: var(--c);
  color: #0b0f16;
  opacity: 0.45;
  cursor: default;
}

/* 数字顺序 */
.pz-nums {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 244px;
  margin: 0 auto;
}
.pz-num {
  height: 56px;
  border-radius: 12px;
  border: 2px solid rgba(120, 160, 210, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #dbe9ff;
  font-size: 23px;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.pz-num.on {
  border-color: rgba(74, 222, 128, 0.8);
  background: rgba(74, 222, 128, 0.22);
  color: #9df3b8;
}

/* 算术锁 */
.pz-expr {
  text-align: center;
  font-size: 26px;
  font-weight: 800;
  color: #dbe9ff;
  letter-spacing: 2px;
  margin: 4px 0 10px;
}
.pz-expr b {
  color: var(--gold);
}
.pz-answer {
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 6px;
  height: 42px;
  line-height: 42px;
  margin-bottom: 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 209, 102, 0.25);
}
.pz-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 236px;
  margin: 0 auto;
}
.pz-key {
  height: 44px;
  border-radius: 10px;
  border: 2px solid rgba(120, 160, 210, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #dbe9ff;
  font-size: 19px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.1s;
}
.pz-key:active {
  background: rgba(79, 209, 255, 0.22);
}
.pz-key-fn {
  color: var(--muted);
}
.pz-key-ok {
  border-color: rgba(74, 222, 128, 0.6);
  background: rgba(74, 222, 128, 0.18);
  color: #9df3b8;
}

/* 找规律 */
.pz-seq {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin: 6px 0 14px;
}
.pz-seq span {
  min-width: 46px;
  height: 46px;
  line-height: 46px;
  text-align: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(120, 160, 210, 0.25);
  font-size: 19px;
  font-weight: 800;
  color: #dbe9ff;
}
.pz-seq span.q {
  color: var(--gold);
  border-color: rgba(255, 209, 102, 0.5);
  background: rgba(255, 209, 102, 0.12);
}
.pz-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 230px;
  margin: 0 auto;
}
.pz-opt {
  height: 50px;
  border-radius: 12px;
  border: 2px solid rgba(120, 160, 210, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #dbe9ff;
  font-size: 21px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s;
}
.pz-opt.ok {
  border-color: rgba(74, 222, 128, 0.85);
  background: rgba(74, 222, 128, 0.25);
  color: #9df3b8;
}
.pz-opt.bad {
  border-color: rgba(255, 91, 91, 0.85);
  background: rgba(255, 91, 91, 0.2);
  color: #ffb3b3;
}

/* 二进制灯 */
.pz-target {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}
.pz-target b {
  color: var(--gold);
  font-size: 22px;
  margin-left: 6px;
}
.pz-lamps {
  display: flex;
  justify-content: center;
  gap: 14px;
}
.pz-lamp {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px;
  width: 66px;
  border-radius: 14px;
  border: 2px solid rgba(120, 160, 210, 0.25);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s;
}
.pz-lamp .bulb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(120, 160, 210, 0.28);
  transition: all 0.14s;
}
.pz-lamp small {
  color: var(--muted);
  font-size: 12px;
}
.pz-lamp.on {
  border-color: rgba(255, 209, 102, 0.75);
  background: rgba(255, 209, 102, 0.14);
}
.pz-lamp.on .bulb {
  background: var(--gold);
  box-shadow: 0 0 20px var(--gold);
}
.pz-sum {
  text-align: center;
  margin-top: 14px;
  font-size: 15px;
  font-weight: 700;
  color: #cfe6ff;
}

/* 翻牌配对 */
.pz-match {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 268px;
  margin: 0 auto;
}
.pz-card {
  height: 62px;
  border-radius: 12px;
  border: 2px solid rgba(120, 160, 210, 0.28);
  background: rgba(255, 255, 255, 0.05);
  font-size: 26px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s;
}
.pz-card.open {
  border-color: rgba(255, 209, 102, 0.7);
  background: rgba(255, 209, 102, 0.12);
}
.pz-card.done {
  border-color: rgba(74, 222, 128, 0.7);
  background: rgba(74, 222, 128, 0.16);
  opacity: 0.75;
}

/* 找不同 */
.pz-odd {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 240px;
  margin: 0 auto;
}
.pz-oddcell {
  height: 66px;
  border-radius: 12px;
  border: 2px solid rgba(120, 160, 210, 0.22);
  background: rgba(255, 255, 255, 0.05);
  font-size: 26px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s;
}
.pz-oddcell span {
  display: inline-block;
  transition: transform 0.12s;
}
.pz-oddcell.ok {
  border-color: rgba(74, 222, 128, 0.85);
  background: rgba(74, 222, 128, 0.2);
}
.pz-oddcell.bad {
  border-color: rgba(255, 91, 91, 0.85);
  background: rgba(255, 91, 91, 0.18);
}

/* 拆弹剪线 */
.pz-cutwires {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin: 6px 0 4px;
}
.pz-cutwire {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  width: 62px;
  border-radius: 12px;
  border: 2px solid rgba(120, 160, 210, 0.22);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s;
}
.pz-cutwire .line {
  width: 8px;
  height: 78px;
  border-radius: 6px;
  background: var(--c);
  box-shadow: 0 0 14px color-mix(in srgb, var(--c) 55%, transparent);
}
.pz-cutwire small {
  color: var(--muted);
  font-size: 12px;
}
.pz-cutwire.cut {
  border-color: rgba(74, 222, 128, 0.8);
  background: rgba(74, 222, 128, 0.16);
}
.pz-cutwire.cut .line {
  height: 44px;
  opacity: 0.5;
}

/* ---------------- 覆盖层 ---------------- */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(4, 7, 11, 0.72);
  backdrop-filter: blur(8px);
  z-index: 40;
}
.overlay-screen.active {
  display: flex;
}
.result-panel {
  width: min(460px, 88vw);
  padding: 26px 28px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(24, 33, 48, 0.96), rgba(10, 15, 22, 0.98));
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
  text-align: center;
}
.result-panel h2 {
  margin: 0 0 10px;
  font-size: 24px;
  letter-spacing: 2px;
}
#result-desc {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}
#result-stats {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-bottom: 20px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-item .v {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.stat-item .l {
  font-size: 11px;
  color: var(--muted);
}
.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.result-actions .btn-primary {
  width: auto;
  padding: 12px 28px;
  font-size: 15px;
  letter-spacing: 1px;
}
#pause-screen .result-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#pause-screen .btn-primary {
  letter-spacing: 2px;
}

@media (max-height: 480px) {
  .menu-panel {
    padding: 14px 22px;
    margin: 1vh auto;
    max-height: 98vh;
  }
  .game-title {
    font-size: 26px;
  }
  .settings {
    gap: 7px;
    margin: 10px 0 12px;
  }
  .opt {
    padding: 6px 12px;
    font-size: 12px;
  }
  .btn-primary {
    padding: 11px;
    font-size: 15px;
  }
  .controls-hint {
    font-size: 11px;
    gap: 10px;
  }
}

/* ---------------- 安装引导 ---------------- */
.install-panel {
  text-align: left;
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.install-panel h2 {
  text-align: center;
}
.install-sub {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.install-steps {
  margin: 0 0 14px;
  padding-left: 20px;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
}
.install-steps li {
  margin-bottom: 6px;
}
.install-steps b {
  color: var(--gold);
  font-weight: 700;
}
.install-diag {
  margin: 0 0 16px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  word-break: break-all;
}
