:root {
  --bg-dark: #140d09;
  --bg-table:
    radial-gradient(circle at 50% 42%, rgba(92, 56, 32, 0.42) 0%, rgba(42, 24, 15, 0.85) 56%, rgba(16, 9, 6, 0.98) 100%),
    repeating-linear-gradient(45deg, rgba(255, 210, 140, 0.015) 0 2px, transparent 2px 16px),
    #1b100b;
  --panel-bg: rgba(24, 15, 10, 0.9);
  --panel-border: rgba(212, 170, 96, 0.46);
  --gold: #e8be6b;
  --gold-bright: #ffe6a8;
  --text-main: #f5ecdc;
  --text-muted: #b7a58a;
  --danger: #d9483b;
  --success: #46b569;
  --accent: #3b82d6;
  --stage-w: 100vw;
  --stage-h: 100dvh;
  --stage-cx: 50%;
  --stage-cy: 50%;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --card-w: clamp(58px, calc(var(--stage-w) * 0.078), 82px);
  --card-h: clamp(82px, calc(var(--stage-h) * 0.235), 116px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

input, textarea, select {
  user-select: text;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  background: #0d0705;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
}

.app-stage {
  position: fixed;
  left: var(--stage-cx);
  top: var(--stage-cy);
  width: var(--stage-w);
  height: var(--stage-h);
  transform: translate(-50%, -50%);
  transform-origin: center center;
  overflow: hidden;
  background: var(--bg-dark);
}

body.is-portrait-rotated .app-stage {
  transform: translate(-50%, -50%) rotate(90deg);
  --safe-l: env(safe-area-inset-bottom, 0px);
  --safe-r: env(safe-area-inset-top, 0px);
}

body.is-portrait-rotated.rotate-ccw .app-stage {
  transform: translate(-50%, -50%) rotate(-90deg);
  --safe-l: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-bottom, 0px);
}

.btn-rotate-stage {
  display: none;
}

body.is-portrait-rotated .btn-rotate-stage {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.screen {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Banners & Toast */
.banner {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #b83227;
  color: #fff;
  padding: 6px 14px;
  border-radius: 0 0 10px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.toast {
  position: absolute;
  top: 13%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  background: rgba(18, 13, 9, 0.95);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 14px;
  max-width: calc(var(--stage-w) - 32px);
  text-align: center;
  pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
}

/* Buttons & Inputs */
.btn {
  min-height: 40px;
  min-width: 44px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: #3d2c1e;
  transition: transform 0.08s ease, opacity 0.15s ease, filter 0.15s ease;
}

.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, #b83c2e, #7b2017);
  border-color: #e98872;
}

.btn-accent {
  background: linear-gradient(180deg, #3c79be, #234d7e);
  border-color: #77b0ee;
}

.btn-danger {
  background: linear-gradient(180deg, #912c2c, #5d1919);
  border-color: #d46565;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--panel-border);
  color: var(--gold-bright);
}

.btn-small {
  min-height: 34px;
  padding: 5px 11px;
  font-size: 13px;
}

.btn-block { width: 100%; }

.mini-btn {
  min-height: 26px;
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

input[type="text"], input[type="number"], select {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.4);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--gold);
}

/* Lobby Screen */
#screen-lobby {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-table);
  padding: 12px calc(16px + var(--safe-r)) 12px calc(16px + var(--safe-l));
  overflow-y: auto;
  touch-action: auto;
}

.lobby-card {
  width: min(500px, calc(var(--stage-w) - 32px));
  background: var(--panel-bg);
  border: 1.5px solid var(--panel-border);
  border-radius: 16px;
  padding: 18px 22px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.72);
}

.lobby-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.lobby-title-wrap {
  flex: 1;
  min-width: 0;
}

.logo-seal {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: radial-gradient(circle, #a32520, #4a100c);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 900;
  color: var(--gold-bright);
  flex-shrink: 0;
  box-shadow: inset 0 0 12px rgba(255, 224, 150, 0.28);
}

.lobby-header h1 {
  margin: 0;
  font-size: clamp(18px, calc(var(--stage-w) * 0.028), 23px);
  color: var(--gold-bright);
}

.subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.join-box {
  display: flex;
  gap: 8px;
}

.join-box input {
  flex: 1;
  text-align: center;
  letter-spacing: 3px;
  font-weight: 700;
}

.lobby-footer {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* Room Screen */
#screen-room {
  background: var(--bg-table);
  padding: clamp(6px, calc(var(--stage-h) * 0.015), 14px) calc(clamp(8px, calc(var(--stage-w) * 0.02), 20px) + var(--safe-r)) clamp(6px, calc(var(--stage-h) * 0.015), 14px) calc(clamp(8px, calc(var(--stage-w) * 0.02), 20px) + var(--safe-l));
}

.room-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 1120px;
  margin: 0 auto;
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.room-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.room-code {
  font-size: clamp(20px, calc(var(--stage-w) * 0.03), 26px);
  color: var(--gold-bright);
  letter-spacing: 3px;
}

.room-header-actions {
  display: flex;
  gap: 6px;
}

.room-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 10px;
}

.room-seats-panel, .room-side-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
}

.room-seats-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 12px;
}

.room-seats-panel h3, .panel-box h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--gold);
}

.room-seats {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
  align-content: start;
}

.seat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.seat-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.seat-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-badges {
  display: flex;
  gap: 4px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.badge-host { background: #96661c; color: #ffe7b3; }
.badge-ready { background: #266b3c; color: #b7f5cb; }
.badge-wait { background: #5a4b38; color: #dfd2bc; }
.badge-bot { background: #31537a; color: #c4e1ff; }
.badge-offline { background: #7a2626; color: #ffd1d1; }

.panel-box {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.room-mode-badges {
  display: flex;
  gap: 4px;
  align-items: center;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  align-items: end;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.settings-grid input, .settings-grid select {
  min-height: 32px;
  padding: 3px 8px;
  font-size: 13px;
}

.room-chat-box {
  flex: 1;
  min-height: 80px;
}

.chat-list {
  flex: 1;
  min-height: 48px;
  overflow-y: auto;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-form {
  display: flex;
  gap: 6px;
}

.chat-form input {
  flex: 1;
  min-height: 34px;
  padding: 4px 10px;
  font-size: 13px;
}

/* Game Screen */
#screen-game {
  background: var(--bg-table);
}

.game-table {
  --dock-h: clamp(120px, calc(var(--stage-h) * 0.34), 168px);
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 44%, rgba(25, 16, 10, 0.14) 0%, rgba(12, 7, 4, 0.72) 78%, rgba(6, 3, 2, 0.92) 100%),
    url('/img/table-bg.jpg') center center / cover no-repeat;
}

.table-watermark {
  position: absolute;
  left: 50%;
  top: 42%;
  width: clamp(160px, calc(var(--stage-w) * 0.25), 320px);
  height: clamp(160px, calc(var(--stage-w) * 0.25), 320px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid rgba(232, 190, 107, 0.08);
  box-shadow: inset 0 0 40px rgba(232, 190, 107, 0.05);
  pointer-events: none;
}

.table-watermark::before {
  content: '杀';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(60px, calc(var(--stage-w) * 0.095), 120px);
  font-weight: 900;
  color: rgba(232, 190, 107, 0.045);
  font-family: serif;
}

/* FX Layers */
.fx-svg, .fx-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

.fx-beam {
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 8 5;
  animation: beamFlow 0.78s ease-out forwards;
}

.fx-beam-preview {
  stroke-width: 2.5;
  stroke-dasharray: 6 5;
  opacity: 0.9;
  animation: beamMarch 0.6s linear infinite;
}

.fx-beam-attack { stroke: #ff5946; filter: drop-shadow(0 0 6px #ff4028); }
.fx-beam-fire { stroke: #ff8c3a; filter: drop-shadow(0 0 7px #ff561c); }
.fx-beam-thunder { stroke: #a87eff; filter: drop-shadow(0 0 7px #7b4dff); }
.fx-beam-chain { stroke: #7dd6ff; filter: drop-shadow(0 0 6px #42a6eb); }
.fx-beam-trick { stroke: #5cb2ff; filter: drop-shadow(0 0 6px #3a96f5); }
.fx-beam-heal { stroke: #56e280; filter: drop-shadow(0 0 6px #3ac465); }
.fx-beam-aim { stroke: #ffe066; filter: drop-shadow(0 0 5px #ffd026); }

/* Flying Card Arc */
.fx-fly-card {
  position: absolute;
  width: 44px;
  height: 60px;
  border-radius: 6px;
  background: linear-gradient(175deg, #fcf5e6, #ebd9b4);
  border: 1.5px solid #c99d4c;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.65);
  transform: translate(-50%, -50%) scale(0.85);
  transition: transform 0.38s cubic-bezier(0.22, 0.85, 0.36, 1), opacity 0.38s ease-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px;
  z-index: 54;
}
.fx-fly-card.red { color: #c42c26; }
.fx-fly-card.black { color: #1d1d22; }
.fx-fly-corner { font-size: 9.5px; font-weight: 800; line-height: 1; }
.fx-fly-title { font-size: 11.5px; font-weight: 900; text-align: center; }

/* Action Splash */
.fx-splash {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "KaiTi", "STKaiti", serif;
  font-weight: 900;
  font-size: clamp(22px, calc(var(--stage-w) * 0.036), 38px);
  letter-spacing: 2px;
  white-space: nowrap;
  text-shadow: 0 3px 10px #000, 0 0 18px rgba(0, 0, 0, 0.9);
  animation: splashPop 0.74s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
  z-index: 56;
}
.fx-splash-sha { color: #ff5640; -webkit-text-stroke: 0.7px #ffe0c4; }
.fx-splash-fire { color: #ff8e38; text-shadow: 0 0 16px #ff4019, 0 2px 8px #000; }
.fx-splash-thunder { color: #b78cff; text-shadow: 0 0 16px #783bff, 0 2px 8px #000; }
.fx-splash-dodge { color: #7ee3ff; }
.fx-splash-jiu { color: #ffca57; text-shadow: 0 0 14px #d96b14, 0 2px 8px #000; }
.fx-splash-wuxie { color: #ffe785; }
.fx-splash-chain { color: #90e0ff; }
.fx-splash-heal { color: #6bf596; }
.fx-splash-trick { color: #78bdff; }
.fx-splash-damage { color: #ff4e3f; }

@keyframes splashPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.45); }
  26% { opacity: 1; transform: translate(-50%, -55%) scale(1.18); }
  75% { opacity: 1; transform: translate(-50%, -60%) scale(1.0); }
  100% { opacity: 0; transform: translate(-50%, -78%) scale(1.08); }
}

/* Diagonal Official Skill Cut-in Banner */
.fx-cutin {
  position: absolute;
  left: 50%;
  top: 35%;
  transform: translate(-50%, -50%) skewX(-8deg);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 22px 6px 8px;
  border-radius: 6px;
  background: linear-gradient(95deg, rgba(16, 10, 7, 0.96) 0%, rgba(72, 34, 16, 0.94) 55%, rgba(16, 10, 7, 0.88) 100%);
  border: 1.5px solid rgba(255, 214, 118, 0.85);
  border-left: 4px solid #ffcf5c;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.85), 0 0 24px rgba(255, 198, 86, 0.35);
  animation: cutinSlide 1.5s ease-out forwards;
  max-width: min(460px, calc(var(--stage-w) * 0.9));
  z-index: 58;
}
.fx-cutin > * { transform: skewX(8deg); }
.fx-cutin-portrait {
  width: 48px;
  height: 54px;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid var(--gold);
  flex-shrink: 0;
}
.fx-cutin-portrait .portrait-frame,
.fx-cutin-portrait .portrait-svg { width: 100%; height: 100%; display: block; }
.fx-cutin-body { min-width: 0; }
.fx-cutin-head { display: flex; align-items: baseline; gap: 8px; }
.fx-cutin-gen { font-size: 12.5px; font-weight: 800; color: #f4dcb0; }
.fx-cutin-sk {
  font-family: "KaiTi", "STKaiti", serif;
  font-size: clamp(20px, calc(var(--stage-w) * 0.03), 26px);
  font-weight: 900;
  color: #ffe485;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.95);
}
.fx-cutin-line {
  font-size: 11.5px;
  color: #f8eed9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-cutin-ultimate {
  background: linear-gradient(95deg, rgba(46, 10, 10, 0.98) 0%, rgba(128, 34, 18, 0.96) 52%, rgba(42, 16, 8, 0.94) 100%);
  border: 2px solid #ffdf73;
  border-left: 5px solid #ff6b42;
  box-shadow: 0 0 36px rgba(255, 196, 64, 0.68), 0 0 18px rgba(255, 76, 48, 0.52);
}

.dying-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 48;
  opacity: 0;
  transition: opacity 0.25s ease;
  box-shadow: inset 0 0 95px 34px rgba(190, 18, 18, 0.72);
}
.dying-vignette.is-active {
  opacity: 1;
  animation: dyingPulse 1.15s ease-in-out infinite alternate;
}
@keyframes dyingPulse {
  from { box-shadow: inset 0 0 75px 24px rgba(185, 18, 18, 0.45); }
  to { box-shadow: inset 0 0 115px 42px rgba(220, 26, 26, 0.82); }
}

@keyframes cutinSlide {
  0% { opacity: 0; transform: translate(-72%, -50%) skewX(-8deg) scale(0.92); }
  14% { opacity: 1; transform: translate(-50%, -50%) skewX(-8deg) scale(1); }
  84% { opacity: 1; transform: translate(-50%, -50%) skewX(-8deg) scale(1); }
  100% { opacity: 0; transform: translate(-34%, -50%) skewX(-8deg) scale(0.98); }
}

/* Epic Kill-Streak & High-Damage Announcement Banner */
.fx-epic-banner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: min(360px, calc(var(--stage-w) * 0.86));
  text-align: center;
  padding: 12px 38px;
  background: linear-gradient(90deg, transparent 0%, rgba(124, 18, 12, 0.94) 18%, rgba(164, 34, 18, 0.96) 50%, rgba(124, 18, 12, 0.94) 82%, transparent 100%);
  border-top: 2px solid #ffd875;
  border-bottom: 2px solid #ffd875;
  box-shadow: 0 0 36px rgba(255, 110, 48, 0.55);
  animation: epicFlash 1.9s ease-out forwards;
  z-index: 62;
  pointer-events: none;
}
.fx-epic-unmatched {
  background: linear-gradient(90deg, transparent 0%, rgba(88, 22, 116, 0.95) 20%, rgba(154, 42, 32, 0.96) 50%, rgba(88, 22, 116, 0.95) 80%, transparent 100%);
  border-color: #ffe88f;
}
.fx-epic-title {
  font-family: "KaiTi", "STKaiti", serif;
  font-size: clamp(24px, calc(var(--stage-w) * 0.04), 34px);
  font-weight: 900;
  letter-spacing: 3px;
  color: #ffe88c;
  text-shadow: 0 3px 10px #000, 0 0 18px rgba(255, 184, 62, 0.85);
}
.fx-epic-sub {
  font-size: 12px;
  color: #fff2d6;
  margin-top: 2px;
  letter-spacing: 1px;
}
@keyframes epicFlash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.25); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  82% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -54%) scale(0.96); }
}

/* Speech Bubble */
.fx-bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  max-width: 170px;
  background: rgba(252, 244, 226, 0.96);
  color: #26180c;
  border: 1.5px solid #b5893e;
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
  animation: bubbleFade 2.4s ease-out forwards;
  z-index: 57;
}
@keyframes bubbleFade {
  0% { opacity: 0; transform: translate(-50%, -85%) scale(0.9); }
  12% { opacity: 1; transform: translate(-50%, -100%) scale(1); }
  84% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -108%); }
}

@keyframes beamFlow {
  0% { stroke-dashoffset: 60; opacity: 0.95; }
  80% { stroke-dashoffset: 0; opacity: 0.9; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

@keyframes beamMarch {
  to { stroke-dashoffset: -22; }
}

.fx-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: clamp(16px, calc(var(--stage-w) * 0.024), 22px);
  text-shadow: 0 2px 6px #000, 0 0 10px rgba(0, 0, 0, 0.85);
  animation: floatUp 0.95s ease-out forwards;
  white-space: nowrap;
}

.fx-float-damage { color: #ff5c4a; }
.fx-float-heal { color: #5ef28b; }
.fx-float-dodge { color: #7cc5ff; }
.fx-float-skill { color: #ffe17a; }

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.75); }
  22% { opacity: 1; transform: translate(-50%, -55%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(0.95); }
}

.fx-banner {
  position: absolute;
  left: 50%;
  top: 28%;
  transform: translate(-50%, -50%);
  background: linear-gradient(90deg, transparent, rgba(162, 42, 28, 0.92) 20%, rgba(162, 42, 28, 0.92) 80%, transparent);
  color: #ffe8ad;
  font-size: clamp(18px, calc(var(--stage-w) * 0.03), 26px);
  font-weight: 900;
  letter-spacing: 4px;
  padding: 8px 46px;
  border-top: 1px solid rgba(255, 220, 140, 0.65);
  border-bottom: 1px solid rgba(255, 220, 140, 0.65);
  animation: bannerPop 1.2s ease-out forwards;
}

@keyframes bannerPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -55%) scale(1.03); }
}

.fx-hit {
  animation: panelHit 0.52s ease;
}

.fx-heal {
  box-shadow: 0 0 18px rgba(86, 232, 130, 0.9) !important;
  border-color: #6df295 !important;
}

.fx-skill {
  box-shadow: 0 0 18px rgba(255, 214, 96, 0.95) !important;
  border-color: #ffe485 !important;
}

@keyframes panelHit {
  0%, 100% { transform: translate(-50%, -50%); }
  20% { transform: translate(calc(-50% - 5px), -50%); box-shadow: 0 0 20px rgba(255, 70, 50, 0.95); }
  45% { transform: translate(calc(-50% + 5px), -50%); }
  70% { transform: translate(calc(-50% - 3px), -50%); }
}

.me-panel.fx-hit {
  animation: meHit 0.52s ease;
}

@keyframes meHit {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); box-shadow: 0 0 20px rgba(255, 70, 50, 0.95); }
  55% { transform: translateX(5px); }
}

/* Top HUD */
.hud-top-left, .hud-top-right {
  position: absolute;
  top: 5px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hud-top-left { left: calc(8px + var(--safe-l)); }
.hud-top-right { right: calc(8px + var(--safe-r)); }

.hud-pill {
  background: rgba(15, 10, 7, 0.84);
  border: 1px solid var(--panel-border);
  color: var(--gold-bright);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.hud-mode-tag {
  background: rgba(110, 32, 22, 0.88);
  border-color: rgba(235, 174, 92, 0.65);
  color: #ffe8b0;
}

body.narrow-stage .hud-mode-tag,
body.tight-hud .hud-mode-tag { display: none; }
body.compact-stage .hud-top-right { gap: 3px; }
body.compact-stage .hud-btn {
  min-height: 26px;
  min-width: 28px;
  padding: 2px 5.5px;
  font-size: 10.5px;
}
body.compact-stage .phase-pip {
  font-size: 9.5px;
  padding: 1px 4px;
}

.phase-strip {
  display: flex;
  background: rgba(15, 10, 7, 0.84);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 2px 4px;
  gap: 2px;
}

body.narrow-stage .phase-strip { display: none; }

.phase-pip {
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 600;
}

.phase-pip.active {
  background: linear-gradient(180deg, #d89b38, #9c6514);
  color: #fff;
  font-weight: 800;
}

.hud-btn {
  min-height: 30px;
  min-width: 38px;
  padding: 3px 9px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(24, 16, 11, 0.88);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.hud-btn.active {
  background: #9b6a1d;
  border-color: var(--gold-bright);
}

.hud-btn-danger {
  background: rgba(138, 36, 32, 0.88);
  border-color: #d66760;
  color: #ffe8e6;
}

/* Opponents Arc Layer */
.opponents-layer {
  position: absolute;
  inset: 34px var(--safe-r) calc(var(--dock-h) + 8px) var(--safe-l);
  pointer-events: none;
}

.opp-panel {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  width: clamp(118px, calc(var(--stage-w) * 0.15), 174px);
  min-height: 80px;
  background: #140d08;
  border: 1.5px solid rgba(222, 180, 102, 0.58);
  border-radius: 9px;
  overflow: visible;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.72), inset 0 0 0 1px rgba(255, 224, 150, 0.12);
}

.opp-portrait-bg {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  overflow: hidden;
  z-index: 0;
}

.portrait-frame {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 14%;
  display: block;
}

.portrait-img-banner {
  object-position: center 16%;
}

.portrait-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.52);
}

.portrait-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.opp-portrait-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(12, 7, 5, 0.78) 0%,
    rgba(14, 9, 6, 0.25) 36%,
    rgba(12, 7, 5, 0.55) 100%
  ),
  linear-gradient(
    180deg,
    rgba(14, 9, 6, 0.55) 0%,
    rgba(14, 9, 6, 0.05) 36%,
    rgba(10, 6, 4, 0.88) 100%
  );
}

.opp-overlay {
  position: relative;
  z-index: 2;
  padding: 4px 5px 5px 25px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
}

.opp-left-rail {
  position: absolute;
  top: 3px;
  left: 3px;
  bottom: 3px;
  width: 19px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(14, 9, 6, 0.78);
  border: 1px solid rgba(232, 190, 107, 0.32);
  border-radius: 5px;
  padding: 2px 1px;
  z-index: 3;
}

.opp-vname {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 9.5px;
  font-weight: 900;
  line-height: 1;
  color: #f9ebd0;
  letter-spacing: 0px;
}

.opp-panel[data-kingdom="wei"] { border-top: 3px solid #4e88ff; }
.opp-panel[data-kingdom="shu"] { border-top: 3px solid #e64b4b; }
.opp-panel[data-kingdom="wu"] { border-top: 3px solid #48c96c; }
.opp-panel[data-kingdom="qun"] { border-top: 3px solid #b8ab8e; }
.opp-panel[data-kingdom="shen"] { border-top: 3px solid #f0b840; box-shadow: 0 0 10px rgba(240, 184, 64, 0.25); }

.opp-panel.is-current {
  border-color: #f6c954;
  box-shadow: 0 0 16px rgba(246, 201, 84, 0.65);
}

.opp-panel.is-waiting {
  border-color: #ff6e4a;
  box-shadow: 0 0 16px rgba(255, 110, 74, 0.72);
}

.opp-panel.is-chained {
  box-shadow: inset 0 0 0 1.5px rgba(125, 214, 255, 0.72), 0 0 10px rgba(96, 192, 255, 0.4);
}

.opp-panel.is-drunk {
  box-shadow: inset 0 0 14px rgba(255, 162, 52, 0.55), 0 0 14px rgba(255, 152, 42, 0.5);
}

.opp-panel.is-flipped .opp-portrait-bg {
  filter: brightness(0.5) saturate(0.45);
}

.opp-panel.target-valid {
  border-color: #5ee68a;
  box-shadow: 0 0 16px rgba(94, 230, 138, 0.85);
}

.opp-panel.target-selected {
  border-color: #ffe270;
  box-shadow: 0 0 22px rgba(255, 226, 112, 0.98);
  transform: translate(-50%, -54%) scale(1.05);
}

.opp-panel.is-dead {
  opacity: 0.5;
  filter: grayscale(0.8);
}

.opp-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
}

.opp-head-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.kingdom-seal {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255, 230, 168, 0.7);
  font-size: 10px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
}

.mini-pack-tag {
  font-size: 9px;
  font-weight: 800;
  padding: 0 3px;
  border-radius: 3px;
  background: rgba(246, 198, 92, 0.26);
  border: 1px solid rgba(246, 198, 92, 0.55);
  color: #ffe49c;
  flex-shrink: 0;
}

.opp-marks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.status-mark {
  font-size: 9px;
  font-weight: 800;
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(255, 210, 120, 0.2);
  border: 1px solid rgba(255, 210, 120, 0.5);
  color: #ffeab3;
}
.mark-jiu { background: rgba(224, 112, 22, 0.65); border-color: #ffbd61; color: #fff; }
.mark-sealed { background: rgba(168, 42, 42, 0.72); border-color: #ff9c92; color: #fff; }
.mark-ying { background: rgba(54, 138, 178, 0.72); border-color: #9ce2ff; color: #fff; }
.mark-kuangfeng { background: rgba(212, 74, 24, 0.78); border-color: #ffa570; color: #fff; }
.mark-dawu { background: rgba(102, 132, 164, 0.75); border-color: #d6ecff; color: #fff; }
.mark-xiongzi { background: rgba(176, 56, 40, 0.78); border-color: #ffcf82; color: #ffe7b8; }
.mark-baonu { background: rgba(192, 32, 32, 0.85); border-color: #ff9494; color: #fff; }
.mark-junlue { background: rgba(180, 74, 18, 0.85); border-color: #ffd088; color: #fff; }
.mark-ren { background: rgba(74, 44, 118, 0.85); border-color: #d8b4ff; color: #fff; }
.mark-wuku { background: rgba(58, 92, 148, 0.85); border-color: #a4ccff; color: #fff; }
.mark-chenglue { background: rgba(140, 102, 24, 0.85); border-color: #ffe285; color: #fff; }
.mark-xianfu { background: rgba(34, 114, 96, 0.85); border-color: #9ff0d6; color: #fff; }
.mark-dinghan { background: rgba(42, 82, 122, 0.85); border-color: #a8d8ff; color: #fff; }
.mark-qinzheng { background: rgba(40, 112, 62, 0.85); border-color: #a6f0b6; color: #fff; }
.mark-xiongluan { background: rgba(164, 22, 54, 0.88); border-color: #ff9cb6; color: #fff; }

.chain-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  background: #234d6e;
  color: #a8e4ff;
  border: 1px solid #88d8ff;
  border-radius: 999px;
  font-size: 10px;
  padding: 0 5px;
  line-height: 15px;
}
.me-portrait-card .chain-badge {
  top: 2px;
  left: auto;
  right: 2px;
  transform: none;
}

.flip-stamp {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-12deg);
  z-index: 5;
  font-size: 11px;
  font-weight: 900;
  color: #d9e8ff;
  background: rgba(20, 32, 54, 0.88);
  border: 1.5px solid #96b8eb;
  border-radius: 4px;
  padding: 1px 6px;
  pointer-events: none;
}

.magatama-wrap {
  display: inline-flex;
  align-items: center;
}
.magatama-svg {
  width: 10px;
  height: 13px;
  display: block;
}
.hp-numeric {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--gold-bright);
}

.opp-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.avatar-circle {
  width: clamp(30px, calc(var(--stage-w) * 0.041), 40px);
  height: clamp(30px, calc(var(--stage-w) * 0.041), 40px);
  border-radius: 50%;
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(14px, calc(var(--stage-w) * 0.019), 18px);
  color: #fff;
  flex-shrink: 0;
  position: relative;
}

.avatar-kingdom {
  position: absolute;
  bottom: -3px;
  left: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid #1a120b;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.opp-meta {
  flex: 1;
  min-width: 0;
}

.opp-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
}

.opp-general-name {
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.id-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: #44372c;
  color: #f4e6cf;
  flex-shrink: 0;
}

.id-pill.guessable {
  cursor: pointer;
  border: 1px dashed rgba(232, 190, 107, 0.45);
}

.opp-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  gap: 3px;
}

.opp-player-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opp-counts {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.dist-pill {
  font-size: 9.5px;
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #d6c5ab;
}

.dist-pill.in-range {
  background: rgba(70, 181, 105, 0.25);
  color: #93f5b2;
  border: 1px solid rgba(70, 181, 105, 0.45);
}

.hand-count-pill {
  font-weight: 700;
  color: var(--gold-bright);
}

.hp-row {
  display: flex;
  gap: 2px;
  align-items: center;
  flex-wrap: wrap;
}

.magatama {
  width: 9px;
  height: 12px;
  border-radius: 60% 40% 60% 40%;
  transform: rotate(-18deg);
  display: inline-block;
  border: 1px solid rgba(0, 0, 0, 0.45);
}

.magatama.full.high { background: #52cc6a; box-shadow: 0 0 4px rgba(82, 204, 106, 0.5); }
.magatama.full.mid { background: #e8b838; box-shadow: 0 0 4px rgba(232, 184, 56, 0.5); }
.magatama.full.low { background: #e3483b; box-shadow: 0 0 5px rgba(227, 72, 59, 0.7); }
.magatama.empty { background: rgba(255, 255, 255, 0.14); }

.opp-equips-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.equip-chip {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(78, 143, 95, 0.35);
  border: 1px solid rgba(120, 200, 140, 0.4);
  color: #d6f5de;
}

.equip-chip.judge-chip {
  background: rgba(141, 75, 187, 0.42);
  border-color: rgba(196, 142, 240, 0.5);
  color: #f0dcff;
}

.equip-chip.selectable-equip {
  min-height: 26px;
  padding: 2px 7px;
  font-size: 11.5px;
  cursor: pointer;
  border-color: #63e691;
  box-shadow: 0 0 8px rgba(99, 230, 145, 0.55);
}

.equip-chip.selected-equip {
  background: #9f7922;
  border-color: #ffe388;
  color: #fff;
}

.opp-hp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.wait-badge {
  position: absolute;
  top: -9px;
  right: 6px;
  z-index: 4;
  background: #e24b37;
  color: #fff;
  border: 1px solid #ffd4a3;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
}

.dead-stamp {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-size: 10.5px;
  font-weight: 800;
  color: #ffe0dc;
  background: rgba(138, 22, 18, 0.92);
  border: 1px solid #ff9c92;
  border-radius: 4px;
  padding: 1px 5px;
  pointer-events: none;
}

/* Live 4-line Battle Feed */
.battle-feed {
  position: absolute;
  left: calc(8px + var(--safe-l));
  bottom: calc(var(--dock-h) + 12px);
  width: clamp(150px, calc(var(--stage-w) * 0.22), 260px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
  z-index: 12;
}

body.narrow-stage .battle-feed,
body.compact-stage .battle-feed {
  display: none;
}

.feed-line {
  background: rgba(14, 9, 6, 0.72);
  border-left: 2.5px solid rgba(212, 170, 96, 0.45);
  padding: 2px 7px;
  border-radius: 0 5px 5px 0;
  font-size: 11px;
  color: #e6dac5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-damage { border-left-color: #ef5443; color: #ffc7c0; }
.feed-heal { border-left-color: #4bd175; color: #c7fad7; }
.feed-skill { border-left-color: #f3c452; color: #ffebaa; }
.feed-use { border-left-color: #4f9be8; }

/* Center Arena */
.center-arena {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  width: clamp(220px, calc(var(--stage-w) * 0.4), 460px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  z-index: 15;
}

.processing-zone {
  display: flex;
  gap: 6px;
  justify-content: center;
  min-height: clamp(60px, calc(var(--stage-h) * 0.16), 96px);
  align-items: center;
}

.processing-zone .card {
  width: clamp(46px, calc(var(--stage-w) * 0.06), 70px);
  height: clamp(64px, calc(var(--stage-h) * 0.16), 98px);
}

.processing-zone .card.center-discarded {
  opacity: 0.75;
  filter: saturate(0.85);
}

.center-waiting {
  background: rgba(210, 82, 46, 0.9);
  border: 1px solid #ffd599;
  color: #fff;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.latest-log {
  background: rgba(12, 9, 6, 0.76);
  border: 1px solid rgba(212, 170, 96, 0.3);
  color: #e9dec9;
  padding: 3px 12px;
  border-radius: 8px;
  font-size: 12px;
  max-width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Opponent Inspector Popover */
.inspector-popover {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(var(--stage-w) * 0.86));
  max-height: calc(var(--stage-h) - 80px);
  overflow-y: auto;
  touch-action: auto;
  background: rgba(24, 16, 11, 0.97);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 10px 12px;
  z-index: 80;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inspector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 8px;
  gap: 6px;
}

.inspector-title {
  font-size: 11.5px;
  color: var(--text-muted);
}

.inspector-meta {
  font-size: 12px;
  color: var(--gold-bright);
}

.inspector-skill {
  font-size: 12px;
  line-height: 1.38;
  color: var(--text-main);
}

.inspector-sk-name {
  color: var(--gold);
  font-weight: 700;
}

/* Bottom Me Area (Official《三国杀移动版》3-Column Layout) */
.me-dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--dock-h);
  background: linear-gradient(180deg, rgba(16, 10, 7, 0.8), rgba(9, 5, 3, 0.97));
  border-top: 1.5px solid rgba(222, 178, 98, 0.58);
  box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: stretch;
  padding: 4px calc(6px + var(--safe-r)) 4px calc(6px + var(--safe-l));
  gap: 6px;
  z-index: 30;
}

/* Left Column: Fixed 4-Slot Equipment Rack */
.me-equips-rack {
  width: clamp(98px, calc(var(--stage-w) * 0.132), 152px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  flex-shrink: 0;
}

.rack-extras {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.rack-judge-pill, .rack-pile-pill {
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(136, 68, 184, 0.55);
  border: 1px solid rgba(206, 154, 248, 0.65);
  color: #f6e4ff;
}

.rack-pile-pill {
  background: rgba(166, 120, 34, 0.55);
  border-color: rgba(245, 200, 92, 0.65);
  color: #ffebb0;
}

.equip-slot {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 23px;
  padding: 2px 5px;
  border-radius: 5px;
  font-size: 10.5px;
  border: 1px solid rgba(196, 156, 84, 0.25);
  background: rgba(16, 11, 8, 0.72);
}

.equip-slot.is-empty {
  color: rgba(186, 168, 140, 0.48);
  border-style: dashed;
}

.equip-slot.is-equipped {
  background: linear-gradient(90deg, rgba(44, 34, 21, 0.92), rgba(26, 20, 12, 0.92));
  border-color: rgba(120, 198, 138, 0.55);
  color: #e2f6e7;
}

.equip-slot-suit.red { color: #ff7e75; font-weight: 800; }
.equip-slot-suit.black { color: #d5cfc2; font-weight: 800; }
.equip-slot-name {
  flex: 1;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.equip-slot-range {
  font-size: 9.5px;
  color: var(--gold);
  font-weight: 800;
}
.equip-slot-tag { font-size: 10px; opacity: 0.7; }
.equip-slot-empty { font-size: 10px; }

.equip-slot.selectable-equip {
  cursor: pointer;
  border-color: #63e691;
  box-shadow: 0 0 8px rgba(99, 230, 145, 0.6);
}
.equip-slot.selected-equip {
  background: #8f6b1e;
  border-color: #ffe388;
  color: #fff;
}

/* Center Column: Full-height Hand Cards */
.me-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: visible;
}

/* Floating Prompt Bar above Dock (Official Sanguosha Mobile Style) */
.prompt-bar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--dock-h) + 5px);
  transform: translateX(-50%);
  width: min(620px, calc(var(--stage-w) * 0.78));
  max-width: calc(var(--stage-w) - 20px);
  z-index: 36;
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: linear-gradient(180deg, rgba(44, 27, 15, 0.96), rgba(22, 13, 8, 0.97));
  border: 1.5px solid var(--gold);
  border-radius: 10px;
  padding: 4px 10px 5px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.68);
}

.prompt-progress {
  width: 100%;
  height: 3.5px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.prompt-progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e5a93b, #ffe078);
  transition: width 0.1s linear;
}

.prompt-progress-fill.is-urgent {
  background: linear-gradient(90deg, #d93829, #ff7e5f);
}

.prompt-main {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.prompt-text {
  flex: 1;
  min-width: 110px;
  font-size: 12px;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prompt-timer {
  font-weight: 800;
  color: #ff9f7f;
  font-size: 12.5px;
  min-width: 26px;
  text-align: center;
}

.prompt-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.prompt-actions .btn {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 12.5px;
}

/* Right Column: Sculpted Skills + Official Hero Portrait Card + Vertical HP */
.me-panel {
  width: clamp(168px, calc(var(--stage-w) * 0.235), 262px);
  background: linear-gradient(180deg, rgba(30, 18, 12, 0.95), rgba(16, 10, 6, 0.98));
  border: 1.5px solid rgba(220, 176, 98, 0.56);
  border-radius: 9px;
  padding: 4px 5px;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 5px;
  flex-shrink: 0;
}

.me-panel[data-kingdom="wei"] { border-right: 3px solid #4e88ff; }
.me-panel[data-kingdom="shu"] { border-right: 3px solid #e64b4b; }
.me-panel[data-kingdom="wu"] { border-right: 3px solid #48c96c; }
.me-panel[data-kingdom="qun"] { border-right: 3px solid #b8ab8e; }
.me-panel[data-kingdom="shen"] { border-right: 3px solid #f0b840; }

.me-panel.is-chained {
  box-shadow: inset 0 0 0 1.5px rgba(125, 214, 255, 0.72), 0 0 10px rgba(96, 192, 255, 0.4);
}
.me-panel.is-drunk {
  box-shadow: inset 0 0 14px rgba(255, 162, 52, 0.55), 0 0 12px rgba(255, 152, 42, 0.45);
}

.me-skills-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 3px;
}

.me-skills {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
}

.me-portrait-card {
  width: clamp(74px, calc(var(--stage-w) * 0.098), 104px);
  border-radius: 7px;
  border: 1.5px solid rgba(232, 190, 107, 0.65);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  background: #140d09;
}

.me-nameplate {
  position: absolute;
  top: 2px;
  left: 2px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(14, 9, 6, 0.76);
  border: 1px solid rgba(232, 190, 107, 0.35);
  border-radius: 4px;
  padding: 2px 1px;
}

.me-vname {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: 11px;
  font-weight: 900;
  color: #ffefd2;
  line-height: 1;
}

.me-id-seal {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 3;
  font-size: 9.5px;
  padding: 1px 4px;
}

.me-hp-col {
  position: absolute;
  right: 2px;
  bottom: 3px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: rgba(12, 7, 5, 0.65);
  border-radius: 5px;
  padding: 2px 1px;
}

.hp-col .magatama-svg {
  width: 9px;
  height: 12px;
}

.me-panel.is-current {
  border-color: #f6c954;
  box-shadow: 0 0 14px rgba(246, 201, 84, 0.5);
}

.me-panel.target-valid {
  cursor: pointer;
  border-color: #5ee68a;
  box-shadow: 0 0 14px rgba(94, 230, 138, 0.75);
}

.me-panel.target-selected {
  border-color: #ffe270;
  box-shadow: 0 0 18px rgba(255, 226, 112, 0.95);
}

.me-stat-tag {
  font-size: 10px;
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
  text-align: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  padding: 1px 4px;
}

.skill-btn {
  min-height: 25px;
  width: 100%;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid rgba(212, 170, 96, 0.45);
  background: linear-gradient(180deg, #4b3523, #2b1d12);
  color: #f8ebd4;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.skill-btn.sk-locked {
  border-style: dashed;
  border-color: rgba(182, 168, 146, 0.55);
}
.skill-btn.sk-limited { border-color: #f07654; }
.skill-btn.sk-awake { border-color: #bd7ef5; }
.skill-btn.sk-lord { border-color: #f2c44d; }

.skill-btn.usable {
  background: linear-gradient(180deg, #d18d28, #8c510a);
  border-color: #ffe285;
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 208, 92, 0.5);
}

.skill-btn.selected {
  background: linear-gradient(180deg, #32995d, #1f653b);
  border-color: #93f7ba;
}

.skill-btn.sk-dynamic {
  border-color: #ffd56c;
}

.skill-btn:disabled {
  opacity: 0.54;
  cursor: default;
}

.hand-row {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  padding: 14px 6px 2px;
  gap: 4px;
}

/* CSS Card Rendering */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 8px;
  background: linear-gradient(175deg, #fcf5e6 0%, #ebd9b4 100%);
  color: #1c1c1e;
  border: 1.5px solid #9c7f50;
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 4px;
  overflow: hidden;
  box-shadow: -2px 3px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.card.red { color: #c42c26; }
.card.black { color: #1e1e23; }

.card-sha { background: linear-gradient(175deg, #fdf3ea, #f2cfb8); }
.card-fire_sha { background: linear-gradient(175deg, #fff1e6, #f7b897); border-color: #c95826; }
.card-thunder_sha { background: linear-gradient(175deg, #f3f0ff, #d4c6fa); border-color: #6b4ac4; }
.card-jiu { background: linear-gradient(175deg, #fff8e2, #efd18e); border-color: #b58524; }
.card-tiesuo { background: linear-gradient(175deg, #edf4fa, #cad9e6); }
.card-huogong { background: linear-gradient(175deg, #fff0e8, #f4bfa4); }
.card-shan { background: linear-gradient(175deg, #f3f8fc, #d8e5f2); }
.card-tao { background: linear-gradient(175deg, #fff3f5, #f5d8df); }

.card-strip {
  height: 4px;
  border-radius: 3px;
  width: 100%;
  z-index: 2;
}

.card.type-basic .card-strip { background: #d4943a; }
.card.type-trick .card-strip { background: #3676b8; }
.card.type-delay .card-strip { background: #8948b8; }
.card.type-equip .card-strip { background: #438a59; }

.card-art-wrap {
  position: absolute;
  inset: 14px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0.45;
  z-index: 1;
}

.card-art {
  width: 100%;
  height: 100%;
}

.card-corner {
  display: flex;
  flex-direction: column;
  line-height: 0.98;
  font-weight: 800;
  font-size: clamp(10.5px, calc(var(--stage-w) * 0.0135), 13.5px);
  z-index: 2;
}

.card-inner-frame {
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(176, 134, 62, 0.45);
  border-radius: 5px;
  pointer-events: none;
  z-index: 1;
}

.card-title {
  text-align: center;
  font-family: "KaiTi", "STKaiti", serif;
  font-weight: 900;
  font-size: clamp(13.5px, calc(var(--stage-w) * 0.0165), 17px);
  line-height: 1.12;
  color: #21160b;
  white-space: pre-line;
  overflow-wrap: anywhere;
  z-index: 2;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75);
}

.card-title.card-title-4 {
  font-size: clamp(11.5px, calc(var(--stage-w) * 0.014), 14px);
  line-height: 1.1;
  letter-spacing: 1px;
}

.card-title.card-title-long {
  font-size: clamp(10.5px, calc(var(--stage-w) * 0.0118), 12.5px);
  line-height: 1.1;
}

.card-foot {
  display: flex;
  justify-content: flex-end;
  z-index: 2;
}

.card-sub {
  font-size: 9px;
  font-weight: 800;
  color: #5f482b;
  background: rgba(186, 146, 78, 0.18);
  padding: 0 3px;
  border-radius: 3px;
  white-space: nowrap;
}

.card.selectable {
  border-color: #f5ce62;
  box-shadow: 0 0 10px rgba(245, 206, 98, 0.65);
}

.card.selectable:hover {
  transform: translateY(-6px);
  z-index: 10;
}

.card.selected {
  transform: translateY(-14px);
  border-color: #ffe885;
  box-shadow: 0 0 18px rgba(255, 232, 133, 0.98);
  z-index: 15;
}

.card.dimmed {
  opacity: 0.45;
  cursor: default;
}

.card-back {
  width: clamp(46px, calc(var(--stage-w) * 0.06), 64px);
  height: clamp(66px, calc(var(--stage-h) * 0.16), 92px);
  border-radius: 8px;
  background: #4e1510 url('/img/card-back.jpg') center center / cover no-repeat;
  border: 2px solid #d4aa60;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f7da96;
  font-weight: 900;
  font-size: 16px;
  text-shadow: 0 1px 4px #000;
  cursor: pointer;
}

/* Drawers (Log / Chat) */
.drawer {
  position: absolute;
  top: 40px;
  right: calc(8px + var(--safe-r));
  width: min(320px, calc(var(--stage-w) * 0.86));
  max-height: min(calc(var(--stage-h) * 0.62), calc(var(--stage-h) - var(--dock-h) - 52px));
  background: rgba(18, 13, 9, 0.95);
  border: 1px solid var(--gold);
  border-radius: 12px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 6px;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: var(--gold-bright);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-damage { color: #ffaba1; }
.log-heal { color: #a7f4bf; }
.log-skill { color: #ffe294; }

/* Modal & Codex */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px calc(10px + var(--safe-r)) 8px calc(10px + var(--safe-l));
}

.modal-box {
  max-width: min(860px, calc(var(--stage-w) * 0.94));
  max-height: calc(var(--stage-h) * 0.92);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  background: #231810;
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.8);
}

.modal-title {
  margin: 0;
  font-size: 16px;
  color: var(--gold-bright);
}

.modal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.general-choice {
  width: clamp(134px, calc(var(--stage-w) * 0.2), 174px);
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid var(--panel-border);
  border-radius: 10px;
  padding: 7px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  color: var(--text-main);
}

.general-choice:hover {
  border-color: var(--gold-bright);
  background: rgba(255, 220, 140, 0.12);
}

.general-choice-head {
  display: flex;
  align-items: center;
  gap: 7px;
}

.general-choice-sub {
  font-size: 11px;
  color: var(--gold);
}

.pack-pill {
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  color: #e6d5b8;
}

.general-skill-item {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

.codex-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.codex-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
  max-height: calc(var(--stage-h) * 0.62);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  padding-right: 4px;
}

.general-card-hero {
  width: clamp(136px, calc(var(--stage-w) * 0.2), 176px);
  padding: 0 0 7px;
  overflow: hidden;
  gap: 3px;
}

.general-hero-banner {
  position: relative;
  width: 100%;
  height: 108px;
  overflow: hidden;
  border-bottom: 1px solid rgba(232, 190, 107, 0.35);
  background: linear-gradient(180deg, #251a12, #120b07);
}
.general-hero-banner[data-kingdom="wei"] { background: linear-gradient(180deg, #1b3668, #0c162b); }
.general-hero-banner[data-kingdom="shu"] { background: linear-gradient(180deg, #521515, #170707); }
.general-hero-banner[data-kingdom="wu"] { background: linear-gradient(180deg, #123e29, #06150e); }
.general-hero-banner[data-kingdom="qun"] { background: linear-gradient(180deg, #423319, #140f08); }
.general-hero-banner[data-kingdom="shen"] { background: linear-gradient(180deg, #351c52, #0e0717); }

.general-hero-kseal {
  position: absolute;
  top: 5px;
  left: 5px;
}

.general-hero-pack {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(18, 12, 8, 0.78);
  border: 1px solid rgba(232, 190, 107, 0.5);
}

.general-choice-meta {
  padding: 2px 8px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.general-card-hero .general-skill-item {
  padding: 0 8px;
}

.quick-chat-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.quick-chat-bar .btn {
  min-height: 26px;
  padding: 2px 7px;
  font-size: 11px;
}

.poxi-status {
  text-align: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold-bright);
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 4px 8px;
}

.codex-card {
  width: 100%;
  cursor: default;
}

.codex-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.codex-search {
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(14, 9, 6, 0.85);
  color: var(--text-main);
  font-size: 13px;
}

.codex-pack-tabs {
  gap: 4px;
}

.codex-skill-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  flex-wrap: wrap;
}

.codex-sk-btn {
  border: 1px solid rgba(232, 190, 107, 0.55);
  background: rgba(120, 74, 24, 0.45);
  color: #ffe399;
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.codex-sk-btn:hover { background: rgba(178, 108, 28, 0.72); }

.codex-voice-row {
  padding: 4px 8px 0;
  display: flex;
  justify-content: flex-end;
}

.damage-preview-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(168, 36, 24, 0.88);
  border: 1px solid rgba(255, 196, 110, 0.78);
  color: #ffe8a3;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.mark-pingding { background: rgba(190, 88, 22, 0.85); color: #fff1cc; }
.mark-longyin { background: rgba(188, 42, 34, 0.88); color: #ffe4b5; }
.mark-fengyin { background: rgba(44, 112, 178, 0.88); color: #e2f2ff; }

.guanxing-zones {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guanxing-zone {
  background: rgba(0, 0, 0, 0.28);
  border: 1px dashed var(--panel-border);
  border-radius: 10px;
  padding: 8px;
}

.guanxing-zone h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--gold);
}

.gameover-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.gameover-table th, .gameover-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}

/* Tooltip */
.tooltip {
  position: absolute;
  z-index: 900;
  max-width: 260px;
  background: rgba(14, 10, 7, 0.96);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-main);
  pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.65);
}

/* Compact Horizontal Stage (Phones in Portrait-Rotated OR Native Landscape <= 480px Height) */
body.compact-stage .game-table {
  --dock-h: clamp(106px, calc(var(--stage-h) * 0.305), 124px);
}
body.compact-stage #screen-lobby {
  padding: 6px calc(12px + var(--safe-r)) 6px calc(12px + var(--safe-l));
}
body.compact-stage .lobby-card {
  width: min(560px, calc(var(--stage-w) - 24px));
  padding: 12px 18px;
}
body.compact-stage .lobby-header {
  margin-bottom: 10px;
  gap: 10px;
}
body.compact-stage .logo-seal {
  width: 44px;
  height: 44px;
  font-size: 24px;
}
body.compact-stage .form-row {
  margin-bottom: 10px;
}
body.compact-stage .lobby-actions {
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
}
body.compact-stage .lobby-actions > #btn-create-room {
  flex: 1;
}
body.compact-stage .lobby-actions > .join-box {
  flex: 1.3;
}
body.compact-stage .lobby-footer {
  margin-top: 8px;
}
body.compact-stage .btn {
  min-height: 36px;
}
body.compact-stage input[type="text"],
body.compact-stage input[type="number"],
body.compact-stage select {
  min-height: 36px;
}

body.compact-stage .room-header {
  padding: 4px 10px;
}
body.compact-stage .room-code {
  font-size: 18px;
}
body.compact-stage .room-body {
  grid-template-columns: 1fr 1.25fr;
  gap: 8px;
}
body.compact-stage .room-seats {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
}
body.compact-stage .panel-box {
  padding: 6px 9px;
  gap: 5px;
}
body.compact-stage .settings-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 6px;
}
body.compact-stage .settings-grid input,
body.compact-stage .settings-grid select {
  min-height: 28px;
  padding: 2px 6px;
  font-size: 12px;
}
body.compact-stage .room-chat-box {
  min-height: 58px;
}

body.compact-stage .modal-box {
  padding: 10px 12px;
  gap: 6px;
}
body.compact-stage .general-grid {
  flex-wrap: nowrap;
  justify-content: flex-start;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
  padding: 2px 2px 6px;
}
body.compact-stage .general-grid .general-card-hero {
  flex: 0 0 auto;
  width: clamp(136px, calc(var(--stage-w) * 0.19), 162px);
  padding: 0 0 6px;
  gap: 3px;
}
body.compact-stage .general-hero-banner {
  height: 78px;
}
body.compact-stage .codex-grid {
  max-height: calc(var(--stage-h) * 0.56);
}

body.compact-stage .fx-cutin { top: 34%; }
body.compact-stage .center-arena { top: 40%; }
body.compact-stage .opp-panel {
  width: clamp(114px, calc(var(--stage-w) * 0.148), 156px);
  min-height: 74px;
}
body.compact-stage .me-equips-rack {
  width: clamp(92px, calc(var(--stage-w) * 0.122), 120px);
  gap: 2px;
}
body.compact-stage .equip-slot {
  min-height: 20px;
  padding: 1px 4px;
  font-size: 9.5px;
}
body.compact-stage .me-panel {
  width: clamp(164px, calc(var(--stage-w) * 0.228), 214px);
  padding: 3px 4px;
}
body.compact-stage .me-portrait-card {
  width: 78px;
}
body.compact-stage .skill-btn {
  min-height: 24px;
  font-size: 11px;
  padding: 2px 5px;
}
body.compact-stage .prompt-bar {
  bottom: calc(var(--dock-h) + 4px);
  padding: 3px 8px;
  width: min(560px, calc(var(--stage-w) * 0.84));
}
body.compact-stage .prompt-actions .btn {
  min-height: 30px;
  padding: 3px 10px;
  font-size: 12px;
}
body.compact-stage .hand-row {
  padding: 12px 4px 2px;
}

body.narrow-stage .opp-panel {
  width: clamp(98px, calc(var(--stage-w) * 0.145), 144px);
}
