/* Dark is the default; ThemeSwitch.js sets data-theme. Grays are numbered from the page
   backdrop (1) up to body text (6), so each step keeps its role when the theme flips. The
   tokens are mazefeud's, so the Feud games read as one family. */
:root {
    color-scheme: dark;

    --gray-1: #0f1115;
    --gray-2: #171a21;
    --gray-3: #1f232c;
    --gray-4: #2a2f3a;
    --gray-5: #8b93a3;
    --gray-6: #e7e9ee;
    --blue: #4f9dff;
    --red: #ff5d5d;
    --green: #3fbf6f;
    --amber: #ffbe3d;
    --slate: #4e5567;

    --text-small: 13px;
    --text-body: 15px;
    --text-display: 32px;

    --space-small: 4px;
    --space-medium: 8px;
    --space-large: 16px;

    --radius: 8px;

    --opacity-faint: 0.2;
    --opacity-dim: 0.35;
    --opacity-strong: 0.7;

    /* Board strokes and text, in tile units. */
    --stroke-thin: 0.03;
    --stroke-medium: 0.06;
    --stroke-wall: 0.1;
    --text-board: 0.36px;

    --duration-fade: 0.35s;
    --duration-move: 0.6s;
}

:root[data-theme="light"] {
    color-scheme: light;

    --gray-1: #f1f4f9;
    --gray-2: #ffffff;
    --gray-3: #e3e9f2;
    --gray-4: #c6cedb;
    --gray-5: #5f6775;
    --gray-6: #1b2027;
    --blue: #2f7fe6;
    --red: #d63c3c;
    --green: #2a9d5a;
    --amber: #e39a0e;
    --slate: #7c8596;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--gray-1);
    color: var(--gray-6);
    font: var(--text-body)/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: var(--opacity-dim); }
[hidden] { display: none !important; }

/* -- Buttons -- */

.primary-button {
    padding: var(--space-medium) var(--space-large);
    border: 0;
    border-radius: var(--radius);
    background: var(--blue);
    color: var(--gray-1);
    font-weight: 600;
}

.board-button {
    padding: var(--space-medium) var(--space-medium);
    border: 0;
    border-radius: var(--radius);
    background: var(--gray-3);
}

.text-button {
    padding: var(--space-small) var(--space-small);
    border: 0;
    background: none;
    color: var(--blue);
    line-height: 1;
}

.button-row { display: flex; gap: var(--space-medium); }
.button-row > button { flex: 1 1 0; min-width: 0; white-space: nowrap; }

/* -- Page -- */

.nav-bar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: calc(48px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--space-medium) 0;
    background: var(--gray-2);
    border-bottom: 1px solid var(--gray-4);
}

.nav-bar__title { font-weight: 600; text-align: center; }
.nav-bar__side { min-width: 0; }
.nav-bar__side--end { text-align: right; }
.nav-bar__note { color: var(--gray-5); font-size: var(--text-small); }

.page { padding: var(--space-medium) var(--space-large) var(--space-large); }

.board-column {
    margin: 0 auto;
    width: min(100%, 480px);
    display: grid;
    gap: var(--space-medium);
}

.hint { margin: 0; color: var(--gray-5); font-size: var(--text-small); text-align: center; }

.buildings, .problems {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: var(--space-small);
    font-size: var(--text-small);
}
.buildings { color: var(--gray-5); }
.problems { color: var(--red); }

/* -- Floor tabs -- */

.floor-tabs {
    display: flex;
    gap: var(--space-small);
    padding: var(--space-small);
    border-radius: var(--radius);
    background: var(--gray-2);
}

.floor-tab {
    flex: 1 1 0;
    position: relative;
    padding: var(--space-medium) var(--space-small);
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--gray-5);
}

.floor-tab.is-active { background: var(--gray-3); color: var(--gray-6); font-weight: 600; }

.floor-tab__marker {
    position: absolute;
    top: var(--space-small);
    right: var(--space-small);
    width: var(--space-medium);
    height: var(--space-medium);
    border-radius: 50%;
    background: var(--blue);
}

/* -- Board -- */

.board-stage { width: 100%; border-radius: var(--radius); overflow: hidden; }

.board-svg {
    display: block;
    width: 100%;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.tile--street { fill: var(--gray-3); }
.tile--park { fill: var(--green); opacity: var(--opacity-faint); }
.tile--floor { fill: var(--gray-4); }
.edge { stroke-linecap: square; pointer-events: none; }
.edge--wall { stroke: var(--gray-5); stroke-width: var(--stroke-wall); }
.edge--window { stroke: var(--gray-6); stroke-width: var(--stroke-medium); stroke-linecap: butt; }
.edge--door { stroke: var(--amber); stroke-width: var(--stroke-medium); stroke-linecap: butt; }
.stair-step { stroke: var(--gray-6); stroke-width: var(--stroke-thin); stroke-linecap: round; opacity: var(--opacity-strong); }

.floor-layer--ghost { opacity: var(--opacity-faint); }

.legend {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-medium) var(--space-large);
    color: var(--gray-5);
    font-size: var(--text-small);
}
.legend li { display: flex; align-items: center; gap: var(--space-small); }
.legend__swatch { width: calc(3 * var(--space-medium)); height: var(--space-medium); overflow: visible; }


.board-label {
    fill: var(--gray-6);
    opacity: var(--opacity-strong);
    font-size: var(--text-board);
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.sight { fill: var(--blue); opacity: var(--opacity-dim); pointer-events: none; }
.sight-origin { fill: none; stroke: var(--blue); stroke-width: var(--stroke-wall); pointer-events: none; }
.sight-origin--elsewhere { stroke-dasharray: 0.12 0.12; opacity: var(--opacity-strong); }
