:root {
    --bg: #10131a;
    --panel: #1a1f2b;
    --panel-border: #2b3444;
    --text: #e8ecf4;
    --muted: #8e9bb0;
    --accent: #57c85a;
    --cell-size: 26px;
    --i: #4fd1e0;
    --j: #4f7ce0;
    --l: #e0913f;
    --o: #e0d24f;
    --s: #57c85a;
    --t: #a45ce0;
    --z: #e05a5a;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

h1 {
    margin: 0 0 16px;
    font-size: 28px;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: var(--accent);
}

h2 {
    margin: 0 0 8px;
    font-size: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
}

.page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.board-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.board {
    display: grid;
    grid-template-columns: repeat(10, var(--cell-size));
    grid-auto-rows: var(--cell-size);
    gap: 2px;
    padding: 8px;
    background: #0b0e14;
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border-radius: 4px;
    background: #151a24;
}

.cell.ghost {
    background: transparent;
    border: 1px dashed currentColor;
    opacity: 0.45;
}

.piece-i { background: var(--i); }
.piece-j { background: var(--j); }
.piece-l { background: var(--l); }
.piece-o { background: var(--o); }
.piece-s { background: var(--s); }
.piece-t { background: var(--t); }
.piece-z { background: var(--z); }

.cell.piece-i, .cell.piece-j, .cell.piece-l, .cell.piece-o,
.cell.piece-s, .cell.piece-t, .cell.piece-z {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 320px;
    flex: 1;
}

.card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 12px 14px;
}

.server-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.server-state {
    font-size: 14px;
    font-weight: 600;
}

.server-state.is-ok {
    color: var(--accent);
}

.server-state.is-warn {
    color: var(--muted);
}

.server-meta {
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.field span,
.stat-label {
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
}

.field input {
    width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--panel-border);
    background: #0b0e14;
    color: var(--text);
    font-size: 14px;
}

button.primary {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: #08210a;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
}

button.primary:hover {
    filter: brightness(1.1);
}

.stats {
    display: flex;
    gap: 18px;
    justify-content: space-between;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.preview {
    display: grid;
    grid-template-columns: repeat(4, 20px);
    grid-auto-rows: 20px;
    gap: 2px;
    margin-top: 6px;
}

.preview .cell {
    width: 20px;
    height: 20px;
}

.hints ul {
    margin: 6px 0 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.6;
}

.leaderboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.leaderboard th,
.leaderboard td {
    text-align: left;
    padding: 5px 6px;
    border-bottom: 1px solid var(--panel-border);
    font-variant-numeric: tabular-nums;
}

.leaderboard th {
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
}

.empty {
    color: var(--muted);
    font-size: 13px;
    margin: 0;
}

.banner {
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.banner-over {
    border-color: var(--z);
}

.error {
    color: var(--z);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 8px;
}

.loading-title {
    font-size: 32px;
    letter-spacing: 10px;
    color: var(--accent);
}

.loading-text {
    color: var(--muted);
}

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    background: #40161a;
    color: #fff;
    z-index: 1000;
}

#blazor-error-ui .reload,
#blazor-error-ui .dismiss {
    color: #ffd166;
    margin-left: 8px;
    cursor: pointer;
}

.hint {
    margin: -4px 0 10px;
    font-size: 11px;
    color: var(--muted);
}

/* Account surface: the header link on every page and the /login form. */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--panel-border);
}

.brand {
    color: var(--accent);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 4px;
    text-decoration: none;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
}

.topbar-nav a {
    color: var(--muted);
    text-decoration: none;
}

.topbar-nav a:hover {
    color: var(--text);
}

.topbar-nav .who {
    color: var(--text);
    font-weight: 600;
}

.link-button {
    padding: 0;
    border: none;
    background: none;
    color: var(--muted);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.link-button:hover {
    color: var(--text);
}

.auth-card {
    min-width: 320px;
    flex: 1;
    max-width: 380px;
}

.auth-note {
    flex: 1;
    min-width: 280px;
}

.auth-note p {
    margin: 0 0 10px;
    line-height: 1.5;
}

.auth-current {
    margin: 0 0 10px;
    font-size: 15px;
}

button.secondary {
    width: 100%;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

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

button.primary:disabled,
button.secondary:disabled {
    opacity: 0.55;
    cursor: progress;
}

code {
    padding: 1px 4px;
    border-radius: 4px;
    background: #0b0e14;
    font-size: 12px;
}

.hint a,
.auth-note a {
    color: var(--accent);
}

/* FocusOnNavigate focuses the h1 after a route change; the ring around a heading is noise. */
h1:focus {
    outline: none;
}

/* Multiplayer: one page, five screens, and the same board component as single player. */

.mp-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    font-size: 13px;
}

.mp-bar .server-state {
    margin-left: auto;
}

.mp-who {
    color: var(--muted);
}

.mp-who strong {
    color: var(--text);
    font-weight: 600;
}

.mp-card {
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mp-card h2 {
    margin: 0;
}

.mp-card .hint {
    margin: 0;
    line-height: 1.5;
}

.mp-card button {
    margin-top: 6px;
}

.mp-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.mp-board-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mp-names {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
}

.mp-versus {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mp-board-wrap {
    position: relative;
}

.mp-countdown {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 96px;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 28px rgba(87, 200, 90, 0.55);
    pointer-events: none;
}

.mp-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 260px;
    flex: 1;
}

/* The opponent's mini-board is the same grid at a smaller cell size, not a second renderer. */
.board-mini {
    --cell-size: 12px;
    gap: 1px;
    padding: 5px;
    box-shadow: none;
    margin-top: 6px;
    /* A grid inside a column flex container would stretch to the card width and leave a dead
       black band next to the cells; the mini-board is exactly as wide as its columns. */
    width: max-content;
    align-self: flex-start;
}

.board-mini .cell {
    border-radius: 2px;
}

.mp-opponent {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mp-opponent-name {
    font-weight: 600;
}

.mp-opponent-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--muted);
}

.mp-opponent-stats strong {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.mp-result {
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mp-result h2 {
    margin: 0;
    font-size: 20px;
    color: var(--accent);
}

.mp-result button {
    margin-top: 4px;
}

.mp-final {
    margin: 4px 0;
}

/* --- Multiplayer attacks --------------------------------------------------------------
   Ink is a stain over the board's grid, never over the HUD: the overlay is confined to the
   board box and ignores the pointer, so the field underneath stays playable. */
.ink-overlay {
    position: absolute;
    inset: 9px;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
    border-radius: 6px;
}

.ink-overlay svg {
    display: block;
    width: 100%;
    height: 100%;
}

.ink-blot {
    fill: #04060b;
    opacity: 0.85;
    transform-origin: center;
    animation: ink-in 150ms ease-out both;
}

.ink-blot.is-leaving {
    animation: ink-out 500ms ease-in both;
}

@keyframes ink-in {
    from { opacity: 0; transform: scale(0.7); }
    to   { opacity: 0.85; transform: scale(1); }
}

@keyframes ink-out {
    from { opacity: 0.85; }
    to   { opacity: 0; }
}

/* «Туман» says why the drop shadow is missing; the board and the piece stay untouched. */
.mp-fog {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    z-index: 3;
    padding: 4px 6px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: rgba(12, 16, 24, 0.88);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: center;
    pointer-events: none;
}

.mp-attack-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.mp-charges {
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.mp-attack-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 8px;
}

.mp-attack-buttons button {
    padding: 6px 8px;
    font-size: 12px;
}

.mp-attack-buttons button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.mp-attack-notice {
    color: var(--accent);
}

/* «Слепая очередь»: the panel is empty on purpose — the server withholds the next piece. */
.mp-next-blind {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
}

.mp-next-question {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: var(--accent);
}

.mp-next-seconds {
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.mp-keys {
    margin-top: 4px;
    font-size: 12px;
}

/* Мультиплеер: лидеры и лента «Последние матчи» (карточка 8/9). */
.mp-highlights {
    margin-top: 1rem;
}

.mp-highlights h2 {
    margin: 0 0 .5rem;
    font-size: 1.1rem;
}

.mp-highlights h2 + .leaderboard,
.mp-highlights h2 + .mp-matches {
    margin-bottom: 1.2rem;
}

.mp-leader-row .mp-winner-badge {
    display: inline-block;
    margin-left: .4rem;
    padding: .05rem .4rem;
    border-radius: .5rem;
    font-size: .75rem;
    background: #2f6f45;
    color: #eaffef;
}

.mp-matches {
    margin: 0;
    padding-left: 1.1rem;
    line-height: 1.7;
}

.mp-match-row {
    white-space: normal;
}

/* Клавиши: страница /settings и ссылка на неё с игровых экранов. */

.hint-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--accent);
    font-size: 12px;
    text-decoration: none;
}

.hint-link:hover {
    text-decoration: underline;
}

.settings-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.settings-card {
    flex: 1;
    min-width: 320px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--panel-border);
}

.settings-row:last-of-type {
    border-bottom: none;
}

.settings-action {
    font-size: 14px;
}

.settings-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-key {
    min-width: 74px;
    padding: 4px 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: #0b0e14;
    color: var(--text);
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 15px;
    text-align: center;
}

.settings-key.is-capturing {
    border-color: var(--accent);
    color: var(--accent);
}

.settings-change {
    padding: 6px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}

.settings-change:hover {
    border-color: var(--accent);
}

.settings-message {
    margin: 12px 0 0;
    font-size: 13px;
    line-height: 1.4;
}

.settings-message.is-ok {
    color: var(--accent);
}

.settings-message.is-error {
    color: #ffb4a2;
}

.settings-swap,
.settings-reset {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
}

.settings-swap {
    border-color: var(--accent);
    color: var(--accent);
}

.settings-swap:hover,
.settings-reset:hover {
    border-color: var(--accent);
}

.settings-preview {
    margin: 0 0 8px;
    padding-left: 18px;
    line-height: 1.9;
    font-size: 14px;
}
