/* 修仙人生重開錄 · 水墨暗金主題樣式 */
:root {
  --bg-deep: #0b0e13;
  --bg-card: #131822;
  --bg-card-hover: #1a2130;
  --bg-input: #0e131b;
  --border: #263042;
  --border-gold: rgba(212, 175, 55, 0.45);
  --text-main: #e8e4d9;
  --text-muted: #9aa3b2;
  --gold: #d4af37;
  --gold-bright: #f3d27a;
  --jade: #34d399;
  --crimson: #f87171;
  --rarity-common: #94a3b8;
  --rarity-rare: #60a5fa;
  --rarity-epic: #c084fc;
  --rarity-legendary: #fbbf24;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --font-serif: "Noto Serif TC", "Songti TC", "Source Han Serif TC", "PMingLiU", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang HK", "Microsoft JhengHei", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(212, 175, 55, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 100%, rgba(52, 211, 153, 0.06) 0%, transparent 45%);
  color: var(--text-main);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--gold-bright);
  text-decoration: none;
}

.hidden {
  display: none !important;
}

/* Layout */
.app-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 16px 16px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 18px 60px;
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 18px;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-mini {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  color: var(--gold-bright);
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-gold {
  color: var(--gold-bright);
  border-color: var(--border-gold);
  background: rgba(212, 175, 55, 0.1);
}

.badge-jade {
  color: var(--jade);
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.1);
}

.badge-danger {
  color: var(--crimson);
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-gold {
  border-color: var(--border-gold);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1b2332;
  color: var(--text-main);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.btn:hover:not(:disabled) {
  background: #243045;
  border-color: #3a4a66;
  transform: translateY(-1px);
}

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

.btn-primary {
  background: linear-gradient(135deg, #b88c27 0%, #e0ba56 100%);
  color: #120f07;
  border-color: #f3d27a;
  font-weight: 700;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #ca9c30 0%, #f0cd6c 100%);
  border-color: #ffe394;
}

.btn-jade {
  background: rgba(52, 211, 153, 0.16);
  border-color: rgba(52, 211, 153, 0.5);
  color: #6ee7b7;
}

.btn-jade:hover:not(:disabled) {
  background: rgba(52, 211, 153, 0.25);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fca5a5;
}

.btn-danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.24);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 1.05rem;
  letter-spacing: 2px;
}

/* Title Screen */
.hero-box {
  text-align: center;
  padding: 46px 24px 36px;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
}

.hero-emblem {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 2px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--gold-bright);
  background: radial-gradient(circle, rgba(212, 175, 55, 0.18) 0%, transparent 72%);
  box-shadow: 0 0 28px rgba(212, 175, 55, 0.2);
}

.hero-title {
  font-family: var(--font-serif);
  font-size: 2.35rem;
  letter-spacing: 6px;
  color: var(--gold-bright);
  margin-bottom: 10px;
  text-shadow: 0 2px 16px rgba(212, 175, 55, 0.25);
}

.hero-subtitle {
  color: var(--text-muted);
  letter-spacing: 4px;
  font-size: 0.98rem;
  margin-bottom: 24px;
}

.announcement-bar {
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: #e9d7a3;
  margin: 0 auto 28px;
  max-width: 600px;
  text-align: left;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Section Headers */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--gold-bright);
  letter-spacing: 2px;
}

/* Talents Grid */
.talents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.talent-card {
  background: #10151f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
  text-align: left;
}

.talent-card:hover {
  background: #171f2e;
  transform: translateY(-2px);
}

.talent-card.selected {
  box-shadow: 0 0 0 2px var(--gold-bright), 0 6px 20px rgba(212, 175, 55, 0.22);
  background: rgba(212, 175, 55, 0.09);
}

.talent-card[data-rarity="common"] { border-left: 4px solid var(--rarity-common); }
.talent-card[data-rarity="rare"] { border-left: 4px solid var(--rarity-rare); }
.talent-card[data-rarity="epic"] { border-left: 4px solid var(--rarity-epic); }
.talent-card[data-rarity="legendary"] {
  border-left: 4px solid var(--rarity-legendary);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.08), #10151f 65%);
}

.talent-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 6px;
}

.talent-name {
  font-weight: 700;
  font-size: 0.96rem;
}

.rarity-tag {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 4px;
  font-weight: 600;
}
.rarity-common { color: var(--rarity-common); background: rgba(148, 163, 184, 0.14); }
.rarity-rare { color: var(--rarity-rare); background: rgba(96, 165, 250, 0.15); }
.rarity-epic { color: var(--rarity-epic); background: rgba(192, 132, 252, 0.16); }
.rarity-legendary { color: var(--rarity-legendary); background: rgba(251, 191, 36, 0.18); }

.talent-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Stat Allocation */
.points-banner {
  text-align: center;
  padding: 12px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 1rem;
}

.points-banner strong {
  color: var(--gold-bright);
  font-size: 1.45rem;
  margin: 0 4px;
}

.stat-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #10151f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.stat-info {
  flex: 1;
  min-width: 170px;
}

.stat-label {
  font-weight: 700;
  font-size: 0.98rem;
}

.stat-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

.stat-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #1d2637;
  color: var(--text-main);
  font-size: 1.1rem;
  cursor: pointer;
}

.stat-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold-bright);
}

.stat-val {
  min-width: 58px;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
}

.stat-bonus {
  font-size: 0.8rem;
  color: var(--jade);
  margin-left: 3px;
}

.stat-bonus.neg {
  color: var(--crimson);
}

/* Gameplay HUD */
.hud-panel {
  position: sticky;
  top: 8px;
  z-index: 20;
  background: rgba(15, 20, 29, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.realm-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--gold-bright);
  font-weight: 700;
}

.progress-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

@media (max-width: 560px) {
  .progress-grid {
    grid-template-columns: 1fr;
  }
}

.bar-wrap label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.bar-track {
  height: 8px;
  background: #1d2534;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.bar-cult { background: linear-gradient(90deg, #b88c27, #f5d67b); }
.bar-life { background: linear-gradient(90deg, #059669, #34d399); }
.bar-life.low { background: linear-gradient(90deg, #b91c1c, #f87171); }

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.82rem;
}

.hud-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text-muted);
}

.hud-pill strong {
  color: var(--text-main);
  margin-left: 3px;
}

/* Timeline Log */
.timeline-box {
  background: #0f141d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  height: 460px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  scroll-behavior: smooth;
}

.log-item {
  background: #141b27;
  border: 1px solid #222c3e;
  border-left: 3px solid #475569;
  border-radius: 8px;
  padding: 10px 13px;
  animation: fadeSlide 0.25s ease-out;
}

.log-item.cat-奇遇 { border-left-color: var(--rarity-epic); background: rgba(192, 132, 252, 0.05); }
.log-item.cat-突破 { border-left-color: var(--gold-bright); background: rgba(212, 175, 55, 0.08); }
.log-item.cat-劫難 { border-left-color: var(--crimson); background: rgba(248, 113, 113, 0.06); }
.log-item.cat-抉擇 { border-left-color: var(--rarity-rare); background: rgba(96, 165, 250, 0.07); }
.log-item.cat-結局 { border-left-color: var(--jade); background: rgba(52, 211, 153, 0.1); }

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

.log-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--gold);
  margin-bottom: 4px;
  gap: 8px;
}

.log-title {
  font-weight: 700;
  color: var(--text-main);
  margin-right: 6px;
}

.log-text {
  font-family: var(--font-serif);
  font-size: 0.96rem;
  color: #e4e0d5;
  line-height: 1.65;
}

.delta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
}

.delta-chip {
  font-size: 0.74rem;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.delta-pos { color: #6ee7b7; background: rgba(52, 211, 153, 0.13); }
.delta-neg { color: #fca5a5; background: rgba(248, 113, 113, 0.14); }

/* Choice Prompt */
.choice-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.choice-btn {
  text-align: left;
  padding: 10px 13px;
  border-radius: 8px;
  border: 1px solid rgba(96, 165, 250, 0.45);
  background: rgba(30, 58, 138, 0.22);
  color: #dbeafe;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
  font-family: inherit;
}

.choice-btn:hover {
  background: rgba(59, 130, 246, 0.35);
  border-color: #93c5fd;
  transform: translateX(3px);
}

/* Gameplay Control Bar */
.play-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.play-controls-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Summary Screen */
.summary-hero {
  text-align: center;
  padding: 20px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.summary-rank {
  font-family: var(--font-serif);
  font-size: 2rem;
  color: var(--gold-bright);
  letter-spacing: 4px;
  margin: 6px 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.summary-stat {
  background: #10151f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px;
  text-align: center;
}

.summary-stat .k {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.summary-stat .v {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold-bright);
  margin-top: 3px;
}

/* History Modal / List */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.history-item {
  background: #10151f;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------- ADMIN STYLES ---------------- */
.login-box {
  max-width: 420px;
  margin: 64px auto;
}

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

.form-group label {
  display: block;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text-main);
  font-size: 0.9rem;
  font-family: inherit;
}

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

textarea.code-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  min-height: 360px;
  line-height: 1.5;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 9px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.92rem;
  font-family: inherit;
}

.tab-btn.active {
  color: var(--gold-bright);
  border-bottom-color: var(--gold-bright);
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.table-wrap {
  overflow-x: auto;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

table.admin-table th,
table.admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
}

table.admin-table th {
  color: var(--gold-bright);
  font-weight: 600;
  white-space: nowrap;
}

table.admin-table input[type="text"],
table.admin-table input[type="number"] {
  padding: 6px 8px;
  font-size: 0.84rem;
}

.list-card {
  background: #10151f;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #162030;
  border: 1px solid var(--border-gold);
  color: var(--text-main);
  padding: 11px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 200;
  font-size: 0.9rem;
  animation: fadeSlide 0.2s ease;
}

.toast.error {
  border-color: var(--crimson);
  color: #fecaca;
}

.toast.success {
  border-color: var(--jade);
  color: #a7f3d0;
}

.footer-note {
  margin-top: auto;
  text-align: center;
  padding-top: 24px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
