:root {
    --bg: #0e0d12; --panel: #17151d; --panel2: #1f1c27; --panel3: #28243a;
    --accent: #d4a72c; --accent2: #f0c85a; --text: #ece8f1; --muted: #9a94a8;
    --border: #2e2a3a; --danger: #e5484d; --success: #3fb67a;
}
* { box-sizing: border-box; }
body {
    margin: 0; min-height: 100vh; color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background:
        radial-gradient(1100px 500px at 50% -10%, #2b2142 0%, transparent 65%),
        radial-gradient(800px 400px at 100% 100%, #1d2a2a 0%, transparent 60%),
        var(--bg);
    background-attachment: fixed;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: 'Cinzel', Georgia, 'Times New Roman', serif; margin: 0; letter-spacing: .5px; }
h1 { color: var(--accent2); font-size: 2rem; }
.container { max-width: 1000px; margin: 0 auto; padding: 24px 20px 60px; }

/* ---------- Top nav ---------- */
.top-nav {
    display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
    background: linear-gradient(180deg, var(--panel2), var(--panel));
    border: 1px solid var(--border); border-radius: 12px; padding: 12px 20px; margin-bottom: 28px;
    box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.brand { font-family: 'Cinzel', Georgia, serif; font-weight: 700; color: var(--accent2); font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.brand svg { width: 26px; height: 26px; }
.nav-links { display: flex; gap: 6px; }
.nav-links a { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .95rem; transition: .15s; }
.nav-links a:hover { color: var(--text); background: var(--panel3); }
.nav-links a.active { color: #15120a; background: var(--accent); }
.user-box { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .9rem; }
.user-box strong { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: linear-gradient(180deg, var(--accent2), var(--accent)); color: #15120a;
    border: none; padding: 10px 18px; font-weight: 700; font-size: .95rem; border-radius: 8px; cursor: pointer;
    transition: transform .1s, filter .15s; font-family: inherit;
}
.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }
.btn.secondary { background: var(--panel3); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #5a2427; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 12px; font-size: .85rem; }

/* ---------- Page header ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.status-msg { color: var(--danger); font-size: .9rem; margin-bottom: 12px; min-height: 1em; }

/* ---------- Portrait ---------- */
.portrait {
    position: relative; width: var(--size, 96px); height: var(--size, 96px); flex-shrink: 0;
}
.portrait .face {
    width: 100%; height: 100%; border-radius: 50%; overflow: hidden;
    background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--tone) 45%, #3a3450), #16131f 80%);
    border: 3px solid var(--tone, var(--accent));
    box-shadow: 0 0 18px color-mix(in srgb, var(--tone) 40%, transparent);
}
.portrait .face svg { width: 100%; height: 100%; display: block; }
.portrait .badge {
    position: absolute; right: -6px; bottom: -6px; width: 42%; height: 42%; border-radius: 50%;
    background: #14121b; border: 2px solid var(--cc, var(--accent)); padding: 14%;
    box-shadow: 0 2px 8px rgba(0,0,0,.6);
}
.portrait .badge svg { width: 100%; height: 100%; display: block; }

/* ---------- Roster ---------- */
.roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.char-card {
    background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--border);
    border-radius: 14px; padding: 20px; box-shadow: 0 6px 18px rgba(0,0,0,.4);
    display: flex; flex-direction: column; gap: 14px; position: relative; overflow: hidden;
    transition: transform .15s, border-color .15s;
}
.char-card::before {
    content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
    background: linear-gradient(90deg, var(--tone), var(--cc));
}
.char-card:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--tone) 60%, var(--border)); }
.char-top { display: flex; gap: 18px; align-items: center; }
.char-info h3 { font-size: 1.25rem; color: var(--text); word-break: break-word; }
.char-info .sub { color: var(--muted); font-size: .9rem; margin-top: 4px; }
.char-info .lvl { display: inline-block; margin-top: 8px; font-size: .75rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent2); background: #2a2310; border: 1px solid #4a3d14; padding: 2px 8px; border-radius: 99px; }
.stat-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.stat-chip { background: #14121b; border: 1px solid var(--border); border-radius: 8px; padding: 6px 0; text-align: center; }
.stat-chip .k { font-size: .65rem; color: var(--muted); font-weight: 700; letter-spacing: 1px; }
.stat-chip .v { font-size: 1.1rem; font-weight: 700; }
.stat-chip .m { font-size: .7rem; color: var(--accent2); }
.card-actions { display: flex; gap: 8px; }
.card-actions .btn { flex: 1; }

.empty-state { text-align: center; padding: 60px 20px; background: var(--panel); border: 1px dashed var(--border); border-radius: 14px; }
.empty-state svg { width: 90px; height: 90px; opacity: .8; margin-bottom: 10px; }
.empty-state p { color: var(--muted); margin: 8px 0 20px; }
.add-card {
    border: 2px dashed var(--border); border-radius: 14px; min-height: 120px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-weight: 600; transition: .15s;
}
.add-card:hover { border-color: var(--accent); color: var(--accent2); }
.add-card .plus { font-size: 2rem; line-height: 1; }

/* ---------- Editor ---------- */
.editor-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 800px) { .editor-layout { grid-template-columns: 1fr; } .preview-col { order: -1; } }
.panel { background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 1px solid var(--border); border-radius: 14px; padding: 22px; margin-bottom: 18px; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.panel h2 { font-size: 1.1rem; color: var(--accent2); margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; }
label.lbl { display: block; margin-bottom: 6px; font-weight: 600; color: var(--muted); font-size: .85rem; }
input[type=text] {
    width: 100%; padding: 12px; background: #14121b; border: 1px solid var(--border); color: var(--text);
    border-radius: 8px; font-size: 1.05rem; font-family: inherit;
}
input[type=text]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,167,44,.2); }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.tile {
    background: #14121b; border: 2px solid var(--border); border-radius: 12px; padding: 12px 8px; cursor: pointer;
    color: var(--text); font-family: inherit; display: flex; flex-direction: column; align-items: center; gap: 8px;
    transition: .15s;
}
.tile:hover:not(.locked) { border-color: var(--tone); transform: translateY(-2px); }
.tile .ico { width: 64px; height: 64px; border-radius: 50%; overflow: hidden; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--tone) 40%, #3a3450), #16131f 80%); }
.tile .ico.emblem { background: #14121b; border: 2px solid var(--tone); padding: 9px; }
.tile .ico svg { width: 100%; height: 100%; display: block; }
.tile .nm { font-weight: 700; font-size: .95rem; }
.tile.selected { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, #14121b); box-shadow: 0 0 14px color-mix(in srgb, var(--tone) 35%, transparent); }
.tile.locked { cursor: not-allowed; opacity: .45; }
.tile.locked.selected { opacity: 1; }
.pick-desc { margin-top: 12px; color: var(--muted); font-size: .9rem; line-height: 1.45; min-height: 2.8em; }
.pick-desc b { color: var(--text); }
.mods { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; min-height: 20px; }
.mod-chip { font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 99px; border: 1px solid; letter-spacing: .3px; }
.mod-chip.plus { color: #6fe3a5; background: #12261c; border-color: #1f5a3c; }
.mod-chip.minus { color: #f19a9d; background: #2a1517; border-color: #5a2427; }
.mod-chip.none { color: var(--muted); background: transparent; border-color: var(--border); font-weight: 600; }
.ability-box .base { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.ability-box .base .plus { color: #6fe3a5; font-weight: 700; }
.ability-box .base .minus { color: #f19a9d; font-weight: 700; }
.hp-row { display: flex; align-items: center; gap: 6px; background: #14121b; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.hp-row svg { width: 18px; height: 18px; flex-shrink: 0; }
.hp-row .hp-val { font-family: 'Cinzel', Georgia, serif; font-weight: 700; font-size: 1.25rem; }
.hp-row .hp-label { color: var(--muted); font-size: .75rem; font-weight: 700; letter-spacing: 1px; }
.hp-row .hp-calc { margin-left: auto; color: var(--muted); font-size: .75rem; }
.resources { display: grid; gap: 6px; }

/* ---------- Gold, gear, Armorer ---------- */
.gold { display: inline-flex; align-items: center; gap: 6px; background: #2a2310; border: 1px solid #4a3d14; border-radius: 99px; padding: 4px 12px; color: var(--accent2); font-weight: 700; }
.gold svg { width: 18px; height: 18px; }
.gear-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 36px; align-items: center; }
.gear-row.empty { color: var(--muted); font-size: .8rem; font-style: italic; }
.gear-chip { position: relative; width: 36px; height: 36px; padding: 4px; background: #14121b; border: 1px solid var(--border); border-bottom: 2px solid var(--tone); border-radius: 8px; }
.gear-chip svg { width: 100%; height: 100%; display: block; }
.gear-chip i { position: absolute; right: -4px; top: -6px; font-style: normal; font-size: .65rem; font-weight: 700; background: var(--accent); color: #15120a; border-radius: 99px; padding: 0 4px; }

.char-select { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.char-pick { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 2px solid var(--border); border-radius: 12px; padding: 8px 16px 8px 8px; cursor: pointer; color: var(--text); font-family: inherit; text-align: left; transition: .15s; }
.char-pick:hover { border-color: var(--tone); }
.char-pick.selected { border-color: var(--tone); background: color-mix(in srgb, var(--tone) 14%, var(--panel)); }
.char-pick .nm { font-weight: 700; }
.char-pick .sub { font-size: .75rem; color: var(--muted); }
.shop-layout { display: grid; grid-template-columns: 1fr 330px; gap: 20px; align-items: start; }
.shop-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.scroll-list { max-height: calc(100vh - 290px); min-height: 220px; overflow-y: auto; padding-right: 4px; }
.item-stat { white-space: normal; overflow-wrap: anywhere; line-height: 1.35; }   /* long item details wrap onto more lines instead of being cut off */
.item-card .btn { min-width: 76px; }
@media (max-width: 860px) { .shop-layout { grid-template-columns: 1fr; } }
.filter-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-tabs button { background: var(--panel3); border: 1px solid var(--border); color: var(--muted); padding: 6px 14px; border-radius: 99px; font-weight: 600; cursor: pointer; font-family: inherit; }
.filter-tabs button.active { background: var(--accent); color: #15120a; border-color: var(--accent); }
.item-list { display: grid; gap: 6px; }
.item-card { display: flex; align-items: center; gap: 10px; background: #14121b; border: 1px solid var(--border); border-left: 3px solid var(--tone); border-radius: 8px; padding: 5px 10px; }
.item-card.soldout { opacity: .5; }
.item-ico { width: 34px; height: 34px; flex-shrink: 0; padding: 3px; border-radius: 8px; background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--tone) 28%, #2a2638), #17151d); }
.item-ico svg { width: 100%; height: 100%; display: block; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 700; font-size: .92rem; display: flex; align-items: center; gap: 8px; }
.item-stat { color: var(--muted); font-size: .76rem; }
.item-meta { margin-top: 4px; display: flex; gap: 8px; align-items: center; font-size: .72rem; color: var(--muted); }
.tag { color: var(--tone); border: 1px solid var(--tone); border-radius: 99px; padding: 0 7px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; font-size: .65rem; }
.item-card .btn { white-space: nowrap; min-width: 84px; padding: 5px 10px; }
.hint { color: var(--muted); font-size: .85rem; margin: -6px 0 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; background: var(--panel3); border: 1px solid var(--border); border-left: 4px solid var(--success); padding: 12px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.5); transition: .25s; max-width: 90vw; z-index: 10; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-left-color: var(--danger); }
.mp-row .hp-val { color: #8fb8ff; }
.mp-row.none { opacity: .55; }
.preview .resources { margin-bottom: 8px; }
.race-mods-line { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lock-note { font-size: .8rem; color: var(--muted); font-weight: 400; font-family: 'Segoe UI', sans-serif; }

.ability-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ability-box { background: #14121b; border: 1px solid var(--border); border-radius: 10px; padding: 12px 6px; text-align: center; }
.ability-box .k { font-size: .75rem; color: var(--muted); font-weight: 700; letter-spacing: 1.5px; }
.ability-box .v { font-size: 1.9rem; font-weight: 700; font-family: 'Cinzel', Georgia, serif; }
.ability-box .m { font-size: .85rem; color: var(--accent2); }
.ability-box.rolled { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }

.preview-col { position: sticky; top: 20px; }
.preview { text-align: center; }
.preview .portrait { margin: 6px auto 16px; }
.preview h3 { font-size: 1.3rem; word-break: break-word; }
.preview .sub { color: var(--muted); margin: 4px 0 14px; }
.preview .stat-row { grid-template-columns: repeat(3, 1fr); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.notice { background: #2a1517; border: 1px solid #5a2427; color: #f3a6a9; padding: 12px 14px; border-radius: 8px; margin-bottom: 16px; }

/* ---------- Experience & spells ---------- */
.xp-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.xp-label { font-size: .65rem; font-weight: 700; letter-spacing: 1px; color: var(--muted); }
.xpbar { flex: 1; height: 8px; background: #14121b; border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.xpbar > i { display: block; height: 100%; background: linear-gradient(90deg, #8a6a12, var(--accent2)); transition: width .25s; }
.xp-num { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.spell-row { display: flex; flex-wrap: wrap; gap: 5px; }
.spell-chip { font-size: .72rem; font-weight: 600; color: #b9a2f0; background: #1d1830; border: 1px solid #3b2f66; border-radius: 99px; padding: 2px 9px; }
.spell-card .item-ico { display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: #b9a2f0; }
.spell-card.known { opacity: .75; }
.spell-card .item-stat { white-space: normal; }
.tag.lv { color: var(--muted); border-color: var(--border); }

/* Armorer / pack lists: never scroll sideways. A bare grid column sizes itself to its widest row (long tag rows), so every list column is
   allowed to shrink (minmax(0,1fr)); the shop keeps its multi-column grid; rows wrap their buttons under the text when space is tight. */
.item-list { grid-template-columns: minmax(0, 1fr); }
.item-list.shop-grid { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.scroll-list { overflow-x: hidden; }
.item-card { flex-wrap: wrap; min-width: 0; }
.item-card .item-info { flex: 1 1 190px; min-width: 0; }
.item-card > :last-child:not(.item-info) { margin-left: auto; }

/* Trial players (and new accounts not yet verified): the warning is shown, not tucked into a tooltip */
.user-box .trial-tag { display: flex; flex-direction: column; line-height: 1.15; color: var(--text); }
.user-box .trial-tag small { color: #f0c85a; font-size: .72rem; }

/* Daily chest (app.js dailyChest) */
.daily-chest { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(5,4,8,.72); padding: 16px; animation: dcIn .25s ease-out; }
.daily-chest .dc-card { max-width: 380px; width: 100%; text-align: center; padding: 22px 22px 18px; border: 2px solid #f0c85a; border-radius: 14px;
    background: linear-gradient(180deg, #2a2230, #17141c); box-shadow: 0 0 40px rgba(240,200,90,.3); color: var(--text); }
.daily-chest .dc-lid { font-size: 52px; line-height: 1; animation: dcPop .6s cubic-bezier(.2,1.6,.4,1); }
.daily-chest h2 { font-family: 'Cinzel', serif; margin: 8px 0 4px; color: #fff3c8; }
.daily-chest .dc-got { font-size: 1.35rem; font-weight: 800; color: #f0c85a; margin: 4px 0 12px; }
.daily-chest .dc-days { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; }
.daily-chest .dc-days i { font-style: normal; width: 30px; height: 30px; line-height: 30px; border-radius: 50%; border: 1px solid #5a5068; color: var(--muted); font-size: .8rem; }
.daily-chest .dc-days i.gift { border-style: dashed; border-color: #b58cff; }
.daily-chest .dc-days i.on { background: #f0c85a; border-color: #f0c85a; color: #2a1a00; font-weight: 800; }
.daily-chest .dc-next { font-size: .92rem; color: #d9cfae; margin: 0 0 10px; line-height: 1.4; }
.daily-chest .dc-trial { font-size: .85rem; color: #f3e3b0; background: rgba(197,155,39,.12); border: 1px solid #c59b27; border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; }
.daily-chest .dc-trial a { color: #f0c85a; }
@keyframes dcIn { from { opacity: 0; } }
@keyframes dcPop { from { transform: scale(.3) rotate(-12deg); opacity: 0; } }
.welcome-note { border-color: #22c55e; background: rgba(34,197,94,.08); line-height: 1.5; margin-bottom: 16px; }
.welcome-note b:first-child { color: #86efac; }
