/* ═══════════════════════════════════════════════════════════════════════════
   GAME-OVER BANNER (THE IMPERIAL RECKONING)
   ═══════════════════════════════════════════════════════════════════════════ */

.game-over-banner {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
    background: radial-gradient(circle at center, rgba(30, 10, 5, 0.94), rgba(0, 0, 0, 0.98));
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.game-over-banner.gob-visible {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

/* Minimized state for board inspection */
.game-over-banner.is-minimized {
    background: rgba(0, 0, 0, 0.12);
    backdrop-filter: none;
    pointer-events: none;
}
.game-over-banner.is-minimized .game-over-card {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
    pointer-events: none;
}
.game-over-banner.is-minimized .gob-restore-btn {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.game-over-card {
    position: relative;
    width: 90%;
    max-width: 440px;
    margin: auto 0;
    padding: 32px 24px 28px;
    background: linear-gradient(145deg, #3d0a0a 0%, #1a0505 100%);
    border: 2px solid #d4af37;
    border-radius: 12px;
    box-shadow:
        0 15px 50px rgba(0, 0, 0, 0.8),
        inset 0 0 40px rgba(212, 175, 55, 0.08);
    text-align: center;
    transform: translateY(20px);
    transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}

.game-over-card::before,
.game-over-card::after {
    content: "";
    position: absolute;
    width: 60px;
    height: 60px;
    border: 2px solid #d4af37;
    pointer-events: none;
    z-index: 3;
}
.game-over-card::before {
    top: -6px; left: -6px;
    border-right: none; border-bottom: none;
}
.game-over-card::after {
    bottom: -6px; right: -6px;
    border-left: none; border-top: none;
}

.gob-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.game-over-ornament {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    border: 3px solid #d4af37;
    padding: 2px;
    background: #000;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.25);
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.gob-dragon-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    filter: brightness(1.1) contrast(1.1);
}

.game-over-badge {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    padding: 4px 14px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid currentColor;
}

.gob-badge-win  { color: #d4af37; }
.gob-badge-loss { color: #9fb5ca; }
.gob-badge-draw { color: #d4cfdd; }

.game-over-title {
    margin: 0 0 8px;
    font-family: 'Noto Serif', serif;
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.8);
    background: linear-gradient(180deg, #fffcf5 0%, #d4af37 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.gob-reason {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    color: rgba(240, 237, 232, 0.50);
    text-transform: uppercase;
    margin: 0 0 20px;
}

.gob-summary {
    display: flex;
    justify-content: center;
    gap: 1px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 20px;
}

.gob-summary-cell {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gob-summary-label {
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.gob-summary-cell strong {
    font-family: 'Noto Serif', serif;
    font-size: 0.85rem;
    color: #fff;
}

.gob-summary-sep {
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.gob-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.gob-stat {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(212, 175, 55, 0.1);
    border-radius: 6px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.gob-stat-icon {
    color: #d4af37;
    opacity: 0.7;
}

.gob-stat-val {
    font-weight: 700;
    color: #fff;
}

.gob-stat-lbl {
    font-size: 0.5rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.gob-career {
    display: flex;
    gap: 1px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: 8px;
    margin-bottom: 24px;
}

.gob-career-cell {
    flex: 1;
    padding: 8px;
}

.gob-career-val {
    display: block;
    font-size: 1.2rem;
    font-weight: 800;
}

.gob-career-lbl {
    font-size: 0.55rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.gob-career-win  .gob-career-val { color: #90d98f; }
.gob-career-draw .gob-career-val { color: #d4af37; }
.gob-career-loss .gob-career-val { color: #9fb5ca; }

.gob-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gob-btn {
    padding: 12px;
    border-radius: 30px; /* More modern pill shape */
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.gob-btn-primary {
    background: linear-gradient(180deg, #c0392b 0%, #8e1a1a 100%);
    border: 1px solid #e74c3c;
    color: #fff;
    box-shadow: 0 4px 15px rgba(192, 57, 43, 0.4);
}
.gob-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(192, 57, 43, 0.5);
}

.gob-btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #d4af37;
}
.gob-btn-ghost:hover {
    background: rgba(212, 175, 55, 0.1);
    border-color: #d4af37;
    color: #fff;
}

/* Restore button - floating at bottom when board is visible */
.gob-restore-btn {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: #c0392b;
    color: #fff;
    border: 2px solid #d4af37;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s ease;
}

.gob-restore-btn:hover {
    background: #d44232;
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.7);
}

@media (max-width: 480px) {
    .game-over-card {
        padding: 24px 16px 20px;
    }
    .game-over-title {
        font-size: 1.8rem;
    }
    .game-over-ornament {
        width: 100px;
        height: 100px;
    }
    .gob-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   AVATAR DISC — "THE DIVINE MEDAL"
   A high-fidelity 3D metallic frame for commander portraits.
   Features: Rotating shimmer, multi-ring gold bezel, and spirit aura.
═══════════════════════════════════════════════════════════════════════════ */

.avatar-disc {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    user-select: none;
    overflow: visible; /* Visible so aura/bezel can overflow slightly if needed */
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a0f08; /* Dark base for depth */
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* 1. The Portrait Container (Inner Circle) */
.avatar-disc-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    z-index: 2;
    background-color: var(--avatar-color, #8B2A2A);
    background-image: var(--avatar-pattern, none);
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    /* Inner pocket shadow for 3D depth */
    box-shadow: inset 0 0 10px rgba(0,0,0,0.6);
}

/* 2. The 3D Metallic Bezel */
.avatar-disc::after {
    content: '';
    position: absolute;
    inset: -3px; /* Extends outside the inner circle */
    border-radius: 50%;
    z-index: 3;
    pointer-events: none;
    /* Divine Gold Gradient */
    background: linear-gradient(135deg, 
        #f9f3e0 0%, 
        #c5a059 25%, 
        #8b6e3a 50%, 
        #c5a059 75%, 
        #f9f3e0 100%
    );
    /* Multi-ring metallic definition */
    padding: 2px;
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    border: 0.5px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.4),
        inset 0 1px 1px rgba(255,255,255,0.4);
}

/* 3. The Spirit Aura (Glow) */
.avatar-disc::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    z-index: 1;
    background: var(--avatar-color);
    filter: blur(12px);
    opacity: 0.25;
    transition: opacity 0.3s, filter 0.3s;
}



.avatar-disc:hover {
    transform: scale(1.1) translateY(-2px);
}
.avatar-disc:hover::before {
    opacity: 0.45;
    filter: blur(18px);
}

/* Large variant for sidebar/player panels */
.avatar-disc-lg {
    width: 80px;
    height: 80px;
}
.avatar-disc-lg::after {
    inset: -5px;
    padding: 3px;
}
.avatar-disc-lg::before {
    inset: -8px;
    filter: blur(16px);
}

/* Compact variant for header/matches */
.avatar-disc-sm {
    width: 38px;
    height: 38px;
}
.avatar-disc-sm::after {
    inset: -2px;
}

.game-hud-strip > .avatar-disc-sm {
    width: 64px;
    height: 64px;
    margin-left: 2px;
}

/* Hide initials - portraits are now high fidelity */
.avatar-disc span {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   TUTORIAL HUD
═══════════════════════════════════════════════════════════════════════════ */

.tutorial-hud {
    width: 100%;
    flex-shrink: 0;
    /* Fixed height prevents inter-step layout jank — board stays still.
       220px = 16px padding + 8px gap + 143px content + 8px gap + 32px controls + 13px buffer */
    height: 220px;
    overflow: hidden;
    margin-top: 6px;
    padding: 8px 12px 8px;
    border: 1px solid rgba(197, 160, 89, 0.16);
    border-radius: 8px;
    background: linear-gradient(168deg, rgba(20, 10, 4, 0.90) 0%, rgba(10, 6, 3, 0.92) 65%, rgba(7, 4, 2, 0.95) 100%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow:
        inset 0 1px 0 rgba(197, 160, 89, 0.12),
        0 10px 24px rgba(0, 0, 0, 0.40);
}

@media (min-width: 600px) {
    .tutorial-hud {
        /* Row layout on desktop — content + controls side-by-side, shallower */
        height: 136px;
        flex-direction: row;
        align-items: stretch;
        justify-content: space-between;
        padding: 10px 14px;
        gap: 14px;
    }
    /* Controls stay vertically centered rather than stretching to full height */
    .tutorial-controls {
        align-self: center;
    }
}

.tutorial-hidden {
    display: none;
}

.tutorial-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.tutorial-head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
}

.tutorial-badge {
    flex-shrink: 0;
    font-size: 0.54rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--gold);
    background: rgba(197, 160, 89, 0.10);
    border: 1px solid rgba(197, 160, 89, 0.24);
    border-radius: 5px;
    padding: 2px 6px;
    white-space: nowrap;
    line-height: 1.2;
}

.tutorial-title {
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-family: 'Noto Serif', serif;
    /* Scale down with viewport so the title always fits one line — no ellipsis */
    font-size: clamp(0.62rem, 2.2vw, 0.76rem);
    font-weight: 700;
    letter-spacing: clamp(0.5px, 0.4vw, 1.4px);
    color: var(--text-main);
    text-transform: uppercase;
    line-height: 1.25;
}

.tutorial-close-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: rgba(240, 237, 232, 0.4);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.tutorial-close-btn:hover {
    background: rgba(224, 112, 112, 0.08);
    border-color: rgba(224, 112, 112, 0.3);
    color: #ff8888;
}

.tutorial-close-btn:active {
    transform: scale(0.92);
}

.tutorial-copy,
.tutorial-objective,
.tutorial-feedback {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.4;
    overflow-wrap: break-word;
    word-break: break-word;
}

.tutorial-copy {
    color: rgba(240, 237, 232, 0.76);
}

.tutorial-objective {
    color: var(--gold);
    font-weight: 600;
    background: rgba(197, 160, 89, 0.08);
    border: 1px solid rgba(197, 160, 89, 0.17);
    border-radius: 5px;
    padding: 5px 7px;
}

.tutorial-feedback {
    font-size: 0.68rem;
    letter-spacing: 0.2px;
    color: rgba(240, 237, 232, 0.50);
}

/* ── Pre-allocate fixed slot per text region so HUD never shifts or overflows ── */
.tutorial-copy,
.tutorial-objective,
.tutorial-feedback {
    flex-shrink: 0;
    overflow: hidden;
    /* Show ellipsis when text overflows the pre-allocated slot */
    display: -webkit-box;
    -webkit-box-orient: vertical;
}

/* Mobile: tighter line budgets inside the 220px panel */
@media (max-width: 599px) {
    .tutorial-copy {
        -webkit-line-clamp: 3;
        line-clamp: 3;
        max-height: calc(0.72rem * 1.4 * 3);
    }

    .tutorial-objective {
        -webkit-line-clamp: 2;
        line-clamp: 2;
        max-height: calc(0.72rem * 1.4 * 2 + 10px);
        box-sizing: border-box;
    }

    .tutorial-feedback {
        -webkit-line-clamp: 1;
        line-clamp: 1;
        max-height: calc(0.68rem * 1.4);
    }
}

/* Desktop: tighter line budgets inside the 136px row panel */
@media (min-width: 600px) {
    .tutorial-copy {
        -webkit-line-clamp: 2;
        line-clamp: 2;
        max-height: calc(0.72rem * 1.4 * 2);
    }

    .tutorial-objective {
        -webkit-line-clamp: 1;
        line-clamp: 1;
        max-height: calc(0.72rem * 1.4 + 10px);
        box-sizing: border-box;
    }

    .tutorial-feedback {
        -webkit-line-clamp: 1;
        line-clamp: 1;
        max-height: calc(0.68rem * 1.4);
    }
}

.tutorial-feedback.is-error {
    color: #e07070;
}

.tutorial-feedback.is-success {
    color: #90d98f;
}

.tutorial-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

@media (max-width: 599px) {
    .tutorial-controls {
        justify-content: stretch;
        width: 100%;
        border-top: 1px solid rgba(197, 160, 89, 0.10);
        padding-top: 6px;
    }
}

.tutorial-controls .lobby-btn {
    width: auto;
    min-width: 72px;
    padding: 7px 12px;
    font-size: 0.65rem;
    letter-spacing: 0.8px;
}

@media (max-width: 599px) {
    .tutorial-controls .lobby-btn {
        flex: 1;
        min-width: 0;
    }
}

.tutorial-controls .lobby-btn:disabled {
    opacity: 0.40;
    cursor: not-allowed;
    transform: none !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GAME HUD — player strips above and below the board
   ═══════════════════════════════════════════════════════════════════════════ */

.hud-hidden {
    display: none !important;
}

/* ── Strip shell ─────────────────────────────────────────────────────────── */

.game-hud-strip {
    width: 100%;
    height: 88px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(164deg, rgba(20, 10, 4, 0.86) 0%, rgba(10, 6, 3, 0.88) 68%, rgba(7, 4, 2, 0.92) 100%);
    border: 1px solid rgba(197, 160, 89, 0.13);
    box-shadow:
        inset 0 1px 0 rgba(197, 160, 89, 0.09),
        0 4px 16px rgba(0, 0, 0, 0.28);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.game-hud-strip::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 240, 210, 0.05) 0%, rgba(255, 240, 210, 0) 38%);
}

.game-hud-strip::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 3px;
    height: 100%;
    border-radius: 0 2px 2px 0;
    opacity: 0.55;
    transition: opacity 0.28s ease, box-shadow 0.28s ease;
}

/* Gradient fades at both edges so the bar blends into the rounded HUD corners.
   Color matches the player's actual assigned color (red / black), not their
   position on screen — applied dynamically via .hud-color-red / .hud-color-black. */
.game-hud-strip.hud-color-red::after {
    background: linear-gradient(180deg,
        rgba(192, 57, 43, 0.0)  0%,
        rgba(192, 57, 43, 1.0) 18%,
        rgba(192, 57, 43, 1.0) 82%,
        rgba(192, 57, 43, 0.0) 100%
    );
}

.game-hud-strip.hud-color-black::after {
    background: linear-gradient(180deg,
        rgba(111, 137, 183, 0.0)  0%,
        rgba(111, 137, 183, 1.0) 18%,
        rgba(111, 137, 183, 1.0) 82%,
        rgba(111, 137, 183, 0.0) 100%
    );
}

.game-hud-strip.hud-active {
    border-color: rgba(197, 160, 89, 0.36);
    box-shadow:
        inset 0 1px 0 rgba(197, 160, 89, 0.20),
        0 6px 24px rgba(0, 0, 0, 0.36),
        0 0 22px rgba(197, 160, 89, 0.10);
}

.game-hud-strip.hud-active::after {
    opacity: 1;
}

/* Active glow bleeds horizontally into the HUD body — feels integrated */
.game-hud-strip.hud-color-red.hud-active::after {
    box-shadow: 3px 0 14px rgba(192, 57, 43, 0.36);
}

.game-hud-strip.hud-color-black.hud-active::after {
    box-shadow: 3px 0 14px rgba(111, 137, 183, 0.36);
}

.game-hud-strip.hud-in-check {
    border-color: rgba(255, 76, 76, 0.55);
    background: linear-gradient(164deg, rgba(34, 10, 9, 0.90) 0%, rgba(16, 7, 6, 0.93) 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 110, 110, 0.20),
        0 6px 24px rgba(255, 60, 60, 0.18);
}

.game-hud-strip.hud-disconnected {
    filter: grayscale(0.75);
    opacity: 0.68;
    border-color: rgba(220, 210, 190, 0.18);
    background: linear-gradient(164deg, rgba(28, 27, 25, 0.88) 0%, rgba(12, 12, 12, 0.92) 100%);
}

.game-hud-strip.hud-disconnected::after {
    background: linear-gradient(180deg,
        rgba(148, 144, 136, 0.0)  0%,
        rgba(148, 144, 136, 0.72) 18%,
        rgba(148, 144, 136, 0.72) 82%,
        rgba(148, 144, 136, 0.0) 100%
    ) !important;
    box-shadow: none !important;
    opacity: 0.36 !important;
}

/* ── AI coaching takeover for assisted vs AI games ──────────────────────── */
.hud-coach-panel {
    display: none;
}

#hudOpponent.hud-coach-mode {
    gap: 8px;
    border-color: rgba(197, 160, 89, 0.34);
    background: linear-gradient(164deg, rgba(26, 13, 5, 0.93) 0%, rgba(10, 7, 4, 0.94) 100%);
}

#hudOpponent.hud-coach-mode #hudOppAvatar,
#hudOpponent.hud-coach-mode .hud-info,
#hudOpponent.hud-coach-mode .hud-right {
    display: none;
}

#hudOpponent.hud-coach-mode .hud-coach-panel {
    width: 100%;
    min-width: 0;
    height: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    align-items: stretch;
}

.hud-coach-card {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(197, 160, 89, 0.18);
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 245, 220, 0.08), rgba(255, 245, 220, 0.015)),
        rgba(0, 0, 0, 0.20);
    box-shadow:
        inset 0 1px 0 rgba(255, 245, 220, 0.06),
        0 2px 10px rgba(0, 0, 0, 0.22);
}

.hud-coach-good {
    border-color: rgba(197, 160, 89, 0.34);
}

.hud-coach-avoid {
    border-color: rgba(214, 126, 72, 0.32);
}

/* Narrow accent stripe — fixed 30px column, icon centred vertically */
.hud-coach-icon {
    width: 30px;
    flex: 0 0 30px;
    align-self: stretch;
    display: grid;
    place-items: center;
    border-radius: 0;
    color: var(--gold);
    background: rgba(197, 160, 89, 0.13);
    border-right: 1px solid rgba(197, 160, 89, 0.22);
}

.hud-coach-icon svg {
    width: 15px;
    height: 15px;
}

.hud-coach-avoid .hud-coach-icon {
    color: #e0a072;
    background: rgba(214, 126, 72, 0.13);
    border-right-color: rgba(214, 126, 72, 0.22);
}

.hud-coach-copy {
    min-width: 0;
    padding: 7px 10px;
    display: flex;
    align-items: center;
}

.hud-coach-text {
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    overflow: hidden;
    font-family: 'Noto Serif', serif;
    font-size: clamp(0.62rem, 0.42rem + 1.0vw, 0.76rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-main);
}

.hud-coach-hidden {
    display: none !important;
}

/* ── Info block: grows to fill, stacks name row above captures ───────────── */

.hud-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hud-name-row {
    container-type: inline-size;
    container-name: hudname;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

/* Color indicator dot */
.hud-color-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.34);
    transition: box-shadow 0.3s;
}
.hud-color-pip.pip-red {
    background: #C0392B;
    box-shadow: 0 0 7px rgba(192, 57, 43, 0.72);
}
.hud-color-pip.pip-black {
    background: #6f89b7;
    box-shadow: 0 0 7px rgba(111, 137, 183, 0.58);
}

/* Player name — takes all remaining row space, scales fluidly, never truncates */
.hud-player-name {
    font-family: 'Noto Serif', serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip; /* No ellipses per user request */
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;

    /* Fluid typography: medium scale */
    font-size: clamp(0.75rem, 0.62rem + 0.7vw, 1.0rem);

    /* Imperial aesthetic touch */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    filter: drop-shadow(0 0 1px rgba(212, 175, 55, 0.1));
}

/* Stepped scaling via Container Queries as fallbacks for very narrow HUD layouts */
@container hudname (max-width: 160px) {
    .hud-player-name { font-size: 0.75rem; letter-spacing: 0.01em; }
}
@container hudname (max-width: 120px) {
    .hud-player-name { font-size: 0.68rem; }
}

.hud-ai-badge {
    flex-shrink: 0;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(76, 190, 178, 0.52);
    background: linear-gradient(180deg, rgba(62, 164, 154, 0.30), rgba(28, 92, 92, 0.42));
    color: rgba(217, 252, 247, 0.98);
    font-family: 'Inter', sans-serif;
    font-size: 0.56rem;
    font-weight: 800;
    letter-spacing: 0.9px;
    line-height: 1.2;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow:
        inset 0 1px 0 rgba(219, 255, 248, 0.26),
        0 0 10px rgba(66, 192, 180, 0.20);
}

.hud-ai-hidden {
    display: none;
}

.hud-connection-badge {
    flex-shrink: 0;
    padding: 2px 6px;
    border-radius: 5px;
    border: 1px solid rgba(230, 220, 205, 0.32);
    background: rgba(240, 237, 232, 0.11);
    color: rgba(250, 247, 240, 0.90);
    font-family: 'Inter', sans-serif;
    font-size: 0.52rem;
    font-weight: 800;
    letter-spacing: 0.55px;
    line-height: 1.25;
    text-transform: uppercase;
    white-space: nowrap;
}

.hud-connection-badge::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 5px;
    margin-right: 4px;
    border-radius: 50%;
    background: #e0d7c7;
    box-shadow: 0 0 7px rgba(240, 237, 232, 0.55);
    vertical-align: 1px;
}

.hud-connection-hidden {
    display: none;
}

/* ── Captured piece icons — row below the name ───────────────────────────── */

.hud-captures {
    --cap-size: 40px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    min-height: var(--cap-size);
    overflow: hidden;
    white-space: nowrap;
}

.hud-captures.cap-density-medium { --cap-size: 38px; }
.hud-captures.cap-density-high   { --cap-size: 35px; }
.hud-captures.cap-density-max    { --cap-size: 33px; }

.hud-cap-stack {
    position: relative;
    flex: 0 0 var(--cap-size);
    width: var(--cap-size);
    height: var(--cap-size);
    min-width: 0;
}

.hud-cap-img {
    width: var(--cap-size);
    height: var(--cap-size);
    border-radius: 50%;
    opacity: 0.95;
    display: block;
    background: transparent;
    object-fit: cover;
    box-shadow: none;
}

.hud-cap-stack::after {
    display: none;
}

.hud-cap-count {
    position: absolute;
    right: 0;
    bottom: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px 3px 6px 3px;
    background: rgba(10, 6, 3, 0.96);
    border: 1px solid rgba(197, 160, 89, 0.62);
    color: var(--gold);
    font-family: 'Inter', sans-serif;
    font-size: 0.55rem;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* ── Right column: timer + move counter ──────────────────────────────────── */

.hud-right {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    align-self: center;
    flex-shrink: 0;
    gap: 4px;
    width: 138px;
    min-width: 138px;
}

.hud-notice {
    --notice-bg: #5d4519;
    --notice-border: rgba(224, 186, 115, 0.38);
    --notice-text: #f8edd1;
    --notice-glow: rgba(197, 160, 89, 0.22);
    position: relative;
    width: 100%;
    height: 25px;
    padding: 4px 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--notice-border);
    background:
        linear-gradient(180deg, rgba(248, 237, 209, 0.20), rgba(248, 237, 209, 0.03) 44%, rgba(0, 0, 0, 0.18)),
        var(--notice-bg);
    color: var(--notice-text);
    font-family: 'Noto Serif', serif;
    /* Fluid font: scales smoothly across all viewport widths so labels never clip */
    font-size: clamp(0.52rem, 0.28rem + 1.3vw, 0.72rem);
    font-weight: 900;
    /* Scale letter-spacing with font so spacing doesn't crowd narrow boxes */
    letter-spacing: clamp(0.25px, 0.05px + 0.35vw, 0.65px);
    line-height: 1;
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow:
        0 1px 1px rgba(0, 0, 0, 0.85),
        0 0 8px var(--notice-glow);
    box-shadow:
        inset 0 1px 0 rgba(248, 237, 209, 0.18),
        inset 0 -1px 0 rgba(0, 0, 0, 0.30),
        0 1px 8px rgba(0, 0, 0, 0.32),
        0 0 14px var(--notice-glow);
}

.hud-notice::before {
    display: none;
}

.hud-notice-hidden {
    --notice-bg: #4e4230;
    --notice-border: rgba(221, 200, 149, 0.26);
    --notice-text: rgba(240, 237, 232, 0.78);
    --notice-glow: rgba(197, 160, 89, 0.08);
}

.hud-notice-check,
.hud-notice-defeat {
    --notice-bg: #a92e28;
    --notice-border: rgba(255, 92, 86, 0.55);
    --notice-text: #ffd7d4;
    --notice-glow: rgba(255, 92, 86, 0.26);
}

.hud-notice-faceoff,
.hud-notice-refusal,
.hud-notice-blocked,
.hud-notice-warning {
    --notice-bg: #a85a1f;
    --notice-border: rgba(238, 139, 54, 0.58);
    --notice-text: #ffe0b8;
    --notice-glow: rgba(238, 139, 54, 0.24);
}

.hud-notice-cannon,
.hud-notice-rule {
    --notice-bg: #937022;
    --notice-border: rgba(224, 177, 84, 0.55);
    --notice-text: #ffebb8;
    --notice-glow: rgba(224, 177, 84, 0.22);
}

.hud-notice-turn,
.hud-notice-victory {
    --notice-bg: #aa8127;
    --notice-border: rgba(232, 196, 103, 0.58);
    --notice-text: #fff0be;
    --notice-glow: rgba(232, 196, 103, 0.24);
}

.hud-notice-draw,
.hud-notice-info {
    --notice-bg: #5f4f3b;
    --notice-border: rgba(214, 186, 132, 0.45);
    --notice-text: #f3e7cb;
    --notice-glow: rgba(197, 160, 89, 0.18);
}

.hud-notice-thinking {
    --notice-bg: #355f57;
    --notice-border: rgba(111, 190, 180, 0.48);
    --notice-text: #def8f3;
    --notice-glow: rgba(111, 190, 180, 0.22);
    animation: hud-thinking-pulse 0.9s ease-in-out infinite alternate;
}

@keyframes hud-thinking-pulse {
    from { filter: brightness(0.94); }
    to   { filter: brightness(1.12); }
}

.hud-notice-reconnect {
    --notice-bg: #635a4b;
    --notice-border: rgba(227, 214, 186, 0.44);
    --notice-text: #f7efe0;
    --notice-glow: rgba(227, 214, 186, 0.18);
}

.hud-timebox {
    --time-progress: 0%;
    position: relative;
    width: 100%;
    height: 39px;
    padding: 7px 10px 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid rgba(197, 160, 89, 0.24);
    background:
        linear-gradient(to right, rgba(197, 160, 89, 0.95), rgba(224, 186, 115, 0.88)) left bottom / var(--time-progress) 6px no-repeat,
        linear-gradient(to right, rgba(240, 237, 232, 0.13), rgba(240, 237, 232, 0.13)) left bottom / 100% 6px no-repeat,
        linear-gradient(170deg, rgba(21, 11, 5, 0.86) 0%, rgba(10, 6, 3, 0.92) 100%);
    box-shadow:
        inset 0 1px 0 rgba(197, 160, 89, 0.11),
        0 1px 8px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.hud-timebox::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 242, 210, 0.07) 0%, rgba(255, 242, 210, 0) 48%);
    pointer-events: none;
}

.hud-timebox.timer-active {
    border-color: rgba(197, 160, 89, 0.42);
    box-shadow:
        inset 0 1px 0 rgba(197, 160, 89, 0.18),
        0 0 12px rgba(197, 160, 89, 0.08);
}

.hud-timebox.timer-urgent {
    border-color: rgba(230, 126, 34, 0.68);
    background:
        linear-gradient(to right, rgba(230, 126, 34, 0.98), rgba(241, 170, 82, 0.90)) left bottom / var(--time-progress) 6px no-repeat,
        linear-gradient(to right, rgba(240, 205, 170, 0.20), rgba(240, 205, 170, 0.20)) left bottom / 100% 6px no-repeat,
        linear-gradient(170deg, rgba(25, 11, 4, 0.88) 0%, rgba(10, 6, 3, 0.92) 100%);
    box-shadow:
        inset 0 1px 0 rgba(230, 126, 34, 0.24),
        0 0 14px rgba(230, 126, 34, 0.18);
}

.hud-timebox.timer-paused {
    border-color: rgba(230, 220, 205, 0.30);
    background:
        linear-gradient(to right, rgba(180, 176, 166, 0.70), rgba(220, 214, 200, 0.64)) left bottom / var(--time-progress) 6px no-repeat,
        linear-gradient(to right, rgba(240, 237, 232, 0.12), rgba(240, 237, 232, 0.12)) left bottom / 100% 6px no-repeat,
        linear-gradient(170deg, rgba(25, 24, 22, 0.88) 0%, rgba(11, 10, 9, 0.92) 100%);
}

.hud-timer {
    position: relative;
    z-index: 1;
    font-family: 'Noto Serif', serif;
    font-size: 1.08rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.7px;
    color: rgba(240, 237, 232, 0.35);
    min-width: 0;
    text-align: center;
    line-height: 1;
    text-shadow:
        0 0 12px rgba(0, 0, 0, 0.70),
        0 0 6px rgba(240, 237, 232, 0.14);
    transition: color 0.3s ease, text-shadow 0.3s ease, transform 0.2s ease;
}

.hud-timer.timer-active {
    color: var(--text-main);
    text-shadow: 0 0 10px rgba(240, 237, 232, 0.14);
}

.hud-timer.timer-urgent {
    color: #E67E22;
    text-shadow: 0 0 14px rgba(230, 126, 34, 0.48);
    animation: hud-timer-pulse 0.75s ease infinite alternate;
}

.hud-timer.timer-paused {
    color: rgba(240, 237, 232, 0.68);
    text-shadow: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   NETWORK STATUS TOAST  (bottom — minimal pill)
   ═══════════════════════════════════════════════════════════════════════════ */

.net-toast {
    --net-bg: rgba(245, 239, 227, 0.96);
    --net-border: rgba(189, 165, 122, 0.54);
    --net-text: rgba(49, 35, 17, 0.96);
    --net-glow: rgba(197, 160, 89, 0.18);
    position: fixed;
    left: 50%;
    bottom: max(6px, env(safe-area-inset-bottom));
    z-index: 2600;
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(640px, calc(100vw - 12px));
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--net-border);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.16) 42%, rgba(219, 206, 179, 0.24)),
        var(--net-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: var(--net-text);
    box-shadow:
        inset 0 1px 0 rgba(247, 236, 208, 0.12),
        0 6px 24px rgba(0, 0, 0, 0.48),
        0 0 16px var(--net-glow);
    transform: translate(-50%, calc(100% + 20px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease;
    font-family: 'Inter', sans-serif;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.net-toast.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.net-toast-icon {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    flex: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    line-height: 1;
    font-weight: 900;
    border: 1px solid rgba(112, 92, 58, 0.32);
    background: rgba(255, 255, 255, 0.62);
    color: rgba(51, 38, 19, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.70);
}

.net-toast-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.1;
}

.net-toast-success .net-toast-icon {
    border-color: rgba(86, 138, 99, 0.45);
    background: rgba(160, 208, 170, 0.34);
    color: rgba(29, 88, 44, 0.95);
}

.net-toast-warn .net-toast-icon {
    border-color: rgba(171, 132, 59, 0.44);
    background: rgba(233, 192, 116, 0.34);
    color: rgba(133, 89, 20, 0.95);
}

.net-toast-error .net-toast-icon {
    border-color: rgba(168, 84, 79, 0.44);
    background: rgba(226, 133, 125, 0.34);
    color: rgba(125, 40, 34, 0.95);
}

/* ═══════════════════════════════════════════════════════════════════════════
   GAME / INFO TOAST  (top — rich card)
   ═══════════════════════════════════════════════════════════════════════════ */

.game-toast {
    --game-toast-bg: rgba(24, 13, 6, 0.96);
    --game-toast-border: rgba(224, 186, 115, 0.46);
    --game-toast-text: #f5e8cb;
    --game-toast-sub: rgba(240, 231, 210, 0.82);
    --game-toast-glow: rgba(197, 160, 89, 0.22);
    position: fixed;
    left: 50%;
    top: max(18px, env(safe-area-inset-top));
    z-index: 2600;
    width: min(960px, 90vw);
    min-height: 58px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 8px;
    border: 1px solid var(--game-toast-border);
    background:
        linear-gradient(180deg, rgba(248, 237, 209, 0.17), rgba(248, 237, 209, 0.03) 42%, rgba(0, 0, 0, 0.26)),
        var(--game-toast-bg);
    color: var(--game-toast-text);
    box-shadow:
        0 10px 32px rgba(0, 0, 0, 0.34),
        inset 0 1px 0 rgba(248, 237, 209, 0.16),
        0 0 18px var(--game-toast-glow);
    transform: translate(-50%, calc(-100% - 22px));
    opacity: 0;
    pointer-events: none;
    transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.20s ease;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.game-toast.is-visible {
    transform: translate(-50%, 0);
    opacity: 1;
}

.game-toast-icon {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: rgba(248, 237, 209, 0.12);
    border: 1px solid rgba(224, 186, 115, 0.24);
    color: #e4b65d;
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    font-weight: 900;
    box-shadow: inset 0 1px 0 rgba(248, 237, 209, 0.16);
}

.game-toast-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.game-toast-title {
    font-family: 'Noto Serif', serif;
    font-size: clamp(0.86rem, 0.66rem + 0.55vw, 0.98rem);
    font-weight: 900;
    line-height: 1.15;
    color: var(--game-toast-text);
    letter-spacing: 0.03em;
}

.game-toast-detail {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.70rem, 0.54rem + 0.35vw, 0.78rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--game-toast-sub);
    letter-spacing: 0.01em;
}

.game-toast-success .game-toast-icon {
    background: rgba(100, 174, 114, 0.18);
    border-color: rgba(127, 198, 139, 0.34);
    color: #c3f0cb;
}

.game-toast-warn .game-toast-icon {
    background: rgba(201, 136, 55, 0.18);
    border-color: rgba(227, 166, 87, 0.34);
    color: #ffe4b1;
}

.game-toast-error .game-toast-icon {
    background: rgba(177, 74, 68, 0.20);
    border-color: rgba(219, 112, 105, 0.38);
    color: #ffd2cf;
}

@keyframes hud-timer-pulse {
    from { opacity: 1; }
    to   { opacity: 0.50; }
}

@media (max-width: 599px) {
    .game-hud-strip {
        height: 80px;
        padding: 8px 9px;
        gap: 8px;
    }

    .game-hud-strip > .avatar-disc-sm {
        width: 56px;
        height: 56px;
        margin-left: 1px;
    }

    .hud-captures {
        --cap-size: 36px;
        gap: 1px;
    }

    .hud-captures.cap-density-medium { --cap-size: 34px; }
    .hud-captures.cap-density-high   { --cap-size: 31px; }
    .hud-captures.cap-density-max    { --cap-size: 29px; }

    .hud-cap-count {
        min-width: 14px;
        height: 14px;
        padding: 0 3px;
        font-size: 0.50rem;
    }

    .hud-right {
        width: 122px;
        min-width: 122px;
    }

    .hud-notice {
        height: 22px;
        padding: 3px 6px;
        /* font-size and letter-spacing handled by clamp() above */
    }

    .hud-timebox {
        height: 38px;
        padding: 6px 8px 10px;
        background:
            linear-gradient(to right, rgba(197, 160, 89, 0.95), rgba(224, 186, 115, 0.88)) left bottom / var(--time-progress) 5px no-repeat,
            linear-gradient(to right, rgba(240, 237, 232, 0.13), rgba(240, 237, 232, 0.13)) left bottom / 100% 5px no-repeat,
            linear-gradient(170deg, rgba(21, 11, 5, 0.86) 0%, rgba(10, 6, 3, 0.92) 100%);
    }

    .hud-timebox.timer-urgent {
        background:
            linear-gradient(to right, rgba(230, 126, 34, 0.98), rgba(241, 170, 82, 0.90)) left bottom / var(--time-progress) 5px no-repeat,
            linear-gradient(to right, rgba(240, 205, 170, 0.20), rgba(240, 205, 170, 0.20)) left bottom / 100% 5px no-repeat,
            linear-gradient(170deg, rgba(25, 11, 4, 0.88) 0%, rgba(10, 6, 3, 0.92) 100%);
    }

    .hud-timer {
        font-size: 0.96rem;
        letter-spacing: 0.5px;
    }

    #hudOpponent.hud-coach-mode .hud-coach-panel {
        gap: 6px;
    }

    .hud-coach-copy {
        padding: 6px 8px;
    }
}

/* No narrow-phone override needed — icon width is fixed at 30px. */
