.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.app { max-width: 900px; margin: 0 auto; padding: 1rem; }
.error { color: #ff8a80; }
.message { color: #86e0a3; }
.board-container { margin: 1rem 0; }

/* Canvas board (drag-and-drop). Wrapper keeps the legacy .board class for E2E, but the
   scene is drawn on <canvas>, so the old grid rules are neutralised here. */
.board.board-stage { display: block; background: none; width: auto; gap: 0; margin: 1rem 0; }
.board-canvas {
    display: block;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    touch-action: none;
    user-select: none;
}
.board-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; max-width: 560px; }

/* Wait: a permanent part of the board (not an action chip). Shows the acting player's occupied
   count vs the opponent's; bold + clickable only when a pass is actually allowed. */
.board-topbar {
    display: flex; align-items: center; justify-content: center; gap: 0.55rem; box-sizing: border-box;
    width: 100%; max-width: 560px; min-height: 52px;
    padding: 0 1.15rem; margin-bottom: 0.4rem;
    background: url('/img/waitbar.png') center / 100% 100% no-repeat;
    color: var(--ink-dim); user-select: none; font-variant-numeric: tabular-nums; cursor: default;
}
.board-topbar .wait-counts { font-weight: 700; color: var(--ink); }
.board-topbar .wait-op { padding: 0 0.15rem; }
.board-topbar .wait-icon { width: 20px; height: 20px; }
.board-topbar .wait-win { font-weight: 800; font-size: 1.1rem; letter-spacing: 0.5px; }
.board-topbar.win-blue .wait-win { color: #6bb0ff; text-shadow: 0 0 10px rgba(74,144,226,.6); }
.board-topbar.win-yellow .wait-win { color: #ffd84a; text-shadow: 0 0 10px rgba(246,214,63,.6); }
.board-topbar.can { background-image: url('/img/waitbar-can.png'); cursor: pointer; color: #fff; }
.board-topbar.can .wait-label { font-weight: 800; color: #fff; letter-spacing: 1.5px; font-size: 1.05rem; }
.board-topbar.can:hover { filter: brightness(1.06); }
.board-topbar:focus-visible { outline: 2px solid #1565c0; outline-offset: 2px; }

/* Clickable areas replacing native buttons/selects */
.chip {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1rem; border-radius: 999px; cursor: pointer; user-select: none;
    background: #eceff1; color: #263238; font-weight: 500; line-height: 1;
    border: 1px solid #cfd8dc; transition: background 0.12s, transform 0.06s;
}
.chip:hover { background: #e0e5e8; }
.chip:active { transform: translateY(1px); }
.chip:focus-visible { outline: 2px solid #1565c0; outline-offset: 2px; }
.chip.disabled { opacity: 0.4; pointer-events: none; }
.chip-primary { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.chip-primary:hover { background: #276b2a; }
.chip-wait { background: #fff3e0; border-color: #ffcc80; color: #e65100; }
.chip-wait:hover { background: #ffe9c7; }

.tile-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.tile {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 4rem; padding: 0.75rem 1rem; border-radius: 10px; cursor: pointer; user-select: none;
    background: #eceff1; border: 2px solid #cfd8dc; font-weight: 600; color: #37474f;
    transition: background 0.12s, border-color 0.12s;
}
.tile:hover { background: #e0e5e8; }
.tile.selected { background: #e8f5e9; border-color: #2e7d32; color: #1b5e20; }
.tile:focus-visible { outline: 2px solid #1565c0; outline-offset: 2px; }

.setup { max-width: 560px; }
.setup-label { font-weight: 600; color: #455a64; }
.game-page .lede { color: #546e7a; max-width: 560px; }

.game-page .moves { margin-top: 1rem; color: #607d8b; }
.game-page .turn { color: var(--gold); font-weight: 600; }
.game-page .turn.over { color: #ff8a80; }
.game-chat { margin-top: 1.5rem; border: 1px solid #ccc; border-radius: 4px; padding: 0.75rem; max-width: 400px; }
.game-chat h2 { margin: 0 0 0.5rem 0; font-size: 1rem; }
.chat-messages { max-height: 200px; overflow-y: auto; margin-bottom: 0.5rem; }
.chat-line { margin-bottom: 0.25rem; word-break: break-word; }
.chat-send { display: flex; gap: 0.5rem; }
.chat-send input { flex: 1; padding: 0.35rem; }
.chat-send button { padding: 0.35rem 0.75rem; }

/* ===================== Premium modern theme (Phase 2 shell) ===================== */
:root {
    --ink: #f2efe6;
    --ink-dim: #9fb0c3;
    --gold: #c9a24b;
    --sheet: #f6f7f9;
    --sheet-ink: #1f2733;
}

html, body {
    min-height: 100%;
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: #141822 url('/img/bg-app.jpg') center top / cover fixed no-repeat;
}

.app { max-width: 1040px; margin: 0 auto; padding: 1rem 1.25rem 2rem; }

/* --- top nav as a graphical bar --- */
.topnav {
    display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
    padding: 0.4rem 0 1rem; margin-bottom: 1rem; border: none;
}
.topnav .brand { padding: 0; display: inline-flex; align-items: center; gap: 0.55rem; text-decoration: none; }
.topnav .brand .brand-mark { height: 42px; width: 42px; object-fit: contain; display: block; border-radius: 9px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.topnav .brand .brand-word { font-size: 1.5rem; font-weight: 800; letter-spacing: 2.5px; color: #eef2f8; }
.nav-links { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1 1 auto; }

.navpill {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 0.95rem; min-height: 40px; color: var(--ink); text-decoration: none;
    background: url('/img/pill.png') center / 100% 100% no-repeat;
    font-weight: 600; font-size: 0.92rem; white-space: nowrap;
    transition: transform 0.08s;
}
.navpill:hover { background-image: url('/img/pill-hover.png'); }
.navpill:active { transform: translateY(1px); }
.navpill.primary { background-image: url('/img/pill-primary.png'); }
.navpill img { width: 18px; height: 18px; }

.badge { display: inline-flex; align-items: center; padding: 0.35rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; }
.badge.guest { background: rgba(255,255,255,.12); color: var(--ink); }
.badge.premium { background: linear-gradient(#e5c57a, #c9a24b); color: #3a2d06; }
.userid { color: var(--ink-dim); font-size: 0.78rem; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- everything on the dark shell now (Phase 2.2) --- */
main { display: block; color: var(--ink); }
main h1, main h2, main h3 { color: var(--ink); }
main h1:focus { outline: none; }   /* programmatic focus ring on heading */
main a { color: #86b7ff; }
main a:hover { color: #a9ccff; }

/* ad slot styled for the dark shell */
.ad-slot { display: flex; align-items: center; gap: 0.5rem; margin-top: 1rem; padding: 0.5rem 0.9rem;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 10px;
    font-size: 0.82rem; color: var(--ink-dim); max-width: max-content; }
.ad-slot .ad-label { font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; opacity: 0.7; }
.ad-slot a { color: var(--gold); text-decoration: none; }
.ad-slot a:hover { text-decoration: underline; }

/* --- Home menu tiles (text on image plates) --- */
.home-hero { padding-top: 0.5rem; }
.menu { display: flex; flex-direction: column; gap: 0.9rem; max-width: 460px; margin: 0.5rem 0 1.25rem; }
.menu-tile {
    display: flex; align-items: center; gap: 1rem; text-decoration: none; color: var(--ink);
    padding: 1.15rem 1.35rem; min-height: 104px;
    background: url('/img/tile.png') center / 100% 100% no-repeat;
    transition: transform 0.1s;
}
.menu-tile:hover { background-image: url('/img/tile-hover.png'); transform: translateY(-2px); }
.menu-tile.primary { background-image: url('/img/tile-primary.png'); }
.menu-tile.primary:hover { background-image: url('/img/tile-primary.png'); }
.menu-icon { width: 52px; height: 52px; flex: 0 0 auto; filter: drop-shadow(0 2px 3px rgba(0,0,0,.4)); }
.menu-text { display: flex; flex-direction: column; gap: 0.15rem; }
.menu-title { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.3px; }
.menu-sub { color: var(--ink-dim); font-size: 0.9rem; }
.home-note { color: var(--ink-dim); max-width: 620px; }
.home-note a { color: var(--gold); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ===================== Phase 2.2: dark form / panel / card system ===================== */

/* glass surfaces for forms and content groups */
.auth-form, .form, .panel {
    max-width: 460px; margin: 0.5rem 0 1rem;
    padding: 1.5rem 1.6rem; border-radius: 16px;
    background: linear-gradient(180deg, rgba(52,64,82,.55), rgba(28,37,51,.62));
    border: 1px solid rgba(201,162,75,.30);
    box-shadow: 0 12px 30px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.06);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.panel-wide { max-width: 880px; }

/* fields + inputs */
.field { margin-bottom: 0.9rem; }
.field label { display: block; margin-bottom: 0.35rem; color: var(--ink-dim); font-weight: 600; font-size: 0.88rem; }
input, select, textarea {
    width: 100%; box-sizing: border-box; padding: 0.6rem 0.7rem;
    background: #1b2430; color: var(--ink); font-size: 0.95rem;
    border: 1px solid rgba(255,255,255,.15); border-radius: 9px;
}
input::placeholder { color: #6b7a8c; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,162,75,.25); }
input[type=checkbox] { width: auto; }

/* buttons -> image plates (text on image) */
main button, .btn, .provider,
.auth-form button, .form button {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
    width: auto; padding: 0.6rem 1.2rem; min-height: 44px; margin: 0.25rem 0;
    border: none; cursor: pointer; color: var(--ink); font-weight: 700; font-size: 0.95rem;
    background: url('/img/pill.png') center / 100% 100% no-repeat; transition: transform 0.08s, filter 0.1s;
}
main button:hover, .btn:hover, .provider:hover { background-image: url('/img/pill-hover.png'); }
main button:active { transform: translateY(1px); }
main button:disabled { filter: grayscale(.4) brightness(.75); cursor: default; }
main button[type=submit], .btn-primary { background-image: url('/img/pill-primary.png'); }
main button[type=submit]:hover { background-image: url('/img/pill-primary.png'); filter: brightness(1.05); }

/* chips + pickers -> plates (override the earlier light rules) */
.chip { background: url('/img/pill.png') center / 100% 100% no-repeat; color: var(--ink); border: none; }
.chip:hover { background-image: url('/img/pill-hover.png'); }
.chip-primary { background-image: url('/img/pill-primary.png'); }
.chip-wait { background-image: url('/img/pill.png'); color: #ffcf8f; box-shadow: inset 0 0 0 2px rgba(230,120,20,.55); }
.tile { background: url('/img/pill.png') center / 100% 100% no-repeat; color: var(--ink); border: none; position: relative; }
.tile:hover { background-image: url('/img/pill-hover.png'); }
.tile.selected { background-image: url('/img/pill-primary.png'); color: var(--ink); }
.tile.locked { opacity: 0.62; padding-right: 1.6rem; }
.tile.locked::after { content: "🔒"; position: absolute; top: 50%; right: 0.55rem; transform: translateY(-50%); font-size: 0.7rem; }
.tile.locked.selected { opacity: 0.62; }
.lock-note { color: #ffcf8f; font-size: 0.88rem; margin: 0.35rem 0 0.5rem; }

/* provider (external sign-in) buttons keep a brand tint */
.external-signin { margin-top: 1rem; }
.divider { color: var(--ink-dim); font-size: 0.85rem; margin: 0.5rem 0; }
.provider.google { color: #ffe08a; }
.provider.apple { color: #e6ecf3; }
.more { color: var(--ink-dim); font-size: 0.85rem; margin-left: 0.5rem; }

/* card lists (replace Games / Friends tables) */
.card-list { display: flex; flex-direction: column; gap: 0.6rem; max-width: 880px; margin: 0.6rem 0 1rem; }
.row-card {
    display: flex; align-items: center; gap: 0.9rem; text-decoration: none; color: var(--ink);
    padding: 0.75rem 1rem; border-radius: 12px;
    background: linear-gradient(180deg, rgba(52,64,82,.5), rgba(28,37,51,.55));
    border: 1px solid rgba(255,255,255,.10); transition: border-color 0.12s, transform 0.08s;
}
a.row-card:hover { border-color: rgba(201,162,75,.55); transform: translateY(-1px); }
.row-card .rc-icon { width: 34px; height: 34px; flex: 0 0 auto; opacity: 0.9; }
.row-card .rc-main { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.row-card .rc-title { font-weight: 700; }
.row-card .rc-sub { color: var(--ink-dim); font-size: 0.85rem; }
.row-card .rc-spacer { flex: 1 1 auto; }
.row-card .rc-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.status-pill { padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
    background: rgba(255,255,255,.10); color: var(--ink-dim); }
.status-pill.live { background: rgba(76,175,80,.22); color: #a5e0ae; }
.status-pill.done { background: rgba(255,255,255,.08); color: var(--ink-dim); }
.empty-note { color: var(--ink-dim); }

/* pickers (Queue / setup) */
.picker-label { display: block; font-weight: 600; color: var(--ink-dim); margin: 0.75rem 0 0.35rem; }
.toggle-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.75rem 0; color: var(--ink-dim); }
.toggle-row input { width: auto; }
.add-friend-row { display: flex; gap: 0.5rem; align-items: center; }
.add-friend-row input { flex: 1; }
main button.sm, .btn.sm { min-height: 34px; padding: 0.32rem 0.85rem; font-size: 0.85rem; }

/* content page tweaks on dark */
.scaffold-note, .hint { color: var(--ink-dim); font-size: 0.9rem; }
.game-page .lede { color: var(--ink-dim); }
.setup-label, .picker-label { color: var(--ink-dim); }
.game-chat { border: 1px solid rgba(255,255,255,.12); border-radius: 12px;
    background: linear-gradient(180deg, rgba(52,64,82,.4), rgba(28,37,51,.5)); }
.game-chat h2 { color: var(--ink); }
.chat-line { color: var(--ink); }
code { color: #ffcf8f; background: rgba(255,255,255,.06); padding: 0.05rem 0.3rem; border-radius: 4px; }

/* Resign chip */
.chip-danger { background: #b71c1c; background-image: none; color: #fff; box-shadow: none; border: none; }
.chip-danger:hover { background: #9e1616; background-image: none; }

/* Full-screen blocking notice (ToastOverlay): dark backdrop, centred card, captures all clicks */
.toast-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: toast-fade 0.15s ease-out;
}
.toast-card {
    background: #1f2937;
    color: #fff;
    padding: 1.25rem 1.75rem;
    border-radius: 12px;
    font-size: 1.15rem;
    line-height: 1.4;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.55);
}
@keyframes toast-fade { from { opacity: 0; } to { opacity: 1; } }

/* Invite QR code — white quiet-zone so it scans against the dark theme */
.invite-qr-wrap { margin-top: 0.4rem; }
.invite-qr { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; padding: 10px; border-radius: 10px; }
