/* Labirintul — the mouse, the cats and the cheese (js/labirintul.js). Theme-aware like the other game
   pages: tokens on :root, redefined under body.dark-theme. The canvas reads the --lb-maze-* tokens. */
:root {
    --lb-accent: #6d28d9;
    --lb-accent-2: #7c3aed;
    --lb-on-accent: #ffffff;
    --lb-gold: #f59e0b;
    --lb-page-bg: #f4f2fb;
    --lb-card-bg: #ffffff;
    --lb-card-border: #ddd6f3;
    --lb-muted: #5f5a75;
    --lb-shadow: 0 10px 30px rgba(40, 20, 90, .12);
    --lb-overlay: rgba(25, 15, 50, .55);
    --lb-stage-bg: #1b1740;
    --lb-hud-bg: linear-gradient(180deg, #14112f, #1d1946);
    --lb-maze-bg: #fbf6ea;
    --lb-maze-wall: #6d4fd8;
    --lb-maze-edge: #3b2a8c;
    --lb-maze-house: #efe6fb;
    --lb-maze-door: #f472b6;
    --lb-maze-dot: #b7791f;
    --lb-maze-text: #3b2a8c;
}

body.dark-theme {
    --lb-accent: #a78bfa;
    --lb-accent-2: #c4b5fd;
    --lb-on-accent: #1a1036;
    --lb-page-bg: #0e0c1d;
    --lb-card-bg: #181530;
    --lb-card-border: #2e2852;
    --lb-muted: #aaa3c8;
    --lb-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --lb-overlay: rgba(0, 0, 0, .65);
    --lb-stage-bg: #0a0818;
    --lb-hud-bg: linear-gradient(180deg, #07060f, #110e26);
    --lb-maze-bg: #0b0a1a;
    --lb-maze-wall: #2e2478;
    --lb-maze-edge: #8b7cf6;
    --lb-maze-house: #15122e;
    --lb-maze-door: #f9a8d4;
    --lb-maze-dot: #fcd9a0;
    --lb-maze-text: #fde68a;
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` would kill position: sticky. */
.lb-body, body.lb-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--lb-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
.lb-main { padding-top: 92px; padding-bottom: 40px; }
.lb-game .container, .lb-hero .container { max-width: 760px; }

/* ---- hero ---- */
.lb-hero { text-align: center; padding: 4px 0 12px; }
.lb-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 0 0 6px; display: inline-flex; align-items: center; gap: 12px; }
.lb-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #6d28d9, #f59e0b); box-shadow: var(--lb-shadow); }
.lb-lead { max-width: 600px; margin: 0 auto; color: var(--lb-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage ---- */
.lb-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 640px;
    margin: 0 auto;
    background: var(--lb-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--lb-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
.lb-stage:focus-visible { box-shadow: 0 0 0 3px var(--lb-accent), var(--lb-shadow); }
@media (max-width: 575.98px) {
    .lb-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.lb-stage:fullscreen { width: 100%; height: 100%; max-width: none; border-radius: 0; margin: 0; }
.lb-stage:-webkit-full-screen { width: 100%; height: 100%; max-width: none; border-radius: 0; margin: 0; }
.lb-stage.is-max { position: fixed; inset: 0; z-index: 1052; width: 100vw; height: 100vh; max-width: none; margin: 0; border-radius: 0; }
@supports (height: 100dvh) { .lb-stage.is-max { height: 100dvh; } }

.lb-hud { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; background: var(--lb-hud-bg); color: #fff; border-bottom: 2px solid #2d2566; }
.lb-stat { display: flex; flex-direction: column; line-height: 1.05; min-width: 52px; }
.lb-stat small { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #b9b0ea; white-space: nowrap; }
.lb-stat b { font-size: 1.15rem; font-weight: 900; font-variant-numeric: tabular-nums; color: #fde68a; }
.lb-stat-lv { min-width: 40px; }
.lb-lives { display: flex; gap: 3px; align-items: center; min-width: 20px; flex: 1 1 auto; justify-content: center; }
.lb-life { position: relative; width: 16px; height: 13px; border-radius: 50% 50% 46% 46%; background: #c9c3d8; margin-top: 4px; }
.lb-life::before, .lb-life::after { content: ""; position: absolute; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: #c9c3d8; box-shadow: inset 0 0 0 2px #c9c3d8, inset 0 0 0 4px #f9a8d4; }
.lb-life::before { left: -2px; }
.lb-life::after { right: -2px; }
.lb-lives-more { font-weight: 800; font-size: .85rem; color: #e9e5ff; }
.lb-tools { flex: none; display: flex; gap: 5px; }
.lb-round { width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .16); display: grid; place-items: center; background: rgba(255, 255, 255, .08); color: #fff; font-size: 15px; cursor: pointer; touch-action: manipulation; padding: 0; }
.lb-round:hover, .lb-round:focus-visible { background: rgba(124, 58, 237, .85); }
.lb-round:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-round span[hidden], .lb-round[hidden] { display: none; }

.lb-view { position: relative; flex: none; width: 100%; aspect-ratio: var(--lb-ar, 1); max-height: calc(100vh - 250px); min-height: 280px; background: var(--lb-maze-bg); overflow: hidden; touch-action: none; }
@supports (height: 100svh) { .lb-view { max-height: calc(100svh - 250px); } }
.lb-stage:fullscreen .lb-view, .lb-stage.is-max .lb-view { flex: 1 1 auto; aspect-ratio: auto; max-height: none; min-height: 0; }
.lb-stage:-webkit-full-screen .lb-view { flex: 1 1 auto; aspect-ratio: auto; max-height: none; min-height: 0; }
.lb-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }

.lb-banner { position: absolute; left: 50%; top: 50%; z-index: 2; transform: translate(-50%, -50%) scale(.9); margin: 0; padding: 10px 22px; border-radius: 18px; max-width: 92%; text-align: center; color: #fff; font-weight: 900; font-size: clamp(1.25rem, 6vw, 2.1rem); line-height: 1.15; text-shadow: 0 3px 12px rgba(0, 0, 0, .5); background: linear-gradient(135deg, rgba(109, 40, 217, .92), rgba(245, 158, 11, .92)); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.lb-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.lb-banner small { display: block; font-size: .5em; font-weight: 700; opacity: .95; }

/* ---- the menu over the maze (new game / pause) ---- */
.lb-menu { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(10, 8, 26, .62); backdrop-filter: blur(2px); overflow-y: auto; }
.lb-menu[hidden] { display: none; }
.lb-panel { width: min(100%, 380px); padding: 16px; border-radius: 18px; background: var(--lb-card-bg); color: var(--text-color); border: 1px solid var(--lb-card-border); box-shadow: 0 16px 40px rgba(0, 0, 0, .4); display: flex; flex-direction: column; gap: 10px; }
.lb-menu-title { margin: 0; font-size: 1.3rem; font-weight: 900; text-align: center; }
.lb-menu-sub { margin: -4px 0 0; text-align: center; color: var(--lb-muted); font-size: .92rem; }
.lb-menu-sub[hidden] { display: none; }
.lb-field { display: flex; flex-direction: column; gap: 5px; }
.lb-label { font-weight: 800; font-size: .88rem; }
.lb-chips { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 5px; padding: 4px; border-radius: 14px; background: var(--lb-page-bg); border: 1px solid var(--lb-card-border); }
.lb-chip { min-height: 44px; padding: 4px 6px; border: 0; border-radius: 10px; background: transparent; color: inherit; font-weight: 800; font-size: .92rem; cursor: pointer; touch-action: manipulation; }
.lb-chip[aria-checked="true"] { background: var(--lb-accent); color: var(--lb-on-accent); }
.lb-chip:focus-visible { outline: 2px solid var(--lb-gold); outline-offset: 2px; }
.lb-keys { margin: 0; font-size: .78rem; color: var(--lb-muted); text-align: center; line-height: 1.5; }
.lb-keys kbd, .lb-help kbd { background: var(--lb-page-bg); color: inherit; border: 1px solid var(--lb-card-border); padding: 0 5px; border-radius: 5px; font-size: .8em; }

.lb-btn { min-height: 48px; padding: 8px 16px; border-radius: 14px; border: 1px solid var(--lb-card-border); background: var(--lb-card-bg); color: inherit; font-weight: 800; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; transition: background .15s, border-color .15s, transform .1s; }
.lb-btn:hover { border-color: var(--lb-accent); }
.lb-btn:active { transform: scale(.98); }
.lb-btn[hidden] { display: none; }
.lb-btn-primary { background: var(--lb-accent); border-color: var(--lb-accent); color: var(--lb-on-accent); }
.lb-btn-primary:hover { background: var(--lb-accent-2); border-color: var(--lb-accent-2); }
.lb-wide { width: 100%; }

/* ---- the arrows under the maze (touch screens) ---- */
.lb-pad { flex: none; display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: 46px 46px; gap: 6px 10px; justify-content: center; padding: 10px 0 12px; background: var(--lb-hud-bg); border-top: 2px solid #2d2566; }
.lb-arrow { border: 1px solid rgba(255, 255, 255, .16); border-radius: 14px; background: rgba(255, 255, 255, .08); color: #fde68a; font-size: 26px; display: grid; place-items: center; cursor: pointer; touch-action: none; padding: 0; }
.lb-arrow.is-on, .lb-arrow:active { background: rgba(124, 58, 237, .85); color: #fff; }
.lb-arrow:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lb-up { grid-column: 2; grid-row: 1; }
.lb-left { grid-column: 1; grid-row: 1 / span 2; }
.lb-right { grid-column: 3; grid-row: 1 / span 2; }
.lb-down { grid-column: 2; grid-row: 2; }
@media (hover: hover) and (pointer: fine) { .lb-pad { display: none; } }

.lb-status { min-height: 1.5em; margin: 8px 0 0; text-align: center; font-weight: 700; color: var(--lb-muted); font-size: .92rem; }
.lb-record { margin: 4px 0 0; text-align: center; color: var(--lb-muted); font-size: .9rem; }
.lb-record b { color: var(--text-color); }
.lb-reset-wrap { margin: 2px 0 0; text-align: center; }
.lb-reset-wrap[hidden] { display: none; }
.lb-link { border: 0; background: none; color: var(--lb-accent); font-weight: 700; font-size: .85rem; text-decoration: underline; cursor: pointer; padding: 6px; }

/* ---- help ---- */
.lb-help { max-width: 640px; margin: 14px auto 0; padding: 12px 16px; border-radius: 16px; background: var(--lb-card-bg); border: 1px solid var(--lb-card-border); box-shadow: var(--lb-shadow); }
.lb-help summary { font-weight: 800; cursor: pointer; min-height: 32px; display: flex; align-items: center; gap: 8px; }
.lb-help summary svg, .lb-help summary i { color: var(--lb-accent); }
.lb-help ul { margin: 10px 0 6px; padding-left: 20px; line-height: 1.55; font-size: .95rem; }
.lb-help li { margin-bottom: 6px; }
.lb-cat { font-weight: 800; padding: 0 6px; border-radius: 6px; color: #1a1036; }
.lb-c0 { background: #e4572e; color: #fff; }
.lb-c1 { background: #f4a6c8; }
.lb-c2 { background: #4cc9f0; }
.lb-c3 { background: #f2a541; }
.lb-credit { margin: 6px 0 0; font-size: .82rem; color: var(--lb-muted); }
.lb-powered { margin: 18px 0 0; text-align: center; color: var(--lb-muted); font-size: .9rem; }
.lb-powered a { color: var(--lb-accent); font-weight: 700; }

/* ---- game over ---- */
.lb-overlay { position: fixed; inset: 0; z-index: 1060; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--lb-overlay); }
.lb-overlay[hidden] { display: none; }
.lb-dialog { width: min(100%, 400px); padding: 20px 18px 16px; border-radius: 20px; background: var(--lb-card-bg); color: var(--text-color); border: 1px solid var(--lb-card-border); box-shadow: 0 20px 50px rgba(0, 0, 0, .4); text-align: center; }
.lb-dialog-icon { width: 58px; height: 58px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; font-size: 26px; color: #fff; background: linear-gradient(135deg, #6d28d9, #f59e0b); }
.lb-dialog h2 { font-size: 1.4rem; font-weight: 900; margin: 0 0 8px; }
.lb-final { list-style: none; margin: 0 0 6px; padding: 0; }
.lb-final li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--lb-page-bg); margin-bottom: 6px; font-weight: 700; }
.lb-final li b { font-variant-numeric: tabular-nums; }
.lb-over-sub { color: var(--lb-muted); margin: 0 0 12px; font-size: .92rem; }
.lb-over-sub strong { color: var(--lb-gold); }
.lb-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.lb-dialog-actions .lb-btn { flex: 1 1 140px; }

@media (max-width: 400px) {
    .lb-hud { gap: 4px; padding-left: 8px; }
    .lb-stat { min-width: 44px; }
    .lb-stat b { font-size: 1rem; }
    .lb-round { width: 36px; height: 36px; font-size: 14px; }
    .lb-life { width: 13px; height: 11px; }
    .lb-life::before, .lb-life::after { width: 7px; height: 7px; top: -4px; }
}
