/* ============================================================
   幽影捲軸 — 古典暗黑羊皮紙風 (Dark Fantasy Parchment)
   ============================================================ */
:root {
  --bg-obsidian: #0f0c0a;
  --bg-stone: #181310;
  --bg-parchment: #1f1914;
  --bg-parchment-light: #2a2119;

  --border-gold: #8c6b3f;
  --border-gold-bright: #d4af6a;
  --border-subtle: rgba(184, 146, 92, 0.25);

  --ink-primary: #efe2c6;
  --ink-secondary: #cbb996;
  --ink-muted: #968366;

  --accent-gold: #d9b061;
  --accent-crimson: #9e2a2b;
  --accent-crimson-bright: #e05353;
  --accent-emerald: #4b8f64;
  --accent-arcane: #6a8fd6;

  --font-display: "Cinzel", "Noto Serif TC", Georgia, serif;
  --font-body: "Noto Serif TC", "Songti TC", Georgia, serif;

  --shadow-deep: 0 14px 36px rgba(0, 0, 0, 0.65);
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg-obsidian);
  color: var(--ink-primary);
  font-family: var(--font-body);
  line-height: 1.65;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

body {
  background-image:
    radial-gradient(circle at 18% 12%, rgba(217, 176, 97, 0.08), transparent 45%),
    radial-gradient(circle at 82% 85%, rgba(168, 66, 36, 0.08), transparent 50%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 240, 210, 0.012) 0px,
      rgba(255, 240, 210, 0.012) 2px,
      transparent 2px,
      transparent 8px
    );
}

.ambient-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
  z-index: 0;
}

.ember-glow {
  position: fixed;
  top: -120px;
  left: 50%;
  transform: translateX(-50%);
  width: 680px;
  height: 240px;
  background: radial-gradient(ellipse, rgba(217, 155, 67, 0.14), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.hidden {
  display: none !important;
}

/* ==================== 頂部導覽 ==================== */
.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: linear-gradient(180deg, rgba(20, 15, 12, 0.96), rgba(15, 11, 9, 0.88));
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-crest {
  width: 40px;
  height: 40px;
  clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
  background: linear-gradient(145deg, #8b6532, #3b2610);
  color: #fff3d6;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.04em;
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
}

.brand-sub {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(140, 107, 63, 0.16);
  border: 1px solid var(--border-gold);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.room-pill strong {
  font-family: var(--font-display);
  color: var(--accent-gold);
  letter-spacing: 0.1em;
}

.dm-switcher {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 3px;
}

.dm-pill {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-body);
  font-size: 0.84rem;
  padding: 6px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.dm-pill:hover {
  color: var(--ink-primary);
}

.dm-pill.active {
  background: linear-gradient(135deg, #6e4f28, #453017);
  color: #fff2d6;
  box-shadow: inset 0 0 0 1px var(--border-gold-bright), 0 2px 10px rgba(0, 0, 0, 0.45);
}

/* ==================== 通用按鈕與羊皮紙卡片 ==================== */
button {
  font-family: var(--font-body);
}

.btn-primary {
  background: linear-gradient(180deg, #8b6532, #5a3e1c);
  color: #fff6e3;
  border: 1px solid var(--border-gold-bright);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 240, 200, 0.25);
  transition: transform 0.15s ease, filter 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

.btn-secondary {
  background: rgba(140, 107, 63, 0.2);
  color: var(--ink-primary);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(140, 107, 63, 0.35);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover {
  color: var(--ink-primary);
  border-color: var(--border-gold);
  background: rgba(217, 176, 97, 0.08);
}

.btn-tiny {
  background: rgba(217, 176, 97, 0.12);
  color: var(--accent-gold);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 4px 9px;
  font-size: 0.78rem;
  cursor: pointer;
}

.btn-tiny:hover {
  background: rgba(217, 176, 97, 0.24);
}

.parchment-panel {
  position: relative;
  background:
    radial-gradient(circle at top left, rgba(217, 176, 97, 0.06), transparent 55%),
    linear-gradient(180deg, var(--bg-parchment-light), var(--bg-parchment));
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-deep), inset 0 0 28px rgba(0, 0, 0, 0.45);
}

.parchment-panel::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(212, 175, 106, 0.14);
  border-radius: calc(var(--radius-md) - 3px);
  pointer-events: none;
}

/* ==================== 主容器與頁尾 ==================== */
.app-shell {
  position: relative;
  z-index: 2;
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 22px auto 28px;
  padding: 0 20px;
}

.site-footer {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 16px 20px 22px;
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-muted);
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.14em;
  background: rgba(12, 9, 7, 0.72);
}

/* ==================== 標題裝飾與表單 ==================== */
.ornament-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}

.ornament-header h2,
.ornament-header h3 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--accent-gold);
  letter-spacing: 0.1em;
}

.ornament-header h2 {
  font-size: 1.6rem;
}

.ornament-header.compact h3 {
  font-size: 1.15rem;
}

.ornament-line {
  flex: 1;
  max-width: 160px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-gold-bright), transparent);
}

.lead-text {
  text-align: center;
  color: var(--ink-secondary);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.86rem;
  color: var(--accent-gold);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
  width: 100%;
  padding: 10px 12px;
  background: rgba(12, 9, 7, 0.72);
  color: var(--ink-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.94rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-gold-bright);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

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

.mode-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px;
  background: rgba(12, 9, 7, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-card input {
  display: none;
}

.mode-card strong {
  color: var(--ink-primary);
  font-size: 0.9rem;
}

.mode-card span {
  font-size: 0.77rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

.mode-card.selected {
  border-color: var(--border-gold-bright);
  background: rgba(140, 107, 63, 0.18);
  box-shadow: 0 0 14px rgba(217, 176, 97, 0.14);
}

/* ==================== 冒險公會大廳（建立／加入房間） ==================== */
.lobby-screen {
  padding: 28px 32px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: stretch;
}

.lobby-card {
  padding: 20px 22px;
  background: rgba(12, 9, 7, 0.45);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.lobby-card h3 {
  margin: 0 0 6px;
  color: var(--accent-gold);
  font-size: 1.15rem;
}

.recent-rooms-box {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  flex: 1;
}

.recent-rooms-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.84rem;
  color: var(--ink-secondary);
}

.recent-rooms-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recent-room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: rgba(25, 19, 14, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.recent-room-meta {
  display: flex;
  flex-direction: column;
}

.recent-room-meta strong {
  color: var(--ink-primary);
}

.recent-room-meta span {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.feedback-bar {
  margin: 18px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(158, 42, 43, 0.22);
  border: 1px solid var(--accent-crimson-bright);
  color: #ffd0d5;
  font-size: 0.88rem;
  text-align: center;
}

/* ==================== 房間集結與創角畫面 ==================== */
.room-screen {
  padding: 24px 28px;
}

.room-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.room-tag {
  font-size: 0.78rem;
  color: var(--ink-muted);
  letter-spacing: 0.08em;
}

.room-banner h2 {
  margin: 2px 0 0;
  color: var(--accent-gold);
  font-family: var(--font-display);
  font-size: 1.5rem;
}

.room-code-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(10, 8, 6, 0.65);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
}

.room-code-label {
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.room-code-box strong {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.16em;
  color: var(--accent-gold);
}

.room-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  align-items: start;
}

.roster-panel {
  padding: 16px;
  background: rgba(12, 9, 7, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

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

.roster-head h3 {
  margin: 0;
  color: var(--accent-gold);
  font-size: 1rem;
}

.roster-head strong {
  color: var(--ink-primary);
  font-family: var(--font-display);
}

.roster-list {
  list-style: none;
  margin: 12px 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.roster-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(31, 25, 20, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.roster-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.roster-thumb {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: #140f0b;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.roster-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.roster-thumb svg {
  width: 26px;
  height: 26px;
}

.roster-info {
  min-width: 0;
}

.roster-info strong {
  display: block;
  font-size: 0.88rem;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster-info span {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.creation-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.9fr;
  gap: 22px;
  align-items: start;
}

.creation-submit-row {
  margin-top: 14px;
}

.stat-preview-box {
  background: rgba(12, 9, 7, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--ink-secondary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.stats-grid.compact {
  grid-template-columns: repeat(3, 1fr);
  margin: 14px 0;
}

.stat-cell {
  text-align: center;
  padding: 8px 4px;
  background: rgba(34, 26, 20, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.stat-cell .stat-label {
  font-size: 0.74rem;
  color: var(--ink-muted);
}

.stat-cell .stat-val {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink-primary);
}

.stat-cell .stat-mod {
  font-size: 0.78rem;
  color: var(--accent-gold);
}

/* 角色圖片上傳區 */
.portrait-upload-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upload-title {
  font-size: 0.86rem;
  color: var(--accent-gold);
  font-weight: 600;
}

.upload-dropzone {
  position: relative;
  height: 270px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-gold);
  border-radius: var(--radius-md);
  background: radial-gradient(circle at center, rgba(217, 176, 97, 0.1), rgba(10, 8, 6, 0.78));
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
  border-color: var(--border-gold-bright);
  background: radial-gradient(circle at center, rgba(217, 176, 97, 0.18), rgba(10, 8, 6, 0.82));
}

.portrait-preview {
  max-width: 90%;
  max-height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 12px rgba(217, 176, 97, 0.28));
}

.portrait-placeholder {
  text-align: center;
  padding: 16px;
  color: var(--ink-secondary);
}

.portrait-placeholder p {
  margin: 8px 0 2px;
  font-size: 0.9rem;
}

.upload-sub {
  font-size: 0.76rem;
  color: var(--ink-muted);
}

.default-class-art svg {
  width: 102px;
  height: 102px;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.65));
}

.upload-tip-box {
  padding: 10px 12px;
  background: rgba(217, 176, 97, 0.09);
  border-left: 3px solid var(--accent-gold);
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.upload-tip-box strong {
  color: var(--accent-gold);
}

.upload-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==================== 遊戲主畫面布局 ==================== */
.game-layout {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 20px;
  align-items: start;
}

.sheet-card {
  padding: 18px;
}

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

.mini-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--border-gold);
  background: radial-gradient(circle, #302419, #120d0a);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mini-avatar svg {
  width: 38px;
  height: 38px;
}

.sheet-name {
  margin: 0;
  font-size: 1.15rem;
  color: var(--accent-gold);
}

.sheet-meta {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.bars-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  margin-bottom: 4px;
  color: var(--ink-secondary);
}

.bar-track {
  height: 10px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 0.35s ease;
}

.hp-fill {
  background: linear-gradient(90deg, #8b2222, #d14545);
}

.mp-fill {
  background: linear-gradient(90deg, #355a9c, #6e99e8);
}

.enemy-fill {
  background: linear-gradient(90deg, #7a1c2d, #c93b52);
}

.quick-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric-chip {
  text-align: center;
  padding: 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.metric-chip span {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.metric-chip strong {
  font-size: 0.98rem;
  color: var(--ink-primary);
}

.party-section,
.inventory-section,
.dungeon-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.party-section h3,
.inventory-section h3,
.dungeon-section h3 {
  margin: 0 0 8px;
  font-size: 0.86rem;
  color: var(--accent-gold);
}

.party-order-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.party-order-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 9px;
  border-radius: 5px;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(184, 146, 92, 0.14);
  color: var(--ink-secondary);
}

.party-order-item.active-turn {
  border-color: var(--border-gold-bright);
  background: rgba(140, 107, 63, 0.28);
  color: #fff3d6;
  font-weight: 700;
}

.party-order-item.downed {
  opacity: 0.45;
  text-decoration: line-through;
}

.inventory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(184, 146, 92, 0.16);
  border-radius: 5px;
  font-size: 0.82rem;
}

.inv-item button {
  padding: 3px 8px;
  font-size: 0.74rem;
}

.dungeon-track {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.room-node {
  font-size: 0.74rem;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  color: var(--ink-muted);
  background: rgba(0, 0, 0, 0.3);
}

.room-node.visited {
  color: var(--ink-secondary);
  border-color: rgba(140, 107, 63, 0.45);
}

.room-node.current {
  color: #fff3d6;
  background: rgba(140, 107, 63, 0.35);
  border-color: var(--border-gold-bright);
  font-weight: 700;
}

/* ==================== 回合舞台 & 角色立繪登場特效 ==================== */
.adventure-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.turn-stage {
  position: relative;
  min-height: 220px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-gold);
  background:
    radial-gradient(circle at 20% 80%, rgba(217, 176, 97, 0.16), transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(158, 42, 43, 0.14), transparent 55%),
    linear-gradient(180deg, #1b1410, #100c09);
  box-shadow: var(--shadow-deep);
  overflow: hidden;
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  align-items: end;
  padding: 16px 20px 0;
  transition: border-color 0.35s ease, box-shadow 0.35s ease;
}

.turn-stage.player-turn {
  border-color: var(--border-gold-bright);
  box-shadow: var(--shadow-deep), 0 0 24px rgba(217, 176, 97, 0.16);
}

.turn-stage.enemy-turn {
  border-color: var(--accent-crimson-bright);
  box-shadow: var(--shadow-deep), 0 0 24px rgba(201, 59, 82, 0.22);
}

.portrait-spotlight {
  position: relative;
  height: 205px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transform: translateY(36px) scale(0.92);
  filter: grayscale(0.55) brightness(0.6);
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.45s ease;
  pointer-events: none;
}

.portrait-spotlight.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: grayscale(0) brightness(1);
}

.portrait-spotlight.standby {
  opacity: 0.22;
  transform: translateY(14px) scale(0.94);
  filter: grayscale(0.75) brightness(0.5);
}

.spotlight-aura {
  position: absolute;
  bottom: 0;
  width: 175px;
  height: 145px;
  background: radial-gradient(ellipse at bottom, rgba(217, 176, 97, 0.34), transparent 72%);
  pointer-events: none;
}

.spotlight-aura.enemy-aura {
  background: radial-gradient(ellipse at bottom, rgba(210, 62, 74, 0.38), transparent 72%);
}

.stage-art {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.stage-art img {
  max-height: 198px;
  max-width: 205px;
  object-fit: contain;
  filter:
    drop-shadow(0 0 10px rgba(217, 176, 97, 0.45))
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.8));
  animation: heroFloat 3.6s ease-in-out infinite;
}

.stage-art svg {
  height: 165px;
  width: 165px;
  filter:
    drop-shadow(0 0 10px rgba(217, 176, 97, 0.38))
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.8));
  animation: heroFloat 3.6s ease-in-out infinite;
}

.enemy-art svg {
  filter:
    drop-shadow(0 0 12px rgba(224, 83, 83, 0.48))
    drop-shadow(0 10px 18px rgba(0, 0, 0, 0.8));
}

.stage-art.action-pulse img,
.stage-art.action-pulse svg {
  animation: actionLunge 0.45s ease;
}

@keyframes heroFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes actionLunge {
  0% { transform: translateX(0) scale(1); }
  40% { transform: translateX(14px) scale(1.05); }
  100% { transform: translateX(0) scale(1); }
}

.turn-center-info {
  align-self: center;
  text-align: center;
  padding: 12px 10px 18px;
}

.turn-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(217, 176, 97, 0.16);
  color: var(--accent-gold);
  border: 1px solid var(--border-gold-bright);
  margin-bottom: 8px;
}

.turn-stage.enemy-turn .turn-badge {
  background: rgba(201, 59, 82, 0.22);
  color: #ffb3bc;
  border-color: var(--accent-crimson-bright);
}

.scene-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--ink-primary);
}

.scene-subtitle {
  margin: 6px 0 0;
  font-size: 0.86rem;
  color: var(--ink-secondary);
}

.enemy-status-box {
  margin: 12px auto 0;
  max-width: 280px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.48);
  border: 1px solid rgba(224, 83, 83, 0.45);
  border-radius: var(--radius-sm);
}

.enemy-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #ffccd2;
  margin-bottom: 5px;
}

.enemy-hp-text {
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--ink-muted);
}

/* ==================== 冒險日誌與擲骰區 ==================== */
.log-panel {
  display: flex;
  flex-direction: column;
  min-height: 460px;
  padding: 18px 20px;
}

.story-log {
  flex: 1;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-log::-webkit-scrollbar {
  width: 6px;
}

.story-log::-webkit-scrollbar-thumb {
  background: rgba(184, 146, 92, 0.35);
  border-radius: 999px;
}

.log-entry {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border-gold);
  background: rgba(12, 9, 7, 0.45);
  animation: fadeInLog 0.3s ease;
}

@keyframes fadeInLog {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.log-entry.dm {
  border-left-color: var(--accent-gold);
}

.log-entry.player {
  border-left-color: var(--accent-arcane);
  background: rgba(45, 65, 105, 0.16);
}

.log-entry.combat {
  border-left-color: var(--accent-crimson-bright);
  background: rgba(158, 42, 43, 0.15);
}

.log-entry.system {
  border-left-color: var(--accent-emerald);
  background: rgba(75, 143, 100, 0.12);
  font-size: 0.86rem;
}

.log-speaker {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}

.log-entry.player .log-speaker {
  color: #9ec0ff;
}

.log-entry.combat .log-speaker {
  color: #ff9ea8;
}

.log-text {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.95rem;
}

.dice-tray {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(10, 8, 6, 0.78);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.d20-die {
  width: 56px;
  height: 56px;
  clip-path: polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%);
  background: linear-gradient(145deg, #916934, #3d2810);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 900;
  color: #fff6e0;
  flex-shrink: 0;
  box-shadow: inset 0 0 12px rgba(255, 232, 175, 0.35);
}

.d20-die.rolling {
  animation: spinRoll 0.45s linear infinite;
}

.d20-die.crit-success {
  background: linear-gradient(145deg, #f3c969, #a67217);
  color: #241505;
  box-shadow: 0 0 18px rgba(243, 201, 105, 0.85);
}

.d20-die.crit-fail {
  background: linear-gradient(145deg, #cf3a3a, #5c1010);
  color: #ffe0e0;
  box-shadow: 0 0 18px rgba(224, 65, 65, 0.85);
}

@keyframes spinRoll {
  0% { transform: rotate(0deg) scale(1); }
  50% { transform: rotate(180deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

.dice-details {
  flex: 1;
}

.dice-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
}

.dice-breakdown {
  font-size: 0.84rem;
  color: var(--ink-secondary);
}

.dice-verdict {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(217, 176, 97, 0.16);
  color: var(--accent-gold);
}

.dice-verdict.crit-success {
  background: rgba(243, 201, 105, 0.25);
  color: #ffe08a;
  border: 1px solid #f3c969;
}

.dice-verdict.success {
  background: rgba(75, 143, 100, 0.25);
  color: #98e6b4;
}

.dice-verdict.fail,
.dice-verdict.crit-fail {
  background: rgba(180, 48, 48, 0.28);
  color: #ff9e9e;
}

/* 行動選項區 */
.action-dock {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.dm-mode-notice {
  font-size: 0.78rem;
  color: var(--ink-muted);
  margin-bottom: 10px;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.choice-btn {
  text-align: left;
  padding: 11px 13px;
  background: linear-gradient(180deg, rgba(44, 34, 25, 0.9), rgba(28, 21, 16, 0.95));
  color: var(--ink-primary);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--border-gold-bright);
  background: linear-gradient(180deg, rgba(66, 50, 34, 0.95), rgba(38, 28, 19, 0.95));
  transform: translateY(-1px);
}

.choice-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.choice-btn strong {
  font-size: 0.92rem;
  color: #fff2d6;
}

.choice-btn span {
  font-size: 0.76rem;
  color: var(--accent-gold);
}

.ai-input-form {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.ai-input-form input {
  flex: 1;
  padding: 10px 13px;
  background: rgba(10, 8, 6, 0.78);
  color: var(--ink-primary);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.92rem;
}

/* ==================== 設定彈窗 ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-card {
  width: 100%;
  max-width: 520px;
  padding: 20px 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.modal-header h3 {
  margin: 0;
  color: var(--accent-gold);
}

.modal-footer {
  margin-top: 18px;
  text-align: right;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 16px 0;
}

/* ==================== RWD 響應式 ==================== */
@media (max-width: 1040px) {
  .lobby-grid,
  .room-layout,
  .creation-grid,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .turn-stage {
    grid-template-columns: 120px 1fr 120px;
    padding: 12px 10px 0;
  }

  .portrait-spotlight {
    height: 150px;
  }

  .stage-art img,
  .stage-art svg {
    max-height: 145px;
    max-width: 115px;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 14px;
  }
  .lobby-screen,
  .room-screen {
    padding: 18px;
  }
  .form-row,
  .mode-cards,
  .choices-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
