:root {
    --bg: #0c0a1f;
    --panel: #181530;
    --panel2: #221c3a;
    --accent: #c084fc;
    --gold: #a78bfa;
    --gold-dim: #7c3aed;
    --text: #ffffff;   /* biały tekst */
    --muted: #9f8ec7;
    --green: #4ade80;
    --blue: #60a5fa;
    --red: #f87171;
    --purple: #c084fc;
    --border: #2f2a45;   /* znacznie ciemniejsza ramka */
    --radius: 12px;
    --radius-lg: 16px;
    --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
    --font-heading: 'Cinzel', serif;
  }
  
  * { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

/* Globalne poprawki layoutu — zapobiegają wystającym elementom */
html, body {
  overflow-x: hidden;
}

#app {
  overflow-x: hidden;
}

#game-screen {
  overflow-x: hidden;
}

/* Lepsze constrainy dla kart i paneli */
.location-card,
.combat-panel,
.inv-item,
.option-card,
.spell-card,
.enemy-card,
.hud-wrapper {
  max-width: 100%;
}

/* Tylko te elementy mogą mieć ukryty overflow */
.inv-item,
.option-card,
.spell-card,
.enemy-card {
  overflow: hidden;
}

/* Sidebar */
#character-sidebar {
  max-width: 320px;
  overflow: hidden;
}

/* Zapobiega wystającym elementom w flex/grid */
.flex, .grid {
  min-width: 0;
}
  
  body {
    background: var(--bg);
    background-image: radial-gradient(circle at 50% 0%, #1a1530 0%, #0c0a1f 80%);
    color: var(--text);
    font-family: var(--font-ui);
    min-height: 100vh;
    overflow-x: clip;
    -webkit-font-smoothing: antialiased;
  }
  
  #app { 
    max-width: 480px; 
    margin: 0 auto; 
    padding: 12px; 
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .screen { display: none; animation: fadeSlideUp .4s cubic-bezier(0.16, 1, 0.3, 1); flex: 1; }
  .screen.active { display: block; }
  @keyframes fadeSlideUp { 
    from { opacity: 0; transform: translateY(15px) scale(0.98); } 
    to { opacity: 1; transform: translateY(0) scale(1); } 
  }

  #title-screen { text-align: center; padding: 10vh 20px 40px; }
  .title-logo { 
    font-family: var(--font-heading);
    font-size: 2.4em; 
    font-weight: 700;
    color: var(--gold); 
    text-shadow: 0 4px 15px rgba(217, 119, 6, 0.2); 
    line-height: 1.15; 
    margin-bottom: 12px; 
  }
  .title-sub { color: var(--muted); font-size: 0.95em; margin-bottom: 40px; font-weight: 600; letter-spacing: 0.5px; }
  .title-art { font-size: 5.5em; margin: 20px 0; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.1)); }

  .btn {
    display: block; 
    width: 100%; 
    padding: 16px; 
    margin: 10px 0;
    background: var(--panel);
    border: 2px solid var(--border); 
    border-radius: var(--radius);
    color: var(--text); 
    font-size: 0.95em; 
    font-family: var(--font-ui);
    font-weight: 700;
    cursor: pointer; 
    transition: all 0.2s ease; 
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  .btn:active { transform: translateY(2px) scale(0.98); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
  
  .btn.primary { background: linear-gradient(135deg, #c084fc, #a855f7); border-color: #7c3aed; color: #fff; box-shadow: 0 4px 10px rgba(192, 132, 252, 0.35); }
  .btn.gold { background: linear-gradient(135deg, #a78bfa, #7c3aed); border-color: #6d28d9; color: #fff; box-shadow: 0 4px 10px rgba(167, 139, 250, 0.35); }
  .btn.blue { background: linear-gradient(135deg, #6366f1, #4f46e5); border-color: #4338ca; color: #fff; box-shadow: 0 4px 10px rgba(99, 102, 241, 0.35); }
  .btn.green { background: linear-gradient(135deg, #34d399, #10b981); border-color: #059669; color: #fff; box-shadow: 0 4px 10px rgba(52, 211, 153, 0.35); }
  .btn.purple { background: linear-gradient(135deg, #c084fc, #a855f7); border-color: #7c3aed; color: #fff; box-shadow: 0 4px 10px rgba(192, 132, 252, 0.35); }
  
  .btn.small { padding: 10px 16px; font-size: 0.85em; width: auto; display: inline-block; margin: 4px; border-radius: 8px; }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(1); transform: none; box-shadow: none; }

  #create-screen { padding: 10px 4px; }
  .section-title { 
    color: var(--gold); 
    font-family: var(--font-heading);
    font-size: 1.2em; 
    margin: 24px 0 12px; 
    border-bottom: 2px solid var(--border); 
    padding-bottom: 8px; 
    font-weight: 700;
  }
  .race-grid, .class-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .feat-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
  
  .option-card {
    padding: 16px 12px; 
    background: var(--panel); 
    border: 2px solid var(--border);
    border-radius: var(--radius-lg); 
    cursor: pointer; 
    text-align: center;
    transition: all 0.2s ease; 
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }
  .option-card:active { transform: scale(0.96); }
  .option-card.selected { 
    border-color: #ffffff;           /* biała ramka zaznaczenia */
    background: #2a2347; 
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.35); 
  }
  .option-card .icon { font-size: 2.2em; margin-bottom: 6px; }
  .option-card .name { font-family: var(--font-heading); font-size: 1em; font-weight: 700; color: var(--gold); margin: 4px 0 6px; }
  .option-card .desc { font-size: 0.75em; color: var(--muted); line-height: 1.4; font-weight: 500;}
  
  .stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-box { 
    background: var(--panel2); 
    border: 1px solid var(--border); 
    border-radius: var(--radius); 
    padding: 12px; 
    text-align: center; 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  }
  .stat-box .stat-name { font-size: 0.75em; color: var(--muted); font-weight: 700; letter-spacing: 0.5px; }
  .stat-box .stat-val { font-family: var(--font-heading); font-size: 1.6em; color: var(--gold); font-weight: bold; margin: 4px 0; }
  .stat-box .stat-mod { font-size: 0.85em; color: var(--blue); font-weight: 700; background: #dbeafe; border-radius: 4px; padding: 2px 0;}
  
  input[type=text] {
    width: 100%; 
    padding: 16px; 
    background: var(--panel); 
    border: 2px solid var(--border);
    border-radius: var(--radius); 
    color: var(--text); 
    font-size: 1em; 
    font-weight: 600;
    font-family: inherit; 
    outline: none;
    transition: border-color 0.2s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
  }
  input[type=text]:focus { border-color: var(--gold); background: #2a2347; }

  #game-screen { padding: 4px; }
  .hud {
    background: linear-gradient(145deg, #181530, #221c3a); 
    border: none;                    /* usunięta ramka */
    border-radius: var(--radius-lg);
    padding: 10px 12px; 
    margin-bottom: 0;
    box-shadow: none;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
  .hud-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
  .hero-name { font-family: var(--font-heading); color: var(--gold); font-size: 1.2em; font-weight: bold; margin-bottom: 4px;}
  .hero-info { font-size: 0.85em; color: var(--muted); font-weight: 600;}

  /* Wspólny sticky kontener HUD + Log (przesuwają się razem) */
  .hud-wrapper {
    position: sticky;
    top: 4px;
    z-index: 110;
    background: var(--panel);
    border: none;                    /* usunięta ramka */
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 18px rgba(0,0,0,0.1);
    overflow: hidden;
    margin-bottom: 8px;
  }

  .hud-portrait {
    width: 118px;
    height: 118px;
    border-radius: 18px;
    border: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    object-fit: cover;
    flex-shrink: 0;
    background: #111;
  }
  
  .bars { display: grid; gap: 6px; }
  .bar-row { display: flex; align-items: center; gap: 8px; }
  .bar-label { font-size: 0.82em; width: 22px; text-align: center; }
  .bar-track { 
    flex: 1; 
    background: #2a2347 !important; 
    border-radius: 8px; 
    height: 14px; 
    overflow: hidden; 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4) !important; 
    border: 1px solid var(--border);
  }
  .bar-fill { height: 100%; border-radius: 6px; transition: width 0.6s ease-in-out; }
  .bar-fill.hp { background: linear-gradient(90deg, #ef4444, #f87171); box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1); }
  .bar-fill.xp { background: linear-gradient(90deg, #3b82f6, #60a5fa); box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1); }
  .bar-fill.mp { background: linear-gradient(90deg, #8b5cf6, #a78bfa); box-shadow: inset 0 -2px 4px rgba(0,0,0,0.1); }
  .bar-num { font-size: 0.72em; color: var(--text); width: 44px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

  .log-box {
    background: transparent;
    border: none;
    box-shadow: none;
    max-height: 128px; 
    overflow-y: auto; 
    padding: 6px 14px 12px; 
    margin: 0;
    font-size: 0.87em; 
    line-height: 1.55; 
    font-weight: 600;
    scroll-behavior: smooth;
    color: #f1e7ff;           /* jaśniejszy, cieplejszy biały dla lepszej czytelności */
  }
  .log-box p { 
    margin-bottom: 6px; 
    border-bottom: 1px solid #3f3659;   /* nieco jaśniejsza ramka */
    padding-bottom: 5px; 
  }
  .log-box p:last-child { border-bottom: none; }

  .log-box .log-combat { color: #f87171; font-weight: 700; }
  .log-box .log-loot   { color: #fbbf24; font-weight: 700; }
  .log-box .log-info   { color: #60a5fa; font-weight: 600; }
  .log-box .log-success{ color: #4ade80; font-weight: 700; }
  .log-box .log-spell  { color: #c084fc; font-weight: 700; }
  .log-box .log-narr   { color: #e0d4ff; font-style: italic; font-weight: 500; }

  .tabs { 
    display: flex; 
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
    margin-bottom: 16px; 
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  }
  .tab {
    flex: 1;
    text-align: center;
    padding: 10px 2px; 
    border-radius: 10px; 
    cursor: pointer; 
    font-size: 0.72em; 
    font-weight: 700;
    color: var(--muted);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent; 
    white-space: nowrap;
  }
  .tab.active { 
    background: var(--panel); 
    color: var(--gold); 
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }

  .location-card {
    background: var(--panel); 
    border: none;                    /* usunięta ramka */
    border-radius: var(--radius-lg);
    padding: 16px; 
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    overflow: visible;
  }
  .location-title { 
    font-family: var(--font-heading); 
    color: var(--gold); 
    font-size: 1.22em; 
    font-weight: 800; 
    margin-bottom: 8px; 
    text-align: center; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px; 
    flex-wrap: wrap;
  }
  .loc-thumb {
    width: 140px;
    height: 140px;
    border-radius: 10px;
    border: none;
    object-fit: cover;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    flex-shrink: 0;
  }
  .location-desc { font-size: 0.9em; color: var(--muted); line-height: 1.5; margin-bottom: 16px; font-weight: 500; text-align: center; }
  .action-grid { 
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
  }

  /* Lepsze zachowanie przycisków akcji */
  .action-grid .btn {
    min-width: 0;
    padding: 8px 10px;
    font-size: 0.95em;
    line-height: 1.3;
    white-space: normal;
    text-align: left;
    word-break: break-word;
  }

  .combat-panel {
    background: linear-gradient(to bottom, #181530, #221c3a); 
    border: none;                    /* usunięta ramka */
    border-radius: var(--radius-lg);
    padding: 16px; 
    margin-bottom: 12px;
    box-shadow: 0 0 15px rgba(192, 132, 252, 0.2);
  }
  .enemy-card {
    background: var(--panel); 
    border: 2px solid var(--border); 
    border-radius: 10px;
    padding: 12px; 
    margin-bottom: 10px; 
    cursor: pointer; 
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  }
  .enemy-card:active { transform: scale(0.98); }
  .enemy-card.selected { 
    border-color: #ffffff;           /* biała ramka wybranego celu */
    background: #2a2347; 
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.4); 
  }
  .enemy-name { font-family: var(--font-heading); color: var(--text); font-size: 1.05em; font-weight: bold; display: flex; justify-content: space-between;}
  .enemy-bar-wrap { margin: 8px 0; }
  .combat-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
  
  .merc-panel {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff); 
    border: 2px solid #818cf8; 
    border-radius: 10px; 
    padding: 12px; 
    margin-bottom: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  }
  .merc-panel.singing { 
    border-color: #f59e0b; 
    background: #fffbeb;
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.3); 
    animation: pulseGlow 2s infinite;
  }
  @keyframes pulseGlow {
    0% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.2); }
    50% { box-shadow: 0 0 16px rgba(245, 158, 11, 0.5); }
    100% { box-shadow: 0 0 8px rgba(245, 158, 11, 0.2); }
  }

  .inv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .inv-item {
    background: var(--panel); 
    border: 2px solid var(--border); 
    border-radius: 10px;
    padding: 14px; 
    cursor: pointer; 
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
  .inv-item:active { transform: scale(0.96); }
  .inv-item .item-icon { font-size: 2.2em; margin-bottom: 6px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
  .inv-item .item-name { font-family: var(--font-heading); font-size: 0.9em; font-weight: 800; color: var(--gold); margin: 4px 0; }
  .inv-item .item-desc { font-size: 0.75em; color: var(--muted); line-height: 1.4; font-weight: 500;}
  .inv-item.equipped { 
    border-color: var(--green); 
    background: #ecfdf5; 
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
  }

  /* Zielona ramka dla unikatowych przedmiotów (np. Srebrny Sztylet) */
  .inv-item.unique-item {
    border-color: #4ade80;
    background: #052e16;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.35);
  }
  .inv-item.unique-item .item-name {
    color: #4ade80;
  }

  .shop-item {
    background: var(--panel2); 
    border: 1px solid var(--border); 
    border-radius: 10px;
    padding: 14px; 
    margin-bottom: 10px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
  }
  .shop-item .item-info .item-name { font-family: var(--font-heading); color: var(--gold); font-size: 0.95em; font-weight: bold; }
  .shop-item .item-info .item-desc { color: var(--muted); font-size: 0.8em; margin-top: 4px; line-height: 1.4; font-weight: 500; }
  .price { color: var(--gold); font-size: 0.9em; font-weight: 800; text-align: right; margin-bottom: 6px; }
  .quest-item { 
    padding: 12px; 
    border: 2px dashed var(--green); 
    background: #ecfdf5; 
    border-radius: 10px; 
    margin-bottom: 10px; 
    font-size: 0.85em; 
    font-weight: 700;
    color: var(--green); 
    text-align: center;
  }

  .story-journal { display: grid; gap: 10px; }
  .story-entry, .story-modal-card {
    background: var(--panel2); border: 1px solid var(--border);
    border-left: 4px solid var(--gold); border-radius: 10px; padding: 12px;
  }
  .story-entry.completed { 
    border-left-color: var(--green); 
    background: #181530; 
    border: 1px solid #4b3f6e;
  }
  .story-entry-top { display: flex; justify-content: space-between; gap: 8px; color: var(--gold); font-family: var(--font-heading); font-size: 0.92em; font-weight: 800; line-height: 1.3; }
  .story-status { flex: 0 0 auto; color: var(--muted); font-family: var(--font-ui); font-size: 0.75em; font-weight: 800; text-transform: uppercase; }
  .story-entry-desc, .story-stage-desc { color: var(--muted); font-size: 0.82em; line-height: 1.45; margin-top: 6px; }
  .story-entry-meta { display: grid; gap: 3px; color: var(--muted); font-size: 0.78em; line-height: 1.4; margin-top: 8px; }
  .story-entry-result { color: var(--green); font-size: 0.78em; font-weight: 700; line-height: 1.4; margin-top: 8px; }
  .story-stage-label { color: var(--muted); font-size: 0.75em; font-weight: 800; text-transform: uppercase; }
  .story-stage-title { color: var(--gold); font-family: var(--font-heading); font-size: 1.05em; font-weight: 800; margin-top: 4px; }
  .story-stage-meta { color: var(--muted); font-size: 0.85em; margin-top: 10px; }

  .language-switcher {
    position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right));
    z-index: 10000; display: flex; gap: 4px; padding: 4px; background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; backdrop-filter: blur(8px);
  }
  .language-switcher button {
    border: 0; border-radius: 6px; padding: 6px 8px; min-width: 34px; color: var(--muted);
    background: transparent; font-family: var(--font-ui); font-weight: 800; font-size: 0.72em; cursor: pointer;
  }
  .language-switcher button.active { color: #111827; background: var(--gold); }
  .martial-actions { margin-top: 10px; }

  /* KREMOWO PŁYNNE ANIMACJE MODALI */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.75); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; 
    z-index: 1000; padding: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
  }
  .modal-overlay.show {
    opacity: 1;
  }

  .modal {
    background: var(--panel); border: 2px solid var(--border); border-radius: var(--radius-lg);
    padding: 24px; max-width: 400px; width: 100%; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15); transform-origin: center;
    will-change: transform, opacity;
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .modal.show {
    transform: scale(1) translateY(0);
    opacity: 1;
  }

  .modal h2 { font-family: var(--font-heading); color: var(--gold); margin-bottom: 16px; font-size: 1.4em; text-align: center; font-weight: 800;}
  .modal p { font-size: 0.95em; line-height: 1.6; margin-bottom: 12px; color: var(--muted); text-align: center; font-weight: 500;}

  .dice-result {
    text-align: center; font-size: 3em; font-family: var(--font-heading); color: var(--gold);
    text-shadow: 0 4px 10px rgba(217, 119, 6, 0.2); margin: 16px 0; font-weight: 800;
    will-change: transform, opacity; animation: dicePop 0.3s ease-out forwards;
  }
  @keyframes dicePop { from{transform:scale(0.8); opacity:0;} to{transform:scale(1); opacity:1;} }

  .spell-list { display: grid; gap: 10px; }
  .spell-card { background: var(--panel2); border: 2px solid var(--purple); border-radius: 10px; padding: 14px; cursor: pointer; transition: all 0.2s; }
  .spell-card:active { transform: scale(0.97); }
  .spell-card .spell-name { font-family: var(--font-heading); color: var(--purple); font-size: 1.05em; font-weight: 800; margin-bottom: 4px; }
  .spell-card .spell-info { font-size: 0.85em; color: var(--muted); line-height: 1.4; font-weight: 500;}

  ::-webkit-scrollbar { width: 8px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 10px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--muted); }

  .level-up-banner {
    text-align: center; padding: 24px; background: radial-gradient(circle, #2a2347 0%, #181530 100%);
    border: 2px solid #a78bfa; border-radius: var(--radius-lg); margin-bottom: 16px;
    box-shadow: 0 4px 15px rgba(167, 139, 250, 0.25);
  }
  .level-up-banner h2 { font-family: var(--font-heading); color: #c084fc; font-size: 2em; margin-bottom: 8px; font-weight: 800;}
  .level-up-banner p { color: #d1c4ff; font-weight: 700; font-size: 1em; margin-bottom: 4px; }

  .separator { border: none; border-top: 2px solid var(--border); margin: 16px 0; }
  .gold-amount { color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; }
  .text-center { text-align: center; }
  .mt8 { margin-top: 12px; }
  .flex-row { display: flex; gap: 10px; align-items: center; }

  .equipped-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 16px 0; }
  .slot-card {
    background: var(--panel); border: 2px solid var(--border); border-radius: 10px; padding: 12px 10px;
    text-align: center; cursor: pointer; transition: all 0.2s ease; min-height: 72px; display: flex; flex-direction: column; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  }
  .slot-card:active { transform: scale(0.97); border-color: var(--gold); background: #fffbeb; }
  .slot-card .slot-label { font-size: 0.75em; color: var(--muted); font-weight: 700; letter-spacing: 0.5px; margin-bottom: 4px; }
  .slot-card .slot-content { font-family: var(--font-heading); font-size: 0.95em; color: var(--gold); font-weight: 800; line-height: 1.2; }

  div[style*="rgba(255,255,255,0.05)"], div[style*="rgba(0,0,0,0.3)"] { background: var(--panel2) !important; border: 1px solid var(--border) !important; color: var(--text) !important; }
  div[style*="rgba(255,255,255,0.03)"] { border-bottom-color: var(--border) !important; }
  div[style*="color:#fff"] { color: var(--text) !important; }
  span[style*="color:#fff"] { color: var(--text) !important; }

  /* =========================================================================
     EFEKTY DLA MAPY PUNKTOWEJ I PODRÓŻY
     ========================================================================= */
  
  .shake-animate {
      animation: screenShakeEffect 0.4s ease-in-out;
  }
  @keyframes screenShakeEffect {
      0%, 100% { transform: translateX(0); }
      10%, 30%, 50%, 70%, 90% { transform: translateX(-3px) translateY(2px); }
      20%, 40%, 60%, 80% { transform: translateX(3px) translateY(-2px); }
  }

  .map-wrapper {
      position: relative;
      background: #18181c;
      background-image: radial-gradient(circle at 50% 50%, #2a2a35 0%, #0e0e12 100%);
      border: none;                    /* usunięta ramka */
      border-radius: var(--radius-lg);
      height: 420px;
      margin: 10px 0 16px 0;
      overflow: hidden;
      box-shadow: inset 0 0 25px rgba(0,0,0,0.8), 0 4px 12px rgba(0,0,0,0.1);
  }

  /* Tryb szeroki ekran — znacznie większa mapa */
  @media (min-width: 1280px) {
    .map-wrapper {
      height: 680px;
      margin: 24px 0 32px 0;
    }
    
    .map-node {
      width: 52px;
      height: 52px;
      font-size: 1.65em;
    }
  }

/* Poprawki dla nowego układu z sidebarami */
@media (min-width: 1024px) {
  #game-screen > div.flex {
    gap: 24px;
  }
  
  .location-card {
    padding: 20px;
  }
}

  .map-svg {
      position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none;
  }

  .map-link-line {
      stroke: rgba(255, 255, 255, 0.15); stroke-width: 2; stroke-dasharray: 4 4; transition: all 0.3s ease;
  }
  .map-link-line.active-path {
      stroke: var(--gold); stroke-width: 3; stroke-dasharray: none; animation: mapLineGlow 2.5s infinite ease-in-out;
  }
  @keyframes mapLineGlow {
      0%, 100% { opacity: 0.5; filter: drop-shadow(0 0 1px var(--gold)); }
      50% { opacity: 1; filter: drop-shadow(0 0 5px #fbbf24); }
  }

  .map-node {
      position: absolute; z-index: 2; transform: translate(-50%, -50%); width: 36px; height: 36px;
      background: var(--panel2); border: 2px solid var(--muted); border-radius: 50%;
      display: flex; align-items: center; justify-content: center; font-size: 1.25em; cursor: pointer;
      transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 4px 8px rgba(0,0,0,0.4);
      -webkit-tap-highlight-color: transparent;
  }
  .map-node:active { transform: translate(-50%, -50%) scale(0.9); }
  .map-node.current { border-color: var(--accent); background: #fff1f2; box-shadow: 0 0 16px var(--accent); animation: nodePulse 2s infinite; }
  .map-node.selectable { border-color: var(--gold); background: #fffbeb; box-shadow: 0 0 12px rgba(217, 119, 6, 0.4); }
  .map-node.locked { filter: grayscale(1) brightness(0.5); opacity: 0.5; cursor: not-allowed; }

  .map-node.has-thumb {
      border: 2.5px solid var(--gold);
      box-shadow: 0 4px 12px rgba(0,0,0,0.5), 0 0 0 3px rgba(167,139,250,0.15);
      background-color: #111;
      filter: brightness(1.18) contrast(1.08);
  }
  .map-node.has-thumb.current {
      border-color: var(--accent);
      box-shadow: 0 0 18px var(--accent), 0 4px 12px rgba(0,0,0,0.5);
      filter: brightness(1.22) contrast(1.1);
  }
  .map-node.has-thumb.selectable {
      border-color: #fbbf24;
      box-shadow: 0 0 14px rgba(251,191,36,0.5), 0 4px 12px rgba(0,0,0,0.5);
      filter: brightness(1.2) contrast(1.08);
  }

  /* Zupełnie ukryte węzły dla nieodkrytych / zablokowanych lokacji */
  .map-node.locked {
      display: none !important;
      pointer-events: none;
      opacity: 0;
  }
  
  @keyframes nodePulse {
      0% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7); }
      70% { box-shadow: 0 0 0 12px rgba(236, 72, 153, 0); }
      100% { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
  }

  .map-avatar-token {
      position: absolute; z-index: 3; width: 30px; height: 30px; background: var(--accent);
      border: 2px solid #ffffff; border-radius: 50%; display: flex; align-items: center; justify-content: center;
      font-size: 0.9em; transform: translate(-50%, -50%);
      transition: top 0.6s cubic-bezier(0.25, 1, 0.5, 1), left 0.6s cubic-bezier(0.25, 1, 0.5, 1);
      pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  }

  .node-title-overlay {
      position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
      background: rgba(15, 23, 42, 0.85); color: #ffffff; padding: 4px 14px; border-radius: 20px;
      font-size: 0.8em; font-family: var(--font-heading); font-weight: bold; pointer-events: none;
      white-space: nowrap; border: 1px solid rgba(255,255,255,0.1); letter-spacing: 0.5px;
  }

  .map-node-label {
      position: absolute;
      z-index: 4;
      transform: translate(-50%, -2px);
      background: rgba(15, 23, 42, 0.95);
      color: #e0d4ff;
      padding: 1px 8px 2px;
      border-radius: 6px;
      font-size: 0.60em;
      font-family: var(--font-heading);
      font-weight: 700;
      letter-spacing: 0.4px;
      white-space: nowrap;
      pointer-events: none;
      border: 1px solid rgba(167, 139, 250, 0.3);
      box-shadow: 0 2px 4px rgba(0,0,0,0.5);
      text-shadow: 0 1px 2px rgba(0,0,0,0.7);
      text-align: center;
  }
/* === ENEMY PORTRAITS IN COMBAT === */
.enemy-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.enemy-portrait {
  width: 100%;
  max-width: 306px;
  height: clamp(204px, 49vw, 289px);
  border-radius: 18px;
  object-fit: cover;
  object-position: center 18%;
  border: 3px solid rgba(167, 139, 250, 0.55);
  box-shadow:
    0 10px 28px rgba(0,0,0,0.48),
    0 0 22px rgba(167,139,250,0.12),
    inset 0 0 0 1px rgba(255,255,255,0.08);
  margin: 0 auto 10px;
  display: block;
  background: radial-gradient(circle at 50% 20%, rgba(167,139,250,0.16), #111 68%);

  /* Wygładzanie miniatur i skalowania */
  image-rendering: auto;
  -webkit-image-rendering: optimizeQuality;
  image-rendering: smooth;

  /* Delikatniejszy kontrast i saturacja — mniej podkreśla piksele */
  filter: brightness(1.06) saturate(1.12) contrast(1.01);
}

.enemy-card.selected .enemy-portrait {
  border-color: #ffffff;
  box-shadow:
    0 12px 34px rgba(0,0,0,0.55),
    0 0 28px rgba(255,255,255,0.28),
    0 0 32px rgba(167,139,250,0.22);
}

.enemy-card .enemy-icon-fallback {
  width: 100%;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5.2em;
  line-height: 1;
  text-align: center;
  margin-bottom: 10px;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 25%, rgba(167,139,250,0.2), #111 70%);
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.5));
}

@media (min-width: 1024px) {
  .enemy-portrait {
    max-width: 280px;
    height: 306px;
  }

  .enemy-card .enemy-icon-fallback {
    min-height: 255px;
    font-size: 5.1em;
    margin-bottom: 10px;
  }
}

@media (min-width: 1400px) {
  .enemy-portrait {
    max-width: 323px;
    height: 357px;
  }
}

/* =============================================
   FIXED COMBAT ACTION BAR (przyklejony na dole)
   ============================================= */
.combat-fixed {
    position: fixed !important;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    background: linear-gradient(160deg, rgba(24,21,48,0.95) 0%, rgba(34,28,58,0.92) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 2px solid rgba(192, 132, 252, 0.35);
    border-top: 3px solid #a78bfa;
    padding: 12px 14px 16px;
    box-shadow: 
        0 -10px 30px rgba(0,0,0,0.4),
        0 0 25px rgba(167, 139, 250, 0.2),
        inset 0 1px 0 rgba(255,255,255,0.08);
    z-index: 300;
    margin-top: 0 !important;
    gap: 9px;
    border-radius: 18px 18px 0 0;
    grid-template-columns: repeat(3, 1fr);
}

/* Lepszy układ walki na desktopie */
@media (min-width: 1024px) {
  .combat-fixed {
    max-width: 1100px;
    padding: 16px 24px 20px;
    border-radius: 20px 20px 0 0;
    grid-template-columns: repeat(4, 1fr); /* więcej miejsca na akcje */
  }
  
  .combat-panel {
    max-width: 1100px;
    margin: 0 auto 16px;
  }
  
  .enemy-card {
    padding: 18px;
  }
}

.combat-fixed .btn {
    padding: 11px 8px;
    font-size: 0.82em;
    margin: 0;
    font-weight: 700;
    white-space: nowrap;
    line-height: 1.25;
    border: 2px solid #b45309;
    box-shadow: 
        0 4px 0 #92400e,
        0 5px 10px rgba(146, 64, 14, 0.45),
        inset 0 1px 0 rgba(255,255,255,0.6),
        inset 0 -2px 3px rgba(0,0,0,0.15);
    transition: all 0.1s cubic-bezier(0.23, 1, 0.32, 1);
    border-radius: 10px;
}

.combat-fixed .btn:hover {
    filter: brightness(1.08) saturate(1.1);
    box-shadow: 
        0 4px 0 #92400e,
        0 7px 18px rgba(245, 158, 11, 0.55);
}

.combat-fixed .btn:active {
    transform: translateY(4px);
    box-shadow: 
        0 1px 0 #92400e,
        0 2px 5px rgba(146, 64, 14, 0.4);
    filter: brightness(0.95);
}

/* Dodatkowy padding na dole ekranu podczas walki */
#game-screen.in-combat #tab-content {
    padding-bottom: 165px;
}

/* =============================================
   DAMAGE GLOW + FLOATING NUMBERS (nowy efekt)
   ============================================= */
.enemy-card.damage-glow {
  animation: enemy-damage-flash 650ms cubic-bezier(0.23, 1.0, 0.32, 1) forwards;
}

@keyframes enemy-damage-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0);
    background: #fff1f2;
    transform: scale(1);
  }
  15% {
    box-shadow: 0 0 0 14px rgba(239, 68, 68, 0.38);
    background: #fee2e2;
    transform: scale(1.015);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    background: var(--panel);
    transform: scale(1);
  }
}

/* Floating damage / heal numbers */
.floating-damage {
  position: fixed;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.6em;
  color: #ef4444;
  text-shadow: 
    0 3px 7px rgba(0,0,0,0.8),
    0 0 14px rgba(239, 68, 68, 0.7);
  pointer-events: none;
  z-index: 99999;
  white-space: nowrap;
  user-select: none;
  transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1), 
              opacity 1.05s ease-out;
}

.floating-damage.crit {
  color: #fbbf24;
  font-size: 2.0em;
  text-shadow: 
    0 4px 10px rgba(0,0,0,0.85),
    0 0 22px rgba(251, 191, 36, 0.85);
  animation: crit-pop 0.3s ease-out;
}

.floating-damage.heal {
  color: #10b981;
  text-shadow: 
    0 3px 7px rgba(0,0,0,0.65),
    0 0 14px rgba(16, 185, 129, 0.7);
}

.floating-damage.player {
  color: #f87171;
  font-size: 1.35em;
}

/* =============================================
   LEPSZE EFEKTY W WALCE (Desktop + Ogólne)
   ============================================= */

/* Silniejszy shake przy dużych obrażeniach */
.screen-shake-strong {
  animation: screenShakeStrong 0.45s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes screenShakeStrong {
  0%, 100% { transform: translate(0); }
  10%, 30%, 50%, 70%, 90% { transform: translate(-6px, 3px); }
  20%, 40%, 60%, 80% { transform: translate(6px, -3px); }
}

/* Efekt "hit stop" — krótka pauza przy trafieniu */
.hit-stop {
  animation: hitStop 120ms ease-out;
}

@keyframes hitStop {
  0% { transform: scale(1); }
  50% { transform: scale(0.985); }
  100% { transform: scale(1); }
}

/* Kolorowe obrażenia w zależności od typu */
.floating-damage.fire { color: #fb923c; text-shadow: 0 0 14px #f97316; }
.floating-damage.cold { color: #60a5fa; text-shadow: 0 0 14px #3b82f6; }
.floating-damage.lightning { color: #a5b4fc; text-shadow: 0 0 14px #6366f1; }
.floating-damage.poison { color: #4ade80; text-shadow: 0 0 14px #22c55e; }
.floating-damage.necrotic { color: #c084fc; text-shadow: 0 0 14px #7e22ce; }

/* Lepsza animacja ataku gracza */
.player-attack-flash {
  animation: playerAttackFlash 280ms ease-out;
}

@keyframes playerAttackFlash {
  0% { filter: brightness(1.4) saturate(1.3); }
  100% { filter: brightness(1) saturate(1); }
}

/* =============================================
   DESKTOP IMPROVEMENTS - Responsive & Wider Layout
   (zwiększona szerokość + ładniejsze układy na desktopie)
   ============================================= */
@media (min-width: 768px) {
  #app {
    max-width: 1100px;
    padding: 24px;
  }

  .title-logo { font-size: 3.2em; }
  .title-art { font-size: 7em; }

  .race-grid, .class-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .feat-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }

  .stats-grid { grid-template-columns: repeat(6, 1fr); gap: 16px; }
  .stat-box .stat-val { font-size: 2em; }

  .inv-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
  .inv-item { padding: 20px; }

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

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

  .map-wrapper {
    height: 480px;
    margin: 20px 0 24px 0;
  }

  .map-node {
    width: 48px;
    height: 48px;
    font-size: 1.5em;
  }

  .tabs {
    padding: 6px;
    margin-bottom: 24px;
  }
  .tab {
    font-size: 0.9em;
    padding: 14px 8px;
  }

  .location-card {
    padding: 24px;
  }

  .combat-panel {
    padding: 24px;
  }

  .enemy-card {
    padding: 18px;
  }

  .spell-list {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
  }

  .combat-fixed {
    max-width: 1100px;
    padding: 16px 24px 20px;
    border-radius: 20px 20px 0 0;
  }

  .combat-fixed .btn {
    font-size: 0.95em;
    padding: 14px 12px;
  }

  #game-screen.in-combat #tab-content {
    padding-bottom: 200px;
  }

  .section-title {
    font-size: 1.4em;
  }

  .hud-portrait {
    width: 140px;
    height: 140px;
  }

  .log-box {
    max-height: 180px;
    font-size: 0.92em;
  }

  .btn {
    font-size: 1.05em;
    padding: 18px;
  }

  .option-card {
    padding: 20px 16px;
  }

  .option-card .icon { font-size: 2.6em; }
  .option-card .name { font-size: 1.15em; }
  .option-card .desc { font-size: 0.85em; }
}

/* Jeszcze szersze ekrany (np. 2K/4K) */
@media (min-width: 1400px) {
  #app {
    max-width: 1280px;
  }
  
  .combat-fixed {
    max-width: 1280px;
  }
  
  .inv-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .action-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
  .equipped-grid { grid-template-columns: repeat(5, 1fr); }
}

@keyframes crit-pop {
  0% { transform: scale(0.6); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Player HUD damage flash */
.hud-wrapper.player-damage-flash,
#hud.player-damage-flash {
  animation: player-hud-damage 550ms ease-out;
}

@keyframes player-hud-damage {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.0); }
  20% { box-shadow: 0 0 0 18px rgba(239, 68, 68, 0.25); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes bossBreathing {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.015); }
}

