/* ============================================================
   CK48 Reunion 30 — 2D Pixel Banquet Hall Styling
   Zero-dependency retro canvas + pixel RPG HUD interface
   ============================================================ */

:root {
  --bg-dark: #0f141c;
  --bg-panel: rgba(18, 24, 38, 0.94);
  --bg-panel-border: rgba(245, 158, 11, 0.35);
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --gold-glow: rgba(245, 158, 11, 0.45);
  --khaki: #c8b082;
  --red-seal: #c8302b;
  --red-seal-bg: rgba(200, 48, 43, 0.15);
  --blue-badge: #2563eb;
  --green-badge: #16a34a;
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --text-light-dim: #cbd5e1;

  --f-body: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-serif: 'Noto Serif TC', serif;
  --f-pixel: 'Silkscreen', 'JetBrains Mono', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--f-body);
  color: var(--text-main);
  overscroll-behavior: none;
}

/* ================= Canvas Container ================= */
#canvas-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #0f141c;
}

#pixel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: grab;
}

#pixel-canvas:active {
  cursor: grabbing;
}

/* ================= Top HUD Bar ================= */
.pixel-hud {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}

.hud-main-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  flex-shrink: 0;
}

.hud-group-left {
  flex-shrink: 1;
  min-width: 0;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 4px 10px 4px 7px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

.hud-brand__logo {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gold);
}

.hud-brand__info h1 {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.badge-pixel {
  font-family: var(--f-pixel);
  font-size: 9.5px;
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #1a0f02;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: none;
}

/* Status Bars Widget */
.hud-status-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 4px 10px;
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
}

.status-label {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

.status-value {
  font-family: var(--f-pixel);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold-light);
}

.meter-track {
  width: 50px;
  height: 7px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.meter-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.meter-sobriety {
  background: linear-gradient(90deg, #10b981, #f59e0b);
}

.meter-nostalgia {
  background: linear-gradient(90deg, #e11d48, #ec4899);
}

/* HUD Buttons & Dropdown */
.hud-select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--gold-light);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  outline: none;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  max-width: 190px;
}

.hud-select option {
  background: #18202c;
  color: #fff;
}

.hud-btn {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  border-color: var(--gold);
  color: var(--gold-light);
  transform: translateY(-1px);
}

.hud-btn.highlight {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(217, 119, 6, 0.5));
  border-color: var(--gold);
  color: #fff;
  font-weight: 700;
}

.hud-btn.highlight:hover {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.5), rgba(217, 119, 6, 0.7));
}

.hud-btn-collapse {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(245, 158, 11, 0.35);
  color: var(--gold-light);
}

/* Secondary Actions Dropdown Menu */
.hud-dropdown-wrap {
  position: relative;
  display: inline-block;
  pointer-events: auto;
}

.hud-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: rgba(15, 23, 42, 0.96);
  border: 1.5px solid var(--gold);
  border-radius: 8px;
  padding: 5px;
  display: none;
  flex-direction: column;
  gap: 3px;
  min-width: 145px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  z-index: 35;
  animation: bannerSlideIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.hud-dropdown-wrap.active .hud-dropdown-menu {
  display: flex;
}

.hud-menu-item {
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 5px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.hud-menu-item:hover {
  background: rgba(245, 158, 11, 0.2);
  color: var(--gold-light);
}

.hud-menu-item.highlight {
  color: var(--gold-light);
  font-weight: 700;
}

/* Floating Collapse Tab (Visible when HUD is collapsed) */
.hud-collapse-tab {
  display: none;
  pointer-events: auto;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--gold);
  border-top: none;
  color: var(--gold-light);
  font-family: var(--f-body);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 14px 4px;
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
}

.hud-collapse-tab:hover {
  background: rgba(245, 158, 11, 0.25);
  color: #fff;
  transform: translateY(2px);
}

/* Collapsed State for pixel-hud */
.pixel-hud.is-collapsed .hud-main-bar {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-24px);
  max-height: 0;
  overflow: hidden;
  margin: 0;
  gap: 0;
}

.pixel-hud.is-collapsed .hud-collapse-tab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 1180px) and (min-width: 769px) {
  .hide-small-desktop {
    display: none !important;
  }
  .hud-select {
    max-width: 155px;
  }
}

/* ================= Bottom Helper Banner & Interaction Pill ================= */
.interaction-prompt {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  visibility: hidden;
}

.interaction-prompt.show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.prompt-pill {
  pointer-events: auto;
  background: rgba(18, 24, 38, 0.95);
  border: 2px solid var(--gold);
  border-radius: 999px;
  padding: 9px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px var(--gold-glow);
  cursor: pointer;
  animation: promptPulse 1.8s ease-in-out infinite;
}

.prompt-icon {
  font-size: 18px;
}

.prompt-text {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.prompt-key {
  font-family: var(--f-pixel);
  font-size: 11px;
  background: var(--gold);
  color: #1a0f02;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 800;
}

@keyframes promptPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* ================= Dialogue Box (Retro RPG Style) ================= */
.dialogue-overlay {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 24px));
  z-index: 30;
  display: none;
}

.dialogue-overlay.active {
  display: block;
  animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.dialogue-box {
  background: rgba(22, 29, 44, 0.96);
  border: 3px solid var(--gold);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7), inset 0 0 0 2px rgba(245, 158, 11, 0.2);
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.dialogue-avatar {
  width: 68px;
  height: 68px;
  flex: none;
  background: #111722;
  border: 2px solid var(--bg-panel-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.dialogue-avatar canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.dialogue-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dialogue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialogue-speaker {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.speaker-badge {
  font-size: 11px;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid var(--gold);
  color: var(--gold-light);
  padding: 1px 6px;
  border-radius: 4px;
}

.dialogue-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}

.dialogue-close:hover {
  color: #fff;
}

.dialogue-text {
  font-size: 15px;
  line-height: 1.6;
  color: #fff;
  min-height: 48px;
}

.dialogue-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.choice-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.12s ease;
}

.choice-btn:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--gold);
  color: var(--gold-light);
  transform: translateX(4px);
}

.choice-btn.highlight {
  background: rgba(245, 158, 11, 0.22);
  border-color: var(--gold);
  color: var(--gold-light);
}

.choice-btn.highlight:hover {
  background: rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.choice-meta {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ================= Table Details Modal ================= */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  width: min(580px, 100%);
  max-height: min(85vh, 720px);
  background: #182130;
  border: 2px solid var(--gold);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(245, 158, 11, 0.05);
}

.modal-title h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-title p {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 22px;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

/* Stats 3-Col Grid */
.table-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.table-stat-card {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.table-stat-card.stat-green { border-color: rgba(34, 197, 94, 0.3); }
.table-stat-card.stat-yellow { border-color: rgba(245, 158, 11, 0.3); }
.table-stat-card.stat-gray { border-color: rgba(148, 163, 184, 0.3); }

.stat-num {
  font-family: var(--f-pixel);
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* Progress bar */
.modal-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-light-dim);
}

.progress-track {
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
}

.progress-seg {
  height: 100%;
}
.progress-seg.reg { background: #22c55e; }
.progress-seg.pending { background: #f59e0b; }
.progress-seg.missing { background: #64748b; }

/* Filter Tabs */
.filter-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 4px;
}

.tab-btn.active {
  background: rgba(245, 158, 11, 0.2);
  color: var(--gold-light);
}

/* Members chips */
.members-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px 0;
}

.member-chip {
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.member-chip.status-reg {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.12);
}

.member-chip.status-pending {
  border-color: rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.12);
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-nav-group {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--bg-panel-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn:hover {
  border-color: var(--gold);
  color: var(--gold-light);
}

.modal-action-btn {
  background: linear-gradient(135deg, var(--gold), #d97706);
  border: none;
  color: #1a0f02;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ================= Attendance Card Souvenir Modal ================= */
.souvenir-card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#souvenir-canvas {
  width: 100%;
  max-width: 440px;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.souvenir-actions {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

/* ================= Mobile Virtual Joystick ================= */
.mobile-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 25;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
}

.virtual-joystick {
  width: 110px;
  height: 110px;
  background: rgba(18, 24, 38, 0.7);
  border: 2px solid rgba(245, 158, 11, 0.4);
  border-radius: 50%;
  position: relative;
  pointer-events: auto;
  backdrop-filter: blur(4px);
  touch-action: none;
}

.joystick-thumb {
  width: 46px;
  height: 46px;
  background: var(--gold);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.mobile-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
}

.mobile-act-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--bg-panel);
  border: 2px solid var(--gold);
  color: #fff;
  font-size: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  touch-action: manipulation;
}

.mobile-act-btn span.label {
  font-size: 9px;
  font-weight: 700;
  color: var(--gold-light);
  margin-top: -2px;
}

.mobile-act-btn:active {
  transform: scale(0.92);
  background: rgba(245, 158, 11, 0.3);
}

/* ================= Notification Toast ================= */
.toast-msg {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 24, 38, 0.94);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-msg.show {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}

/* ================= Swordsman Welcome / Quest Banner ================= */
.swordsman-banner {
  position: absolute;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.94);
  border: 1.5px solid var(--gold);
  border-radius: 999px;
  padding: 7px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 28;
  pointer-events: auto;
  cursor: pointer;
  animation: bannerSlideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: calc(100vw - 32px);
  text-align: center;
  white-space: nowrap;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.swordsman-banner.fade-out {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-14px);
}

.banner-top-row {
  display: contents;
}

.banner-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  margin-left: 6px;
  transition: all 0.15s ease;
}

.banner-close-btn:hover {
  background: rgba(245, 158, 11, 0.25);
  color: var(--gold-light);
}

.swordsman-banner__badge {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.swordsman-banner__text {
  font-size: 12px;
  color: #e2e8f0;
}

.swordsman-banner__text strong {
  color: #38bdf8;
}
}

@keyframes bannerSlideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-14px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ================= Collapsible Edge Keyboard Shortcuts Guide ================= */
.keyboard-guide-card {
  position: fixed;
  top: 76px;
  right: 0;
  z-index: 45;
  display: flex;
  align-items: flex-start;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.keyboard-guide-card.collapsed {
  transform: translateX(100%);
}

.guide-tab-handle {
  position: absolute;
  left: -36px;
  top: 10px;
  background: rgba(18, 24, 38, 0.95);
  border: 1.5px solid var(--gold);
  border-right: none;
  border-radius: 8px 0 0 8px;
  color: var(--gold-light);
  cursor: pointer;
  padding: 8px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: -4px 4px 14px rgba(0, 0, 0, 0.6);
  transition: all 0.2s ease;
  user-select: none;
}

.guide-tab-handle:hover {
  background: rgba(245, 158, 11, 0.22);
  color: #fff;
  transform: translateX(-2px);
}

.guide-tab-handle .guide-tab-icon {
  font-size: 14px;
}

.guide-tab-handle .guide-tab-text {
  writing-mode: vertical-rl;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1.1;
}

.guide-content-wrapper {
  background: rgba(18, 24, 38, 0.96);
  border: 1.5px solid var(--gold);
  border-right: none;
  border-radius: 12px 0 0 12px;
  padding: 12px 16px;
  min-width: 280px;
  max-width: 330px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7), 0 0 20px rgba(245, 158, 11, 0.15);
  backdrop-filter: blur(12px);
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-light);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.guide-close-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.guide-close-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.guide-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.guide-item kbd {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--gold-light);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.guide-item span {
  color: #e2e8f0;
  text-align: right;
  font-size: 12px;
}

.guide-footer {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

/* ================= High School Trivia Toasting Modal ================= */
.trivia-card {
  max-width: 520px;
  border: 2px solid var(--gold);
}

.trivia-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.trivia-subject-badge {
  display: inline-flex;
  align-self: flex-start;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid var(--gold);
  color: var(--gold-light);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.trivia-question {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.5;
  background: rgba(15, 23, 42, 0.6);
  border-left: 3px solid var(--gold);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
}

.trivia-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trivia-choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.85);
  border: 1.5px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  color: #f1f5f9;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  user-select: none;
}

.trivia-choice-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--gold);
  transform: translateX(4px);
}

.trivia-choice-btn:active {
  transform: scale(0.98);
}

.trivia-choice-btn .choice-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.25);
  color: var(--gold-light);
  font-family: monospace;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.trivia-feedback {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
  animation: fadeIn 0.3s ease;
}

.trivia-feedback.correct {
  background: rgba(22, 163, 74, 0.2);
  border: 1px solid #16a34a;
  color: #86efac;
}

.trivia-feedback.wrong {
  background: rgba(220, 38, 38, 0.2);
  border: 1px solid #dc2626;
  color: #fca5a5;
}

/* ================= 90s Classic Hits Music Trivia Modal ================= */
.music-trivia-card {
  max-width: 540px;
  border: 2px solid #f59e0b;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.75), 0 0 25px rgba(245, 158, 11, 0.25);
}

.music-trivia-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.music-player-box {
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.4);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.music-equalizer {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 2px 0;
}

.music-equalizer .eq-bar {
  width: 7px;
  height: 6px;
  background: linear-gradient(to top, #f59e0b, #ef4444, #f43f5e);
  border-radius: 3px;
  transition: height 0.12s cubic-bezier(0.4, 0, 0.2, 1);
}

.music-equalizer.playing .eq-bar:nth-child(1) { animation: eqPulse 0.45s ease-in-out infinite alternate; }
.music-equalizer.playing .eq-bar:nth-child(2) { animation: eqPulse 0.60s ease-in-out infinite alternate 0.1s; }
.music-equalizer.playing .eq-bar:nth-child(3) { animation: eqPulse 0.40s ease-in-out infinite alternate 0.15s; }
.music-equalizer.playing .eq-bar:nth-child(4) { animation: eqPulse 0.55s ease-in-out infinite alternate 0.05s; }
.music-equalizer.playing .eq-bar:nth-child(5) { animation: eqPulse 0.70s ease-in-out infinite alternate 0.2s; }
.music-equalizer.playing .eq-bar:nth-child(6) { animation: eqPulse 0.48s ease-in-out infinite alternate 0.12s; }
.music-equalizer.playing .eq-bar:nth-child(7) { animation: eqPulse 0.62s ease-in-out infinite alternate 0.18s; }
.music-equalizer.playing .eq-bar:nth-child(8) { animation: eqPulse 0.50s ease-in-out infinite alternate 0.08s; }

@keyframes eqPulse {
  0% { height: 6px; opacity: 0.6; }
  50% { height: 28px; opacity: 1; }
  100% { height: 36px; opacity: 1; }
}

.music-status-text {
  font-size: 13.5px;
  font-weight: 700;
  color: #fef08a;
  letter-spacing: 0.03em;
  text-align: center;
}

.music-control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(245, 158, 11, 0.18);
  border: 1.5px solid var(--gold);
  color: var(--gold-light);
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.music-control-btn:hover {
  background: rgba(245, 158, 11, 0.35);
  transform: translateY(-1px);
}

.music-control-btn:active {
  transform: scale(0.96);
}

.music-next-btn {
  width: 100%;
  padding: 12px 18px;
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  color: #ffffff;
  border: 1px solid #f59e0b;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14.5px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.4);
  transition: all 0.2s ease;
}

.music-next-btn:hover {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5);
}

.music-next-btn:active {
  transform: scale(0.98);
}

/* ================= Retro Title Splash Screen Overlay ================= */
.title-screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: radial-gradient(circle at center, rgba(30, 20, 25, 0.96) 0%, rgba(10, 14, 22, 0.98) 100%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(12px);
  overflow-y: auto;
  transition: opacity 0.5s ease;
}

.title-screen-overlay.active {
  display: flex;
}

.title-screen-overlay.fading-out {
  opacity: 0;
  pointer-events: none;
}

.title-screen-card {
  max-width: 580px;
  width: 100%;
  background: rgba(18, 24, 38, 0.95);
  border: 2px solid var(--gold);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(245, 158, 11, 0.15);
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  position: relative;
}

.title-crest {
  font-size: 40px;
  margin-bottom: -6px;
}

.title-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.15em;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 4px 14px;
  border-radius: 999px;
}

.title-main {
  font-family: var(--f-serif);
  font-size: clamp(24px, 6vw, 34px);
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 12px rgba(245, 158, 11, 0.4);
  margin-top: -4px;
}

.title-sub {
  font-size: 13.5px;
  color: #cbd5e1;
  margin-top: -8px;
}

.title-event-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 6px 0;
}

.title-event-info .info-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  color: #e2e8f0;
}

.title-quests-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  text-align: left;
  margin: 4px 0 10px 0;
}

.quest-preview-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
}

.quest-preview-item .q-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.quest-preview-item strong {
  font-size: 12px;
  color: var(--gold-light);
  display: block;
}

.quest-preview-item p {
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.35;
  margin-top: 2px;
}

.title-start-btn {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  border: 2px solid #fef08a;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  padding: 14px 36px;
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.4), 0 0 12px rgba(245, 158, 11, 0.3);
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  animation: pulseGlow 2s infinite ease-in-out;
}

.title-start-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 8px 30px rgba(245, 158, 11, 0.6);
}

.title-start-btn:active {
  transform: scale(0.96);
}

.title-sound-hint {
  font-size: 11px;
  color: var(--text-dim);
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.4);
  }
  50% {
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.7), 0 0 20px rgba(254, 240, 138, 0.5);
  }
}

/* ================= Mobile Menu Drawer ================= */
.mobile-drawer-card {
  max-width: 440px;
  width: 100%;
}

.mobile-drawer-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.drawer-action-btn {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 8px;
  padding: 12px 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.drawer-action-btn.highlight {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--gold);
  color: var(--gold-light);
}

.drawer-action-btn:hover {
  background: rgba(245, 158, 11, 0.25);
}

/* ================= Mobile Controls & Responsive Overhaul ================= */
.mobile-only {
  display: none !important;
}

.joystick-arrows {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.j-arrow {
  position: absolute;
  font-size: 10px;
  color: rgba(245, 158, 11, 0.45);
}

.j-up { top: 6px; left: 50%; transform: translateX(-50%); }
.j-down { bottom: 6px; left: 50%; transform: translateX(-50%); }
.j-left { left: 6px; top: 50%; transform: translateY(-50%); }
.j-right { right: 6px; top: 50%; transform: translateY(-50%); }

.mobile-act-btn.btn-primary {
  width: 62px;
  height: 62px;
  background: linear-gradient(135deg, #b45309 0%, #78350f 100%);
  border-color: #fef08a;
}

.mobile-act-btn.btn-secondary {
  width: 52px;
  height: 52px;
}

.mobile-act-btn.btn-tertiary {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .mobile-only {
    display: inline-flex !important;
  }

  /* Compact Top HUD on Mobile */
  .pixel-hud {
    top: env(safe-area-inset-top, 8px);
    left: 8px;
    right: 8px;
    gap: 4px;
  }

  .hud-brand {
    padding: 3px 8px;
  }

  .hud-brand__logo {
    width: 22px;
    height: 22px;
  }

  .hud-brand__info h1 {
    font-size: 11.5px;
  }

  .badge-pixel {
    display: none;
  }

  .hud-status-card {
    padding: 3px 6px;
    gap: 6px;
  }

  .status-item .status-label {
    display: none;
  }

  .meter-track {
    width: 32px;
    height: 5px;
  }

  .hud-btn {
    font-size: 11px;
    padding: 5px 8px;
  }

  /* ================= Full-Width Top Notification Card (手機版滿寬頂部訊息通知) ================= */
  .swordsman-banner {
    top: calc(env(safe-area-inset-top, 8px) + 44px);
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: none;
    border-radius: 10px;
    padding: 7px 11px 8px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: rgba(15, 23, 42, 0.96);
    border: 1.5px solid var(--gold);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
    white-space: normal;
    text-align: left;
    backdrop-filter: blur(12px);
    z-index: 28;
  }

  .swordsman-banner.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
  }

  .banner-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .swordsman-banner__badge {
    font-size: 11px;
    font-weight: 800;
    color: var(--gold-light);
    letter-spacing: 0.02em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
  }

  .banner-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #cbd5e1;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    margin-left: 0;
  }

  .banner-close-btn:active {
    background: rgba(245, 158, 11, 0.35);
    color: #fff;
  }

  .swordsman-banner__text {
    font-size: 11px;
    line-height: 1.45;
    color: #f1f5f9;
    text-align: left;
    white-space: normal;
    word-break: break-word;
  }

  .swordsman-banner__text strong {
    color: #38bdf8;
    font-weight: 700;
  }

  /* Full-width Top Toast Notification */
  .toast-msg {
    top: calc(env(safe-area-inset-top, 8px) + 44px);
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 11px;
    line-height: 1.4;
    text-align: center;
    white-space: normal;
    background: rgba(18, 24, 38, 0.96);
    border: 1px solid rgba(245, 158, 11, 0.7);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
  }

  .toast-msg.show {
    opacity: 1;
    transform: translateY(2px);
  }

  /* ================= Bottom Interaction Prompt Card (手機版底部提示卡) ================= */
  .interaction-prompt {
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: none;
    z-index: 25;
  }

  .prompt-pill {
    width: 100%;
    border-radius: 9px;
    padding: 6px 10px;
    gap: 6px;
    box-sizing: border-box;
    justify-content: center;
    background: rgba(15, 23, 42, 0.95);
    border: 1.5px solid var(--gold);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
  }

  .prompt-icon {
    font-size: 13px;
    flex-shrink: 0;
  }

  .prompt-text {
    font-size: 11px;
    line-height: 1.35;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    color: #f1f5f9;
  }

  .prompt-key {
    display: none !important;
  }

  /* Controls & Overlays */
  .mobile-controls {
    display: flex;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: 14px;
    right: 14px;
  }

  .dialogue-overlay {
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    right: 8px;
    width: auto;
  }

  .dialogue-box {
    padding: 10px 12px;
    gap: 10px;
    border-radius: 10px;
  }

  .dialogue-avatar {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
  }

  .dialogue-text {
    font-size: 12px;
    line-height: 1.45;
  }

  .title-quests-preview {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .keyboard-guide-card {
    top: 48px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

