/* Life counter: full-screen, touch friendly. Nothing here is shared with the rest of the site. */
html, body {
    margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overscroll-behavior: none; touch-action: manipulation;
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
#lc-board {
    position: fixed; inset: 0; display: grid; gap: 2px; background: #000;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}
.lc-cell { position: relative; overflow: hidden; min-width: 0; min-height: 0; color: var(--fg, #fff); }

/* Background colors: a soft diagonal gradient per mana color. */
.c-W { --fg: #2b2616; background: linear-gradient(160deg, #fffdf0 0%, #e9e0c2 100%); }
.c-U { --fg: #ffffff; background: linear-gradient(160deg, #54acdf 0%, #164f8c 100%); }
.c-B { --fg: #f3eff6; background: linear-gradient(160deg, #54505b 0%, #0e0c11 100%); }
.c-R { --fg: #ffffff; background: linear-gradient(160deg, #f0735a 0%, #8f1c15 100%); }
.c-G { --fg: #ffffff; background: linear-gradient(160deg, #57b772 0%, #145630 100%); }

/* The rotated inner box: JS gives it the right size and turn for the player's seat. */
.lc-in { position: absolute; left: 50%; top: 50%; transform-origin: center center; }

.lc-zone { position: absolute; top: 0; bottom: 0; width: 50%; display: flex; align-items: center; cursor: pointer; }
.lc-minus { left: 0; justify-content: flex-start; padding-left: 12%; }
.lc-plus { right: 0; justify-content: flex-end; padding-right: 12%; }
.lc-zone span { font-size: 2.4rem; font-weight: 300; opacity: .45; line-height: 1; pointer-events: none; }
.lc-zone:active { background: rgba(255, 255, 255, .08); }
.c-W .lc-zone:active { background: rgba(0, 0, 0, .07); }

.lc-num {
    position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-52%); text-align: center;
    font-weight: 700; line-height: 1; letter-spacing: -.02em; pointer-events: none;
    font-variant-numeric: tabular-nums; text-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.lc-delta {
    position: absolute; left: 0; right: 0; top: 50%; text-align: center; pointer-events: none;
    font-weight: 600; opacity: 0; transition: opacity .25s;
}
.lc-delta.on { opacity: .85; }

.lc-color-btn {
    position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 38px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .55);
    background: rgba(0, 0, 0, .28); padding: 6px; box-sizing: border-box; cursor: pointer;
}
.c-W .lc-color-btn { border-color: rgba(0, 0, 0, .4); background: rgba(0, 0, 0, .1); }
.lc-color-btn img, .lc-tray img { width: 100%; height: 100%; display: block; pointer-events: none; }
.lc-tray {
    position: absolute; bottom: 58px; left: 10px;
    display: flex; gap: 10px; padding: 8px 10px; border-radius: 30px; background: rgba(0, 0, 0, .55);
    max-width: 96%; box-sizing: border-box;
}
.lc-tray[hidden] { display: none; }
.lc-tray button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; background: #ddd; padding: 5px; cursor: pointer; flex: 0 0 auto; }
.lc-tray button.sel { border-color: #fff; box-shadow: 0 0 0 2px #000; }

/* Dice roll overlay inside a panel */
.lc-dice {
    position: absolute; inset: 0; background: rgba(12, 10, 28, .96); color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; cursor: pointer;
}
.lc-dice[hidden] { display: none; }
.lc-die { position: relative; }
.lc-d20 { width: 100%; height: 100%; display: block; overflow: visible; }
.lc-d20-body { fill: rgba(255, 255, 255, .08); stroke: #e8dcff; stroke-width: 3; stroke-linejoin: round; }
.lc-d20-edges { fill: none; stroke: #e8dcff; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; opacity: .85; }
.lc-dice-n { position: absolute; left: 0; right: 0; top: 56%; transform: translateY(-50%); text-align: center; font-weight: 800; line-height: 1; }
.lc-dice.winner .lc-d20-body, .lc-dice.winner .lc-d20-edges { stroke: #ffd75e; }
.lc-dice.winner .lc-d20-body { fill: rgba(255, 215, 94, .14); }
.lc-dice.rolling .lc-die { animation: lcTumble .55s linear infinite; }
.lc-dice.landed .lc-die { animation: lcLand .5s ease-out; }
@keyframes lcTumble {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(100deg) scale(1.1); }
    50% { transform: rotate(190deg) scale(.94); }
    75% { transform: rotate(280deg) scale(1.08); }
    100% { transform: rotate(360deg) scale(1); }
}
@keyframes lcLand {
    0% { transform: rotate(-18deg) scale(1.22); }
    55% { transform: rotate(7deg) scale(.95); }
    100% { transform: rotate(0deg) scale(1); }
}
.lc-win { font-weight: 800; letter-spacing: .04em; color: #ffd75e; text-transform: uppercase; min-height: 1.2em; }
.lc-dice.winner { background: rgba(48, 38, 6, .96); box-shadow: inset 0 0 0 6px #ffd75e; }

/* Center button and menu */
#lc-menu-btn {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 20;
    width: 54px; height: 54px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .7);
    background: rgba(15, 12, 30, .82); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .5);
}
.lc-overlay { position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .72); display: flex; align-items: center; justify-content: center; padding: 14px; box-sizing: border-box; }
.lc-overlay[hidden] { display: none; }
.lc-sheet { width: 100%; max-width: 420px; max-height: 92vh; overflow: auto; background: #17132b; border: 1px solid #3a3363; border-radius: 16px; padding: 14px 16px; box-sizing: border-box; }
.lc-row { margin-bottom: 14px; }
.lc-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: #a9a2d0; margin-bottom: 6px; }
.lc-seg { display: flex; gap: 6px; }
.lc-seg button, .lc-big, .lc-custom button {
    flex: 1; min-height: 46px; border-radius: 10px; border: 1px solid #4b4380; background: #231d45; color: #fff;
    font-size: 1rem; font-weight: 600; cursor: pointer; padding: 0 10px;
}
.lc-seg button.sel { background: #e0b34a; border-color: #e0b34a; color: #1b1500; }
.lc-custom { display: flex; gap: 6px; margin-top: 8px; }
.lc-custom[hidden] { display: none; }
.lc-custom input { flex: 2; min-height: 46px; border-radius: 10px; border: 1px solid #4b4380; background: #0f0c1f; color: #fff; font-size: 16px; padding: 0 12px; box-sizing: border-box; min-width: 0; }
.lc-actions { display: flex; flex-direction: column; gap: 8px; }
.lc-warn { border-color: #8b3b3b; background: #3a1b22; }
.lc-warn.confirm { background: #b33a3a; border-color: #ff8f8f; }
.lc-primary { background: #e0b34a; border-color: #e0b34a; color: #1b1500; flex: 0 0 38%; }
.lc-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 0; }
.lc-foot a { color: #b9b2e6; font-size: .95rem; padding: 10px 4px; }

input { -webkit-user-select: text; user-select: text; }

/* ---- number look: depth, negative = red with a halo, small minus bar ---- */
.lc-num { text-shadow: 0 2px 2px rgba(0, 0, 0, .28), 0 8px 18px rgba(0, 0, 0, .34); }
.c-W .lc-num { text-shadow: 0 2px 2px rgba(0, 0, 0, .18), 0 8px 16px rgba(0, 0, 0, .22); }
.lc-bar { display: inline-block; width: .3em; height: .085em; border-radius: .05em; background: currentColor; vertical-align: .3em; margin-right: .07em; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .3)); }
.lc-num.neg { color: #ff3d3d; text-shadow: 0 0 2px #fff, 0 0 7px rgba(255, 255, 255, .85), 0 5px 12px rgba(0, 0, 0, .35); }
.lc-num.neg .lc-bar { filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 5px rgba(255, 255, 255, .8)); }
.c-R .lc-num.neg { color: #4a0606; }
.c-W .lc-num.neg { color: #d11a1a; text-shadow: 0 2px 2px rgba(0, 0, 0, .2), 0 6px 12px rgba(0, 0, 0, .22); }
.c-W .lc-num.neg .lc-bar { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25)); }

/* ---- bottom row: counters button + color button ---- */
.lc-btnrow { position: absolute; bottom: 10px; left: 10px; display: flex; gap: 8px; align-items: center; }
.lc-btnrow .lc-color-btn, .lc-btnrow .lc-drawer-btn { position: static; transform: none; }
.lc-drawer-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .55);
    background: rgba(0, 0, 0, .28); color: inherit; padding: 6px; box-sizing: border-box; cursor: pointer;
}
.lc-drawer-btn[hidden] { display: none; }
.lc-drawer-btn svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.c-W .lc-drawer-btn { border-color: rgba(0, 0, 0, .4); background: rgba(0, 0, 0, .1); }

/* ---- chips (counters above zero), bottom left ---- */
.lc-chips { position: absolute; left: 100px; bottom: 10px; display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 100px - 96px); }
.lc-chip {
    display: inline-flex; align-items: center; gap: 3px; min-height: 28px; padding: 0 8px; border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, .5); background: rgba(0, 0, 0, .38); color: #fff; font-size: .88rem; font-weight: 700; cursor: pointer;
}
.c-W .lc-chip { background: rgba(0, 0, 0, .55); }
.lc-chip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, .8); }
.lc-chip.lethal { background: #b82525; border-color: #ffb3b3; }

/* ---- markers (monarch, initiative), bottom right ---- */
.lc-marks { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 6px; }
.lc-mk { width: 40px; height: 40px; border: 0; background: none; padding: 5px; box-sizing: border-box; cursor: pointer; color: rgba(255, 255, 255, .3); }
.c-W .lc-mk { color: rgba(0, 0, 0, .25); }
.lc-mk[hidden] { display: none; }
.lc-mk svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.lc-mk.on[data-mk="monarch"] { color: #ffc928; filter: drop-shadow(0 0 5px rgba(255, 201, 40, .8)); }
.lc-mk.on[data-mk="initiative"] { color: #4fd0ff; filter: drop-shadow(0 0 5px rgba(79, 208, 255, .8)); }

/* ---- defeated ---- */
.lc-cell.out::before { content: ''; position: absolute; inset: 0; background: rgba(35, 35, 48, .4); pointer-events: none; }
.lc-stamp {
    position: absolute; left: 10px; top: 10px; padding: .12em .6em;
    background: rgba(150, 18, 18, .92); color: #fff; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
    border: 2px solid rgba(255, 255, 255, .85); border-radius: 6px; white-space: nowrap; cursor: pointer; font-family: inherit; line-height: 1.3;
}
.lc-stamp[hidden] { display: none; }

/* ---- counter drawer ---- */
.lc-drawer { position: absolute; inset: 0; background: rgba(12, 10, 28, .97); color: #fff; display: flex; flex-direction: column; padding: 8px 10px 10px; box-sizing: border-box; }
.lc-drawer[hidden] { display: none; }
.lc-dh { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: .85rem; color: #b9b2e6; }
.lc-dclose { min-height: 34px; padding: 0 16px; border-radius: 10px; border: 0; background: #e0b34a; color: #1b1500; font-weight: 700; cursor: pointer; }
.lc-grid { flex: 1; min-height: 0; display: flex; flex-flow: row wrap; gap: 6px; align-content: flex-start; overflow: auto; }
.lc-cnts { flex: 1 1 170px; align-self: flex-start; display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); grid-auto-rows: 52px; gap: 6px; }
.lc-tile { position: relative; border: 1px solid #4b4380; border-radius: 10px; background: #231d45; overflow: hidden; }
/* the tall tile in the 3 player layout keeps its number in the middle */
.lc-tile.tall .lc-tv { bottom: auto; top: 50%; transform: translateY(-50%); }

/* commander tiles take the color of the player they belong to */
.lc-tile.c-W, .lc-tile.c-U, .lc-tile.c-B, .lc-tile.c-R, .lc-tile.c-G { color: var(--fg); border-color: rgba(255, 255, 255, .35); }
.lc-tile.c-W .lc-tl, .lc-tile.c-U .lc-tl, .lc-tile.c-B .lc-tl, .lc-tile.c-R .lc-tl, .lc-tile.c-G .lc-tl { color: inherit; opacity: .8; }
.lc-tile.c-W { background: linear-gradient(160deg, #fffdf0 0%, #e9e0c2 100%); }
.lc-tile.c-U { background: linear-gradient(160deg, #54acdf 0%, #164f8c 100%); }
.lc-tile.c-B { background: linear-gradient(160deg, #54505b 0%, #0e0c11 100%); }
.lc-tile.c-R { background: linear-gradient(160deg, #f0735a 0%, #8f1c15 100%); }
.lc-tile.c-G { background: linear-gradient(160deg, #57b772 0%, #145630 100%); }
.lc-tile.lethal { background: #5a1a1a; border-color: #ff8f8f; }
.lc-tl { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: #b9b2e6; pointer-events: none; }
.lc-tl .sw { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; border: 1px solid rgba(255, 255, 255, .8); vertical-align: -1px; }
.lc-tv { position: absolute; left: 0; right: 0; bottom: 6px; text-align: center; font-size: 1.7rem; font-weight: 800; line-height: 1; pointer-events: none; }
.lc-tz { position: absolute; top: 0; bottom: 0; width: 50%; display: flex; align-items: center; cursor: pointer; }
.lc-tz-m { left: 0; padding-left: 9px; }
.lc-tz-p { right: 0; justify-content: flex-end; padding-right: 9px; }
.lc-tz span { font-size: 1.3rem; opacity: .45; pointer-events: none; line-height: 1; }
.lc-tz:active { background: rgba(255, 255, 255, .08); }
/* ---- commander damage table map ---- */
.lc-map { display: grid; flex: 1 1 170px; align-self: flex-start; gap: 6px; grid-auto-rows: 52px; }
.lc-me { display: flex; align-items: center; justify-content: center; border: 1px dashed #4b4380; border-radius: 10px; color: #8d86bd; font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; }

/* ---- menu extras ---- */
.lc-more > summary { cursor: pointer; font-weight: 600; padding: 10px 0; color: #e8dcff; }
.lc-checks { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.lc-checks label { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: .98rem; cursor: pointer; }
.lc-checks input { width: 22px; height: 22px; accent-color: #e0b34a; flex: 0 0 auto; }
