/* =========================================================
   MỘNG TU TIÊN - CỔ PHONG ĐỈNH CAO ARCHITECTURE (2026)
   Cảm hứng Mộng Tu Tiên (mongtutien.online): Tiên Cảnh, Tụ Linh Trận, Thần Thú, Lực Chiến
   ========================================================= */

:root {
  --bg-deep: #07090e;
  --panel-bg: rgba(14, 19, 28, 0.88);
  --panel-border: rgba(212, 180, 106, 0.3);
  --panel-hover: rgba(20, 26, 38, 0.95);
  
  --gold: #d4b46a;
  --gold-bright: #fbbf24;
  --gold-glow: rgba(212, 180, 106, 0.38);
  
  --jade: #7fc7a3;
  --jade-bright: #34d399;
  --jade-glow: rgba(127, 199, 163, 0.35);
  
  --red: #d96a6a;
  --red-seal: #b91c1c;
  --purple: #c084fc;
  
  --ink: #f1ede1;
  --ink-muted: #9e9786;
  --line: rgba(212, 180, 106, 0.22);
  --line-dashed: rgba(212, 180, 106, 0.16);
  
  --font-title: 'Cinzel Decorative', 'Noto Serif SC', serif;
  --font-serif: 'Spectral', 'Noto Serif SC', serif;
  --font-sans: 'Be Vietnam Pro', sans-serif;
  
  --radius: 10px;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  background: 
    linear-gradient(180deg, rgba(6, 8, 14, 0.72) 0%, rgba(9, 13, 21, 0.85) 100%),
    url('assets/bg.jpg') center/cover no-repeat fixed;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13.5px;
  line-height: 1.5;
}

/* 1. MIST DRIFT ANIMATION */
.mist-drift {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: 
    radial-gradient(800px 300px at 30% 60%, rgba(255, 255, 255, 0.035), transparent 70%),
    radial-gradient(800px 300px at 70% 40%, rgba(255, 255, 255, 0.025), transparent 70%);
  animation: drift 35s linear infinite;
  z-index: 1;
}

@keyframes drift {
  0% { transform: translateX(0); }
  100% { transform: translateX(-60px); }
}

#qi-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2;
}

/* FLOATING TEXT LAYER (+Tu Vi, Damage numbers floating) */
#floating-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99999;
  overflow: hidden;
}

.floating-text {
  position: absolute;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.5px;
  pointer-events: none;
  animation: floatUpFade 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes floatUpFade {
  0% { transform: translate(-50%, 0) scale(0.8); opacity: 0; }
  15% { transform: translate(-50%, -15px) scale(1.18); opacity: 1; }
  100% { transform: translate(-50%, -75px) scale(1); opacity: 0; }
}

/* LIGHTNING TRIBULATION */
#lightning-overlay {
  position: fixed;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
  transition: opacity 0.04s ease;
}

#lightning-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9998;
}

.screen-shake {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-4px, -2px, 0); }
  20%, 80% { transform: translate3d(5px, 4px, 0); }
  30%, 50%, 70% { transform: translate3d(-7px, -4px, 0); }
  40%, 60% { transform: translate3d(7px, 4px, 0); }
}

/* =========================================================
   TOP NAV BAR
   ========================================================= */
.top-nav-bar {
  position: relative;
  z-index: 10;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(10, 14, 22, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

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

.ancient-seal {
  width: 34px;
  height: 34px;
  background: radial-gradient(circle, #b91c1c 0%, #7f1d1d 100%);
  border: 1.5px solid #ef4444;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.55);
  transform: rotate(-2deg);
}

.brand-text .main-title {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 2.5px;
  color: var(--gold);
  text-shadow: 0 0 12px var(--gold-glow);
}

.brand-text .sub-title {
  font-family: var(--font-serif);
  font-size: 0.68rem;
  color: var(--ink-muted);
  letter-spacing: 0.5px;
  display: block;
  margin-top: -3px;
}

/* Đạo Lịch Tử Vi */
.dao-calendar-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(212, 180, 106, 0.08);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: 999px;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  color: var(--gold);
}

.cal-season {
  color: var(--jade);
  font-weight: 600;
}

/* Tốc Độ Tu Luyện Thời Gian Thực (Mộng Tu Tiên Signature) */
.speed-indicator-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, rgba(212, 180, 106, 0.18), rgba(20, 26, 38, 0.7));
  border: 1px solid var(--gold);
  padding: 4px 12px;
  border-radius: 999px;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: #fffbeb;
  box-shadow: 0 0 12px var(--gold-glow);
  animation: pulseGold 2.5s infinite alternate;
}

@keyframes pulseGold {
  0% { border-color: rgba(212, 180, 106, 0.4); box-shadow: 0 0 6px var(--gold-glow); }
  100% { border-color: var(--gold-bright); box-shadow: 0 0 16px var(--gold-glow); }
}

.speed-highlight {
  color: var(--gold-bright);
  font-weight: 800;
  font-size: 0.95rem;
}
.speed-unit { font-size: 0.7rem; color: var(--ink-muted); }

.nav-utils {
  display: flex;
  gap: 6px;
}

.btn-top-util {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  transition: all 0.2s;
  font-weight: 600;
}

.btn-top-util:hover {
  background: rgba(212, 180, 106, 0.2);
  border-color: var(--gold);
}

.btn-top-danger:hover {
  background: rgba(217, 106, 106, 0.2);
  border-color: var(--red);
}

/* =========================================================
   3-COLUMN GAME WRAPPER (DESKTOP)
   ========================================================= */
.game-wrapper {
  position: relative;
  z-index: 5;
  height: calc(100vh - 52px);
  display: grid;
  grid-template-columns: 290px 1fr 340px;
  gap: 12px;
  padding: 12px 14px;
  overflow: hidden;
}

/* CHUNG CHO CẢ 3 CỘT (PANELS) */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4) inset, 0 10px 35px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  overflow-y: auto;
  gap: 12px;
}

.panel::-webkit-scrollbar { width: 5px; }
.panel::-webkit-scrollbar-thumb { background: rgba(212, 180, 106, 0.25); border-radius: 3px; }

.panel-header h2 {
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-sub-section h3 {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: var(--gold);
  letter-spacing: 1px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =========================================================
   CỘT TRÁI: ĐẠO THỂ & ATTRIBUTES
   ========================================================= */
.identity-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.hero-avatar-frame {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  border: 2px solid var(--gold);
  box-shadow: 0 0 14px var(--gold-glow);
  overflow: hidden;
}

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

.hero-avatar-halo {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px dashed var(--gold);
  animation: rotateHalo 25s linear infinite;
}

@keyframes rotateHalo { 100% { transform: rotate(360deg); } }

.name-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.p-name {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 800;
  color: #fffbeb;
  letter-spacing: 0.5px;
}

.p-sect {
  font-size: 0.72rem;
  color: var(--jade);
  background: rgba(127, 199, 163, 0.12);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid rgba(127, 199, 163, 0.3);
}

.realm-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.p-realm {
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
}

/* LỰC CHIẾN BADGE */
.combat-power-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(180, 83, 9, 0.45));
  border: 1px solid #f59e0b;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.76rem;
  color: #fffbeb;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.35);
  margin-top: 4px;
}

.power-val {
  font-family: var(--font-title);
  color: #fde047;
  font-size: 0.88rem;
  letter-spacing: 0.5px;
}

/* Tâm cảnh */
.state-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 6px;
}

.state-calm { color: var(--jade); font-weight: 700; }

/* Bars */
.bars-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-unit {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.bar-track {
  height: 6px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

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

.exp-gradient { background: linear-gradient(90deg, #d97706, #fbbf24, #34d399); }
.hp-gradient { background: linear-gradient(90deg, #b91c1c, #ef4444); }
.mp-gradient { background: linear-gradient(90deg, #0284c7, #38bdf8); }

/* Attributes table rows */
.attributes-table {
  display: flex;
  flex-direction: column;
}

.attr-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line-dashed);
}

.attr-row .k {
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.attr-row .v { color: var(--ink); }
.v.gold { color: var(--gold); font-weight: 700; }
.v.jade { color: var(--jade); font-weight: 700; }
.v.purple { color: var(--purple); font-weight: 700; }

/* Bản Mệnh Trang Bị Slots */
.equip-grid-slots {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.equip-slot-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  transition: all 0.2s;
}

.equip-slot-card:hover {
  border-color: var(--gold);
  background: rgba(212, 180, 106, 0.08);
}

.slot-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  border: 1.5px solid var(--gold);
  overflow: hidden;
  box-shadow: 0 0 12px var(--gold-glow);
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.equip-slot-card:hover .slot-thumb img {
  transform: scale(1.08);
}


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

.slot-meta {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.slot-type {
  font-size: 0.68rem;
  color: var(--ink-muted);
}

.slot-val {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* =========================================================
   CỘT GIỮA: ĐẠI ĐIỆN TU HÀNH & SỬ KÝ
   ========================================================= */
.panel-center {
  padding: 14px 18px;
  gap: 14px;
}

/* SÂN KHẤU TIÊN CẢNH (HERO STAGE) */
.cultivation-scene {
  flex: 0 0 210px;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: 
    radial-gradient(circle at 50% 60%, rgba(212, 180, 106, 0.15) 0%, rgba(10, 14, 22, 0.92) 80%),
    url('assets/bg.jpg') center/cover no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 35px rgba(0, 0, 0, 0.85), 0 0 15px var(--gold-glow);
}

.scene-cultivator-wrap {
  width: 95px;
  height: 95px;
  border-radius: 50%;
  border: 2px solid var(--gold-bright);
  box-shadow: 0 0 22px var(--gold-glow);
  position: relative;
  overflow: hidden;
  animation: heroFloat 3.5s ease-in-out infinite alternate;
}

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

.scene-cultivator-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-lotus-glow {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 20px;
  background: radial-gradient(ellipse at bottom, rgba(251, 191, 36, 0.8), transparent);
  pointer-events: none;
}

.scene-meta-box {
  text-align: center;
  margin-top: 8px;
  z-index: 2;
}

.scene-realm-title {
  font-family: var(--font-title);
  font-size: 1.55rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 8px;
  text-shadow: 0 0 16px var(--gold-glow);
}

.scene-realm-sub {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: #f1ede1;
  letter-spacing: 3px;
  font-weight: 600;
}

.scene-quote {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  font-style: italic;
  color: #7dd3fc;
  margin-top: 3px;
}

/* Action Grid (Nút bấm cổ phong) */
.cultivation-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  background: rgba(14, 18, 26, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.22s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.action-btn:hover {
  transform: translateY(-2px);
  border-color: var(--gold);
  box-shadow: 0 6px 20px rgba(212, 180, 106, 0.25);
}

.action-btn:active { transform: scale(0.97); }

.btn-main-txt {
  font-family: var(--font-serif);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.8px;
}

.btn-sub-txt {
  font-size: 0.68rem;
  color: var(--ink-muted);
}

.btn-qi-cultivate {
  background: linear-gradient(135deg, rgba(3, 105, 161, 0.35), rgba(15, 23, 42, 0.85));
  border-color: rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
}
.btn-meditate {
  background: linear-gradient(135deg, rgba(107, 33, 168, 0.35), rgba(15, 23, 42, 0.85));
  border-color: rgba(192, 132, 252, 0.45);
  color: #f3e8ff;
}
.btn-tribulation {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.4), rgba(15, 23, 42, 0.85));
  border-color: rgba(251, 191, 36, 0.55);
  color: #fffbeb;
}
.btn-rest-heal {
  background: linear-gradient(135deg, rgba(6, 95, 70, 0.35), rgba(15, 23, 42, 0.85));
  border-color: rgba(52, 211, 153, 0.45);
  color: #d1fae5;
}

/* Sử ký chronicle log */
.log-panel-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 180px;
  background: rgba(8, 10, 15, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.7);
}

.log-header {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  color: var(--gold);
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.log-hint {
  font-size: 0.7rem;
  color: var(--ink-muted);
  font-style: italic;
}

.chronicle-log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}

.chronicle-log::-webkit-scrollbar { width: 4px; }
.chronicle-log::-webkit-scrollbar-thumb { background: rgba(212, 180, 106, 0.25); border-radius: 2px; }

.log-entry {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  color: var(--ink);
  line-height: 1.45;
  border-bottom: 1px dashed rgba(212, 180, 106, 0.1);
  padding-bottom: 4px;
}

.log-entry.good { color: var(--jade); }
.log-entry.bad { color: var(--red); }
.log-entry.sys { color: var(--gold); font-weight: 600; }
.log-entry.hint { color: var(--ink-muted); font-style: italic; }

/* =========================================================
   CỘT PHẢI: HỆ THỐNG (TABS)
   ========================================================= */
.system-tabs-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.sys-tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-muted);
  font-family: var(--font-serif);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 2px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all 0.2s;
  white-space: nowrap;
}

.sys-tab-btn:hover { color: var(--gold); background: rgba(212, 180, 106, 0.08); }

.sys-tab-btn.active {
  background: rgba(212, 180, 106, 0.18);
  border-color: var(--gold);
  color: var(--gold-bright);
}

.sys-tab-content { display: none; }
.sys-tab-content.active { display: flex; flex-direction: column; gap: 10px; }

.sys-panel-intro h3 {
  font-family: var(--font-title);
  font-size: 0.88rem;
  color: var(--gold);
  letter-spacing: 1px;
}
.sys-panel-intro p {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

/* Furnace Hero Banner */
.furnace-hero-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: radial-gradient(circle at 30% 50%, rgba(234, 88, 12, 0.25) 0%, rgba(15, 20, 30, 0.85) 80%);
  border: 1px solid rgba(234, 88, 12, 0.4);
  border-radius: 8px;
  padding: 10px;
}

.furnace-img {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 14px rgba(234, 88, 12, 0.5);
  border: 1px solid #f97316;
}

.furnace-desc h4 {
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: #fb923c;
  letter-spacing: 1px;
}
.furnace-desc p {
  font-size: 0.7rem;
  color: var(--ink-muted);
}

/* Động Phủ Cards (Đặc trưng Mộng Tu Tiên) */
.dong-phu-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

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

.dp-title {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
}

.dp-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--jade);
  background: rgba(127, 199, 163, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(127, 199, 163, 0.3);
}

.dp-text {
  font-size: 0.72rem;
  color: var(--ink-muted);
  line-height: 1.4;
}

.dp-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--line-dashed);
}

.dp-cost {
  font-size: 0.74rem;
  color: var(--ink);
}

/* Sub nav toggles */
.craft-sub-nav {
  display: flex;
  gap: 6px;
}

.craft-toggle-btn {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  color: var(--ink-muted);
  padding: 6px;
  border-radius: 6px;
  font-family: var(--font-serif);
  font-size: 0.76rem;
  cursor: pointer;
}

.craft-toggle-btn.active {
  background: rgba(212, 180, 106, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}

/* BÍ CẢNH BANNER CARDS VỚI ẢNH NỀN THẬT */
.areas-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.area-card-banner {
  height: 95px;
  border-radius: 8px;
  position: relative;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  transition: all 0.25s ease;
}

.area-card-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(8, 11, 18, 0.94) 35%, rgba(8, 11, 18, 0.25) 100%);
  pointer-events: none;
}

.area-card-banner:hover {
  border-color: var(--gold-bright);
  box-shadow: 0 6px 20px rgba(212, 180, 106, 0.35);
  transform: translateY(-2px);
}

.area-card-banner.locked {
  filter: grayscale(0.9);
  opacity: 0.5;
}

.area-content-row {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.area-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.area-banner-title {
  font-family: var(--font-title);
  font-size: 0.88rem;
  font-weight: 800;
  color: #fffbeb;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}

.area-banner-desc {
  font-size: 0.7rem;
  color: var(--ink-muted);
}

.recipes-grid, .market-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recipe-card, .market-item-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  transition: all 0.2s;
}

.recipe-card:hover, .market-item-card:hover {
  border-color: var(--gold);
  background: rgba(212, 180, 106, 0.05);
}

.card-left-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.recipe-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  border: 1.5px solid var(--gold);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--gold-glow);
  transition: transform 0.25s ease;
}

.recipe-card:hover .recipe-thumb img, .market-item-card:hover .recipe-thumb img {
  transform: scale(1.08);
}


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


.card-title {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.card-desc {
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: 2px;
}

.card-reqs {
  font-size: 0.7rem;
  color: var(--jade);
  margin-top: 3px;
}

.btn-card-act {
  background: linear-gradient(135deg, rgba(212, 180, 106, 0.2), rgba(180, 83, 9, 0.3));
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-family: var(--font-serif);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 8px rgba(212, 180, 106, 0.2);
}

.btn-card-act:hover {
  background: rgba(212, 180, 106, 0.35);
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Inventory Grid */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.inventory-item {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.22s ease;
}

.inventory-item:hover {
  border-color: var(--gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px var(--gold-glow);
}

.item-thumb-box {
  width: 64px;
  height: 64px;
  margin: 0 auto 8px;
  border-radius: 8px;
  border: 1px solid rgba(212, 180, 106, 0.4);
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s ease, border-color 0.25s ease;
}

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

.item-count-badge {
  position: absolute;
  top: 4px; right: 4px;
  background: var(--gold-bright);
  color: #000;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  box-shadow: 0 0 6px rgba(0,0,0,0.8);
  z-index: 2;
}

.item-name {
  font-family: var(--font-serif);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}

.item-grade {
  font-size: 0.68rem;
  color: var(--jade);
}

.item-desc {
  font-size: 0.68rem;
  color: var(--ink-muted);
  line-height: 1.3;
}


/* =========================================================
   MOBILE DOCK (Bottom navigation on phones)
   ========================================================= */
.mobile-dock {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(10, 14, 22, 0.96);
  border-top: 1px solid var(--line);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  backdrop-filter: blur(10px);
}

.dock-btn {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-family: var(--font-serif);
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.dock-btn.active {
  color: var(--gold-bright);
}

/* =========================================================
   MODALS
   ========================================================= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 8, 0.88);
  backdrop-filter: blur(10px);
  z-index: 9990;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active { display: flex; }

.modal-box {
  background: linear-gradient(180deg, rgba(22, 28, 40, 0.98), rgba(12, 16, 24, 0.98));
  border: 1px solid var(--gold);
  border-radius: 10px;
  box-shadow: 0 0 35px rgba(0, 0, 0, 0.8), 0 0 15px var(--gold-glow);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.seal-mark {
  width: 42px;
  height: 42px;
  background: radial-gradient(circle, #b91c1c 0%, #7f1d1d 100%);
  border: 1.5px solid #ef4444;
  border-radius: 6px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 900;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
  transform: rotate(-3deg);
}

.seal-mark.red {
  background: radial-gradient(circle, #dc2626 0%, #450a0a 100%);
}

.modal-header h2 {
  font-family: var(--font-title);
  font-size: 1.25rem;
  color: var(--gold);
  letter-spacing: 1px;
}

.modal-sub {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  color: var(--ink-muted);
  font-style: italic;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row label {
  font-family: var(--font-serif);
  font-size: 0.78rem;
  color: var(--ink-muted);
}

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

input[type="text"], textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.85rem;
  outline: none;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}

.btn-seal {
  background: rgba(212, 180, 106, 0.15);
  border: 1px solid var(--gold);
  color: var(--gold);
  padding: 0 10px;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-serif);
  font-size: 0.78rem;
  white-space: nowrap;
}

.roll-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
}

.roll-unit {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.roll-k { font-family: var(--font-serif); font-size: 0.82rem; color: var(--ink-muted); }
.roll-v { font-family: var(--font-title); font-size: 0.95rem; font-weight: 700; }
.roll-desc { font-family: var(--font-serif); font-size: 0.74rem; color: var(--ink-muted); font-style: italic; margin-top: 2px; }

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

.modal-btn {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: all 0.2s;
}

.modal-btn.btn-primary {
  background: linear-gradient(135deg, #b45309, #78350f);
  border-color: var(--gold);
  color: #fffbeb;
}
.modal-btn.btn-primary:hover {
  box-shadow: 0 0 15px var(--gold-glow);
}

.modal-btn.btn-secondary {
  background: rgba(212, 180, 106, 0.12);
  color: var(--gold);
}

.modal-btn.btn-dark {
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink-muted);
}

/* Combat Modal Arena */
.combat-box { max-width: 520px; }

.combat-top-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-title);
  font-size: 0.85rem;
  color: var(--red);
  border-bottom: 1px dashed var(--line);
  padding-bottom: 6px;
}

.combat-stage {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: radial-gradient(circle, rgba(185, 28, 28, 0.15) 0%, rgba(8, 11, 16, 0.85) 75%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 10px;
}

.combat-fighter {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.fighter-avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--jade);
  background: radial-gradient(circle, #0284c7 0%, #082f49 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 0 12px var(--jade-glow);
  overflow: hidden;
  position: relative;
}

.fighter-avatar.enemy {
  border-color: var(--red);
  background: radial-gradient(circle, #b91c1c 0%, #450a0a 100%);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

.fighter-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}


.fighter-name {
  font-family: var(--font-title);
  font-size: 0.82rem;
  font-weight: 700;
}

.fighter-bar-track {
  width: 85%;
  height: 6px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.fighter-bar-fill.hp {
  height: 100%;
  background: linear-gradient(90deg, #dc2626, #ef4444);
}

.fighter-hp-val {
  font-size: 0.68rem;
  color: var(--ink-muted);
}

.combat-clash {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #7f1d1d;
  border: 2px solid var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.6);
}

.combat-feed {
  height: 110px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cb-line {
  font-family: var(--font-serif);
  font-size: 0.78rem;
}

.combat-btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.cb-act-btn {
  padding: 8px 4px;
  border-radius: 6px;
  font-family: var(--font-serif);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--line);
  color: #fff;
}

.cb-act-btn.sword { background: linear-gradient(135deg, #0284c7, #082f49); }
.cb-act-btn.fire { background: linear-gradient(135deg, #ea580c, #7c2d12); }
.cb-act-btn.heal { background: linear-gradient(135deg, #059669, #064e3b); }
.cb-act-btn.shield { background: linear-gradient(135deg, #d97706, #78350f); }
.cb-act-btn.flee { background: linear-gradient(135deg, #475569, #1e293b); }

/* Event Box */
.event-box { text-align: center; }
.event-sigil { font-size: 2.8rem; margin-bottom: -4px; }
.event-title { font-family: var(--font-title); font-size: 1.15rem; color: var(--gold); }
.event-text { font-family: var(--font-serif); font-size: 0.85rem; color: var(--ink); line-height: 1.5; margin-top: 6px; }
.event-gain-card {
  background: rgba(212, 180, 106, 0.1);
  border: 1px dashed var(--gold);
  border-radius: 6px;
  padding: 10px;
  font-family: var(--font-serif);
  font-size: 0.85rem;
  color: var(--gold-bright);
  margin-top: 10px;
  font-weight: 700;
}

/* =========================================================
   RESPONSIVE DESIGN CHO MÀN HÌNH NHỎ & ĐIỆN THOẠI
   ========================================================= */
@media (max-width: 959px) {
  html, body { overflow: auto; }
  
  .game-wrapper {
    height: auto;
    display: flex;
    flex-direction: column;
    padding-bottom: 64px;
  }

  .panel {
    height: auto;
    overflow: visible;
  }

  .mobile-dock {
    display: flex;
  }

  .game-wrapper.mobile-mode .panel {
    display: none;
  }
  .game-wrapper.mobile-mode .panel.mobile-active {
    display: flex;
  }
}
