:root {
    color-scheme: dark;
    --ink: #f7f1ff;
    --muted: #c9bdd5;
    --panel: rgba(18, 12, 27, 0.88);
    --line: rgba(255, 255, 255, 0.13);
    --violet: #c873ff;
    --violet2: #7650ff;
    --gold: #ffdd7a;
    --danger: #ff687a;
    --cyan: #83ecff;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-text-size-adjust: 100%;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    color: var(--ink);
    background: #263a3c;
  }
  body {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }
  #shell {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: #1c2930;
    isolation: isolate;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }
  canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #27393d;
    cursor: default;
    touch-action: none;
  }
  #shell.playing canvas { cursor: none; }

  #hud {
    position: absolute;
    inset: 0;
    z-index: 10;
    pointer-events: none;
    padding: clamp(10px, 1.7vw, 22px);
    display: grid;
    grid-template-columns: minmax(230px, 1fr) auto;
    grid-template-rows: auto 1fr auto;
    gap: 10px;
  }
  .panel {
    background: linear-gradient(180deg, rgba(25,16,36,.9), rgba(10,8,18,.82));
    border: 1px solid var(--line);
    border-radius: 14px;
    backdrop-filter: blur(9px);
    box-shadow: 0 10px 30px rgba(0,0,0,.22);
  }
  #statusPanel {
    justify-self: start;
    align-self: start;
    display: grid;
    gap: 7px;
    width: min(280px, 34vw);
    padding: 8px 10px;
    border-radius: 12px;
  }
  .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .label {
    font-size: clamp(11px, 1.2vw, 14px);
    font-weight: 900;
    letter-spacing: .08em;
    color: #eadff2;
  }
  .small {
    font-size: clamp(10px, 1.05vw, 13px);
    color: var(--muted);
  }
  .bar {
    height: clamp(8px, 1.2vw, 12px);
    margin-top: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.1);
    box-shadow: inset 0 2px 5px rgba(0,0,0,.3);
  }
  .fill { height: 100%; width: 100%; border-radius: inherit; transform-origin: left center; }
  #statusPanel .statusBar {
    height: clamp(7px, .85vw, 10px);
    margin-top: 0;
  }
  #hpFill { background: linear-gradient(90deg, #ff516e, #ffad78); }
  #witchFill { background: linear-gradient(90deg, #7e4dff, #e58cff, #99f3ff); }
  #witchWrap {
    background: rgba(147,100,184,.18);
    opacity: .62;
    transition: opacity 140ms ease;
  }
  #witchWrap.active { opacity: 1; }
  #rightPanel {
    justify-self: end;
    align-self: start;
    min-width: 205px;
    padding: 10px 13px;
  }
  #comboReadout {
    grid-column: 2;
    grid-row: 2;
    align-self: center;
    justify-self: end;
    text-align: right;
    text-shadow: 0 4px 18px rgba(0,0,0,.55);
  }
  #hits {
    font-size: clamp(28px, 5vw, 64px);
    line-height: .9;
    font-weight: 1000;
    font-style: italic;
    letter-spacing: -.04em;
    color: #fff;
  }
  #multiplier {
    margin-top: 7px;
    color: var(--gold);
    font-size: clamp(16px, 2.5vw, 30px);
    font-weight: 1000;
  }
  #score {
    color: #d8cbe3;
    font-size: clamp(12px, 1.4vw, 17px);
    font-weight: 850;
  }

  #bottomHud {
    grid-column: 1 / -1;
    grid-row: 3;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: end;
    gap: 12px;
  }
  #weaponPanel, #inputPanel, #controlsPanel { padding: 10px 13px; }
  #weaponPanel { min-width: 205px; }
  #inputPanel {
    justify-self: center;
    min-width: min(420px, 42vw);
    text-align: center;
  }
  #inputSequence {
    margin-top: 5px;
    min-height: 28px;
    font-size: clamp(15px, 2vw, 23px);
    font-weight: 1000;
    letter-spacing: .14em;
    color: #fff6c9;
  }
  #offsetText {
    min-height: 16px;
    color: #e8a5ff;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .1em;
  }
  #controlsPanel {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
    color: var(--muted);
    font-size: clamp(10px, 1vw, 12px);
  }
  .key {
    display: inline-grid;
    min-width: 22px;
    height: 22px;
    place-items: center;
    margin-right: 4px;
    padding: 0 5px;
    border-radius: 6px;
    color: #fff;
    background: rgba(255,255,255,.11);
    border: 1px solid rgba(255,255,255,.16);
    box-shadow: inset 0 -2px 0 rgba(0,0,0,.18);
    font-size: 10px;
    font-weight: 1000;
  }

  #message {
    position: absolute;
    z-index: 17;
    top: 19%;
    left: 50%;
    translate: -50% 0;
    padding: 9px 17px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 999px;
    background: rgba(23, 12, 34, .84);
    color: #fff;
    font-weight: 1000;
    letter-spacing: .11em;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 150ms ease, transform 150ms ease;
    pointer-events: none;
    white-space: nowrap;
  }
  #message.show { opacity: 1; transform: translateY(0); }

  #overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 22px;
    overflow-y: auto;
    background:
      linear-gradient(180deg, rgba(9,5,14,.25), rgba(9,5,14,.8)),
      radial-gradient(circle at 50% 32%, rgba(197,103,255,.12), transparent 46%);
    transition: opacity 180ms ease, visibility 180ms ease;
  }
  #overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
  #card {
    width: min(780px, 94%);
    max-height: calc(100% - 44px);
    overflow-y: auto;
    padding: clamp(22px, 4vw, 42px);
    text-align: center;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(33,18,47,.96), rgba(12,8,20,.96));
    border: 1px solid rgba(255,255,255,.14);
    box-shadow: 0 28px 90px rgba(0,0,0,.55);
    backdrop-filter: blur(12px);
  }
  #eyebrow {
    margin-bottom: 9px;
    color: #dca7ff;
    font-size: 11px;
    font-weight: 1000;
    letter-spacing: .25em;
  }
  h1 {
    margin: 0;
    font-family: Georgia, "Songti SC", serif;
    font-size: clamp(42px, 7vw, 78px);
    line-height: .96;
    letter-spacing: .03em;
    text-shadow: 0 8px 30px rgba(0,0,0,.4);
  }
  #subtitle {
    margin: 17px auto 20px;
    max-width: 560px;
    color: var(--muted);
    line-height: 1.7;
    font-size: clamp(13px, 1.5vw, 16px);
  }
  #equipmentSelect {
    display: grid;
    gap: 14px;
    margin: 20px 0 22px;
  }
  .equipmentLabel {
    margin: 0 0 7px 3px;
    text-align: left;
    color: #e3c4f7;
    font-size: 11px;
    font-weight: 1000;
    letter-spacing: .12em;
  }
  .weaponSelect {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .weaponSelect.handWeapons {
    grid-template-columns: repeat(4, 1fr);
  }
  .weaponCard {
    pointer-events: auto;
    padding: 15px;
    text-align: left;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 16px;
    background: rgba(255,255,255,.045);
    cursor: pointer;
    transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
  }
  .weaponCard:hover { transform: translateY(-2px); }
  .weaponCard.selected {
    border-color: rgba(224,137,255,.8);
    background: linear-gradient(180deg, rgba(197,103,255,.17), rgba(255,255,255,.045));
    box-shadow: 0 0 0 2px rgba(197,103,255,.13);
  }
  .weaponName { font-size: 17px; font-weight: 1000; }
  .weaponTag {
    display: inline-block;
    margin: 7px 0;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.09);
    color: #f1d8ff;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
  }
  .weaponDesc { color: var(--muted); font-size: 12px; line-height: 1.55; }
  #touchControlsOption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin: -5px 0 17px;
    padding: 11px 14px;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
    cursor: pointer;
    text-align: left;
  }
  .optionCopy {
    display: grid;
    gap: 3px;
  }
  .optionCopy strong {
    color: #f1e4f8;
    font-size: 12px;
    letter-spacing: .05em;
  }
  .optionCopy small {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.45;
  }
  #touchControlsToggle {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
  }
  .toggleTrack {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 25px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    background: rgba(8,6,13,.58);
    transition: border-color 140ms ease, background 140ms ease;
  }
  .toggleTrack span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #c8bccc;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
    transition: transform 140ms ease, background 140ms ease;
  }
  #touchControlsToggle:checked + .toggleTrack {
    border-color: rgba(255,224,128,.72);
    background: rgba(145,96,42,.72);
  }
  #touchControlsToggle:checked + .toggleTrack span {
    transform: translateX(21px);
    background: #ffe594;
  }
  #touchControlsToggle:focus-visible + .toggleTrack {
    outline: 2px solid #d88cff;
    outline-offset: 3px;
  }
  #resultStats {
    display: none;
    justify-content: center;
    gap: 22px;
    margin: 8px 0 20px;
    color: #f3e8f8;
    font-weight: 900;
  }
  button {
    pointer-events: auto;
    appearance: none;
    border: 0;
    border-radius: 999px;
    padding: 13px 32px;
    color: #24172c;
    background: linear-gradient(180deg, #ffe99b, #e7bd50);
    box-shadow: 0 10px 28px rgba(255,222,111,.18), inset 0 1px 0 rgba(255,255,255,.7);
    font: inherit;
    font-weight: 1000;
    letter-spacing: .09em;
    cursor: pointer;
    transition: transform 120ms ease, filter 120ms ease;
  }
  button:hover { transform: translateY(-2px); filter: brightness(1.04); }
  button:active { transform: translateY(1px) scale(.99); }
  #menuActions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
  }
  #pwaInstallButton {
    color: #e9faff;
    border: 1px solid rgba(177,235,255,.35);
    background: linear-gradient(180deg, rgba(50,95,106,.92), rgba(25,54,61,.96));
    box-shadow: 0 10px 28px rgba(56,190,224,.12), inset 0 1px 0 rgba(255,255,255,.15);
  }
  #hint { margin-top: 13px; color: rgba(230,218,238,.55); font-size: 11px; }

  #debug {
    position: absolute;
    z-index: 16;
    left: 12px;
    top: 118px;
    display: none;
    width: 260px;
    padding: 10px 12px;
    white-space: pre-wrap;
    color: #bff9d0;
    background: rgba(0,0,0,.72);
    border: 1px solid rgba(170,255,196,.22);
    border-radius: 10px;
    font: 11px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
    pointer-events: none;
  }
  #debug.visible { display: block; }

  #touchControls {
    display: none;
  }

  #fullscreenButton {
    position: absolute;
    z-index: 25;
    left: 50%;
    bottom: max(11px, env(safe-area-inset-bottom));
    translate: -50% 0;
    display: none;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    color: rgba(255,255,255,.86);
    background: rgba(17,12,25,.68);
    box-shadow: 0 8px 24px rgba(0,0,0,.24);
    backdrop-filter: blur(7px);
    font-size: 11px;
    letter-spacing: .06em;
    touch-action: none;
  }
  #fullscreenButton[hidden] {
    display: none !important;
  }
  #fullscreenButton:hover {
    transform: none;
    filter: brightness(1.08);
  }
  #fullscreenButton:active {
    transform: scale(.94);
  }
  #fullscreenButton.isFullscreen {
    display: inline-flex;
    color: #fff4bd;
    border-color: rgba(255,226,138,.42);
  }
  .fullscreenIcon {
    font-size: 18px;
    line-height: 1;
  }
  #shell.portraitBlocked #fullscreenButton {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  #shell:not(.playing) #fullscreenButton {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  #returnToEditorButton {
    position: absolute;
    z-index: 35;
    left: max(10px, env(safe-area-inset-left));
    top: max(10px, env(safe-area-inset-top));
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid rgba(255,235,173,.42);
    border-radius: 999px;
    color: #fff1bd;
    background: rgba(26,15,32,.78);
    box-shadow: 0 8px 24px rgba(0,0,0,.28);
    backdrop-filter: blur(8px);
    font: 800 11px/1 system-ui,"Microsoft YaHei",sans-serif;
    letter-spacing: .04em;
  }
  #returnToEditorButton[hidden] { display: none; }

  #orientationNotice {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: none;
    place-items: center;
    padding:
      max(24px, env(safe-area-inset-top))
      max(24px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
    background:
      radial-gradient(circle at 50% 42%, rgba(200,115,255,.17), transparent 42%),
      rgba(9,7,15,.88);
    backdrop-filter: blur(10px);
    text-align: center;
  }
  #shell.portraitBlocked #orientationNotice {
    display: grid;
  }
  .orientationCard {
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(310px, 86vw);
    padding: 28px 22px;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(37,21,51,.94), rgba(14,10,23,.94));
    box-shadow: 0 24px 70px rgba(0,0,0,.45);
  }
  .orientationCard strong {
    color: #fff;
    font-size: 22px;
    letter-spacing: .08em;
  }
  .orientationCard small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
  }
  .rotatePhone {
    position: relative;
    width: 46px;
    height: 72px;
    margin: 10px 0 15px;
    border: 3px solid #ffe28a;
    border-radius: 10px;
    box-shadow: 0 0 24px rgba(255,218,116,.2);
    animation: rotatePhone 1.8s ease-in-out infinite;
  }
  .rotatePhone::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 5px;
    width: 13px;
    height: 3px;
    translate: -50% 0;
    border-radius: 999px;
    background: rgba(255,226,138,.72);
  }
  .rotatePhone span {
    position: absolute;
    left: 50%;
    bottom: 5px;
    width: 5px;
    height: 5px;
    translate: -50% 0;
    border-radius: 50%;
    background: #ffe28a;
  }
  @keyframes rotatePhone {
    0%, 22% { transform: rotate(0deg); }
    58%, 82% { transform: rotate(90deg); }
    100% { transform: rotate(0deg); }
  }
  @media (prefers-reduced-motion: reduce) {
    .rotatePhone {
      animation: none;
      transform: rotate(90deg);
    }
  }

  @media (hover: none) and (pointer: coarse), (max-width: 900px) and (max-height: 500px) {
    #fullscreenButton {
      display: inline-flex;
    }
  }
  #touchControls {
      position: absolute;
      inset: 0;
      z-index: 18;
      display: block;
      pointer-events: none;
      opacity: 0;
      visibility: hidden;
      transition: opacity 160ms ease, visibility 160ms ease;
  }
  #shell.playing.touchControlsEnabled #touchControls {
      opacity: 1;
      visibility: visible;
  }
  #shell.touchControlsEnabled.portraitBlocked #touchControls {
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
  }
    .touchMove,
    .touchActions {
      position: absolute;
      bottom: max(14px, env(safe-area-inset-bottom));
      -webkit-user-select: none;
      user-select: none;
    }
    .touchMove {
      left: 0;
      bottom: 0;
      width: min(44vw, 340px);
      height: min(62vh, 250px);
      pointer-events: auto;
      touch-action: none;
    }
    .touchActions {
      right: max(14px, env(safe-area-inset-right));
      width: 184px;
      height: 166px;
      pointer-events: none;
    }
    .joystickBase {
      --base-x: 0px;
      --base-y: 0px;
      position: absolute;
      left: max(18px, env(safe-area-inset-left));
      bottom: max(18px, env(safe-area-inset-bottom));
      width: 120px;
      height: 120px;
      border: 1px solid rgba(211,190,232,.24);
      border-radius: 50%;
      background:
        radial-gradient(circle, rgba(151,101,181,.10) 0 39%, transparent 40%),
        radial-gradient(circle, rgba(15,11,23,.38) 0 67%, rgba(22,15,32,.2) 68% 100%);
      box-shadow:
        inset 0 0 28px rgba(8,5,14,.34),
        0 8px 26px rgba(0,0,0,.14);
      opacity: .62;
      transform: translate3d(var(--base-x), var(--base-y), 0);
      transition: opacity 100ms ease, border-color 100ms ease;
      pointer-events: none;
    }
    .joystickBase::before,
    .joystickBase::after {
      content: "";
      position: absolute;
      background: rgba(232,218,246,.09);
      pointer-events: none;
    }
    .joystickBase::before {
      left: 18px;
      right: 18px;
      top: calc(50% - .5px);
      height: 1px;
    }
    .joystickBase::after {
      top: 18px;
      bottom: 18px;
      left: calc(50% - .5px);
      width: 1px;
    }
    .joystickGuide {
      position: absolute;
      inset: 26px;
      border: 1px solid rgba(255,255,255,.08);
      border-radius: 50%;
    }
    .joystickKnob {
      --knob-x: 0px;
      --knob-y: 0px;
      position: absolute;
      left: calc(50% - 26px);
      top: calc(50% - 26px);
      width: 52px;
      height: 52px;
      border: 1px solid rgba(255,255,255,.38);
      border-radius: 50%;
      background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,.28), transparent 34%),
        linear-gradient(145deg, rgba(137,89,169,.74), rgba(48,31,67,.78));
      box-shadow:
        0 8px 18px rgba(0,0,0,.28),
        inset 0 0 0 3px rgba(255,255,255,.045);
      transform: translate3d(var(--knob-x), var(--knob-y), 0);
      will-change: transform;
    }
    .joystickBase.is-active {
      opacity: .94;
      border-color: rgba(226,190,255,.48);
    }
    .joystickBase.is-active .joystickKnob {
      border-color: rgba(255,232,166,.68);
      box-shadow:
        0 9px 22px rgba(0,0,0,.32),
        0 0 18px rgba(194,119,255,.18),
        inset 0 0 0 3px rgba(255,255,255,.06);
    }
    .touchButton {
      position: relative;
      min-width: 0;
      padding: 0;
      display: grid;
      place-items: center;
      border: 1px solid rgba(255,255,255,.28);
      border-radius: 50%;
      color: rgba(255,255,255,.9);
      background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,.18), transparent 35%),
        rgba(19,13,29,.5);
      box-shadow:
        0 7px 20px rgba(0,0,0,.2),
        inset 0 0 0 2px rgba(255,255,255,.045);
      backdrop-filter: blur(5px);
      font: 900 17px/1 system-ui, sans-serif;
      letter-spacing: 0;
      cursor: default;
      pointer-events: auto;
      touch-action: none;
      -webkit-tap-highlight-color: transparent;
      transition: transform 70ms ease, background 70ms ease, border-color 70ms ease;
    }
    .actionIcon {
      width: 58%;
      height: 58%;
      overflow: visible;
      fill: none;
      stroke: currentColor;
      stroke-width: 4;
      stroke-linecap: round;
      stroke-linejoin: round;
      filter: drop-shadow(0 2px 3px rgba(0,0,0,.32));
      pointer-events: none;
    }
    .actionIcon .iconDetail {
      stroke-width: 3;
      opacity: .72;
    }
    .touchSecondary .actionIcon {
      fill: rgba(255,255,255,.12);
      stroke-width: 3.6;
    }
    .weaponIconWhip {
      display: none;
    }
    .weaponIconMeteor {
      display: none;
      filter: drop-shadow(0 2px 3px rgba(0,0,0,.32));
    }
    .weaponIconStaff {
      display: none;
      fill: rgba(255,207,74,.25);
      stroke: #ffe796;
    }
    .touchPrimary[data-weapon="whip"] .weaponIconBlade {
      display: none;
    }
    .touchPrimary[data-weapon="whip"] .weaponIconWhip {
      display: block;
    }
    .touchPrimary[data-weapon="meteor"] .weaponIconBlade,
    .touchPrimary[data-weapon="meteor"] .weaponIconWhip,
    .touchPrimary[data-weapon="meteor"] .weaponIconStaff {
      display: none;
    }
    .touchPrimary[data-weapon="meteor"] .weaponIconMeteor {
      display: block;
    }
    .touchPrimary[data-weapon="staff"] .weaponIconBlade,
    .touchPrimary[data-weapon="staff"] .weaponIconWhip,
    .touchPrimary[data-weapon="staff"] .weaponIconMeteor {
      display: none;
    }
    .touchPrimary[data-weapon="staff"] .weaponIconStaff {
      display: block;
    }
    .touchButton:hover {
      transform: none;
      filter: none;
    }
    .touchButton.is-active {
      transform: scale(.91);
      border-color: rgba(255,231,150,.84);
      color: #fff8cf;
      background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,.25), transparent 36%),
        rgba(120,74,150,.68);
    }
    .touchActions .touchButton {
      position: absolute;
      width: 62px;
      height: 62px;
    }
    .touchPrimary {
      right: 0;
      bottom: 8px;
      width: 82px !important;
      height: 82px !important;
      border-color: rgba(255,224,128,.5);
      background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,.22), transparent 34%),
        rgba(104,72,35,.55);
    }
    .touchPrimary[data-weapon="whip"] {
      border-color: rgba(232,132,255,.56);
      color: #f5d6ff;
      background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,.21), transparent 34%),
        rgba(86,43,111,.6);
    }
    .touchPrimary[data-weapon="meteor"] {
      border-color: rgba(255,190,104,.62);
      color: #ffe9b0;
      background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,.23), transparent 34%),
        rgba(91,43,70,.66);
    }
    .touchPrimary[data-weapon="staff"] {
      border-color: rgba(255,211,83,.72);
      color: #fff0a8;
      background:
        radial-gradient(circle at 38% 30%, rgba(255,255,255,.25), transparent 34%),
        rgba(113,62,25,.68);
    }
    .touchSecondary {
      right: 80px;
      top: 0;
      border-color: rgba(217,145,255,.45);
    }
    .touchDodge {
      left: 0;
      bottom: 4px;
      border-color: rgba(135,233,255,.48);
      color: #caf7ff;
    }
  @media (hover: none) and (pointer: coarse), (max-width: 900px) and (max-height: 500px) {
    #bottomHud {
      display: none;
    }
    #statusPanel {
      width: min(280px, 45vw);
    }
    #rightPanel {
      min-width: 145px;
    }
    #comboReadout {
      align-self: start;
      margin-top: 10px;
      margin-right: max(3px, env(safe-area-inset-right));
    }
  }

  @media (hover: none) and (pointer: coarse) and (max-height: 500px),
    (max-width: 900px) and (max-height: 500px) {
    #hud {
      padding:
        max(7px, env(safe-area-inset-top))
        max(9px, env(safe-area-inset-right))
        7px
        max(9px, env(safe-area-inset-left));
    }
    #statusPanel,
    #rightPanel {
      padding: 7px 10px;
      border-radius: 11px;
    }
    #witchWrap {
      margin-top: 6px;
    }
    .touchMove {
      left: 0;
      bottom: 0;
    }
    .touchActions {
      right: max(8px, env(safe-area-inset-right));
      bottom: max(8px, env(safe-area-inset-bottom));
    }
    #overlay {
      align-items: start;
      overflow-y: auto;
      padding:
        max(8px, env(safe-area-inset-top))
        max(12px, env(safe-area-inset-right))
        max(8px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
    }
    #card {
      width: min(720px, 96%);
      padding: 12px 20px;
      border-radius: 18px;
    }
    #eyebrow {
      display: none;
    }
    h1 {
      font-size: 32px;
    }
    #subtitle {
      margin: 7px auto 9px;
      font-size: 11px;
      line-height: 1.45;
    }
    #equipmentSelect {
      gap: 8px;
      margin: 8px 0 9px;
    }
    #touchControlsOption {
      margin: -1px 0 8px;
      padding: 7px 11px;
    }
    .optionCopy small {
      display: none;
    }
    .equipmentLabel {
      margin-bottom: 4px;
      font-size: 9px;
    }
    .weaponSelect {
      grid-template-columns: 1fr 1fr;
      gap: 8px;
    }
    .weaponCard {
      padding: 8px 10px;
      border-radius: 12px;
    }
    .weaponName {
      font-size: 14px;
    }
    .weaponTag {
      margin: 5px 0 0;
    }
    .weaponDesc {
      display: none;
    }
    #resultStats {
      margin: 4px 0 8px;
    }
    #mainButton {
      padding: 10px 28px;
    }
    #pwaInstallButton {
      padding: 10px 22px;
    }
    #hint {
      margin-top: 7px;
    }
  }

  @media (max-width: 720px) {
    #controlsPanel { display: none; }
    #bottomHud { grid-template-columns: auto 1fr; }
    #inputPanel { justify-self: end; min-width: 46vw; }
    .weaponSelect,
    .weaponSelect.handWeapons { grid-template-columns: 1fr; }
    #statusPanel { width: 47vw; }
    #rightPanel { min-width: 150px; }
  }

  @media (max-width: 720px) and (max-height: 500px) {
    .weaponSelect,
    .weaponSelect.handWeapons { grid-template-columns: 1fr 1fr; }
  }

/* ============================================================
   主菜单与独立武器配置
   ============================================================ */
#overlay {
  padding: clamp(14px, 3vw, 36px);
  background:
    linear-gradient(90deg, rgba(7,5,11,.84), rgba(9,6,15,.48) 48%, rgba(7,5,11,.8)),
    radial-gradient(circle at 24% 30%, rgba(197,103,255,.2), transparent 40%);
}
#card {
  position: relative;
  width: min(1060px, 96%);
  max-height: calc(100% - 28px);
  overflow: hidden;
  padding: clamp(24px, 4vw, 52px);
  text-align: initial;
  border-radius: 30px;
  background: linear-gradient(115deg, rgba(38,21,50,.97), rgba(15,10,23,.97) 58%, rgba(10,8,17,.98));
  box-shadow: 0 32px 110px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(16px);
}
#card::before {
  content: "";
  position: absolute;
  left: -170px;
  bottom: -210px;
  width: 360px;
  height: 360px;
  border: 1px solid rgba(222,158,255,.18);
  border-radius: 50%;
  box-shadow: 0 0 80px rgba(184,91,242,.09);
  pointer-events: none;
}
.menuOrnament {
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(255,255,255,.045);
  border-radius: 22px;
  pointer-events: none;
}
.menuView { display: none; position: relative; z-index: 1; }
.menuView.active { display: grid; }
#mainMenuView {
  grid-template-columns: minmax(280px, .92fr) minmax(330px, 1.08fr);
  align-items: center;
  gap: clamp(36px, 6vw, 80px);
  min-height: 430px;
}
.brandBlock { text-align: center; }
.witchSigil {
  position: relative;
  width: 112px;
  height: 112px;
  margin: 0 auto 25px;
  border: 1px solid rgba(233,192,255,.3);
  border-radius: 50%;
  box-shadow: 0 0 42px rgba(200,115,255,.12), inset 0 0 30px rgba(200,115,255,.06);
}
.witchSigil::before,
.witchSigil::after {
  content: "";
  position: absolute;
  inset: 11px;
  border: 1px solid rgba(255,227,145,.22);
  transform: rotate(45deg);
}
.witchSigil::after { inset: 25px; border-color: rgba(229,190,255,.22); }
.sigilMoon {
  position: absolute;
  left: 33px;
  top: 22px;
  width: 44px;
  height: 58px;
  border-radius: 50%;
  border-right: 5px solid #ffe499;
  transform: rotate(-18deg);
  filter: drop-shadow(0 0 9px rgba(255,224,139,.34));
}
.sigilStar { position: absolute; right: 22px; bottom: 22px; color: #e5a8ff; font-size: 18px; }
#eyebrow { margin-bottom: 12px; font-size: 10px; letter-spacing: .34em; }
#mainMenuView h1 { font-size: clamp(48px, 6.5vw, 76px); line-height: 1; letter-spacing: .1em; }
#subtitle { margin: 20px auto 0; max-width: 350px; font-size: 13px; line-height: 1.75; }
.mainMenuPanel { display: grid; gap: 13px; }
#menuActions { display: grid; gap: 10px; }
#card button { border-radius: 15px; padding: 0; color: inherit; background: none; box-shadow: none; letter-spacing: 0; }
.primaryMenuButton {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 17px 22px !important;
  border: 1px solid rgba(255,238,175,.52) !important;
  border-radius: 17px !important;
  color: #2a192d !important;
  background: linear-gradient(135deg, #fff1b6, #e8bd58) !important;
  box-shadow: 0 13px 34px rgba(228,177,63,.16), inset 0 1px 0 rgba(255,255,255,.72) !important;
  font-size: 18px;
  font-weight: 1000;
  letter-spacing: .13em !important;
}
.primaryMenuButton small { padding: 5px 7px; border: 1px solid rgba(45,27,43,.18); border-radius: 6px; font-size: 9px; }
.secondaryMenuButton {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 13px 17px !important;
  border: 1px solid rgba(255,255,255,.11) !important;
  border-radius: 17px !important;
  color: #f7ecfc !important;
  background: linear-gradient(135deg, rgba(255,255,255,.075), rgba(255,255,255,.035)) !important;
  text-align: left;
}
.menuButtonIcon,
.settingIcon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(226,173,255,.2);
  border-radius: 10px;
  color: #e3b1fb;
  background: rgba(198,105,246,.08);
}
.menuButtonCopy,
.optionCopy { display: grid; gap: 3px; }
.menuButtonCopy strong,
.optionCopy strong { color: #f1e4f8; font-size: 12px; letter-spacing: .06em; }
.menuButtonCopy small,
.optionCopy small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.menuChevron { color: #dca7ff; font-size: 28px; font-weight: 300; }
.settingsPanel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.settingOption {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 9px;
  min-width: 0;
  margin: 0;
  padding: 11px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  background: rgba(255,255,255,.025);
  cursor: pointer;
}
.settingIcon { width: 28px; height: 28px; border-radius: 9px; font-size: 13px; }
#audioToggle,
#touchControlsToggle { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.settingOption .toggleTrack { width: 40px; height: 22px; }
.settingOption .toggleTrack span { width: 14px; height: 14px; }
#audioToggle:checked + .toggleTrack,
#touchControlsToggle:checked + .toggleTrack { border-color: rgba(255,224,128,.72); background: rgba(145,96,42,.72); }
#audioToggle:checked + .toggleTrack span,
#touchControlsToggle:checked + .toggleTrack span { transform: translateX(18px); background: #ffe594; }
#audioToggle:focus-visible + .toggleTrack,
#touchControlsToggle:focus-visible + .toggleTrack { outline: 2px solid #d88cff; outline-offset: 3px; }
#resultStats {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255,225,139,.18);
  border-radius: 13px;
  color: #ffeca7;
  background: rgba(255,216,102,.045);
  font-size: 11px;
  text-align: center;
}
#pwaInstallButton.utilityMenuButton {
  justify-self: center;
  padding: 8px 14px !important;
  border: 1px solid rgba(177,235,255,.25) !important;
  border-radius: 999px !important;
  color: #cceff7 !important;
  background: rgba(50,95,106,.24) !important;
  font-size: 10px;
}
#hint { margin-top: 0; font-size: 10px; letter-spacing: .04em; text-align: center; }

#equipmentMenuView { gap: 18px; max-height: calc(100vh - 110px); overflow-y: auto; padding-right: 4px; }
.equipmentHeader { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 16px; text-align: left; }
#card .backButton {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 13px;
  color: #f1dcfc;
  background: rgba(255,255,255,.05);
  font-size: 31px;
  line-height: 1;
}
.sectionEyebrow { margin-bottom: 4px; color: #dca7ff; font-size: 9px; font-weight: 1000; letter-spacing: .3em; }
.equipmentHeader h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(30px, 4vw, 43px); letter-spacing: .08em; }
.equipmentHeader p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
#equipmentSelect { gap: 18px; margin: 0; }
.equipmentLabel { display: flex; align-items: center; gap: 8px; margin: 0 0 9px 2px; text-align: left; }
.equipmentLabel kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 6px;
  color: #fff1b7;
  background: rgba(255,255,255,.05);
  font: 900 9px/1 system-ui, sans-serif;
}
.weaponSelect { gap: 9px; }
.weaponSelect.feetWeapons { grid-template-columns: repeat(2, 1fr); }
#card .weaponCard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  min-height: 154px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 15px;
  color: var(--ink);
  background: rgba(255,255,255,.045);
  text-align: left;
}
#card .weaponCard.selected {
  border-color: rgba(255,224,128,.65);
  background: linear-gradient(155deg, rgba(197,103,255,.18), rgba(255,211,96,.075));
  box-shadow: inset 0 0 0 1px rgba(255,224,128,.08), 0 8px 26px rgba(0,0,0,.12);
}
.weaponCard.selected::after { content: "已装备"; position: absolute; top: 11px; right: 11px; color: #ffe99f; font-size: 9px; font-weight: 900; }
.weaponIndex { color: rgba(224,178,246,.48); font-size: 9px; font-weight: 900; letter-spacing: .12em; }
.weaponCard .weaponName { margin-top: 9px; font-size: 16px; }
.weaponCard .weaponTag { margin: 7px 0 8px; padding: 3px 7px; font-size: 9px; }
.weaponCard .weaponDesc { color: var(--muted); font-size: 10px; line-height: 1.55; }
.equipmentFooter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 15px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  background: rgba(255,255,255,.035);
  text-align: left;
}
.equipmentFooter div { display: grid; gap: 3px; }
.equipmentFooter small { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
.equipmentFooter strong { color: #fff1b1; font-size: 13px; }
#card #confirmEquipmentButton {
  flex: 0 0 auto;
  padding: 11px 22px;
  border-radius: 999px;
  color: #291b2f;
  background: linear-gradient(180deg, #ffe99b, #e7bd50);
  box-shadow: 0 10px 28px rgba(255,222,111,.18), inset 0 1px 0 rgba(255,255,255,.7);
  font-weight: 1000;
  letter-spacing: .09em;
  font-size: 11px;
}

@media (max-width: 760px) {
  #card { overflow-y: auto; padding: 25px; }
  #mainMenuView { grid-template-columns: 1fr; gap: 24px; min-height: auto; }
  .witchSigil { width: 76px; height: 76px; margin-bottom: 15px; }
  .witchSigil::before { inset: 8px; }
  .witchSigil::after { inset: 18px; }
  .sigilMoon { left: 22px; top: 14px; width: 31px; height: 42px; }
  .sigilStar { right: 14px; bottom: 14px; font-size: 14px; }
  #mainMenuView h1 { font-size: 42px; }
  #subtitle { margin-top: 10px; }
  .weaponSelect.handWeapons { grid-template-columns: 1fr 1fr; }
  .weaponSelect.feetWeapons { grid-template-columns: 1fr 1fr; }
}

@media (max-height: 560px) and (orientation: landscape) {
  #overlay { align-items: start; padding: 8px 12px; }
  #card { width: min(920px, 97%); max-height: none; padding: 16px 24px; border-radius: 20px; overflow-y: auto; }
  #card::before { display: none; }
  #mainMenuView { grid-template-columns: minmax(210px,.8fr) minmax(350px,1.2fr); gap: 28px; min-height: 0; }
  .witchSigil { width: 68px; height: 68px; margin-bottom: 11px; }
  .witchSigil::before { inset: 7px; }
  .witchSigil::after { inset: 16px; }
  .sigilMoon { left: 20px; top: 13px; width: 28px; height: 38px; border-width: 4px; }
  .sigilStar { right: 12px; bottom: 12px; font-size: 12px; }
  #eyebrow { margin-bottom: 5px; font-size: 8px; }
  #mainMenuView h1 { font-size: 36px; }
  #subtitle { margin-top: 8px; font-size: 10px; line-height: 1.5; }
  .mainMenuPanel { gap: 7px; }
  #menuActions { gap: 7px; }
  .primaryMenuButton { min-height: 50px; padding: 11px 16px !important; font-size: 14px; }
  .secondaryMenuButton { min-height: 50px; padding: 8px 12px !important; }
  .settingsPanel { gap: 7px; }
  .settingOption { padding: 7px 9px; }
  #hint { display: none; }
  #equipmentMenuView { gap: 10px; max-height: none; }
  .equipmentHeader h2 { font-size: 27px; }
  .equipmentHeader p { display: none; }
  #equipmentSelect { gap: 9px; }
  .equipmentLabel { margin-bottom: 5px; }
  #card .weaponCard { min-height: 102px; padding: 9px 10px; }
  .weaponCard .weaponName { margin-top: 5px; font-size: 13px; }
  .weaponCard .weaponTag { margin: 4px 0 0; }
  .weaponCard .weaponDesc { display: none; }
  .equipmentFooter { padding: 8px 11px; }
}
