* {
  box-sizing: border-box;
}

:root {
  --judge-line-height: 48px;
  --bottom-zone-height: var(--judge-line-height);
  --game-sidebar-width: 168px;
  --game-sidebar-width-color: 212px;
  --portrait-height: 148px;
  --playfield-width: 360px;
  --setup-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 50% 0%, rgba(248, 74, 75, 0.12), transparent 42%),
    #0f0d14;
  color: #f3f4f6;
}

.page {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.page:has(#gameScreen.is-setup) {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--site-nav-height, 52px) - var(--site-icp-height, 28px));
  padding-bottom: 12px;
}

.page:has(#gameScreen.is-setup) #gameScreen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page:has(#gameScreen.is-setup) .setup-stage {
  flex: 1;
  min-height: 0;
  padding: 0;
}

.page.is-playing {
  max-width: none;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--site-nav-height, 52px) - var(--site-icp-height, 28px));
  padding: 6px 10px 6px;
  box-sizing: border-box;
}

.header {
  margin-bottom: 20px;
}

.title {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 900;
  color: #ff4d5a;
}

.subtitle {
  margin: 0;
  color: #9ca3af;
  font-size: 13px;
  line-height: 1.6;
}

.screen[hidden] {
  display: none !important;
}

#gameScreen.is-setup .game-layout,
#gameScreen.is-setup .settings-toggle {
  display: none !important;
}

#gameScreen:not(.is-setup) .setup-stage {
  display: none !important;
}

.setup-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}

.setup-card {
  width: min(100%, var(--setup-width));
}

.settings-toggle {
  position: fixed;
  top: calc(var(--site-nav-height, 52px) + 10px);
  left: 10px;
  z-index: 30;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(15, 13, 20, 0.88);
  backdrop-filter: blur(8px);
  color: #e5e7eb;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s, background 0.15s;
}

.settings-toggle[hidden] {
  display: none !important;
}

.settings-toggle:hover {
  border-color: rgba(255, 77, 90, 0.55);
  background: rgba(255, 77, 90, 0.12);
}

.settings-compact {
  padding: 12px 14px !important;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.settings-row--checks {
  gap: 8px;
}

.settings-label {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: #d1d5db;
  white-space: nowrap;
}

.chip-row {
  flex: 1 1 140px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.chip-row--stretch .chip-option {
  flex: 1 1 0;
  min-width: 44px;
}

.chip-option {
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: #e5e7eb;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.chip-option.is-selected {
  border-color: rgba(255, 77, 90, 0.65);
  background: rgba(255, 77, 90, 0.12);
  color: #fff;
}

.check-chip {
  flex: 1 1 calc(50% - 4px);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  color: #d1d5db;
  cursor: pointer;
  min-width: 0;
}

.check-chip input {
  flex-shrink: 0;
  margin: 0;
}

.check-chip > span {
  font-weight: 600;
}

.info-tip {
  position: relative;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #fcd34d;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  cursor: help;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  z-index: 40;
  width: max-content;
  max-width: min(260px, 72vw);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(12, 10, 18, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color: #d1d5db;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 0.12s, transform 0.12s;
}

.info-tip.is-open::after,
.info-tip:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (hover: hover) and (pointer: fine) {
  .info-tip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.settings-start {
  width: 100%;
  margin-top: 2px;
}

.panel {
  padding: 20px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.hint {
  margin: 0;
  color: #9ca3af;
  font-size: 13px;
  line-height: 1.55;
}

.sub-panel {
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
}

.mode-grid {
  display: grid;
  gap: 10px;
}

.mode-option {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.mode-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.mode-option.is-selected {
  border-color: rgba(255, 77, 90, 0.65);
  background: rgba(255, 77, 90, 0.1);
}

.mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-option-title {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.mode-option-desc {
  display: block;
  font-size: 12px;
  color: #9ca3af;
  line-height: 1.45;
}

.section-title {
  margin: 18px 0 10px;
  font-size: 16px;
}

.section-title:first-of-type {
  margin-top: 0;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  font-size: 12px;
  line-height: 1.45;
  color: #d1d5db;
}

.toggle-row input {
  margin-top: 3px;
  flex-shrink: 0;
}

.lane-count-field {
  margin-bottom: 12px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #d1d5db;
}

.lane-count-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.lane-count-option {
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
  color: #e5e7eb;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.lane-count-option.is-selected {
  border-color: rgba(255, 77, 90, 0.65);
  background: rgba(255, 77, 90, 0.12);
  color: #fff;
}

.primary-button,
.secondary-button,
.skill-button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 12px;
  transition: transform 0.08s, opacity 0.15s;
}

.primary-button:active,
.secondary-button:active,
.skill-button:active {
  transform: scale(0.97);
}

.primary-button {
  width: 100%;
  margin-top: 8px;
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ff4d5a, #d93645);
}

.secondary-button {
  width: 100%;
  padding: 10px 12px;
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.game-over-back {
  margin-top: 8px;
}

.page.is-playing #gameScreen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page.is-playing .game-layout {
  flex: 1;
  min-height: 0;
}

.page.is-playing .game-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--playfield-width);
}

.page.is-playing .playfield {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.game-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.game-main {
  position: relative;
  width: min(100%, var(--playfield-width));
  max-width: var(--playfield-width);
  min-height: 280px;
}

.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: var(--game-sidebar-width);
  max-width: var(--game-sidebar-width);
  flex-shrink: 0;
  margin-left: auto;
  margin-right: auto;
}

.sidebar-hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.hud-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hud-item--score {
  grid-column: 1 / -1;
}

.hud-label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 2px;
}

.hud-value {
  font-size: 20px;
  font-weight: 800;
}

.hud-value--small {
  font-size: 16px;
}

.line-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
}

.line-badge.is-physical {
  color: #ffb347;
  background: rgba(255, 107, 53, 0.18);
}

.line-badge.is-magic {
  color: #74c0fc;
  background: rgba(77, 171, 247, 0.18);
}

.feedback {
  min-height: 22px;
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: #fcd34d;
}

.feedback--overlay {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 12px;
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.85);
}

.game-over {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 6, 12, 0.88);
  backdrop-filter: blur(4px);
}

.game-over-card {
  width: min(100%, 260px);
  padding: 20px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.game-over[hidden] {
  display: none !important;
}

.game-over-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: #ff4d5a;
}

.game-over-score {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
}

.game-over-actions {
  width: min(100%, 220px);
  display: flex;
  flex-direction: column;
  gap: 0;
}

.game-over-actions .primary-button {
  margin-top: 0;
}

.play-guide {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  pointer-events: none;
  border-radius: inherit;
}

.play-guide[hidden] {
  display: none !important;
}

.play-guide.is-awaiting {
  pointer-events: auto;
  cursor: pointer;
}

.play-guide-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 4, 10, 0.64);
  border-radius: inherit;
}

.play-guide-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  width: 100%;
  min-height: 0;
  padding: 16px 12px max(18px, env(safe-area-inset-bottom, 0px));
}

.play-guide-headline {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.55);
}

.play-guide-rule {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.78);
  text-align: center;
}

.play-guide-layout {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.play-guide-zones {
  display: flex;
  flex: 1 1 auto;
  min-height: 140px;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.play-guide-zones--single {
  min-height: 120px;
}

.play-guide-zone {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 10px;
  text-align: center;
}

.play-guide-zone--kill {
  background: rgba(124, 58, 237, 0.28);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.play-guide-zone--revive {
  background: rgba(5, 150, 105, 0.28);
}

.play-guide-zone--toggle {
  background: rgba(255, 77, 90, 0.24);
}

.play-guide-zone-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.play-guide-zone-desc {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
}

.play-guide-desktop {
  padding: 14px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.play-guide-desktop p {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.play-guide-desktop-sub {
  margin-top: 6px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: rgba(255, 255, 255, 0.72) !important;
}

.play-guide-desktop kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 800;
}

.play-guide-extra {
  margin: 0;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  text-align: center;
}

.play-guide-prompt {
  margin: 0;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  text-align: center;
  animation: play-guide-pulse 1.6s ease-in-out infinite;
}

@keyframes play-guide-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.82;
    transform: scale(0.985);
  }
}

.page.is-mobile-play .play-guide {
  position: fixed;
  inset: 0;
  z-index: 35;
}

.page.is-mobile-play .play-guide-body {
  justify-content: flex-end;
  padding-top: max(56px, calc(env(safe-area-inset-top, 0px) + 48px));
}

.page.is-mobile-play .play-guide-zones {
  min-height: min(42vh, 280px);
}

@media (min-width: 900px) {
  .page.is-playing:not(.is-mobile-play) .game-main {
    border-radius: 16px;
    overflow: hidden;
  }

  .page:not(.is-mobile-play) .play-guide {
    align-items: center;
    justify-content: center;
  }

  .page:not(.is-mobile-play) .play-guide-body {
    flex: 0 1 auto;
    width: min(calc(100% - 28px), 280px);
    margin: auto;
    padding: 14px 14px 12px;
    border-radius: 14px;
    background: rgba(14, 12, 20, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.5);
    justify-content: flex-start;
    gap: 8px;
  }

  .page:not(.is-mobile-play) .play-guide-headline {
    font-size: 14px;
  }

  .page:not(.is-mobile-play) .play-guide-rule {
    font-size: 10px;
  }

  .page:not(.is-mobile-play) .play-guide-desktop {
    padding: 10px;
  }

  .page:not(.is-mobile-play) .play-guide-desktop p {
    font-size: 13px;
  }

  .page:not(.is-mobile-play) .play-guide-extra {
    font-size: 10px;
    padding: 6px 8px;
  }

  .page:not(.is-mobile-play) .play-guide-prompt {
    font-size: 12px;
    padding: 8px 10px;
  }
}

.playfield {
  position: relative;
  width: 100%;
  max-width: var(--playfield-width);
  margin: 0 auto;
  min-height: 280px;
  border-radius: 16px;
  overflow: hidden;
  contain: layout paint;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.18)),
    #121018;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.lanes {
  display: grid;
  grid-template-columns: repeat(var(--lane-count, 3), minmax(0, 1fr));
  height: calc(100% - var(--bottom-zone-height));
  contain: layout style;
}

.lane {
  position: relative;
  border-right: 1px dashed rgba(255, 255, 255, 0.06);
}

.lane:last-child {
  border-right: none;
}

.enemy {
  position: absolute;
  top: 0;
  left: 50%;
  width: 34px;
  height: 34px;
  margin-left: -17px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transform: translate3d(0, var(--enemy-y, 0px), 0);
  will-change: transform;
}

.enemy-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.enemy-badge {
  position: absolute;
  right: -2px;
  bottom: -1px;
  min-width: 14px;
  padding: 0 3px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.25);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.lane.is-active {
  background: rgba(255, 255, 255, 0.04);
}

.playfield.is-single-lane .lane.is-inactive {
  opacity: 0.55;
}

.enemy.is-physical .enemy-art {
  filter:
    drop-shadow(0 0 2px rgba(255, 160, 80, 0.95))
    drop-shadow(0 0 6px rgba(255, 107, 53, 0.7))
    drop-shadow(0 0 12px rgba(255, 80, 30, 0.38));
}

.enemy.is-magic .enemy-art {
  filter:
    drop-shadow(0 0 2px rgba(140, 210, 255, 0.95))
    drop-shadow(0 0 6px rgba(51, 154, 240, 0.7))
    drop-shadow(0 0 12px rgba(30, 100, 220, 0.38));
}

.enemy.has-color .enemy-art {
  filter:
    hue-rotate(var(--enemy-hue, 0deg))
    saturate(1.14)
    brightness(1.04)
    drop-shadow(0 0 3px rgba(255, 255, 255, 0.45))
    drop-shadow(0 0 8px rgba(255, 255, 255, 0.22));
}

.judge-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--judge-line-height);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 3px solid transparent;
  transition: left 0.12s ease;
  z-index: 2;
}

.playfield.is-single-lane .judge-line {
  width: calc(100% / var(--lane-count, 3));
  left: calc(var(--active-lane, 0) * (100% / var(--lane-count, 3)));
  right: auto;
}

.playfield.is-single-lane.is-lane-locked .judge-line {
  opacity: 0.72;
  filter: saturate(0.75);
}

.playfield.is-single-lane.is-lane-movable {
  touch-action: none;
  cursor: grab;
}

.playfield.is-single-lane.is-lane-movable:active {
  cursor: grabbing;
}

.judge-line.is-physical {
  border-top-color: #ff6b35;
  background: rgba(255, 107, 53, 0.12);
  box-shadow: inset 0 8px 24px rgba(255, 107, 53, 0.18);
}

.judge-line.is-magic {
  border-top-color: #339af0;
  background: rgba(51, 154, 240, 0.12);
  box-shadow: inset 0 8px 24px rgba(51, 154, 240, 0.18);
}

.judge-line-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0.85;
}

.legend {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 10px;
  font-size: 10px;
  color: #9ca3af;
}

.legend.legend--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.legend.legend--colors {
  width: 100%;
}

.page.has-color-legend.is-playing {
  --game-sidebar-width: var(--game-sidebar-width-color);
}

.legend-block {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
}

.legend-colors {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  min-height: 12px;
}

.legend-color {
  display: block;
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.08);
}

.legend-color.is-physical {
  border-radius: 2px;
  background: #ff6b35;
  filter:
    hue-rotate(var(--enemy-hue, 0deg))
    saturate(1.14)
    brightness(1.04);
}

.legend-color.is-magic {
  border-radius: 50%;
  background: #339af0;
  filter:
    hue-rotate(var(--enemy-hue, 0deg))
    saturate(1.14)
    brightness(1.04);
}

.legend-color.is-locked {
  opacity: 0.28;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.legend-shape {
  width: 14px;
  height: 14px;
}

.legend-shape.is-physical {
  border-radius: 3px;
  background: #ff6b35;
}

.legend-shape.is-magic {
  border-radius: 50%;
  background: #339af0;
}

.char-panel {
  padding: 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.portrait {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: var(--portrait-height);
  overflow: hidden;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.portrait img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center bottom;
}

.portrait--dead {
  filter: saturate(0.82) brightness(0.92);
}

.mobile-field-hud,
.mobile-touch-bar {
  display: none;
}

.mobile-field-hud {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  display: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  pointer-events: none;
}

.mobile-score {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.mobile-field-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.mobile-lives {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 700;
  color: #fca5a5;
}

.mobile-touch-bar {
  display: none;
  width: 100%;
  min-height: 0;
}

.mobile-touch-zone {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0;
  padding: 8px 6px;
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mobile-touch-zone--kill {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.95), rgba(91, 33, 182, 0.98));
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.mobile-touch-zone--revive {
  background: linear-gradient(180deg, rgba(5, 150, 105, 0.95), rgba(4, 120, 87, 0.98));
}

.mobile-touch-zone:active {
  filter: brightness(1.08);
}

.mobile-touch-zone.is-charging {
  box-shadow: inset 0 0 0 2px rgba(252, 211, 77, 0.85);
}

.mobile-touch-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
}

.mobile-touch-hint {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.72;
}

.page.is-mobile-play {
  max-width: none;
  padding: 0;
  min-height: 0;
}

.page.is-mobile-play .header {
  display: none;
}

.page.is-mobile-play #gameScreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  touch-action: manipulation;
}

body.tang-mobile-immersive.site-nav-collapsible.site-nav-visible .page.is-mobile-play #gameScreen {
  top: var(--site-nav-height, 52px);
  bottom: var(--site-icp-height, 28px);
}

.page.is-mobile-play .game-layout {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.page.is-mobile-play .game-main {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
}

.page.is-mobile-play .playfield {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  height: auto;
  max-width: none;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.page.is-mobile-play .mobile-field-hud:not([hidden]) {
  display: flex;
}

.page.is-mobile-play .game-sidebar {
  display: none;
}

.page.is-mobile-play .settings-toggle {
  position: fixed;
  top: max(6px, env(safe-area-inset-top, 0px));
  left: 8px;
  z-index: 40;
}

body.tang-mobile-immersive.site-nav-collapsible.site-nav-visible .page.is-mobile-play .settings-toggle {
  top: calc(var(--site-nav-height, 52px) + 6px);
}

.page.is-mobile-play #gameScreen::before,
.page.is-mobile-play #gameScreen::after {
  content: none;
}

@media (max-width: 899px) {
  .enemy {
    will-change: auto;
  }

  .enemy.is-physical .enemy-art,
  .enemy.is-magic .enemy-art {
    filter: none;
  }

  .enemy.has-color .enemy-art {
    filter:
      hue-rotate(var(--enemy-hue, 0deg))
      saturate(1.08);
  }

  .judge-line {
    transition: left 0.12s ease;
  }

  .playfield.is-single-lane.is-lane-locked .judge-line {
    filter: none;
    opacity: 0.72;
  }
}

.page.is-mobile-play.is-single-lane-hint .playfield.is-single-lane.is-lane-movable::after {
  content: "左右滑动移动单格防线";
  position: absolute;
  left: 50%;
  bottom: calc(var(--judge-line-height) + 8px);
  transform: translateX(-50%);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.82);
  pointer-events: none;
  z-index: 2;
}

.page.is-mobile-play .playfield.is-single-lane.is-lane-movable {
  touch-action: none;
}

.page.is-mobile-play .game-main,
.page.is-mobile-play .playfield,
.page.is-mobile-play .lanes {
  position: relative;
  z-index: 1;
}

.skill-panel {
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.skill-panel-label {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 700;
  color: #9ca3af;
  text-align: center;
}

.skill-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.skill-buttons.is-single {
  grid-template-columns: 1fr;
}

.skill-button {
  padding: 8px 4px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.skill-button--kill {
  background: linear-gradient(135deg, #7c3aed, #5b21b6);
}

.skill-button--revive {
  background: linear-gradient(135deg, #059669, #047857);
}

.skill-button--toggle {
  background: linear-gradient(135deg, #ff4d5a, #c92a40);
}

.skill-button kbd {
  display: inline-block;
  margin-left: 3px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 9px;
  font-family: inherit;
  background: rgba(0, 0, 0, 0.25);
  vertical-align: middle;
}

.skill-button.is-charging {
  box-shadow: inset 0 0 0 2px rgba(252, 211, 77, 0.8);
}

@media (min-width: 900px) {
  .page.is-playing {
    height: calc(100vh - var(--site-nav-height, 52px) - var(--site-icp-height, 28px));
    min-height: calc(100vh - var(--site-nav-height, 52px) - var(--site-icp-height, 28px));
    max-width: none;
    padding: 4px 14px 4px;
    overflow: hidden;
  }

  .page.is-playing .header {
    display: none;
  }

  #gameScreen {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    position: relative;
  }

  #gameScreen.is-setup {
    justify-content: center;
  }

  .setup-stage {
    flex: 1;
    min-height: 0;
    padding: 0;
  }

  .settings-toggle {
    top: 10px;
    left: 14px;
  }

  .game-layout {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    position: relative;
    width: 100%;
  }

  .game-main {
    flex: 0 0 var(--playfield-width);
    width: var(--playfield-width);
    max-width: var(--playfield-width);
    min-height: 0;
    height: 100%;
    align-self: stretch;
    display: flex;
    flex-direction: column;
  }

  .page.is-playing .game-main {
    flex: 0 0 var(--playfield-width);
    height: 100%;
  }

  .playfield {
    flex: 1 1 auto;
    width: 100%;
    max-width: var(--playfield-width);
    height: auto;
    min-height: 0;
    margin: 0;
    border-radius: 14px;
  }

  .game-sidebar {
    position: absolute;
    top: 0;
    left: calc(50% + var(--playfield-width) / 2 + 14px);
    width: var(--game-sidebar-width);
    max-width: var(--game-sidebar-width);
    margin: 0;
    max-height: 100%;
    overflow-y: auto;
    padding: 4px 0;
  }

  .sidebar-hud {
    grid-template-columns: 1fr;
  }

  .hud-item--score .hud-value {
    font-size: 26px;
  }

  .char-panel--tang {
    flex-shrink: 0;
  }

  .char-panel--tang .portrait {
    height: calc(var(--portrait-height) + 12px);
  }
}

@media (max-width: 899px) {
  :root {
    --setup-width: 296px;
  }

  .page.is-playing .header {
    display: none;
  }

  .page.is-playing:not(.is-mobile-play) .game-layout {
    flex: 1;
    min-height: 0;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
  }

  .page.is-playing:not(.is-mobile-play) .game-main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: var(--playfield-width);
  }

  .page.is-playing:not(.is-mobile-play) .playfield {
    flex: 1 1 auto;
    height: auto;
    min-height: 220px;
  }

  .page.is-playing:not(.is-mobile-play) .game-sidebar {
    flex: 0 0 auto;
    width: min(100%, var(--playfield-width));
    max-width: var(--playfield-width);
  }

  .settings-compact {
    padding: 10px 12px !important;
    gap: 8px;
  }

  .chip-option {
    padding: 6px 8px;
    font-size: 11px;
  }

  .feedback--overlay {
    position: static;
    margin-top: 8px;
    text-shadow: none;
  }
}
