:root {
    --bg: #12110f;
    --bg-elev: #1c1a16;
    --line: #3a3428;
    --text: #f3ead7;
    --muted: #b7aa90;
    --accent: #d4a017;
    --accent-dark: #9a7010;
    --danger: #c45c48;
    --danger-bg: #3a1f1a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    background:
        radial-gradient(1200px 600px at 50% -10%, #2a2418 0%, transparent 60%),
        var(--bg);
    color: var(--text);
}

.kicker {
    margin: 0;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: var(--accent);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(24rem, 100%);
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 2rem 1.6rem;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.login-card h1,
.stage h1 {
    margin: 0.35rem 0 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.lede {
    margin: 0 0 1.4rem;
    color: var(--muted);
    line-height: 1.45;
}

form {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

input[type="text"],
input[type="password"] {
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #100f0c;
    color: var(--text);
    font: inherit;
}

input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

button {
    cursor: pointer;
    border: 0;
    border-radius: 3px;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: #1a1408;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.04em;
}

button:hover {
    background: #e0b42b;
}

button.ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
    font-weight: 600;
}

button.ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.flash.error {
    margin: 0 0 1rem;
    padding: 0.7rem 0.8rem;
    background: var(--danger-bg);
    color: #f3c7be;
    border: 1px solid var(--danger);
    border-radius: 3px;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(8rem, 1fr) auto minmax(8rem, 1fr) auto;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0.65rem 1rem 0.75rem 1.2rem;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elev);
}

.topbar .points {
    justify-self: center;
    text-align: center;
    min-width: 7rem;
}

.topbar .points strong {
    font-size: 1.45rem;
    letter-spacing: 0.04em;
    color: var(--accent);
    line-height: 1.1;
}

.tick-meta {
    margin: 0.2rem 0 0;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.topbar form {
    display: block;
    justify-self: end;
}

.hp-bar {
    min-width: 0;
}

.hp-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.hp-enemy .hp-meta {
    flex-direction: row-reverse;
}

.hp-name {
    color: var(--text);
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hp-track {
    height: 16px;
    background: #140f0c;
    border: 2px solid #5a513f;
    box-shadow: inset 0 0 0 1px #000;
    overflow: hidden;
}

.hp-self .hp-track {
    border-color: var(--accent-dark);
}

.hp-enemy .hp-track {
    border-color: #7a3030;
    display: flex;
    justify-content: flex-end;
}

.hp-fill {
    height: 100%;
    width: 100%;
    transition: width 0.35s ease;
}

.hp-self .hp-fill {
    background: linear-gradient(180deg, #f2d36a 0%, #d4a017 45%, #8a5a10 100%);
}

.hp-enemy .hp-fill {
    background: linear-gradient(180deg, #f09191 0%, #c45c48 45%, #7a241c 100%);
}

.stage {
    padding: 2.4rem 1.4rem;
    max-width: 44rem;
}

.stage p {
    color: var(--muted);
    line-height: 1.5;
}

.board-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.board-page .stage {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: 0;
    max-width: none;
    width: 100%;
    padding: 0.75rem 1rem 1rem;
}

.board-wrap {
    flex: 1;
    min-width: 0;
    min-height: 0;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#board {
    display: block;
    touch-action: none;
    user-select: none;
}

@media (max-width: 800px) {
    .topbar {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "self logout"
            "points points"
            "enemy enemy";
    }

    .hp-self { grid-area: self; }
    .hp-enemy { grid-area: enemy; }
    .topbar .points { grid-area: points; }
    .topbar form { grid-area: logout; }
}
