/* ========================================================
   WORLD QUEST — RPG FANTASY GAME UI THEME
   Inspired by classic RPGs, modern gamified interfaces, 
   golden borders, runic glowing accents & responsive layouts
   ======================================================== */

:root {
  color-scheme: dark;
  --bg-dark: #0a0e17;
  --bg-card: rgba(18, 25, 43, 0.85);
  --bg-surface: #111827;
  --gold-primary: #f59e0b;
  --gold-glow: #fbbf24;
  --gold-border: #d97706;
  --blue-magic: #38bdf8;
  --purple-arcane: #a855f7;
  --green-health: #10b981;
  --red-damage: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-heading: 'Cinzel', 'Cinzel Decorative', 'Cinzel Decorative', 'Trajan Pro', 'Segoe UI', serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 50% 10%, rgba(99, 102, 241, 0.15), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(245, 158, 11, 0.08), transparent 40%),
    linear-gradient(180deg, #070a12 0%, #0d1322 100%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* RTL Support */
[dir="rtl"] {
  direction: rtl;
  text-align: right;
}

/* Glassmorphism RPG Card */
.rpg-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(245, 158, 11, 0.3);
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.6), 0 0 15px rgba(245, 158, 11, 0.1);
  border-radius: 14px;
  position: relative;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.rpg-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-glow), transparent);
  border-radius: 14px 14px 0 0;
}

.rpg-card:hover {
  border-color: rgba(245, 158, 11, 0.6);
  box-shadow: 0 12px 35px -5px rgba(0, 0, 0, 0.7), 0 0 25px rgba(245, 158, 11, 0.25);
}

/* Gold Game Button */
.btn-rpg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  color: #1a0f02;
  background: linear-gradient(180deg, #fcd34d 0%, #f59e0b 60%, #d97706 100%);
  border: 1px solid #fef08a;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-rpg:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  background: linear-gradient(180deg, #fef08a 0%, #fbbf24 60%, #b45309 100%);
  color: #0d0600;
}

.btn-rpg:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.btn-rpg-secondary {
  background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
  border: 1px solid #475569;
  color: #f1f5f9;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  text-shadow: none;
}

.btn-rpg-secondary:hover {
  background: linear-gradient(180deg, #475569 0%, #334155 100%);
  border-color: #64748b;
  color: #ffffff;
}

.btn-rpg-danger {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 60%, #b91c1c 100%);
  border: 1px solid #fca5a5;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* =========================================================
   Dark-Themed Select & Custom RPG Dropdowns
   Fixes White-on-White System Default Background Glitch
   ========================================================= */

/* Custom RPG Dropdown Select Component */
.rpg-custom-select-wrapper {
  position: relative;
  display: inline-block;
  user-select: none;
  font-family: var(--font-body);
  text-align: left;
}

.rpg-custom-select-trigger {
  width: 100%;
  background: #0f172a;
  background-image: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #f8fafc;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.rpg-custom-select-trigger:hover,
.rpg-custom-select-wrapper.open .rpg-custom-select-trigger {
  border-color: #fbbf24;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.35);
}

.rpg-custom-select-trigger .chevron {
  color: #fbbf24;
  font-size: 0.85rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.rpg-custom-select-wrapper.open .rpg-custom-select-trigger .chevron {
  transform: rotate(180deg);
}

.rpg-custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 100%;
  background: #0f172a;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.85), 0 0 18px rgba(245, 158, 11, 0.25);
  z-index: 9999;
  max-height: 280px;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 0.4rem 0;
  box-sizing: border-box;
}

.rpg-custom-select-wrapper.open .rpg-custom-select-menu {
  display: flex;
}

.rpg-custom-select-option {
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.rpg-custom-select-option:hover {
  background: #1e293b;
  color: #fbbf24;
}

.rpg-custom-select-option.selected {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  font-weight: 700;
}

.rpg-custom-select-option.selected::after {
  content: '✓';
  font-weight: bold;
  color: #fbbf24;
}

/* Fallback native select dark styles */
select, .rpg-select, select.btn-rpg-secondary {
  color-scheme: dark !important;
  background-color: #0f172a !important;
  background-image: 
    linear-gradient(180deg, #1e293b 0%, #0f172a 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat, no-repeat !important;
  background-position: center, right 0.85rem center !important;
  background-size: cover, 16px !important;
  color: #f8fafc !important;
  border: 1px solid rgba(245, 158, 11, 0.45) !important;
  border-radius: 8px !important;
  padding: 0.65rem 2.4rem 0.65rem 1rem !important;
  font-family: var(--font-body) !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
  transition: all 0.2s ease !important;
}

select:hover, .rpg-select:hover, select.btn-rpg-secondary:hover {
  border-color: #fbbf24 !important;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.25) !important;
}

select:focus, .rpg-select:focus, select.btn-rpg-secondary:focus {
  outline: none !important;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.35) !important;
}

/* Windows Chrome & Universal Native Select Dark Fix:
   Forces dark charcoal/navy background and bright white/gold text on both
   closed <select> and expanded dropdown popup <option> elements across Windows Chrome,
   Firefox, Edge, macOS Safari, and mobile browsers. Eliminates the white-box glitch completely. */
select, .rpg-select, select.btn-rpg-secondary {
  color-scheme: dark !important;
  background-color: #0f172a !important;
  color: #f8fafc !important;
}

select option, select optgroup,
.rpg-select option, .rpg-select optgroup,
select.btn-rpg-secondary option {
  background-color: #0f172a !important;
  background: #0f172a !important;
  color: #f8fafc !important;
  padding: 0.75rem 1rem !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
}

select option:checked,
select option:hover,
select option:focus,
.rpg-select option:checked,
.rpg-select option:hover,
.rpg-select option:focus {
  background-color: #1e3a8a !important;
  background: #1e3a8a !important;
  color: #38bdf8 !important;
}

/* RPG HUD Header */
.rpg-hud {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  padding: 0.45rem 1rem;
  width: 100%;
  box-sizing: border-box;
}

.hud-container {
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0 0.5rem;
  box-sizing: border-box;
}

.hud-left-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* 3-Line Hamburger Button (Desktop Toggle & Mobile Drawer Opener) */
.sidebar-toggle-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 8px;
  padding: 8px 7px;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}

.sidebar-toggle-btn:hover {
  background: rgba(245, 158, 11, 0.22);
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
  transform: scale(1.04);
}

.hamburger-bar {
  display: block;
  width: 100%;
  height: 2.5px;
  background-color: #fbbf24;
  border-radius: 2px;
  transition: all 0.2s ease;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-main);
  flex-shrink: 0;
}

.brand-gem {
  width: 30px;
  height: 30px;
  filter: drop-shadow(0 0 8px #f59e0b);
  flex-shrink: 0;
}

.brand-text {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 50%, #d97706 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

/* Player Mini HUD */
.player-hud-summary {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9999px;
  padding: 0.25rem 0.75rem 0.25rem 0.35rem;
  flex-shrink: 0;
}

.player-avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gold-glow);
  background: #1e293b;
  overflow: hidden;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.player-bars {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 95px;
}

.player-name-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.player-name-text {
  color: #fbbf24;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-lvl-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fef08a;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.7rem;
}

.bar-wrap {
  height: 6px;
  background: #1f2937;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.bar-fill-hp {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.4s ease;
}

.bar-fill-exp {
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #c084fc);
  transition: width 0.4s ease;
}

.hud-currencies {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.currency-pill {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(0, 0, 0, 0.45);
  padding: 0.2rem 0.5rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.coin-icon {
  color: #fbbf24;
}

.kp-icon {
  color: #38bdf8;
}

/* Nav links: Constrained Flex Item with Smooth Scroll */
.hud-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  white-space: nowrap;
}

.hud-nav::-webkit-scrollbar {
  display: none;
}

.hud-link {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.84rem;
  padding: 0.38rem 0.6rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  white-space: nowrap !important;
  word-break: keep-all !important;
}

.hud-link:hover, .hud-link.active {
  color: #ffffff;
  background: rgba(245, 158, 11, 0.16);
  box-shadow: inset 0 0 10px rgba(245, 158, 11, 0.2);
}

.hud-link.active {
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.hud-nav-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.hud-nav-text {
  white-space: nowrap !important;
  word-break: keep-all !important;
}

/* Actions: SFX, Language, Admin & Auth (Pinned Right, Never Pushed Off) */
.hud-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  flex-shrink: 0 !important;
  z-index: 100;
}

.hud-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 0.38rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.18s ease;
  user-select: none;
}

.hud-action-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--gold-border);
  color: #ffffff;
}

.lang-open-btn {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  font-weight: 700;
}

.lang-open-btn:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: #fbbf24;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
}

.lang-flag-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.lang-arrow {
  opacity: 0.7;
  font-size: 0.75rem;
}

.btn-logout {
  color: #f87171 !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
}

.btn-login-google {
  background: rgba(66, 133, 244, 0.15) !important;
  border-color: rgba(66, 133, 244, 0.45) !important;
  color: #93c5fd !important;
}

.btn-login-google:hover {
  background: rgba(66, 133, 244, 0.28) !important;
  border-color: #60a5fa !important;
}

/* =========================================================
   RPG Left Sidebar & Navigation Shell
   With Vertical Scrollbar, Mobile 3-Bar Drawer & Backlinks
   ========================================================= */
.app-layout-shell {
  display: flex;
  width: 100%;
  min-height: calc(100vh - 60px);
  position: relative;
  align-items: stretch;
}

.main-content-flow {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

/* Sidebar Backdrop on Mobile */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  z-index: 99990;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.open {
  display: block;
  opacity: 1;
}

/* Left Sidebar Base */
.rpg-sidebar {
  width: 270px;
  min-width: 270px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98) 0%, rgba(9, 13, 22, 0.98) 100%);
  border-right: 1px solid rgba(245, 158, 11, 0.25);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.65);
  position: sticky;
  top: 58px;
  height: calc(100vh - 58px);
  display: flex;
  flex-direction: column;
  z-index: 95;
  box-sizing: border-box;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), width 0.25s ease;
}

/* Mobile Header inside Sidebar */
.sidebar-header-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(245, 158, 11, 0.25);
}

.sidebar-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #94a3b8;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.sidebar-close-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ffffff;
  transform: rotate(90deg);
}

/* Vertical Scrollable Container with Custom Golden Scrollbar */
.sidebar-nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.1rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(245, 158, 11, 0.45) rgba(15, 23, 42, 0.3);
}

.sidebar-nav-scroll::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav-scroll::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
}
.sidebar-nav-scroll::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.4);
  border-radius: 9999px;
}
.sidebar-nav-scroll::-webkit-scrollbar-thumb:hover {
  background: #fbbf24;
  box-shadow: 0 0 8px #fbbf24;
}

.sidebar-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 0.65rem 0.6rem 0.25rem 0.6rem;
  margin-top: 0.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.sidebar-section-title:first-child {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.58rem 0.8rem;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.18s ease;
  border: 1px solid transparent;
  position: relative;
}

.sidebar-link:hover {
  background: rgba(245, 158, 11, 0.16);
  color: #ffffff;
  border-color: rgba(245, 158, 11, 0.35);
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.12) 100%);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.5);
  font-weight: 700;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 3.5px;
  background: #fbbf24;
  border-radius: 0 4px 4px 0;
  box-shadow: 0 0 10px #fbbf24;
}

.sidebar-link-icon {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-link-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Backlinks at the Bottom of Sidebar */
.sidebar-backlinks-section {
  margin-top: 1.25rem;
  padding-top: 0.9rem;
  border-top: 1px solid rgba(245, 158, 11, 0.25);
}

.sidebar-backlink-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: rgba(17, 24, 39, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  text-decoration: none;
  font-size: 0.82rem;
  transition: all 0.2s ease;
  margin-bottom: 0.4rem;
  box-sizing: border-box;
}

.sidebar-backlink-item:hover {
  background: rgba(245, 158, 11, 0.16);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fef08a;
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.backlink-icon {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.backlink-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
  flex: 1;
}

.backlink-name {
  font-weight: 700;
  font-size: 0.84rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-backlink-item:hover .backlink-name {
  color: #fbbf24;
}

.backlink-url {
  font-size: 0.72rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.backlink-arrow {
  margin-left: auto;
  font-size: 0.85rem;
  color: #fbbf24;
  opacity: 0.65;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-backlink-item:hover .backlink-arrow {
  opacity: 1;
  transform: translate(2px, -2px);
}

/* Mobile & Tablet Drawer Responsive Rules */
@media (max-width: 1023px) {
  .rpg-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: min(84vw, 320px);
    z-index: 100000;
    transform: translateX(-100%);
    box-shadow: 20px 0 50px rgba(0, 0, 0, 0.95);
  }

  .rpg-sidebar.open {
    transform: translateX(0) !important;
  }

  .sidebar-header-mobile {
    display: flex !important;
  }
}

/* Desktop Collapsed State (Toggleable via Hamburger) */
@media (min-width: 1024px) {
  .sidebar-header-mobile {
    display: none !important;
  }
  .app-layout-shell.sidebar-collapsed .rpg-sidebar {
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden !important;
    border-right: none !important;
    transform: translateX(-100%);
  }
}

/* =========================================================
   World Language Modal Dialog (Root Level Architecture)
   Immune to Header Overflow, Viewport Glitches & Hover Slips
   ========================================================= */
.lang-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.lang-modal-overlay.open {
  display: flex !important;
}

.lang-modal-dialog {
  background: linear-gradient(180deg, #0f172a 0%, #090d16 100%);
  border: 2px solid var(--gold-border);
  border-radius: 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.95), 0 0 35px rgba(245, 158, 11, 0.25);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

@keyframes modalPopIn {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.lang-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
}

.lang-modal-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.lang-modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.lang-modal-close:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #ffffff;
  transform: rotate(90deg);
}

.lang-modal-search {
  position: relative;
  padding: 0.85rem 1.25rem;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lang-modal-search input {
  width: 100%;
  box-sizing: border-box;
  background: #1e293b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 0.65rem 1rem 0.65rem 2.4rem;
  color: #ffffff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.lang-modal-search input:focus {
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.35);
}

.lang-modal-search .search-icon {
  position: absolute;
  left: 2rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  opacity: 0.6;
  pointer-events: none;
}

.lang-modal-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  max-height: 55vh;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

@media (max-width: 520px) {
  .lang-modal-list {
    grid-template-columns: 1fr;
    max-height: 60vh;
  }
}

.lang-card-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  color: #e2e8f0;
  transition: all 0.18s ease;
  min-height: 52px;
  cursor: pointer;
  box-sizing: border-box;
}

.lang-card-item:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--gold-border);
  transform: translateY(-2px);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.lang-card-item.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25) 0%, rgba(217, 119, 6, 0.15) 100%);
  border-color: #fbbf24;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.lang-flag-badge {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.lang-info-block {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  overflow: hidden;
  flex: 1;
}

.lang-native-txt {
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-en-txt {
  font-size: 0.74rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-check-badge {
  font-size: 0.7rem;
  font-weight: 800;
  background: #f59e0b;
  color: #000000;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  flex-shrink: 0;
}

.lang-flag {
  font-size: 1.25rem;
}

.lang-name-block {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.lang-native-name {
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
}

.lang-en-name {
  color: #94a3b8;
  font-size: 0.75rem;
}

.lang-check {
  color: #10b981;
  font-weight: 800;
  font-size: 1rem;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Main Container */
.main-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
  width: 100%;
}

/* Flash alerts */
.flash-alert {
  padding: 0.9rem 1.4rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideDown 0.3s ease;
}

.flash-success {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #6ee7b7;
}

.flash-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #fca5a5;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.rpg-footer {
  background: #080c14;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

.footer-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--gold-glow);
}

/* Media Queries for Mobile Responsiveness */
html {
  overflow-x: hidden;
  width: 100%;
}

img, svg {
  max-width: 100%;
}

.mobile-bottom-nav {
  display: none;
}

/* Responsive Breakpoints for HUD & Navigation */
@media (max-width: 1600px) {
  .hud-container {
    gap: 0.45rem;
  }
  .hud-link {
    padding: 0.32rem 0.45rem !important;
    font-size: 0.78rem !important;
    gap: 0.2rem !important;
  }
  .player-bars {
    min-width: 80px;
  }
}

@media (max-width: 1280px) {
  .player-bars {
    display: none !important;
  }
  .hud-currencies {
    display: none !important;
  }
  .hud-actions .action-btn-text {
    display: none !important;
  }
  .lang-open-btn .lang-label-text {
    display: none !important;
  }
}

@media (max-width: 992px) {
  /* On compact screens / tablets, condense top nav text into iconic badges */
  .hud-nav-text {
    display: none !important;
  }
  .hud-link {
    padding: 0.4rem 0.55rem !important;
    font-size: 1.05rem !important;
  }
}

@media (max-width: 820px) {
  /* On tablets and mobile, top nav hides in favor of fixed bottom nav */
  .hud-nav {
    display: none !important;
  }
}

@media (max-width: 768px) {
  body {
    padding-bottom: 74px;
    overflow-x: hidden;
  }
  .main-wrapper {
    padding: 0.85rem;
  }
  .lesson-main-wrapper {
    width: 100vw;
    max-width: 100vw;
    margin-inline: 0;
    padding: .5rem !important;
  }
  .lesson-main-wrapper .lesson-flow,
  .lesson-main-wrapper .lesson-flow-heading,
  .lesson-main-wrapper #lesson-content-steps,
  .lesson-main-wrapper .lesson-flow-step,
  .lesson-main-wrapper #lesson-quiz-step,
  .lesson-main-wrapper #quiz-steps-wrapper,
  .lesson-main-wrapper .lesson-quiz-step {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-self: stretch;
  }
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(10, 14, 23, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(245, 158, 11, 0.35);
    z-index: 1000;
    justify-content: space-around;
    align-items: center;
    padding: 0 0.4rem;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.7);
  }
  .mob-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 700;
    gap: 0.1rem;
    flex: 1;
    padding: 0.25rem 0;
    transition: all 0.2s ease;
  }
  .mob-nav-item .mob-icon {
    font-size: 1.25rem;
    line-height: 1;
  }
  .mob-nav-item.active,
  .mob-nav-item:hover {
    color: var(--gold-glow);
  }
  .mob-nav-item.active .mob-icon {
    filter: drop-shadow(0 0 6px #f59e0b);
  }
}

@media (max-width: 580px) {
  .hud-container {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand actions"
      "player player";
    gap: 0.35rem 0.5rem;
    padding: 0;
  }
  .hud-left-group {
    grid-area: brand;
    min-width: 0;
    gap: 0.4rem;
  }
  .sidebar-toggle-btn {
    width: 34px;
    height: 34px;
  }
  .brand-link {
    min-width: 0;
    gap: 0.35rem;
  }
  .brand-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    letter-spacing: 0.01em;
  }
  .hud-actions {
    grid-area: actions;
    display: grid;
    grid-template-columns: repeat(4, 34px);
    gap: 0.15rem;
    margin-left: 0;
    justify-content: end;
  }
  .hud-actions .hud-action-btn {
    width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    gap: 0;
    overflow: visible;
  }
  .hud-actions .action-btn-text,
  .hud-actions .lang-label-text,
  .hud-actions .lang-arrow {
    display: none !important;
  }
  .player-hud-summary {
    grid-area: player;
    justify-self: center;
    padding: 0.15rem;
  }
}

@media (max-width: 360px) {
  .brand-text {
    display: none;
  }
}

/* ========================================================
   FANTASY RPG VISUAL EXPANSION (Image 5 & Image 1 Themes)
   Hero Stage, Floating Islands, Daily Quests & Paperdoll
   ======================================================== */

/* Hero Avatar Stage & Anime Speech Bubble */
.hero-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 1rem 1rem;
  background: radial-gradient(circle at 50% 25%, rgba(56, 189, 248, 0.18), transparent 70%),
              linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, rgba(10, 14, 23, 0.95) 100%);
  border-radius: 16px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.hero-podium {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.5rem;
}

.hero-podium-base {
  position: absolute;
  bottom: 0;
  width: 180px;
  height: 24px;
  background: radial-gradient(ellipse at center, rgba(56, 189, 248, 0.5) 0%, rgba(245, 158, 11, 0.3) 50%, transparent 80%);
  border-radius: 50%;
  filter: blur(4px);
  animation: pulsePodium 3s infinite alternate;
}

@keyframes pulsePodium {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.1); opacity: 1; }
}

.hero-speech-bubble {
  position: relative;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 2px solid var(--gold-glow);
  color: #ffffff;
  padding: 0.85rem 1.1rem;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 1rem;
  width: 100%;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.hero-speech-bubble:hover {
  transform: translateY(-2px);
  border-color: #fef08a;
}

.hero-wink-eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: heroWink 6s ease-in-out infinite;
}

@keyframes heroWink {
  0%, 91%, 95%, 100% { transform: scaleY(1); }
  92.5%, 94% { transform: scaleY(0.08); }
}

.hud-action-btn,
.sidebar-link,
.btn-rpg,
.floating-kingdom-node,
.island-icon-badge {
  transition: transform 180ms ease, filter 180ms ease, box-shadow 180ms ease;
}

.hud-action-btn:hover,
.sidebar-link:hover,
.btn-rpg:hover,
.floating-kingdom-node:hover,
.island-icon-badge:hover {
  transform: translateY(-2px) scale(1.025);
  filter: brightness(1.15);
}

@media (max-width: 600px) {
  .library-content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .library-content-grid .rpg-card {
    min-width: 0;
  }

  .library-content-grid img {
    height: 110px !important;
  }

  .quiz-size-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .45rem;
  }

  .quiz-size-picker .btn-rpg {
    padding: .45rem .65rem;
    font-size: .82rem;
  }

  .auth-login-page {
    margin-top: .5rem !important;
    margin-bottom: .75rem !important;
    padding-inline: .75rem !important;
  }

  .auth-login-card {
    padding: 1.15rem !important;
  }

  .auth-login-header {
    margin-bottom: .8rem !important;
  }

  .auth-login-title {
    font-size: 1.35rem !important;
    line-height: 1.2;
  }

  .auth-login-character-note {
    display: none;
  }

  .auth-login-card .btn-google-sso {
    gap: .5rem !important;
    padding: .7rem .8rem !important;
    font-size: .88rem !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-wink-eye { animation: none; }
  .hud-action-btn,
  .sidebar-link,
  .btn-rpg,
  .floating-kingdom-node,
  .island-icon-badge { transition: none; }
}

.hero-speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 9px 0 9px;
  border-style: solid;
  border-color: var(--gold-glow) transparent transparent transparent;
}

/* Floating Islands Main Viewport */
.floating-sky-realm {
  position: relative;
  min-height: 480px;
  background: radial-gradient(circle at 50% 20%, rgba(59, 130, 246, 0.25) 0%, transparent 60%),
              radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.2) 0%, transparent 50%),
              linear-gradient(180deg, #070d1d 0%, #0c1427 50%, #070a14 100%);
  border-radius: 16px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 1.5rem;
  overflow: hidden;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6);
}

.cloud-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  pointer-events: none;
  background-image: radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.05) 0%, transparent 40%),
                    radial-gradient(ellipse at 70% 60%, rgba(255, 255, 255, 0.04) 0%, transparent 50%);
  animation: driftClouds 50s linear infinite;
}

@keyframes driftClouds {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.islands-grid-canvas {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.floating-kingdom-node {
  position: relative;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(56, 189, 248, 0.3);
  border-radius: 16px;
  padding: 1.2rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  animation: floatIsland 6s ease-in-out infinite alternate;
}

.floating-kingdom-node:nth-child(2) { animation-delay: -1.5s; }
.floating-kingdom-node:nth-child(3) { animation-delay: -3s; }
.floating-kingdom-node:nth-child(4) { animation-delay: -4.5s; }
.floating-kingdom-node:nth-child(5) { animation-delay: -2s; }
.floating-kingdom-node:nth-child(6) { animation-delay: -3.5s; }

@keyframes floatIsland {
  0% { transform: translateY(0); }
  100% { transform: translateY(-10px); }
}

.floating-kingdom-node:hover {
  transform: translateY(-14px) scale(1.03);
  border-color: var(--gold-glow);
  box-shadow: 0 15px 30px rgba(245, 158, 11, 0.35), 0 0 20px rgba(56, 189, 248, 0.4);
}

.island-icon-badge {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 0.6rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.island-star-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  border-radius: 9999px;
  margin-top: 0.5rem;
}

/* Daily Quests & Activity List */
.quest-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 0.9rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  gap: 0.8rem;
  transition: all 0.2s ease;
}

.quest-row-item:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(245, 158, 11, 0.3);
}

.quest-progress-track {
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.3rem;
}

.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 3px;
}

/* Daily Mystery Chest Card */
.mystery-chest-box {
  background: linear-gradient(135deg, rgba(88, 28, 135, 0.4) 0%, rgba(30, 27, 75, 0.6) 100%);
  border: 2px solid rgba(168, 85, 247, 0.5);
  border-radius: 14px;
  padding: 1.2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  position: relative;
  overflow: hidden;
}

.chest-icon-anim {
  font-size: 3rem;
  filter: drop-shadow(0 0 15px rgba(245, 158, 11, 0.6));
  animation: chestBounce 2.5s infinite ease-in-out;
  cursor: pointer;
}

@keyframes chestBounce {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-6px) rotate(-3deg); }
  75% { transform: translateY(-4px) rotate(3deg); }
}

/* Bottom Subject Cards */
.subjects-deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.subject-banner-card {
  position: relative;
  border-radius: 16px;
  padding: 1.5rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 180px;
  text-decoration: none;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.subject-banner-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 255, 255, 0.4);
}

.subject-bg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  opacity: 0.85;
}

.subject-content-wrap {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

/* Inventory Paperdoll Layout (Image 1) */
.paperdoll-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .paperdoll-layout {
    grid-template-columns: 1fr;
  }
}

.paperdoll-stage {
  position: relative;
  min-height: 420px;
  background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
  border: 2px solid var(--gold-border);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7);
}

.slot-circular {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a3447 0%, #111827 100%);
  border: 2px solid var(--gold-glow);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.3), inset 0 2px 4px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.slot-circular:hover {
  transform: scale(1.08);
  border-color: #fef08a;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
}

.slot-qty-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: #f59e0b;
  color: #000;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  border: 1px solid #ffffff;
}

.inv-circular-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 1rem;
  padding: 1rem;
  background: rgba(10, 14, 23, 0.8);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: 280px;
}

.shop-items-grid {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.learning-shortcuts-grid,
.learning-academies-grid,
.learning-lessons-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.learning-shortcuts-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.lesson-tile h3 {
  font-size: 1rem !important;
}

.academy-world-map {
  margin: 0 0 1.2rem;
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid rgba(56, 189, 248, .35);
  border-radius: 16px;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(16, 185, 129, .18), transparent 40%),
    radial-gradient(ellipse at 80% 75%, rgba(168, 85, 247, .18), transparent 42%),
    linear-gradient(140deg, #0b1725, #101a2d 55%, #10252d);
}

#academy-world-map[hidden] {
  display: none !important;
}

.academy-map-path {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .75rem;
}

.academy-map-node {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: .8rem;
  color: #e2e8f0;
  text-decoration: none;
  border: 1px solid rgba(56, 189, 248, .45);
  border-radius: 12px;
  background: rgba(15, 23, 42, .82);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
}

.academy-map-node:hover {
  border-color: #fbbf24;
  transform: translateY(-2px);
}

.academy-map-node.locked {
  border-color: rgba(245, 158, 11, .45);
}

.academy-map-node-icon {
  font-size: 1.4rem;
}

.academy-map-node small {
  color: #94a3b8;
}

.academy-map-node strong {
  font-size: .86rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.equipment-slot:focus-visible,
.slot-circular:focus-visible {
  outline: 3px solid #38bdf8;
  outline-offset: 3px;
}

.equipment-picker svg {
  display: block;
}

@media (max-width: 1023px) {
  .learning-shortcuts-grid,
  .learning-academies-grid,
  .learning-lessons-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .academy-map-path {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 580px) {
  .shop-items-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .55rem !important;
  }
  .shop-items-grid > .rpg-card {
    padding: .7rem !important;
    overflow-wrap: anywhere;
  }
  .shop-items-grid .btn-rpg {
    padding: .5rem .55rem;
    font-size: .8rem;
  }
}

