/* --- HAND-MADE RETRO RPG STYLE --- */
:root {
    --bg: #14110f;
    --card: #1c1815;
    --card-2: #221d19;
    --inset: #0f0d0b;
    --line: #3a2e26;
    --line-strong: #4a3b32;
    --text: #e6dfd5;
    --muted: #9c9186;
    --soft: #b8ad9e;
    --gold: #d4af37;
    --green: #81c784;
    --red: #e57373;
    --common: #cfc6b8;
    --unique: #6fa8dc;
    --heroic: #b48ae0;
    --legendary: #f0a640;
    --nav-h: 64px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image: radial-gradient(circle at top, #241f1a 0%, #14110f 70%);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Georgia', 'Times New Roman', serif;
    font-size: 15px;
    line-height: 1.45;
}

h1, h2, h3 { font-weight: normal; letter-spacing: 0.5px; margin: 0; }
h3 { color: var(--gold); font-size: 1.05rem; }
a { color: var(--gold); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.gold-text { color: var(--gold); font-weight: bold; }

/* --- Karty (stara księga) --- */
.card {
    background: var(--card);
    border: 3px double var(--line-strong);
    border-radius: 4px;
    padding: 1.1rem 1.2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* --- Ekrany startowe --- */
.screen.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; padding: 2rem; }
.auth-card::before {
    content: ""; position: absolute; inset: 5px; border: 1px solid #2d241f; pointer-events: none;
}
.logo { color: var(--gold); text-align: center; font-size: 1.6rem; text-shadow: 2px 2px 4px rgba(0,0,0,.9); }
.tagline { text-align: center; color: var(--soft); font-style: italic; margin: 0.4rem 0 1.4rem; }

.tabs { display: flex; margin-bottom: 1.4rem; background: var(--bg); border: 1px solid var(--line); padding: 3px; }
.tab-btn {
    flex: 1; background: transparent; border: none; color: var(--muted); padding: 0.55rem;
    font: inherit; font-weight: bold; cursor: pointer; border-radius: 2px;
}
.tab-btn:hover { color: var(--text); background: #241f1a; }
.tab-btn.active { background: var(--line); color: var(--gold); box-shadow: inset 0 1px 3px rgba(0,0,0,.5); }

.field { margin-bottom: 1rem; }
label { display: block; margin-bottom: 0.35rem; font-size: 0.85rem; color: var(--soft); }
input {
    width: 100%; padding: 0.7rem; border: 1px solid var(--line-strong); background: var(--inset); color: #f4eee1;
    border-radius: 2px; font: inherit; box-shadow: inset 0 2px 4px rgba(0,0,0,.6);
}
input:focus { outline: none; border-color: var(--gold); }
.hint { display: block; margin-top: 0.3rem; font-size: 0.75rem; color: #8c7a6b; font-style: italic; }
.message { margin: 1rem 0 0; text-align: center; font-size: 0.88rem; font-style: italic; min-height: 1.2em; }
.message.error { color: var(--red); }
.message.success { color: var(--green); }
.logout-btn.block { margin-top: 0.8rem; }

/* --- Przyciski --- */
.btn {
    padding: 0.6rem 1rem;
    background: linear-gradient(to bottom, #5a2e18, #3b1d0f);
    color: var(--text);
    border: 1px solid #7c4122;
    border-radius: 2px;
    font: inherit;
    font-weight: bold;
    letter-spacing: 0.4px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.1);
    transition: background 0.1s, border-color 0.1s, transform 0.05s;
}
.btn:hover:not(:disabled) { background: linear-gradient(to bottom, #6d381e, #4a2513); border-color: #9c532d; color: #fff; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.small { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn.ghost { background: transparent; border-color: var(--line-strong); box-shadow: none; color: var(--soft); }
.btn.ghost:hover:not(:disabled) { background: #241f1a; color: var(--text); }
.btn.green { background: linear-gradient(to bottom, #2b3a2a, #1b261a); border-color: #3e543c; }
.btn.danger { background: linear-gradient(to bottom, #5a1818, #3b0f0f); border-color: #8b2222; }

/* --- Pasek górny --- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.6rem 1.2rem;
    background: rgba(20, 17, 15, 0.94);
    border-bottom: 3px double var(--line-strong);
    backdrop-filter: blur(4px);
}
.brand { color: var(--gold); font-size: 1.15rem; letter-spacing: 1px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 0.7rem; }
.gold-pill { border: 1px solid #6e5827; border-radius: 20px; padding: 0.2rem 0.75rem; color: var(--gold); white-space: nowrap; }
.topbar-link { font-size: 0.85rem; text-decoration: none; white-space: nowrap; }
.topbar-link:hover { text-decoration: underline; }

/* --- Układ gry --- */
/* menu po lewej, treść na środku, bohater po prawej (jak w Shakes & Fidget) */
.layout {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr) 300px;
    grid-template-areas: "nav content hero";
    gap: 1.2rem;
    max-width: 1320px;
    margin: 0 auto;
    padding: 1.2rem;
    align-items: start;
}
/* .layout > .hero: karta bohatera (nie mylić z kartą wyprawy „hero” dla bossów) */
.layout > .hero { grid-area: hero; position: sticky; top: 80px; }
.content { grid-area: content; min-width: 0; }
.hero-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; border-bottom: 1px solid var(--line); padding-bottom: 0.6rem; margin-bottom: 0.8rem; }
.hero-head h2 { color: var(--gold); font-size: 1.3rem; overflow-wrap: anywhere; }
.level-badge { color: var(--soft); font-size: 0.85rem; white-space: nowrap; }
.level-badge b { color: var(--gold); }

.bar-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--soft); margin-top: 0.5rem; }
.bar { height: 10px; background: var(--inset); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; margin-top: 0.2rem; }
.bar > div { height: 100%; width: 0; transition: width 0.4s ease; }
.bar.hp > div { background: linear-gradient(to right, #7a2020, var(--red)); }
.bar.xp > div { background: linear-gradient(to right, #8b6b1f, var(--gold)); }

/* Statystyki z dymkiem */
.stat-list { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.15rem; }
.stat {
    position: relative; display: flex; justify-content: space-between; align-items: center;
    padding: 0.45rem 0.5rem; border-radius: 2px; cursor: help; outline: none;
}
.stat:hover, .stat:focus { background: var(--card-2); }
.stat .name { color: var(--soft); }
.stat .value { font-weight: bold; font-variant-numeric: tabular-nums; }
.stat .value .bonus { color: var(--green); font-weight: normal; font-size: 0.85rem; margin-left: 0.25rem; }
.stat.rating { border-top: 1px solid var(--line); margin-top: 0.4rem; padding-top: 0.6rem; }
.stat.rating .value { color: var(--gold); }

.tip {
    position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
    background: #0f0c0a; border: 1px solid var(--line-strong); border-radius: 3px;
    padding: 0.6rem 0.7rem; font-size: 0.82rem; line-height: 1.5;
    box-shadow: 0 8px 20px rgba(0,0,0,.8);
    opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity 0.12s, transform 0.12s;
    pointer-events: none; cursor: default;
}
.stat:hover .tip, .stat:focus .tip, .item:hover .tip, .item:focus .tip {
    opacity: 1; visibility: visible; transform: translateY(0);
}
.tip .row { display: flex; justify-content: space-between; gap: 1rem; }
.tip .row b { font-variant-numeric: tabular-nums; }
.tip .total { border-top: 1px solid var(--line); margin-top: 0.3rem; padding-top: 0.3rem; color: var(--gold); }
.tip .note { color: var(--muted); font-style: italic; margin-top: 0.35rem; }
.tip .title { font-weight: bold; margin-bottom: 0.2rem; }

/* --- Menu gry --- */
.game-nav {
    grid-area: nav;
    position: sticky; top: 80px;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.nav-btn {
    background: var(--card); border: 1px solid var(--line-strong); color: var(--soft);
    padding: 0.75rem 0.5rem; font: inherit; font-weight: bold; cursor: pointer; border-radius: 3px;
    display: flex; align-items: center; justify-content: flex-start; gap: 0.6rem;
    text-align: left;
}
.nav-btn span { font-size: 1.15rem; width: 1.5rem; text-align: center; }
/* licznik wyprawy przy przycisku menu: widać go z każdej zakładki */
.nav-timer {
    margin-left: auto; font-style: normal; font-size: 0.75rem; font-variant-numeric: tabular-nums;
    color: var(--gold); border: 1px solid #6e5827; border-radius: 10px; padding: 0 0.4rem;
}
.nav-timer.ready { color: #0f0c0a; background: var(--green); border-color: var(--green); }
.nav-btn:hover { color: var(--text); background: var(--card-2); }
.nav-btn.active { color: var(--gold); border-color: #6e5827; background: #2b241e; box-shadow: inset 3px 0 0 var(--gold); }

.view-title { color: var(--gold); font-size: 1.4rem; margin-bottom: 0.9rem; }
.section-title { margin: 1.2rem 0 0.6rem; }
.card .section-title { margin-top: 0; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.notice { border-left: 3px solid var(--gold); background: #221c14; padding: 0.7rem 0.9rem; margin-bottom: 1rem; display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.notice.danger { border-color: var(--red); background: #241414; }

/* --- Wyprawy --- */
.expeditions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
.expedition { display: flex; flex-direction: column; gap: 0.6rem; }
.expedition p { color: var(--soft); font-size: 0.88rem; margin: 0; flex: 1; }
.expedition.normal { border-color: #3e543c; }
.expedition.normal .btn { background: linear-gradient(to bottom, #2b3a2a, #1b261a); border-color: #3e543c; }
.expedition.elite { border-color: #6e5827; }
.expedition.elite .btn { background: linear-gradient(to bottom, #4a3b1a, #2e2410); border-color: #6e5827; }
.expedition.hero { border-color: #8b2222; }
.expedition.hero .btn { background: linear-gradient(to bottom, #5a1818, #3b0f0f); border-color: #8b2222; }

/* trwająca wyprawa */
.expedition-active { border-color: #6e5827; margin-bottom: 1rem; }
.exp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.exp-head h3 { color: var(--gold); margin: 0 0 0.2rem; }
.exp-head p { margin: 0; }
.exp-timer { font-size: 2rem; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1; white-space: nowrap; }
.bar.time { height: 12px; margin: 0.9rem 0; }
.bar.time > div { background: linear-gradient(to right, #6e5827, var(--gold)); transition: width 0.25s linear; }
.exp-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.exp-duration { margin: 0 0 0.8rem; font-size: 0.9rem; }

.combat-log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.combat-log li { background: var(--card); border: 1px solid var(--line); border-left-width: 3px; padding: 0.55rem 0.8rem; font-size: 0.9rem; }
.combat-log li.win { border-left-color: var(--green); }
.combat-log li.loss { border-left-color: var(--red); }
.combat-log li.levelup { border-left-color: var(--gold); }
.combat-log .time { color: var(--muted); font-size: 0.75rem; margin-right: 0.4rem; }
.combat-log .loot { font-weight: bold; }

/* --- Przedmioty --- */
.rarity-common    { color: var(--common); }
.rarity-unique    { color: var(--unique); }
.rarity-heroic    { color: var(--heroic); }
.rarity-legendary { color: var(--legendary); text-shadow: 0 0 6px rgba(240, 166, 64, 0.35); }

.item {
    position: relative; display: flex; align-items: center; gap: 0.55rem; width: 100%;
    background: var(--inset); border: 1px solid var(--line); border-radius: 3px;
    padding: 0.55rem 0.6rem; font: inherit; text-align: left; cursor: pointer; color: inherit;
}
.item:hover, .item:focus { border-color: var(--line-strong); background: #17130f; outline: none; }
.item.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.item .icon { font-size: 1.25rem; width: 1.6rem; text-align: center; flex: none; }
.item .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.item.border-unique { border-color: #35506a; }
.item.border-heroic { border-color: #5a4570; }
.item.border-legendary { border-color: #7a5a24; }
.item .tip { left: 0; right: auto; min-width: 220px; }

.equipment-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 1rem; }
.slots { display: flex; flex-direction: column; gap: 0.5rem; }
.slot-label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.15rem; }
.slot-empty { border: 1px dashed var(--line-strong); color: var(--muted); padding: 0.6rem; border-radius: 3px; font-size: 0.85rem; font-style: italic; }
.bag { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.5rem; }
.bag-empty { color: var(--muted); font-style: italic; }

.item-detail { margin-top: 1rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; }
.item-detail .info { min-width: 0; }
.item-detail .desc { color: var(--soft); font-style: italic; font-size: 0.88rem; margin: 0.25rem 0 0; }
.item-detail .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* --- Sklep --- */
.healer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.healer p { margin: 0.3rem 0 0; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.8rem; margin-bottom: 1rem; }
.offer { display: flex; flex-direction: column; gap: 0.6rem; padding: 0.9rem; }
.offer .price { color: var(--gold); font-weight: bold; }
.offer .meta { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.offer.sold { opacity: 0.5; }
.offer .req { font-size: 0.78rem; color: var(--red); }

/* --- Trening --- */
.training-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.9rem; }
.train-card { display: flex; flex-direction: column; gap: 0.5rem; }
.train-card .head { display: flex; justify-content: space-between; align-items: baseline; }
.train-card .head .value { font-size: 1.5rem; color: var(--gold); font-variant-numeric: tabular-nums; }
.train-card p { margin: 0; color: var(--soft); font-size: 0.88rem; flex: 1; }

/* --- Powiadomienie --- */
.toast {
    position: fixed; right: 1rem; bottom: 1rem; z-index: 50; max-width: min(420px, calc(100vw - 2rem));
    background: var(--card); border: 1px solid var(--line-strong); border-left: 4px solid var(--green);
    padding: 0.75rem 1rem; box-shadow: 0 8px 24px rgba(0,0,0,.8); font-size: 0.9rem;
}
.toast.error { border-left-color: var(--red); }

/* --- Konto gościa --- */
.guest-box { margin-top: 1.2rem; display: flex; flex-direction: column; gap: 0.4rem; text-align: center; }
.guest-box .or { color: var(--muted); font-size: 0.8rem; }
.demo-badge {
    font-size: 0.75rem; color: var(--gold); border: 1px dashed #6e5827; border-radius: 10px;
    padding: 0.15rem 0.6rem; white-space: nowrap;
}

/* --- Mniejszy laptop: bohater pod menu, po lewej --- */
@media (max-width: 1180px) {
    .layout {
        grid-template-columns: 260px minmax(0, 1fr);
        grid-template-areas: "nav content" "hero content";
    }
    .layout > .hero { position: static; }
    .game-nav { position: static; }
}

/* --- Tablet --- */
@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; grid-template-areas: "nav" "hero" "content"; }
    .layout > .hero { position: static; }
    .game-nav { flex-direction: row; }
    .nav-btn { flex: 1; justify-content: center; }
    .stat-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.15rem 0.8rem; }
    .stat.rating { grid-column: 1 / -1; }
    .expeditions { grid-template-columns: 1fr; }
    .equipment-layout { grid-template-columns: 1fr; }
}

/* --- Telefon: menu jako pasek na dole ekranu --- */
@media (max-width: 640px) {
    body { font-size: 14px; }
    .layout { padding: 0.8rem 16px calc(var(--nav-h) + 1rem); gap: 0.8rem; }
    .topbar { padding: 0.5rem 16px; }
    .brand span { display: none; }
    .layout { grid-template-areas: "hero" "content"; }
    .exp-timer { font-size: 1.5rem; }
    .demo-badge { display: none; }
    .game-nav {
        position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 25; margin: 0;
        height: var(--nav-h); gap: 0; background: rgba(20, 17, 15, 0.97);
        border-top: 3px double var(--line-strong);
    }
    .nav-btn { flex-direction: column; justify-content: center; gap: 0.1rem; border: 0; border-radius: 0; font-size: 0.72rem; padding: 0.4rem 0.2rem; background: transparent; position: relative; }
    .nav-timer { position: absolute; top: 2px; right: 4px; margin: 0; font-size: 0.62rem; }
    .nav-btn span { font-size: 1.25rem; }
    .nav-btn.active { box-shadow: inset 0 3px 0 var(--gold); background: #1c1815; }
    .training-list { grid-template-columns: 1fr; }
    .bag { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .card { padding: 0.9rem; }
    .auth-card { padding: 1.4rem; }
    .toast { bottom: calc(var(--nav-h) + 0.8rem); }
}

/* Kafelek w sklepie tylko pokazuje dymek, kupuje się przyciskiem */
.offer .item { cursor: default; }
body.busy .btn { cursor: progress; }
