/* Dračí hlídka – vlastní styly (R13). Velké dotykové prvky, světlý i tmavý režim. */

:root {
    --bg: #f4efe6;
    --surface: #fffaf2;
    --surface-2: #efe6d6;
    --text: #2b2118;
    --muted: #6f6152;
    --border: #d8ccb8;
    --accent: #8c2f1b;
    --accent-text: #ffffff;
    --accent-soft: #f3ddd5;
    --ok: #2f6b3a;
    --ok-soft: #dcefdc;
    --warn: #8a5a00;
    --warn-soft: #f6e7c4;
    --danger: #a3261b;
    --danger-soft: #f7d9d5;
    --hidden: #4b3f7a;
    --hidden-soft: #e5e0f5;
    --radius: 10px;
    --tap: 48px;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.05);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #17130f;
        --surface: #221c16;
        --surface-2: #2c241c;
        --text: #efe6d8;
        --muted: #b3a491;
        --border: #3d3226;
        --accent: #d4694d;
        --accent-text: #1a120d;
        --accent-soft: #3a231b;
        --ok: #7cc489;
        --ok-soft: #1f3324;
        --warn: #e0b45a;
        --warn-soft: #3a2f17;
        --danger: #ef8579;
        --danger-soft: #3d1f1b;
        --hidden: #b3a6f0;
        --hidden-soft: #2a2442;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
small, .muted { color: var(--muted); }

/* --- Rozvržení --- */

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 8px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); margin-right: 8px; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a {
    display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px;
    border-radius: 8px; text-decoration: none; color: var(--text);
}
.topbar nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar .who { display: flex; align-items: center; gap: 8px; color: var(--muted); }

.page { max-width: 1200px; margin: 0 auto; padding: 16px; }
.page.narrow { max-width: 460px; padding-top: 8vh; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.split { display: grid; gap: 16px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
/* minmax(0, …): široké tabulky (editor nestvůry) se posouvají uvnitř, nerozšíří stránku. */
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }
/* Katalog: úzký seznam vlevo, široký editor; na úzké obrazovce pod sebou (výše). */
@media (min-width: 901px) { .split.catalog { grid-template-columns: minmax(240px, 1fr) minmax(0, 2.4fr); } }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--accent); }

/* --- Formuláře --- */

label { display: block; font-weight: 600; margin-bottom: 4px; }
label .hint { font-weight: 400; color: var(--muted); }
.field { margin-bottom: 14px; }
.fields { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.fields.wide { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}
textarea { min-height: 96px; resize: vertical; }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 14px; min-height: 320px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=number] { max-width: 140px; }
.fields input[type=number] { max-width: none; }

.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 400; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

button, .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--tap); padding: 0 18px;
    font: inherit; font-weight: 600;
    color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 8px;
    cursor: pointer; text-decoration: none; user-select: none;
    touch-action: manipulation;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.small, .btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
button.link { background: none; border: none; color: var(--accent); padding: 0 6px; min-height: 36px; }
button.big { min-height: 64px; font-size: 1.2rem; padding: 0 24px; }

/* --- Hlášky --- */

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--surface-2); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

.monster-image { display: block; max-width: 100%; max-height: 320px; margin: 6px 0; object-fit: contain; }

.check-list { margin: 4px 0 0; padding-left: 18px; font-size: .9rem; }
.check-list.warn { color: var(--warn); }

.badge {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.badge.gm { background: var(--accent-soft); color: var(--accent); }
.badge.hidden { background: var(--hidden-soft); color: var(--hidden); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }

/* --- Tabulky a seznamy --- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .9rem; }
.table-wrap { overflow-x: auto; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: none; }
.list button.item {
    width: 100%; justify-content: flex-start; text-align: left; font-weight: 400;
    background: none; border: none; border-radius: 8px; padding: 8px 10px;
}
.list button.item.active { background: var(--accent-soft); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { font-weight: 500; }
.tabs button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* --- Úvodní načítání a chyby Blazoru --- */

.boot { min-height: 100vh; display: grid; place-content: center; text-align: center; gap: 8px; }
.boot-title { font-size: 2rem; font-weight: 700; }
.boot-text { color: var(--muted); }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    padding: 12px 16px; background: var(--danger-soft); color: var(--danger);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; font-size: 1.4rem; }
#blazor-error-ui .reload { margin-left: 8px; }

/* --- Herní stůl --- */

.table3 { display: grid; gap: 16px; grid-template-columns: minmax(240px, 1fr) minmax(0, 1.6fr) minmax(280px, 1fr); align-items: start; }
.table2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .table3 { grid-template-columns: 1fr 1fr; } .table3 > :nth-child(2) { grid-column: 1 / -1; order: 3; } }
@media (max-width: 760px) { .table3, .table2 { grid-template-columns: 1fr; } }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.dot.on { background: var(--ok); }

.mini-char { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; margin-top: 8px; cursor: pointer; }
.mini-char.active { border-color: var(--accent); background: var(--accent-soft); }

.bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 4px 0; }
.bar .fill { height: 100%; border-radius: 999px; }
.bar .fill.hp { background: var(--ok); }
.bar .fill.mana { background: var(--hidden); }
.bar-label { margin-top: 8px; }

.attrs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 12px 0; }
.attr { text-align: center; border: 1px solid var(--border); border-radius: 8px; padding: 6px 4px; background: var(--surface-2); }
.attr .code { font-size: .8rem; color: var(--muted); font-weight: 600; }
.attr .score { font-size: 1.4rem; font-weight: 700; }
.attr .mod { font-size: .9rem; }
.stats { display: flex; flex-wrap: wrap; gap: 6px 18px; }

.log { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.log-entry { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); }
.log-entry.hidden { background: var(--hidden-soft); }
.log-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.log-head .time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.log-roll { margin-top: 4px; }

.dice { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.die {
    display: inline-flex; align-items: center; gap: 2px; min-width: 32px; height: 32px; padding: 0 8px;
    border: 2px solid var(--text); border-radius: 7px; font-weight: 700; justify-content: center; background: var(--surface);
}
.die.open { border-style: double; border-width: 3px; }
.die .six { color: var(--accent); }
.die .chain { color: var(--muted); font-weight: 400; }
.dice .total { font-weight: 700; font-size: 1.1rem; margin-left: 4px; }
.dice .op { font-weight: 600; }

.pad { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin: 8px 0 12px; }
.manual { margin-bottom: 12px; }

.inv-row { border-bottom: 1px solid var(--border); padding: 8px 0; display: grid; gap: 6px; }

.qr { background: #fff; padding: 8px; border-radius: 8px; width: fit-content; margin: 8px 0; }
.qr svg { display: block; width: 240px; height: 240px; }

/* --- Nestvůry --- */
.mini-char.down { opacity: .6; }
.monster-card h4 { margin: 10px 0 4px; font-size: .95rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; }
.kv > span:nth-child(odd) { color: var(--muted); }
.unknown, .kv > span:nth-child(even):is(:empty) { color: var(--muted); }

/* --- Boj --- */
.proposal { border-left: 4px solid var(--accent); }
.request {
    border: 2px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius);
    padding: 12px; margin: 12px 0; display: grid; gap: 8px;
}
.combat-player { border-color: var(--accent); }
.list > li.current { background: var(--accent-soft); border-radius: 8px; padding-left: 8px; }
.roll-buttons .pad { max-width: 520px; }

/* --- Mapa --- */
.map-canvas-wrap { position: relative; width: 100%; height: 100%; min-height: 240px; }
.map-canvas {
    display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: crosshair;
}
.map-stage { height: min(70vh, 820px); }
.map-stage.compact { height: min(55vh, 560px, calc(var(--map-ratio, 60) * 1vw + 40px)); }
.map-layout { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 960px) { .map-layout { grid-template-columns: 1fr; } }
.toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.toolbar button.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.toolbar .sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.toolbar select, .toolbar input[type=number] { width: auto; min-height: 36px; padding: 0 8px; }
.map-full { position: fixed; inset: 0; z-index: 50; background: var(--bg); padding: 8px; display: flex; flex-direction: column; }
.map-full .map-stage { flex: 1; height: auto; min-height: 0; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--border); vertical-align: -2px; margin-right: 4px; }
.map-info { font-size: .95rem; }
.map-info h3 { margin-bottom: .3em; }
.map-toast {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 2; max-width: calc(100% - 24px);
    min-height: 0; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); box-shadow: var(--shadow);
    background: var(--surface); color: var(--text); font-size: .95rem; text-align: center;
}
.map-toast.error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* --- Tvorba postavy --- */
.die {
    display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; margin: 0 3px 3px 0;
    border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-weight: 600; font-size: .9rem;
}
.die.best { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.die.dropped { opacity: .45; text-decoration: line-through; }

/* --- Mapa světa --- */
.world-zoom { margin-bottom: 6px; }
.world-scroll { overflow: auto; max-height: min(78vh, 900px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.world-stage { position: relative; min-width: 100%; user-select: none; -webkit-user-select: none; }
.world-stage img { display: block; width: 100%; height: auto; pointer-events: none; }
.world-stage.placing { cursor: crosshair; }
.world-pin {
    /* Bod mapy je střed ikony (34 px), popisek visí pod ní. */
    position: absolute; transform: translate(-50%, -17px); z-index: 1;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    min-height: 0; padding: 0; background: none; border: none; cursor: pointer;
}
.world-pin-icon {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
    background: #fffaf2; border: 2px solid #2b2118; box-shadow: 0 1px 4px rgb(0 0 0 / .35); font-size: 18px; line-height: 1;
}
.world-pin-label {
    max-width: 140px; padding: 0 6px; border-radius: 999px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    background: rgb(255 250 242 / .9); color: #2b2118; font-size: .75rem; font-weight: 700; box-shadow: 0 1px 3px rgb(0 0 0 / .3);
}
.world-pin.selected .world-pin-icon { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent); }
.world-pin.hidden { opacity: .55; }
.world-pin.hidden .world-pin-icon { border-style: dashed; }
.world-party {
    /* Vlaječka nad pravým horním okrajem ikony lokace, ať ji nezakryje. */
    position: absolute; transform: translate(4px, -40px); z-index: 2; pointer-events: none;
    display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
    background: var(--accent); color: var(--accent-text); border: 2px solid #fff; font-size: 18px; box-shadow: 0 2px 6px rgb(0 0 0 / .45);
}
.world-info { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
