/* style.css - Litenus: Primal Quest (2.5D Dino Action RPG Interface) */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-dark: #090d16;
  --panel-bg: rgba(15, 23, 42, 0.88);
  --panel-border: rgba(56, 189, 248, 0.28);
  --hp-gradient: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
  --mp-gradient: linear-gradient(90deg, #0284c7 0%, #38bdf8 100%);
  --exp-gradient: linear-gradient(90deg, #d97706 0%, #facc15 100%);
  --gold: #facc15;
  --accent: #38bdf8;
  --font-rpg: 'Press Start 2P', monospace;
  --font-ui: 'Outfit', sans-serif;
}

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

body {
  background: var(--bg-dark);
  color: #f1f5f9;
  font-family: var(--font-ui);
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

#game-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--bg-dark);
}

canvas#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--bg-dark);
  cursor: grab;
}

canvas#gameCanvas.rotating {
  cursor: grabbing;
}

/* =========================================
   GUI TOP LEFT: PLAYER STATUS (HP/MP/EXP)
========================================= */
.player-status-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  z-index: 10;
}

.avatar-container {
  position: relative;
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 2px solid #38bdf8;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.avatar-icon {
  font-size: 26px;
}

.level-badge {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: #f59e0b;
  color: #000;
  font-family: var(--font-rpg);
  font-size: 8px;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: bold;
  border: 1px solid #fef08a;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
}

.bars-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 170px;
}

.stat-bar-group {
  display: flex;
  flex-direction: column;
}

.stat-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}

.stat-bar-bg {
  width: 100%;
  height: 9px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.exp-bar-bg {
  height: 6px;
}

.hp-label { color: #f87171; }
.hp-val { color: #fca5a5; }
.mp-label { color: #38bdf8; }
.mp-val { color: #bae6fd; }
.exp-val { color: #fde047; font-size: 10px; }

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#hp-bar {
  background: var(--hp-gradient);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

#mp-bar {
  background: var(--mp-gradient);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

#exp-bar {
  background: var(--exp-gradient);
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.6);
}

/* =========================================
   GUI TOP RIGHT: MINIMAP, BAG & SELECTION
========================================= */
.top-right-hud {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 10;
}

.hud-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-pill-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  color: #f1f5f9;
  padding: 6px 12px;
  border-radius: 20px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: all 0.15s ease;
}

.hud-pill-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.35);
}

.hud-pill-btn:active {
  transform: translateY(0);
}

.coin-wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--font-rpg);
  font-size: 11px;
  color: #fde047;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.minimap-wrapper {
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

#minimap-canvas {
  display: block;
  border-radius: 6px;
  image-rendering: pixelated;
}

/* =========================================
   DINO COMPANION WIDGET (ซ้ายล่าง)
========================================= */
.pet-widget {
  position: absolute;
  bottom: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(245, 158, 11, 0.45);
  padding: 7px 12px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  z-index: 10;
}

.pet-icon {
  font-size: 24px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pet-desc {
  display: flex;
  flex-direction: column;
}

.pet-name {
  color: #f59e0b;
  font-weight: 700;
  font-size: 12px;
}

.pet-task {
  color: #94a3b8;
  font-size: 10px;
}

.mount-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  border: 1px solid #fef08a;
  padding: 6px 12px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.4);
}

.mount-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.5);
}

.mount-toggle-btn:active {
  transform: translateY(0);
}

/* =========================================
   BOTTOM CENTER: SKILL ACTION BAR
========================================= */
.action-bar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  padding: 8px 16px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.skill-slot {
  position: relative;
  width: 54px;
  height: 54px;
  background: #1e293b;
  border: 2px solid #475569;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.15s ease;
}

.skill-slot:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}

.skill-slot:active {
  transform: translateY(0);
}

.skill-icon {
  font-size: 24px;
  z-index: 1;
}

.key-hint {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-family: var(--font-rpg);
  font-size: 8px;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 3px;
  border-radius: 3px;
  z-index: 2;
}

.mana-cost-badge {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  font-weight: 700;
  color: #38bdf8;
  z-index: 2;
}

.cooldown-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 0%;
  background: rgba(0, 0, 0, 0.75);
  transition: height 0.05s linear;
  z-index: 3;
}

.cooldown-text {
  position: absolute;
  font-family: var(--font-rpg);
  font-size: 10px;
  color: #facc15;
  z-index: 4;
  display: none;
  text-shadow: 0 0 4px #000;
}

/* =========================================
   BOTTOM HINT CONTROLS
========================================= */
.controls-guide {
  position: absolute;
  bottom: 82px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.guide-badge {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2px 7px;
  border-radius: 5px;
  color: #38bdf8;
  font-family: var(--font-rpg);
  font-size: 9px;
}

/* =========================================
   RPG MODAL SYSTEM (INVENTORY & SELECTION)
========================================= */
.rpg-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.2s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  touch-action: pan-y !important;
  user-select: auto;
}

.rpg-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 7, 13, 0.75);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid rgba(56, 189, 248, 0.4);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: calc(100dvh - 24px);
  touch-action: pan-y !important;
  margin: auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(30, 41, 59, 0.7);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

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

.modal-title h3 {
  font-size: 16px;
  font-weight: 700;
  color: #f8fafc;
}

.modal-icon {
  font-size: 20px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}

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

.modal-footer {
  padding: 12px 20px;
  background: rgba(15, 23, 42, 0.9);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: #94a3b8;
}

.modal-footer.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* -----------------------------------------
   INVENTORY MODAL STYLING
----------------------------------------- */
.inventory-card {
  width: 780px;
}

.inventory-body {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  padding: 18px 20px;
  overflow-y: auto;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.equipment-doll {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
}

.paperdoll-avatar {
  width: 90px;
  height: 160px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.doll-emoji {
  font-size: 42px;
}

.doll-tribe {
  font-size: 11px;
  font-weight: 700;
}

.equip-slots-grid {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.equip-slot {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slot-label {
  font-size: 10px;
  color: #94a3b8;
  width: 50px;
}

.slot-box {
  flex: 1;
  height: 32px;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.slot-box:hover {
  border-color: #38bdf8;
  background: #334155;
}

.slot-box.filled {
  border-color: rgba(56, 189, 248, 0.6);
  background: rgba(30, 41, 59, 0.9);
}

.slot-item-icon {
  font-size: 16px;
}

.slot-item-img {
  width: 22px;
  height: 22px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
  flex-shrink: 0;
}

.cell-item-img {
  width: 36px;
  height: 36px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
}

.detail-sprite-img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px;
  flex-shrink: 0;
}

.card-header-dino {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dino-portrait-img {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 3px;
  flex-shrink: 0;
}

.slot-item-name {
  font-size: 11px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-plus {
  color: #64748b;
  font-size: 14px;
}

.stats-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-badge {
  font-size: 11px;
  color: #cbd5e1;
}

.stat-num {
  font-weight: 700;
  color: #facc15;
}

/* กระเป๋าเป้ 12 ช่อง */
.backpack-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.bag-cell {
  position: relative;
  aspect-ratio: 1;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.bag-cell.has-item:hover {
  border-color: #38bdf8;
  background: #334155;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.cell-icon {
  font-size: 26px;
}

.cell-badge {
  position: absolute;
  bottom: 3px;
  right: 5px;
  background: rgba(0, 0, 0, 0.8);
  color: #facc15;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
}

/* Tooltip รายละเอียดไอเทม */
.item-detail-panel {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: 120px;
}

.detail-empty {
  font-size: 11px;
  color: #64748b;
  text-align: center;
  padding-top: 35px;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.detail-icon {
  font-size: 24px;
}

.detail-name {
  font-size: 13px;
  font-weight: 700;
}

.detail-eng {
  font-size: 10px;
  color: #94a3b8;
}

.detail-desc {
  font-size: 11px;
  color: #e2e8f0;
  margin-bottom: 8px;
  line-height: 1.4;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.stat-pill {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #38bdf8;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.detail-lore {
  font-size: 10px;
  font-style: italic;
  color: #94a3b8;
  margin-bottom: 10px;
}

.detail-action-row {
  display: flex;
  justify-content: flex-end;
}

.btn-action-primary {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  border: 1px solid #38bdf8;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.btn-action-secondary {
  background: #334155;
  color: #cbd5e1;
  border: 1px solid #64748b;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

/* -----------------------------------------
   SELECTION MODAL STYLING (TRIBE & DINO)
----------------------------------------- */
.selection-card {
  width: 860px;
}

.selection-body {
  padding: 16px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.category-title {
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.tribes-grid,
.dinos-grid {
  display: grid;
  gap: 12px;
}

.tribes-grid {
  grid-template-columns: repeat(4, 1fr);
}

.dinos-grid {
  grid-template-columns: repeat(3, 1fr);
}

.selection-box {
  position: relative;
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 14px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.selection-box:hover {
  border-color: rgba(56, 189, 248, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.selection-box.active {
  border-color: #facc15;
  background: rgba(30, 41, 59, 0.95);
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.4);
}

.card-badge {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
}

.card-subtitle,
.card-role {
  font-size: 10px;
  font-weight: 600;
}

.card-subtitle { color: #94a3b8; }

.card-desc {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.35;
  margin: 2px 0 6px 0;
}

.card-perks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.perk-tag {
  background: rgba(255, 255, 255, 0.08);
  font-size: 9px;
  color: #38bdf8;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 600;
}

.card-special {
  font-size: 10px;
  color: #fde047;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 6px;
  border-radius: 5px;
}

.card-stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  margin-top: 4px;
}

.btn-confirm-genesis {
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff;
  border: 1px solid #86efac;
  padding: 8px 20px;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.4);
}

.btn-confirm-genesis:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(34, 197, 94, 0.5);
}

.btn-confirm-genesis:active {
  transform: translateY(0);
}

/* ========================================================
   LUMIVARA-INSPIRED RETRO FANTASY STYLES & COMPONENTS
   ======================================================== */

/* HUD Pixel Art Icons & Badges */
.hud-btn-pixel-icon {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
  vertical-align: middle;
}

.hud-pill-btn {
  position: relative;
}

.hud-notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: radial-gradient(circle at 40% 35%, #ff5252, #dc2626);
  border: 1.5px solid #fff;
  border-radius: 999px;
  color: #fff;
  font-family: var(--font-rpg);
  font-size: 8px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.8);
  animation: pulse-badge 1.6s infinite ease-in-out;
}

.hud-notif-badge.hidden {
  display: none !important;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); box-shadow: 0 0 12px rgba(239, 68, 68, 1); }
}

/* ========================================================
   ACTION / BATTLE & EXP LOG (BOTTOM-LEFT RPG HUD)
   ======================================================== */
.action-log-panel {
  position: absolute;
  bottom: 74px;
  left: 14px;
  width: 275px;
  height: 145px;
  background: rgba(11, 19, 36, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 12;
  transition: height 0.25s ease, opacity 0.2s ease;
  pointer-events: auto;
}

.action-log-panel.collapsed {
  height: 34px;
}

.log-header {
  background: linear-gradient(90deg, #152744, #1e3a63);
  border-bottom: 1px solid rgba(56, 189, 248, 0.25);
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.log-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
  margin-right: 6px;
}

.log-title-text {
  font-family: var(--font-rpg);
  font-size: 8px;
  color: #bae6fd;
  letter-spacing: 0.5px;
  flex: 1;
}

.log-btn-mini {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.log-btn-mini:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.log-tabs {
  display: flex;
  gap: 4px;
}

.log-tab {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.log-tab:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.08);
}

.log-tab.active {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.18);
  border-bottom: 2px solid #38bdf8;
}

.log-body {
  flex: 1;
  min-height: 0;
  padding: 6px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  line-height: 1.35;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.3) transparent;
}

.log-body::-webkit-scrollbar {
  width: 4px;
}
.log-body::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.35);
  border-radius: 2px;
}

.log-line {
  display: flex;
  align-items: baseline;
  gap: 5px;
  word-break: break-word;
}

.log-time {
  font-size: 9px;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.log-tag {
  font-weight: 700;
  font-size: 10px;
  flex-shrink: 0;
}

.tag-system { color: #38bdf8; }
.tag-combat { color: #fb923c; }
.tag-exp { color: #4ade80; }
.tag-loot { color: #facc15; }
.tag-quest { color: #c084fc; }

.log-system .log-text { color: #e2e8f0; }
.log-combat .log-text { color: #fed7aa; }
.log-exp .log-text { color: #bbf7d0; font-weight: 600; }
.log-loot .log-text { color: #fef08a; }
.log-quest .log-text { color: #e9d5ff; font-weight: 600; }

/* ========================================================
   QUEST JOURNAL (บันทึกเควสต์สไตล์ Lumivara Online)
   ======================================================== */
.quest-card {
  width: min(720px, 94vw);
  max-height: 85vh;
  background: #111a2e;
  border: 2px solid #c9a45c;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), inset 0 0 0 1px #f5e4b7;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.quest-titlebar {
  background: linear-gradient(90deg, #13274f, #1e3d78 60%, #2b549e);
  border-bottom: 2px solid #c9a45c;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.qj-icon {
  font-size: 26px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.qj-main-title {
  font-size: 18px;
  font-weight: 700;
  color: #f7eed6;
  text-shadow: 0 2px 2px #0a1730;
  margin: 0;
  line-height: 1.1;
}

.qj-sub-title {
  font-size: 11px;
  color: #ffd98a;
  letter-spacing: 0.5px;
}

.qj-motto {
  margin: 0;
  padding: 6px 14px;
  background: #fdf6e3;
  color: #7a5c1e;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  border-bottom: 1px solid #d9b25a;
}

.qj-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0 14px;
  background: #142038;
  border-bottom: 1px solid rgba(201, 164, 92, 0.35);
}

.qj-tab {
  background: transparent;
  border: none;
  color: #cbd5e1;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: all 0.15s;
}

.qj-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.qj-tab.active {
  background: linear-gradient(180deg, #2a4c8a, #1b325c);
  color: #ffd98a;
  border: 1px solid #c9a45c;
  border-bottom: 0;
  font-weight: 700;
}

.quest-body-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  flex: 1;
  min-height: 320px;
  overflow: hidden;
  background: #0d1526;
}

.quest-list-panel {
  border-right: 1px solid rgba(201, 164, 92, 0.25);
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qj-item {
  background: #16223b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.qj-item:hover {
  background: #1e3054;
  border-color: rgba(201, 164, 92, 0.4);
}

.qj-item.selected {
  background: linear-gradient(90deg, #223c6d, #1a2d52);
  border: 1.5px solid #c9a45c;
  box-shadow: inset 0 0 10px rgba(201, 164, 92, 0.25);
}

.qj-item.is-ready {
  border-color: #4ade80;
  background: #112822;
}

.qj-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.qj-item-title {
  font-size: 11px;
  font-weight: 700;
  color: #f1f5f9;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qj-claim-badge {
  background: #22c55e;
  color: #052e16;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
}

.qj-done-badge {
  background: #64748b;
  color: #f8fafc;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

.qj-mini-progress {
  height: 4px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 2px;
  overflow: hidden;
}

.qj-mini-bar {
  height: 100%;
  background: linear-gradient(90deg, #c9a45c, #facc15);
  border-radius: 2px;
}

.quest-detail-panel {
  padding: 16px;
  overflow-y: auto;
  background: #0f182c;
}

.qj-detail-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qj-card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid rgba(201, 164, 92, 0.3);
  padding-bottom: 8px;
}

.qj-card-title {
  font-size: 16px;
  font-weight: 700;
  color: #fef08a;
  margin: 0 0 2px 0;
}

.qj-card-sub {
  font-size: 11px;
  color: #94a3b8;
}

.qj-stamp-badge {
  color: #ef4444;
  font-family: var(--font-rpg);
  font-size: 11px;
  font-weight: 900;
  border: 2px solid #ef4444;
  padding: 3px 8px;
  border-radius: 6px;
  transform: rotate(-6deg);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.qj-card-desc {
  font-size: 12px;
  color: #e2e8f0;
  line-height: 1.5;
  background: rgba(0, 0, 0, 0.25);
  padding: 10px 12px;
  border-radius: 6px;
  border-left: 3px solid #c9a45c;
}

.qj-goal-block {
  background: #16243f;
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 10px 12px;
}

.qj-goal-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #cbd5e1;
}

.qj-goal-count {
  font-weight: 700;
  color: #facc15;
  font-size: 13px;
}

.qj-meter-bg {
  height: 12px;
  background: #090e18;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.qj-meter-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fde047);
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.5);
  border-radius: 6px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.qj-reward-block {
  background: linear-gradient(135deg, #182238, #1c2a47);
  border: 1px solid #c9a45c;
  border-radius: 8px;
  padding: 10px 12px;
}

.qj-reward-header {
  font-size: 11px;
  font-weight: 700;
  color: #ffd98a;
  margin-bottom: 4px;
}

.qj-reward-text {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.qj-action-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.qj-btn-claim {
  padding: 10px 24px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.qj-btn-claim.ready {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #1a1001;
  border: 2px solid #fef08a;
  box-shadow: 0 0 16px rgba(234, 179, 8, 0.7);
  animation: pulse-ready 1.5s infinite;
}

.qj-btn-claim.ready:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(250, 204, 21, 0.9);
}

.qj-btn-claim.disabled {
  background: #1e293b;
  color: #64748b;
  border: 1px solid #334155;
  cursor: not-allowed;
}

.qj-btn-claim.claimed {
  background: #064e3b;
  color: #6ee7b7;
  border: 1px solid #10b981;
  cursor: default;
}

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

.qj-empty {
  text-align: center;
  color: #64748b;
  padding: 30px 10px;
  font-size: 12px;
}

/* ========================================================
   STATUS ALLOCATION WINDOW (หน้าต่างสเตตัสสไตล์ Lumivara Online)
   ======================================================== */
.status-card {
  width: min(680px, 94vw);
  background: #10192e;
  border: 2px solid #38bdf8;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
}

.status-header-gold {
  background: linear-gradient(90deg, #0f2b48, #184777);
  border-bottom: 2px solid #38bdf8;
}

.status-body-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  background: #0a1120;
}

.status-col {
  background: #121c33;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.status-section-head h4 {
  font-size: 13px;
  font-weight: 700;
  color: #bae6fd;
  margin: 0;
}

.points-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #cbd5e1;
}

.unspent-badge {
  background: #334155;
  color: #94a3b8;
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-rpg);
  font-size: 9px;
  transition: all 0.2s;
}

.unspent-badge.has-points {
  background: #f59e0b;
  color: #000;
  box-shadow: 0 0 10px #f59e0b;
  animation: pulse-points 1.4s infinite;
}

@keyframes pulse-points {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.stat-alloc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-alloc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-name {
  font-size: 12px;
  font-weight: 700;
}

.str-color { color: #f87171; }
.agi-color { color: #38bdf8; }
.vit-color { color: #4ade80; }
.int-color { color: #c084fc; }

.stat-desc {
  font-size: 9px;
  color: #94a3b8;
}

.stat-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-curr-val {
  font-family: var(--font-rpg);
  font-size: 11px;
  font-weight: 700;
  color: #f1f5f9;
  min-width: 22px;
  text-align: right;
}

.btn-stat-plus {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  border: 1px solid #7dd3fc;
  color: #000;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-stat-plus:hover:not(:disabled) {
  transform: scale(1.15);
  box-shadow: 0 0 8px #38bdf8;
}

.btn-stat-plus:disabled {
  background: #334155;
  border-color: #475569;
  color: #64748b;
  cursor: not-allowed;
  opacity: 0.5;
}

.status-plaque-tag {
  margin-top: auto;
  text-align: center;
  font-family: var(--font-rpg);
  font-size: 8px;
  color: #475569;
  letter-spacing: 1px;
  padding-top: 6px;
}

.tribe-sub-tag {
  font-size: 11px;
  font-weight: 700;
}

.derived-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.derived-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.derived-card.span-2 {
  grid-column: 1 / span 2;
}

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

.d-data {
  display: flex;
  flex-direction: column;
}

.d-data small {
  font-size: 9px;
  color: #94a3b8;
}

.d-data b {
  font-size: 13px;
  color: #f1f5f9;
}

/* ========================================================
   LUMIVARA GUEST LOGIN & CHARACTER CLASS SELECTION MODAL
   ======================================================== */
.login-modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 1;
  transition: opacity 0.4s ease, transform 0.4s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  touch-action: pan-y !important;
  user-select: auto;
}

.login-modal-overlay.fade-out {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

.login-keyart-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(14, 28, 54, 0.88) 0%, rgba(3, 7, 18, 0.96) 100%),
              url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="60" height="60" opacity="0.05"><path d="M0 30 L30 0 L60 30 L30 60 Z" fill="%2338bdf8"/></svg>');
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
}

.login-card-wrapper {
  position: relative;
  width: 760px;
  max-width: 95vw;
  max-height: min(94vh, 94dvh);
  background: #111a2e;
  border: 2px solid #eab308;
  box-shadow: 0 0 35px rgba(234, 179, 8, 0.25), 0 20px 50px rgba(0, 0, 0, 0.8);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 2;
  animation: modal-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  touch-action: pan-y !important;
  margin: auto 0;
}

@keyframes modal-pop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.login-brand-header {
  flex-shrink: 0;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 2px solid #ca8a04;
  padding: 16px 20px;
  text-align: center;
  position: relative;
}

.login-brand-sub {
  font-family: var(--font-rpg);
  font-size: 9px;
  letter-spacing: 2px;
  color: #facc15;
  display: block;
  margin-bottom: 4px;
}

.login-brand-title {
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 900;
  color: #f8fafc;
  letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
  margin: 0;
}

.login-brand-title span {
  color: #38bdf8;
  font-size: 22px;
  font-weight: 700;
}

.login-brand-tagline {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

.login-step-card {
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
  flex: 1 1 auto;
}

.login-step-card.hidden {
  display: none !important;
}

.step-ribbon-title {
  background: linear-gradient(90deg, #b45309, #d97706, #b45309);
  color: #fef08a;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #fde047;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  box-shadow: 0 2px 8px rgba(217, 119, 6, 0.35);
  display: inline-flex;
  align-self: flex-start;
}

.guest-notice {
  background: rgba(234, 179, 8, 0.12);
  border: 1px dashed rgba(234, 179, 8, 0.45);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #fef08a;
  display: flex;
  align-items: center;
  gap: 10px;
}

.guest-notice .notice-icon {
  font-size: 18px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 12px;
  font-weight: 700;
  color: #cbd5e1;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  pointer-events: none;
}

.input-with-icon input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: rgba(15, 23, 42, 0.9);
  border: 1.5px solid rgba(56, 189, 248, 0.4);
  border-radius: 8px;
  color: #f8fafc;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  outline: none;
  transition: all 0.2s ease;
}

.input-with-icon input:focus {
  border-color: #facc15;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.35);
}

.btn-primary-gold {
  background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 800;
  border: 1.5px solid #fef08a;
  border-radius: 10px;
  padding: 12px 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.45);
  transition: all 0.15s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.btn-primary-gold:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(251, 191, 36, 0.6);
  background: linear-gradient(180deg, #fbbf24 0%, #d97706 100%);
}

.btn-primary-gold:active {
  transform: translateY(0);
}

/* Class Selection Layout */
.class-picker-layout {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 18px;
}

.picker-section-title {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.class-card {
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  align-items: center;
  transition: all 0.15s ease;
}

.class-card:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-2px);
}

.class-card.active {
  background: rgba(30, 41, 59, 1);
  border-color: #facc15;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.4);
}

.class-sprite-wrap {
  width: 48px;
  height: 48px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.class-pixel-avatar {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  object-fit: contain;
}

.class-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.class-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.class-info small {
  font-size: 9px;
  color: #94a3b8;
}

.class-role-badge {
  font-size: 8.5px;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
  color: #38bdf8;
  font-weight: 600;
  margin-top: 2px;
  display: inline-block;
}

.pyre-text { color: #f87171; }
.zephyr-text { color: #38bdf8; }
.aqua-text { color: #60a5fa; }
.terra-text { color: #4ade80; }

/* Starter Dino Row */
.dino-selection-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.dino-card {
  background: rgba(15, 23, 42, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.15s ease;
}

.dino-card:hover {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(30, 41, 59, 0.8);
}

.dino-card.active {
  border-color: #f59e0b;
  background: rgba(30, 41, 59, 1);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

.dino-emoji-avatar {
  font-size: 24px;
}

.dino-card b {
  font-size: 11px;
  color: #f8fafc;
}

.dino-card small {
  font-size: 8.5px;
  color: #94a3b8;
}

/* Class Preview Box */
.class-preview-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.preview-tag {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
}

.preview-bonus {
  font-size: 10px;
  color: #facc15;
}

.preview-lore {
  font-size: 11px;
  color: #cbd5e1;
  line-height: 1.4;
  margin: 0;
}

.btn-enter-game {
  margin-top: 6px;
  width: 100%;
}

/* ========================================================
   MOBILE TOUCH CONTROLS (JOYSTICK & RADIAL SKILL WHEEL)
   Fantasy RPG Mobile UI, Responsive Portrait & Landscape
======================================================== */
.mobile-controls-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 25;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* 1. Virtual Joystick (ฝั่งซ้ายล่าง) */
.mobile-joystick-container {
  position: absolute;
  bottom: calc(75px + env(safe-area-inset-bottom, 24px));
  left: calc(24px + env(safe-area-inset-left, 12px));
  width: 146px;
  height: 146px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.65));
}

.joystick-base {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  touch-action: none;
}

.joystick-base-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  opacity: 0.92;
  transition: opacity 0.2s ease;
}

.mobile-joystick-container:active .joystick-base-img {
  opacity: 1;
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 68px;
  margin-top: -34px;
  margin-left: -34px;
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 4px 14px rgba(245, 158, 11, 0.6));
  transition: transform 0.04s ease-out;
}

.joystick-knob-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

/* 2. Radial Skill Wheel (ฝั่งขวาล่าง) */
.mobile-skill-wheel-container {
  position: absolute;
  bottom: calc(75px + env(safe-area-inset-bottom, 24px));
  right: calc(20px + env(safe-area-inset-right, 12px));
  width: 250px;
  height: 250px;
  pointer-events: none;
}

/* กรอบวงล้อประดับลวดลายแฟนตาซีด้านหลัง */
.radial-wheel-backing {
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 290px;
  height: 290px;
  pointer-events: none;
  opacity: 0.78;
  filter: drop-shadow(0 8px 26px rgba(0, 0, 0, 0.75));
  animation: wheel-subtle-spin 180s linear infinite;
}

.radial-wheel-backing img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

@keyframes wheel-subtle-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ปุ่มกลมในวงล้อสกิล */
.radial-btn {
  position: absolute;
  border-radius: 50%;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  transition: transform 0.1s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.15s ease;
}

.radial-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.55));
}

.radial-btn:hover {
  transform: scale(1.08);
  filter: brightness(1.15);
}

.radial-btn:active,
.radial-btn.btn-pressed {
  transform: scale(0.92);
  filter: brightness(1.3) drop-shadow(0 0 16px rgba(250, 204, 21, 0.8));
}

/* ปุ่มโจมตีหลักตรงกลาง (Primary Center Attack) */
.radial-btn-attack {
  bottom: 24px;
  right: 24px;
  width: 86px;
  height: 86px;
  z-index: 10;
  box-shadow: 0 0 24px rgba(234, 179, 8, 0.45);
  animation: attack-pulse 2.8s ease-in-out infinite;
}

@keyframes attack-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(234, 179, 8, 0.35); }
  50% { box-shadow: 0 0 32px rgba(234, 179, 8, 0.7); }
}

.radial-btn-label {
  position: absolute;
  bottom: 8px;
  font-family: var(--font-rpg);
  font-size: 8px;
  color: #fef08a;
  text-shadow: 0 0 4px #000, 0 0 8px #d97706;
  pointer-events: none;
}

/* กลุ่มปุ่มสกิลบริวารรอบวงกลม (Satellite Buttons) */
.sat-btn {
  z-index: 11;
}

/* สกิล 1: Dash (วายุทะลวง) - บนซ้ายของปุ่มโจมตี */
.sat-dash {
  bottom: 122px;
  right: 14px;
  width: 58px;
  height: 58px;
}

/* สกิล 2: Arcane Nova (เพลิงอัคคี) - บนเยื้องซ้าย */
.sat-nova {
  bottom: 108px;
  right: 80px;
  width: 58px;
  height: 58px;
}

/* สกิล 3: Holy Blessing (มนตราฟื้นฟู) - ซ้ายเยื้องบน */
.sat-heal {
  bottom: 58px;
  right: 124px;
  width: 58px;
  height: 58px;
}

/* สกิล 4: Judgment of the Storm (ท่าไม้ตาย) - ด้านซ้ายระนาบล่าง */
.sat-storm {
  bottom: 0px;
  right: 126px;
  width: 60px;
  height: 60px;
}

/* ปุ่มขึ้นขี่ไดโนเสาร์ (Mount Dino) - วงนอกบน */
.sat-mount {
  bottom: 160px;
  right: 76px;
  width: 50px;
  height: 50px;
}

/* ปุ่มโพชันยาฟื้นพลัง (Potion) - วงนอกซ้ายบน */
.sat-potion {
  bottom: 136px;
  right: 138px;
  width: 48px;
  height: 48px;
}

/* ฟองบอกค่ามานา (Mana Bubble) */
.mana-bubble {
  position: absolute;
  top: -2px;
  right: -2px;
  background: rgba(2, 132, 199, 0.95);
  color: #fff;
  font-family: var(--font-rpg);
  font-size: 8px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 999px;
  border: 1px solid #7dd3fc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

/* แผ่นคูลดาวน์สกิลวงกลม (Radial Cooldown Overlay) */
.radial-cd-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.78);
  height: 0%;
  bottom: 0;
  top: auto;
  overflow: hidden;
  pointer-events: none;
  transition: height 0.05s linear;
}

/* ตัวเลขคูลดาวน์บนปุ่มวงกลม */
.radial-cd-text {
  position: absolute;
  font-family: var(--font-rpg);
  font-size: 10px;
  color: #facc15;
  text-shadow: 0 0 6px #000;
  pointer-events: none;
  z-index: 12;
  display: none;
}

/* ตัวเลขจำนวนโพชันยา */
.potion-count-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #dc2626;
  color: #fff;
  font-family: var(--font-rpg);
  font-size: 8px;
  padding: 1px 4px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  pointer-events: none;
}

/* ไฟสถานะขึ้นขี่ไดโนเสาร์ */
.mount-glow-indicator {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
  transition: all 0.2s ease;
}

.mount-glow-indicator.active {
  border-color: #f59e0b;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.8), inset 0 0 8px rgba(245, 158, 11, 0.5);
  animation: mount-pulse 1.5s ease-in-out infinite alternate;
}

@keyframes mount-pulse {
  from { box-shadow: 0 0 10px rgba(245, 158, 11, 0.6); }
  to { box-shadow: 0 0 18px rgba(245, 158, 11, 0.95); }
}

/* ========================================================
   RESPONSIVE DESIGN: รองรับทั้งแนวตั้ง (Portrait) & แนวนอน (Landscape)
======================================================== */

/* โหมดแนวตั้ง (Portrait Orientation - มือถือถือแนวตั้ง) */
@media (orientation: portrait) {
  .player-status-hud {
    top: calc(10px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    padding: 6px 10px;
    gap: 8px;
    border-radius: 12px;
  }

  .avatar-container {
    width: 40px;
    height: 40px;
  }

  .avatar-icon {
    font-size: 20px;
  }

  .bars-container {
    width: 125px;
    gap: 3px;
  }

  .stat-label-row {
    font-size: 9px;
  }

  .stat-bar-bg {
    height: 7px;
  }

  .top-right-hud {
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    gap: 6px;
  }

  .hud-action-row {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
    max-width: 180px;
  }

  .hud-pill-btn {
    padding: 4px 8px;
    font-size: 9px;
  }

  .hud-pill-btn span:nth-child(2) {
    display: none; /* ซ่อนข้อความยาวบนจอมือถือแนวตั้ง คงไว้เฉพาะไอคอนและ Badge */
  }

  .coin-wallet {
    padding: 4px 8px;
    font-size: 9px;
  }

  .minimap-wrapper {
    display: none; /* ซ่อน Minimap ในแนวตั้ง เพื่อเปิดมุมมองกว้างให้เห็นตัวละครชัดเจน */
  }

  .desktop-only-bar,
  .controls-guide,
  .pet-widget {
    display: none !important; /* สลับไปใช้ปุ่มวงล้อและจอยสติ๊กสัมผัสบนมือถือแทน */
  }

  /* ปรับขนาดและตำแหน่งจอยสติ๊กในแนวตั้ง ยกสูงพ้นแถบโฮมบาร์มือถือ */
  .mobile-joystick-container {
    bottom: calc(78px + env(safe-area-inset-bottom, 24px));
    left: calc(16px + env(safe-area-inset-left, 10px));
    width: 130px;
    height: 130px;
  }

  .joystick-knob {
    width: 60px;
    height: 60px;
    margin-top: -30px;
    margin-left: -30px;
  }

  /* ปรับย่อขนาดและยกตำแหน่งวงล้อสกิลให้สูงพ้นขอบล่าง */
  .mobile-skill-wheel-container {
    bottom: calc(78px + env(safe-area-inset-bottom, 24px));
    right: calc(14px + env(safe-area-inset-right, 10px));
    transform: scale(0.85);
    transform-origin: bottom right;
  }

  /* ย้าย Battle/System Log ไปไว้ใต้หลอดเลือดซ้ายบน ไม่ทับจอยสติ๊กและปุ่มสกิล */
  .action-log-panel {
    bottom: auto !important;
    top: calc(75px + env(safe-area-inset-top, 6px));
    left: calc(10px + env(safe-area-inset-left, 6px));
    width: 220px;
    height: 85px;
    z-index: 12;
    background: rgba(11, 19, 36, 0.88);
    font-size: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  }

  .action-log-panel.collapsed {
    height: 28px;
  }

  /* ปุ่มไอคอนเมนูด้านบน ขยายพื้นที่แตะให้กดง่ายขึ้น */
  .hud-pill-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  .hud-pill-btn .hud-btn-pixel-icon {
    width: 18px;
    height: 18px;
  }

  /* หน้าต่างเลือกตัวละคร & เริ่มเกมในแนวตั้ง (Portrait Modal) */
  .login-modal-overlay {
    align-items: flex-start;
    padding: calc(6px + env(safe-area-inset-top, 0px)) calc(6px + env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) calc(6px + env(safe-area-inset-left, 0px));
  }

  .login-card-wrapper {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    margin: auto 0;
    border-radius: 12px;
  }

  .login-brand-header {
    padding: 8px 12px;
  }

  .login-brand-sub {
    font-size: 8px;
    letter-spacing: 1px;
    margin-bottom: 2px;
  }

  .login-brand-title {
    font-size: 18px;
  }

  .login-brand-title span {
    font-size: 16px;
  }

  .login-brand-tagline {
    font-size: 10px;
    margin-top: 2px;
  }

  .login-step-card {
    padding: 10px 12px 14px;
    gap: 10px;
  }

  .step-ribbon-title {
    font-size: 11px;
    padding: 3px 8px;
  }

  .picker-section-title {
    font-size: 10px;
    margin-bottom: 6px;
  }

  .class-picker-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .class-cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .class-card {
    padding: 6px 8px;
    gap: 6px;
    border-radius: 8px;
  }

  .class-sprite-wrap {
    width: 36px;
    height: 36px;
  }

  .class-pixel-avatar {
    width: 30px;
    height: 30px;
  }

  .class-info b {
    font-size: 10.5px;
    line-height: 1.2;
  }

  .class-info small {
    display: none; /* ซ่อนภาษาอังกฤษเพื่อประหยัดพื้นที่แนวตั้ง */
  }

  .class-role-badge {
    font-size: 7.5px;
    padding: 1px 3px;
    margin-top: 1px;
  }

  .dino-selection-section {
    gap: 8px;
  }

  .dino-cards-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .dino-card {
    padding: 5px 2px;
    gap: 2px;
  }

  .dino-emoji-avatar {
    font-size: 18px;
  }

  .dino-card b {
    font-size: 9.5px;
  }

  .dino-card small {
    font-size: 7.5px;
  }

  .class-preview-box {
    padding: 6px 8px;
    gap: 3px;
  }

  .preview-header {
    font-size: 9px;
  }

  .preview-tag {
    font-size: 8px;
    padding: 1px 4px;
  }

  .preview-bonus {
    font-size: 9px;
  }

  .preview-lore {
    font-size: 9.5px;
    line-height: 1.3;
  }

  /* ปุ่มเข้าสู่เกม เด่นชัดและกดง่ายบนมือถือ พร้อม Sticky ด้านล่าง */
  .btn-enter-game {
    position: sticky;
    bottom: 0;
    margin-top: 6px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 800;
    z-index: 25;
    background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
    border: 2px solid #fef08a;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.8), 0 0 16px rgba(245, 158, 11, 0.5);
  }
}

/* โหมดแนวนอน (Landscape Orientation - มือถือถือแนวนอน) */
@media (orientation: landscape) and (max-height: 600px) {
  .player-status-hud {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(14px + env(safe-area-inset-left, 0px));
    padding: 6px 12px;
  }

  .top-right-hud {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(14px + env(safe-area-inset-right, 0px));
  }

  .desktop-only-bar,
  .controls-guide,
  .pet-widget {
    display: none !important;
  }

  .minimap-wrapper {
    padding: 2px;
  }

  #minimap-canvas {
    width: 64px;
    height: 64px;
  }

  .mobile-joystick-container {
    bottom: calc(28px + env(safe-area-inset-bottom, 12px));
    left: calc(22px + env(safe-area-inset-left, 10px));
    width: 132px;
    height: 132px;
  }

  .mobile-skill-wheel-container {
    bottom: calc(28px + env(safe-area-inset-bottom, 12px));
    right: calc(22px + env(safe-area-inset-right, 10px));
    transform: scale(0.9);
    transform-origin: bottom right;
  }

  /* ย้าย Action Log ในแนวนอนเพื่อไม่บังปุ่ม */
  .action-log-panel {
    bottom: auto !important;
    top: calc(56px + env(safe-area-inset-top, 4px));
    left: calc(14px + env(safe-area-inset-left, 6px));
    width: 195px;
    height: 72px;
  }

  /* หน้าต่างเลือกตัวละคร & เริ่มเกมในแนวนอน (Landscape Modal) */
  .login-modal-overlay {
    align-items: flex-start;
    padding: calc(4px + env(safe-area-inset-top, 0px)) calc(10px + env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) calc(10px + env(safe-area-inset-left, 0px));
  }

  .login-card-wrapper {
    max-height: calc(100dvh - 12px);
    border-radius: 12px;
  }

  .login-brand-header {
    padding: 6px 12px;
  }

  .login-brand-title {
    font-size: 16px;
  }

  .login-brand-tagline {
    display: none;
  }

  .login-step-card {
    padding: 8px 12px;
    gap: 8px;
  }

  .class-picker-layout {
    grid-template-columns: 1.15fr 1fr;
    gap: 10px;
  }

  .class-cards-grid {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
  }

  .class-card {
    padding: 4px 6px;
    gap: 6px;
  }

  .class-sprite-wrap {
    width: 32px;
    height: 32px;
  }

  .class-pixel-avatar {
    width: 28px;
    height: 28px;
  }

  .class-info b {
    font-size: 10px;
  }

  .class-info small {
    display: none;
  }

  .dino-selection-section {
    gap: 6px;
  }

  .dino-cards-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .dino-card {
    padding: 3px 2px;
  }

  .dino-emoji-avatar {
    font-size: 16px;
  }

  .class-preview-box {
    padding: 4px 8px;
  }

  .preview-lore {
    display: none; /* ประหยัดความสูงในแนวนอน */
  }

  .btn-enter-game {
    position: sticky;
    bottom: 0;
    padding: 10px 14px;
    font-size: 12px;
  }
}

/* เมื่อหน้าจอแคบ หรือเป็นอุปกรณ์ Touch Device */
@media (max-width: 900px), (pointer: coarse) {
  .desktop-only-bar,
  .controls-guide,
  .pet-widget {
    display: none !important;
  }

  /* ========================================================
     MOBILE IN-GAME MODALS: ปรับหน้าต่างในเกมทุกอันให้เหมาะกับมือถือ
     ======================================================== */
  .rpg-modal {
    align-items: flex-start;
    padding: calc(6px + env(safe-area-inset-top, 0px)) calc(6px + env(safe-area-inset-right, 0px)) calc(12px + env(safe-area-inset-bottom, 0px)) calc(6px + env(safe-area-inset-left, 0px));
  }

  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - 16px) !important;
    border-radius: 12px;
    margin: auto 0;
  }

  .modal-header {
    padding: 10px 14px;
  }

  .modal-title h3 {
    font-size: 14px;
  }

  .modal-close-btn {
    min-width: 36px;
    min-height: 36px;
    font-size: 26px;
  }

  /* 1. กระเป๋า & อุปกรณ์ (Inventory Modal) */
  .inventory-card {
    width: 100% !important;
  }

  .inventory-body {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px 12px;
    overflow-y: auto;
  }

  .equipment-doll {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .equip-slots-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .equip-slot {
    padding: 4px;
  }

  .inventory-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
  }

  .inv-slot {
    width: auto;
    height: 52px;
  }

  /* 2. ค่าสถานะ & แต้มสเตตัส (Status Modal) */
  .status-card {
    width: 100% !important;
  }

  .status-body-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px 12px;
    overflow-y: auto;
  }

  .stat-row {
    padding: 6px 8px;
  }

  .stat-btn-plus, .stat-btn-minus {
    min-width: 34px;
    min-height: 34px;
    font-size: 16px;
  }

  /* 3. บันทึกเควสต์ (Quest Journal Modal) */
  .quest-card {
    width: 100% !important;
  }

  .quest-titlebar {
    padding: 8px 12px;
  }

  .qj-main-title {
    font-size: 15px;
  }

  .qj-body-layout,
  .quest-body-layout {
    grid-template-columns: 1fr;
    min-height: auto;
    overflow-y: auto;
  }

  .quest-list-panel {
    max-height: 150px;
    border-right: none;
    border-bottom: 1px solid rgba(201, 164, 92, 0.25);
  }

  /* 4. เปลี่ยนเผ่า & คู่หู (Selection Modal) */
  .selection-card {
    width: 100% !important;
  }

  .selection-body {
    padding: 10px 12px;
    gap: 10px;
    overflow-y: auto;
  }

  .tribes-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .dinos-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .selection-box {
    padding: 8px 6px;
  }
}


