/* Kroniki Popiołu: Edycja Legendarna v3.0 — Autonomiczny arkusz stylów (działa w 100% offline) */
:root {
  --bg-deep: #070911;
  --bg-panel: rgba(14, 19, 32, 0.96);
  --bg-card: #0f172a;
  --bg-card-2: #162033;
  --border-gold: rgba(229, 185, 76, 0.38);
  --border-slate: rgba(148, 163, 184, 0.22);
  --gold: #e5b94c;
  --gold-light: #fde68a;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --red: #f87171;
  --green: #4ade80;
  --blue: #38bdf8;
  --purple: #c084fc;
  --orange: #fb923c;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
html, body { margin: 0; padding: 0; width: 100%; height: 100dvh; overflow: hidden; background: var(--bg-deep); color: var(--text-main); font-family: 'Inter', system-ui, -apple-system, sans-serif; }
body { display: flex; flex-direction: column; position: relative; }

.hidden { display: none !important; }
.font-fantasy { font-family: 'Cinzel', Georgia, serif; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.35); }
::-webkit-scrollbar-thumb { background: rgba(229, 185, 76, 0.45); border-radius: 99px; }

/* Panele i przyciski */
.glass-panel {
  background: linear-gradient(180deg, rgba(18, 24, 40, 0.96) 0%, rgba(9, 12, 21, 0.99) 100%);
  border: 1px solid var(--border-gold);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

button { font-family: inherit; color: inherit; cursor: pointer; border: none; background: none; }
button:disabled { opacity: 0.38; cursor: not-allowed; filter: grayscale(0.55); }

.btn-gold {
  background: linear-gradient(180deg, #2b2317 0%, #16120c 100%);
  border: 1px solid rgba(229, 185, 76, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 236, 179, 0.22), 0 4px 12px rgba(0, 0, 0, 0.5);
  color: #fef3c7;
  transition: transform 0.1s ease, filter 0.15s ease, border-color 0.15s ease;
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.18); border-color: var(--gold-light); }
.btn-gold:active:not(:disabled) { transform: scale(0.97); }

.btn-ember {
  background: linear-gradient(180deg, #c2410c 0%, #7c2d12 100%);
  border: 1px solid rgba(251, 146, 60, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 4px 14px rgba(194, 65, 12, 0.45);
  color: #fff7ed;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn-ember:hover:not(:disabled) { filter: brightness(1.16); }
.btn-ember:active:not(:disabled) { transform: scale(0.97); }

.btn-ult {
  background: linear-gradient(180deg, #9333ea 0%, #581c87 100%);
  border: 1px solid #e879f9;
  box-shadow: 0 0 18px rgba(192, 132, 252, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  color: #faf5ff;
  transition: transform 0.1s ease, filter 0.15s ease;
}
.btn-ult:hover:not(:disabled) { filter: brightness(1.18); }
.btn-ult:disabled { box-shadow: none; }

.btn-slate {
  background: #1e293b;
  border: 1px solid #475569;
  color: #e2e8f0;
  transition: filter 0.15s ease;
}
.btn-slate:hover:not(:disabled) { filter: brightness(1.18); }

.btn-danger {
  background: rgba(69, 10, 10, 0.85);
  border: 1px solid rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}
.btn-danger:hover:not(:disabled) { background: rgba(127, 29, 29, 0.9); }

@keyframes comboPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.85), inset 0 0 12px rgba(250, 204, 21, 0.35); border-color: #fde047; }
  50% { box-shadow: 0 0 20px 4px rgba(250, 204, 21, 0.6), inset 0 0 18px rgba(250, 204, 21, 0.55); border-color: #fef08a; }
}
.combo-glow { animation: comboPulse 1.1s infinite ease-in-out !important; }

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.7; }
}

/* Rzadkości */
.rar-common    { border-color: #64748b !important; color: #e2e8f0; }
.rar-rare      { border-color: #3b82f6 !important; color: #93c5fd; box-shadow: 0 0 10px rgba(59, 130, 246, 0.22); }
.rar-epic      { border-color: #a855f7 !important; color: #d8b4fe; box-shadow: 0 0 12px rgba(168, 85, 247, 0.28); }
.rar-legendary { border-color: #f97316 !important; color: #fdba74; box-shadow: 0 0 16px rgba(249, 115, 22, 0.35); }
.rar-mythic    { border-color: #ef4444 !important; color: #fca5a5; box-shadow: 0 0 20px rgba(239, 68, 68, 0.45); background: linear-gradient(180deg, rgba(69, 10, 10, 0.65), rgba(15, 23, 42, 0.95)) !important; }

/* TOP HUD */
.top-hud {
  position: relative; z-index: 20; flex-shrink: 0;
  background: rgba(10, 13, 22, 0.96);
  border-bottom: 1px solid rgba(229, 185, 76, 0.3);
  padding: 6px 10px;
}
.hud-inner {
  max-width: 1320px; margin: 0 auto;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px;
}
.hud-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.class-badge {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: rgba(69, 26, 3, 0.75); border: 1px solid rgba(251, 191, 36, 0.6);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.hud-hero-meta { min-width: 0; }
.hud-name-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hero-title { font-size: 13px; font-weight: 700; color: #fde68a; white-space: nowrap; }
.pill { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; }
.pill-gold { background: rgba(245, 158, 11, 0.2); border: 1px solid rgba(245, 158, 11, 0.45); color: #fcd34d; }
.pill-slate { background: #1e293b; border: 1px solid #334155; color: #cbd5e1; }
.hud-vitals { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; font-size: 11px; }
.vital { font-weight: 600; }
.vital-hp { color: #6ee7b7; }
.vital-mp { color: #93c5fd; }
.vital-xp { color: #d8b4fe; }

.torch-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 99px; font-size: 10px; font-weight: 700;
  background: rgba(124, 45, 18, 0.65); border: 1px solid rgba(251, 146, 60, 0.65); color: #fed7aa;
}
.torch-pill.tier-low { background: rgba(127, 29, 29, 0.8); border-color: #ef4444; color: #fecaca; }
.torch-pill.tier-mid { background: rgba(113, 63, 18, 0.7); border-color: #eab308; color: #fef08a; }
.torch-tier { font-size: 9px; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.04em; }

.hud-right { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.res-pill { padding: 4px 7px; border-radius: 8px; font-size: 11px; font-weight: 700; border: 1px solid; }
.res-gold  { background: rgba(69, 26, 3, 0.55); border-color: rgba(245, 158, 11, 0.4); color: #fcd34d; }
.res-crys  { background: rgba(8, 51, 68, 0.55); border-color: rgba(6, 182, 212, 0.4); color: #67e8f9; }
.res-ess   { background: rgba(74, 4, 78, 0.55); border-color: rgba(217, 70, 239, 0.4); color: #f0abfc; }
.res-torch { background: rgba(67, 20, 7, 0.55); border-color: rgba(249, 115, 22, 0.4); color: #fdba74; }

.nav-btn {
  position: relative; padding: 5px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px;
}
.nav-lbl { display: none; }
@media (min-width: 960px) { .nav-lbl { display: inline; } }

.icon-btn {
  width: 28px; height: 28px; border-radius: 8px; background: #1e293b;
  border: 1px solid #334155; font-size: 12px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { border-color: var(--gold); }

.notif-dot {
  position: absolute; top: -3px; right: -3px; width: 9px; height: 9px;
  border-radius: 50%; border: 1px solid #000; animation: pulseDot 1.3s infinite;
}
.dot-amber { background: #fbbf24; }
.dot-green { background: #34d399; }
.dot-red   { background: #ef4444; }

/* STAGE / CANVAS */
.stage-wrap { position: relative; flex: 1; width: 100%; overflow: hidden; min-height: 200px; }
canvas#game-canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; }

.map-hint {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 10;
  padding: 6px 14px; border-radius: 99px; max-width: 92%; text-align: center;
  background: rgba(10, 13, 22, 0.9); border: 1px solid rgba(251, 191, 36, 0.45);
  font-size: 12px; font-weight: 600; color: #fef3c7; pointer-events: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
}

.init-bar {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 10;
  padding: 5px 10px; border-radius: 14px; max-width: 96%; overflow-x: auto;
  background: rgba(10, 13, 22, 0.9); border: 1px solid rgba(245, 158, 11, 0.35);
  display: flex; align-items: center; gap: 5px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}
.init-chip {
  padding: 2px 7px; border-radius: 8px; font-size: 10px; font-weight: 700; white-space: nowrap;
  border: 1px solid #334155; background: #1e293b; color: #e2e8f0;
}
.init-chip.active { background: rgba(245, 158, 11, 0.3); border-color: #fbbf24; color: #fef3c7; }
.init-chip.enemy { background: rgba(69, 10, 10, 0.75); border-color: rgba(220, 38, 38, 0.6); color: #fecaca; }

.combat-log {
  position: absolute; top: 46px; left: 10px; z-index: 9;
  width: 260px; max-width: 44vw; pointer-events: none;
  display: flex; flex-direction: column; gap: 3px;
}
.combat-log-line {
  background: rgba(7, 10, 18, 0.76); border-left: 2px solid rgba(229, 185, 76, 0.6);
  padding: 3px 7px; border-radius: 0 6px 6px 0; font-size: 10px; color: #cbd5e1;
  line-height: 1.25;
}
@media (max-width: 640px) { .combat-log { display: none; } }

.boss-banner {
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%); z-index: 30;
  padding: 14px 24px; border-radius: 16px; text-align: center; pointer-events: none;
  background: rgba(69, 10, 10, 0.96); border: 2px solid #fbbf24;
  box-shadow: 0 0 42px rgba(239, 68, 68, 0.85);
}
.boss-banner-title { font-size: 20px; font-weight: 800; color: #fcd34d; }
.boss-banner-sub { font-size: 12px; color: #fecaca; font-weight: 600; margin-top: 3px; }

/* TITLE OVERLAY */
.title-overlay {
  position: absolute; inset: 0; z-index: 20; overflow-y: auto;
  display: flex; align-items: center; justify-content: center; padding: 14px;
  background: radial-gradient(circle at 50% 25%, rgba(30, 20, 24, 0.7), rgba(7, 9, 17, 0.92));
}
.title-container {
  max-width: 1080px; width: 100%; margin: auto; text-align: center; padding: 10px 0;
}
.title-kicker { font-size: 11px; letter-spacing: 0.32em; color: #fbbf24; text-transform: uppercase; margin-bottom: 4px; }
.title-main {
  margin: 0; font-size: clamp(28px, 5vw, 52px); font-weight: 800;
  background: linear-gradient(180deg, #fef3c7 0%, #fbbf24 55%, #ea580c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(249, 115, 22, 0.42));
}
.title-sub { font-size: 13px; letter-spacing: 0.22em; color: #cbd5e1; text-transform: uppercase; margin: 4px 0 16px; }
.title-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 520px; margin: 0 auto 18px; }
.title-btn-lg { flex: 1; min-width: 190px; padding: 11px 16px; border-radius: 14px; font-weight: 700; font-size: 13px; }
.title-btn-sm { padding: 11px 15px; border-radius: 14px; font-weight: 700; font-size: 12px; }
.title-btn-icon { padding: 11px 14px; border-radius: 14px; font-weight: 700; font-size: 13px; }
.title-pick-label { font-size: 11px; letter-spacing: 0.14em; color: #fde68a; text-transform: uppercase; margin-bottom: 10px; }

.class-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px; text-align: left;
}
.class-card {
  border-radius: 16px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.class-card:hover { border-color: #fbbf24; transform: translateY(-2px); }
.class-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.class-ico {
  width: 44px; height: 44px; border-radius: 12px; background: #0f172a;
  border: 1px solid rgba(251, 191, 36, 0.5); display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.stat-mini-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; text-align: center; margin: 10px 0 12px; }
.stat-mini { background: #0f172a; border-radius: 6px; padding: 4px 2px; font-size: 9px; }
.stat-mini div { color: var(--text-muted); }
.stat-mini b { font-size: 11px; }

/* CASTLE PANEL */
.castle-panel {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 20;
  background: rgba(10, 13, 22, 0.97); border-top: 1px solid rgba(245, 158, 11, 0.42);
  padding: 12px; max-height: 60%; overflow-y: auto;
}
.castle-inner { max-width: 1160px; margin: 0 auto; }

/* COMBAT CONTROLS */
.combat-controls {
  position: relative; z-index: 20; flex-shrink: 0;
  background: rgba(10, 13, 22, 0.97); border-top: 1px solid rgba(245, 158, 11, 0.35);
  padding: 8px 10px;
}
.combat-controls-inner { max-width: 1160px; margin: 0 auto; }
.combat-top-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 7px; }
.combat-actor-info { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: #fde68a; }
.fury-badge { padding: 2px 8px; border-radius: 99px; background: #3b0764; border: 1px solid rgba(192, 132, 252, 0.55); color: #e9d5ff; font-size: 10px; }
.combat-tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.mini-btn { padding: 4px 7px; border-radius: 8px; font-size: 10px; font-weight: 700; border: 1px solid; }
.mini-hp { background: #052e16; border-color: rgba(34, 197, 94, 0.45); color: #bbf7d0; }
.mini-mp { background: #172554; border-color: rgba(59, 130, 246, 0.45); color: #bfdbfe; }
.mini-fury { background: #3b0764; border-color: rgba(168, 85, 247, 0.45); color: #e9d5ff; }
.mini-cleanse { background: #083344; border-color: rgba(6, 182, 212, 0.45); color: #a5f3fc; }
.mini-torch { background: #431407; border-color: rgba(249, 115, 22, 0.5); color: #fed7aa; }

.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skill-btn { position: relative; padding: 8px 10px; border-radius: 12px; text-align: left; }
.skill-head { display: flex; justify-content: space-between; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: #fff; }
.skill-desc { font-size: 10px; color: rgba(226, 232, 240, 0.88); margin-top: 3px; line-height: 1.25; }
.combo-tag {
  position: absolute; top: -8px; right: 6px; padding: 1px 6px; border-radius: 5px;
  background: #facc15; color: #000; font-size: 9px; font-weight: 800;
}

/* TOASTS */
.toast-container {
  position: fixed; top: 62px; left: 50%; transform: translateX(-50%); z-index: 60;
  pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 92%; max-width: 440px;
}
.toast-item {
  padding: 8px 14px; border-radius: 12px; border: 1px solid; font-size: 12px; font-weight: 700;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.65); transition: opacity 0.3s, transform 0.3s;
}
.toast-amber  { background: rgba(69, 26, 3, 0.96); border-color: #fbbf24; color: #fef3c7; }
.toast-red    { background: rgba(69, 10, 10, 0.96); border-color: #f87171; color: #fee2e2; }
.toast-green  { background: rgba(6, 78, 59, 0.96); border-color: #34d399; color: #d1fae5; }
.toast-blue   { background: rgba(23, 37, 84, 0.96); border-color: #60a5fa; color: #dbeafe; }
.toast-purple { background: rgba(59, 7, 100, 0.96); border-color: #c084fc; color: #f3e8ff; }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.82);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.modal-box {
  width: 100%; max-width: 820px; border-radius: 16px; padding: 16px 18px;
  max-height: 90dvh; overflow-y: auto; border: 1px solid rgba(251, 191, 36, 0.5);
}

/* UTILITY LAYOUTS FOR MODALS & PANELS */
.row-between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.row-gap { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.col-gap { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 6px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border-slate);
  border-radius: 12px; padding: 10px;
}
.card-gold { border-color: rgba(245, 158, 11, 0.45); }
.tab-btn { padding: 6px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.close-btn { padding: 5px 10px; border-radius: 8px; background: #1e293b; color: #e2e8f0; font-size: 12px; font-weight: 700; }
.scroll-area { max-height: 54dvh; overflow-y: auto; padding-right: 2px; }
.text-center { text-align: center; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.text-gold { color: #fde68a; }
.text-amber { color: #fbbf24; }
.text-green { color: #4ade80; }
.text-red { color: #f87171; }
.text-blue { color: #38bdf8; }
.text-purple { color: #d8b4fe; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.w-full { width: 100%; }
.pad-btn { padding: 8px 12px; border-radius: 10px; font-size: 12px; font-weight: 700; }
.pad-btn-sm { padding: 5px 9px; border-radius: 8px; font-size: 11px; font-weight: 700; }
textarea.save-area {
  width: 100%; height: 110px; padding: 8px; border-radius: 10px;
  background: #020617; border: 1px solid #334155; color: #fde68a; font-family: monospace; font-size: 11px;
  user-select: text;
}
