/* ============================================================
   Cathedral
   Inspired by the 1985 film: stormy New England night, candlelight,
   dark mahogany trim, blood-red drama.
   ============================================================ */

:root {
    --bg-deep:      #0a0d12;   /* darkest — page background */
    --bg-mid:       #0e1218;   /* midnight ink */
    --panel:        #1a2030;   /* deep navy velvet card */
    --panel-2:      #232a3a;   /* lifted / hover */
    --panel-edge:   #2a3144;
    --wood:         #3a2418;   /* dark mahogany frame */
    --wood-2:       #5a3a26;   /* lighter mahogany */
    --candle:       #f0c95e;   /* candle gold accent */
    --candle-glow:  rgba(240, 201, 94, 0.35);
    --blood:        #8b1a22;   /* drama / errors */
    --blood-bright: #a12830;
    --blood-dim:    rgba(139, 26, 34, 0.25);
    --vellum:       #e8e1d0;   /* primary text */
    --vellum-dim:   rgba(232, 225, 208, 0.7);
    --muted:        rgba(232, 225, 208, 0.5);
    --ink:          #0a0c0e;
    --green-good:   #6fb86f;   /* "ready" indicator */
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Crimson Text', Georgia, serif;
    color: var(--vellum);
    background:
        radial-gradient(ellipse at 20% 0%, rgba(240, 201, 94, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(139, 26, 34, 0.08) 0%, transparent 50%),
        linear-gradient(160deg, var(--bg-deep) 0%, var(--bg-mid) 100%);
    min-height: 100vh;
}

a { color: var(--candle); text-decoration: none; }
a:hover { color: #fff3c5; text-decoration: underline; }

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

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 26px;
    background: linear-gradient(180deg, #06080c 0%, #0e1218 100%);
    border-bottom: 2px solid var(--wood);
    color: var(--vellum);
    box-shadow: 0 4px 20px rgba(0,0,0,0.7);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--candle);
    font-family: 'Cinzel', serif;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    text-decoration: none;
    text-shadow: 0 0 12px var(--candle-glow);
}

.brand-icon { font-size: 1.5rem; filter: drop-shadow(0 0 6px var(--candle-glow)); }
.brand-text { font-size: 1.1rem; }

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-user {
    color: var(--vellum-dim);
    font-style: italic;
}

.topbar-link {
    color: var(--vellum);
    text-decoration: none;
    font-size: 0.95rem;
}

.topbar-link:hover {
    color: var(--candle);
    text-decoration: none;
}

/* ---------- Landing ---------- */
.landing {
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    background:
        radial-gradient(ellipse at center, rgba(0,0,0,0.25) 0%, rgba(0,0,0,0.75) 90%),
        url('/images/splash.png') center / cover no-repeat,
        var(--bg-deep);
    box-shadow: inset 0 0 200px rgba(0,0,0,0.8);
    overflow: hidden;
}

.landing::after {
    /* Slow vignette + rain shimmer effect to make the photo feel cinematic */
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 30%, transparent 0%, rgba(0,0,0,0.4) 70%);
    pointer-events: none;
}

.landing-card {
    width: 100%;
    max-width: 560px;
    text-align: center;
    background: linear-gradient(160deg, rgba(26, 32, 48, 0.78) 0%, rgba(35, 42, 58, 0.85) 100%);
    backdrop-filter: blur(6px) saturate(120%);
    -webkit-backdrop-filter: blur(6px) saturate(120%);
    border: 1px solid var(--wood);
    border-radius: 6px;
    padding: 48px 44px;
    box-shadow:
        0 30px 80px rgba(0,0,0,0.9),
        0 0 60px rgba(240, 201, 94, 0.08),
        inset 0 1px 0 rgba(240, 201, 94, 0.15);
    position: relative;
    z-index: 1;
}

.landing-card::before {
    content: '';
    position: absolute;
    inset: 8px;
    border: 1px solid rgba(240, 201, 94, 0.25);
    border-radius: 4px;
    pointer-events: none;
}

.landing-seal {
    font-size: 3rem;
    margin-bottom: 6px;
    color: var(--candle);
    filter: drop-shadow(0 0 14px var(--candle-glow));
}

.landing-title {
    font-family: 'Cinzel', serif;
    font-size: 3.2rem;
    color: var(--candle);
    margin: 0 0 8px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    text-shadow: 0 0 20px var(--candle-glow), 0 2px 4px rgba(0,0,0,0.8);
}

.landing-subtitle {
    color: var(--vellum-dim);
    font-style: italic;
    margin-bottom: 28px;
    letter-spacing: 0.08em;
}

.landing-welcome {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    margin-bottom: 6px;
    color: var(--vellum);
}

.landing-help {
    color: var(--vellum-dim);
    margin-bottom: 24px;
    font-style: italic;
}

.landing-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-size: 0.95rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 11px 26px;
    border-radius: 3px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
}

.btn-primary {
    color: var(--ink);
    background: linear-gradient(180deg, #f5d680 0%, var(--candle) 60%, #c8a13a 100%);
    box-shadow: 0 4px 14px rgba(240, 201, 94, 0.35), inset 0 1px 0 rgba(255,255,255,0.4);
    font-weight: 700;
}

.btn-primary:hover {
    color: var(--ink);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(240, 201, 94, 0.55), inset 0 1px 0 rgba(255,255,255,0.5);
    text-decoration: none;
}

.btn-secondary {
    color: var(--vellum);
    background: linear-gradient(180deg, var(--blood-bright) 0%, var(--blood) 100%);
    box-shadow: 0 4px 12px rgba(139, 26, 34, 0.4);
}

.btn-secondary:hover {
    color: var(--vellum);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(139, 26, 34, 0.6);
    text-decoration: none;
}

.btn-tertiary {
    color: var(--vellum-dim);
    background: transparent;
    border: 1px solid rgba(232, 225, 208, 0.25);
}

.btn-tertiary:hover {
    background: rgba(232, 225, 208, 0.08);
    color: var(--vellum);
    border-color: var(--vellum-dim);
    text-decoration: none;
}

.btn:disabled, .btn-tertiary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ---------- Music controls (topbar) ---------- */
.music-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--vellum);
    font-size: 0.9rem;
    padding: 4px 12px;
    border-right: 1px solid rgba(240, 201, 94, 0.2);
    margin-right: 6px;
}

.music-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.music-toggle input[type="checkbox"] {
    accent-color: var(--candle);
    cursor: pointer;
}

.music-toggle .toggle-label {
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--vellum-dim);
}

.volume-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--vellum-dim);
}

.volume-icon { font-size: 0.95rem; line-height: 1; }

.volume-slider {
    appearance: none;
    -webkit-appearance: none;
    width: 90px;
    height: 4px;
    background: rgba(232, 225, 208, 0.18);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--candle);
    border: 1px solid var(--wood);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px var(--candle-glow);
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: var(--candle);
    border: 1px solid var(--wood);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 6px var(--candle-glow);
}

.volume-pct {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    letter-spacing: 0.06em;
    color: var(--vellum-dim);
    min-width: 22px;
    text-align: right;
}

.audio-loading-bar {
    width: 60px;
    height: 4px;
    background: rgba(232, 225, 208, 0.12);
    border-radius: 2px;
    overflow: hidden;
}

.audio-loading-progress {
    height: 100%;
    background: var(--candle);
    box-shadow: 0 0 6px var(--candle-glow);
    transition: width 0.2s linear;
}

.audio-load-error {
    color: var(--blood-bright);
    font-weight: bold;
}

.now-playing {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--candle);
    font-style: italic;
    max-width: 280px;
}

.music-note { font-size: 1rem; text-shadow: 0 0 8px var(--candle-glow); }

.track-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    font-size: 0.85rem;
}

.skip-track-btn {
    background: transparent;
    border: 1px solid rgba(240, 201, 94, 0.4);
    color: var(--candle);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
}

.skip-track-btn:hover {
    background: rgba(240, 201, 94, 0.15);
    border-color: var(--candle);
}

/* ---------- Debug Grid button (game pages only) ---------- */
.grid-debug-btn {
    background: transparent;
    border: 1px solid rgba(232, 225, 208, 0.3);
    color: var(--vellum-dim);
    padding: 5px 12px;
    border-radius: 3px;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.15s ease;
}

.grid-debug-btn:hover {
    border-color: var(--candle);
    color: var(--candle);
}

.grid-debug-btn.is-active {
    background: rgba(220, 50, 50, 0.7);
    color: #fff;
    border-color: #ff8888;
    box-shadow: 0 0 8px rgba(220, 50, 50, 0.5);
}

/* ---------- Lobby ---------- */
.lobby {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    padding: 28px;
    max-width: 1200px;
    margin: 0 auto;
}

.lobby-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--wood);
    padding-bottom: 8px;
}

.lobby-section-header h2 {
    font-family: 'Cinzel', serif;
    color: var(--candle);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin: 0;
    font-size: 1.2rem;
}

.lobby-subheading {
    font-family: 'Cinzel', serif;
    color: var(--vellum-dim);
    margin-top: 24px;
    margin-bottom: 8px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.lobby-error {
    color: var(--blood-bright);
    background: rgba(139, 26, 34, 0.15);
    border: 1px solid var(--blood);
    padding: 10px 14px;
    border-radius: 3px;
    margin: 8px 0;
}

.lobby-empty {
    color: var(--muted);
    font-style: italic;
    margin: 8px 0;
}

.lobby-game-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.lobby-game-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 3px;
}

.lobby-game-players { font-family: 'Crimson Text', serif; }
.lobby-game-players .vs { color: var(--muted); font-style: italic; padding: 0 6px; }
.lobby-game-status {
    font-size: 0.8rem;
    color: var(--vellum-dim);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.lobby-game-mine {
    font-style: italic;
    color: var(--candle);
    font-size: 0.85rem;
}

.lobby-chat {
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 3px;
    padding: 14px;
    height: min(70vh, 600px);
}

.lobby-chat-scroll {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 6px;
}

.chat-line { padding: 4px 0; }
.chat-name { color: var(--candle); font-weight: 600; margin-right: 8px; }
.chat-body { color: var(--vellum); }

.chat-form {
    display: flex;
    gap: 8px;
}
.chat-input {
    flex: 1;
    background: var(--bg-mid);
    border: 1px solid var(--panel-edge);
    color: var(--vellum);
    padding: 8px 10px;
    border-radius: 3px;
    font-family: 'Crimson Text', serif;
}

/* ---------- Game waiting ---------- */
.game-waiting {
    max-width: 600px;
    margin: 60px auto;
    text-align: center;
    padding: 40px;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 4px;
}
.game-waiting h2 {
    font-family: 'Cinzel', serif;
    color: var(--candle);
    letter-spacing: 0.2em;
}

/* ---------- Game (2D board) ---------- */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.game-players { display: flex; gap: 12px; }
.player-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    font-family: 'Cinzel', serif;
    letter-spacing: 0.08em;
}
.player-pill.active {
    border-color: var(--candle);
    box-shadow: 0 0 12px var(--candle-glow);
}
.swatch { width: 14px; height: 14px; border-radius: 2px; display: inline-block; }
.swatch-light { background: #d4b56a; }
.swatch-dark { background: #6b1a22; }
.score { color: var(--candle); font-weight: 700; margin-left: 6px; }

.game-status {
    font-family: 'Cinzel', serif;
    letter-spacing: 0.12em;
    color: var(--vellum-dim);
}

.game-error {
    color: var(--blood-bright);
    background: rgba(139, 26, 34, 0.15);
    border: 1px solid var(--blood);
    padding: 8px 14px;
    border-radius: 3px;
    margin: 10px 0;
}

.game-board-and-tray {
    display: grid;
    grid-template-columns: auto 280px;
    gap: 24px;
    align-items: start;
}

.game-board-wrap {
    background: var(--wood);
    padding: 12px;
    border-radius: 4px;
    outline: none;
}
.game-board {
    width: 100%;
    max-width: 560px;
    height: auto;
    display: block;
}

.game-board-3d {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1 / 1;
    display: block;
    background: #0a0d12;
    border-radius: 3px;
}

.game-view-toggle {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}
.game-view-toggle .btn {
    padding: 6px 18px;
    font-size: 0.8rem;
}
.game-view-toggle .btn.active {
    border-color: var(--candle);
    color: var(--candle);
    background: rgba(240, 201, 94, 0.1);
}

.cell.preview-ok { fill-opacity: 0.95; outline: 2px solid var(--candle); }
.cell.preview-bad { fill-opacity: 0.95; outline: 2px solid var(--blood-bright); }

.game-tray {
    background: var(--panel);
    border: 1px solid var(--panel-edge);
    border-radius: 3px;
    padding: 14px;
}
.game-tray h3, .game-tray h4 {
    font-family: 'Cinzel', serif;
    color: var(--candle);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin: 0 0 10px;
    font-size: 0.95rem;
}

.tray-pieces { display: flex; flex-wrap: wrap; gap: 6px; }
.tray-piece {
    background: var(--panel-2);
    border: 1px solid var(--panel-edge);
    color: var(--vellum);
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
}
.tray-piece.selected {
    border-color: var(--candle);
    background: rgba(240, 201, 94, 0.12);
}
.tray-piece-name { display: block; }
.tray-piece-qty { color: var(--candle); font-size: 0.75rem; }

.tray-controls {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tray-mini-preview {
    font-family: 'Special Elite', monospace;
    background: var(--bg-mid);
    color: var(--candle);
    padding: 8px;
    border-radius: 3px;
    font-size: 0.95rem;
    line-height: 1.1;
    letter-spacing: 0.2em;
}

.captures-list {
    list-style: none;
    padding: 0;
    margin: 8px 0;
    color: var(--vellum-dim);
    font-style: italic;
}

.tray-spectator {
    color: var(--muted);
    font-style: italic;
}

/* ---------- Blazor error UI ---------- */
#blazor-error-ui {
    background: var(--blood);
    color: var(--vellum);
    bottom: 0;
    box-shadow: 0 -2px 6px rgba(0,0,0,0.6);
    display: none;
    left: 0;
    padding: 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;
    color: var(--vellum);
}
