/* ============================================================
   GAME LAYOUT
   ============================================================ */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: radial-gradient(circle at 50% 50%, #151525 0%, #06060c 100%);
    position: relative;
    z-index: 2;
    overflow: hidden;
    justify-content: space-between;
}

/* Lock board interaction during modals */
.game-container.board-locked {
    pointer-events: none;
    user-select: none;
}

/* TOP: Opponent Hand & Stats Bar */
.game-header {
    height: 90px;
    background: rgba(10, 10, 18, 0.7);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 215, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0 20px;
}

.players-roster {
    display: flex;
    gap: 16px;
    width: 100%;
    justify-content: center;
    align-items: center;
    overflow-x: auto;
    padding: 5px 0;
}

/* Roster Cards (Player plates at the top) */
.roster-card {
    background: rgba(20, 20, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 5;
}

.roster-card.active-turn {
    border-color: var(--gold);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
    background: rgba(255, 215, 0, 0.04);
    transform: translateY(-2px);
}

.roster-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.roster-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.roster-name {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: white;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.roster-stats {
    display: flex;
    gap: 10px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    color: var(--text-dim);
}

.roster-stats div {
    white-space: nowrap;
}

.stat-val {
    color: var(--gold-light);
    font-size: 0.85rem;
}

.stat-val.danger {
    color: var(--red);
}

/* Roster Hand (Opponent cards back container) */
.roster-hand {
    display: flex;
    align-items: center;
    margin-left: 10px;
    position: relative;
    height: 24px;
    padding-right: 25px;
    /* space for badge */
}

.mini-card-back {
    width: 14px;
    height: 20px;
    background: linear-gradient(135deg, #a6750c 0%, #e5a91e 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    margin-left: -8px;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.mini-card-back:first-child {
    margin-left: 0;
}

.mini-card-back:hover {
    transform: translateY(-4px) scale(1.1);
    z-index: 10;
}

.hand-count-badge {
    position: absolute;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: var(--gold-light);
    border: 1px solid var(--gold);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 0.65rem;
    font-family: 'Orbitron', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* CENTER: The Game Table */
.game-table {
    flex: 1;
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    height: calc(100vh - 320px);
    position: relative;
    z-index: 5;
    padding: 10px 20px;
    gap: 20px;
    align-items: stretch;
}

.table-side-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    z-index: 10;
    padding-top: 10px;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

.table-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    position: relative;
}

/* Board Area */
.board-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.empire-triangle {
    width: 100%;
    max-width: 800px;
}

/* Enlarge board segments for larger space */
.empire-triangle .level-1 .segment {
    width: 90px;
    height: 70px;
    font-size: 0.65rem;
}

.empire-triangle .level-2 .segment {
    width: 100px;
    height: 80px;
    font-size: 0.65rem;
}

.empire-triangle .level-3 .segment {
    width: 110px;
    height: 90px;
    font-size: 0.65rem;
}

.empire-triangle .level-4 .segment {
    width: 180px;
    height: 100px;
    font-size: 0.8rem;
}

.empire-triangle .triangle-level {
    gap: 6px;
    margin-bottom: 6px;
}

.segment {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    border-width: 2px;
    touch-action: manipulation;
    /* Prevent tap delay on mobile */
}

.segment.claimed {
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    opacity: 0.9;
}

.segment-owner {
    font-size: 0.6rem;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 4px;
}



/* Action Log widget */
.action-log-wrap {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    background: rgba(10, 10, 18, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(5px);
    overflow: hidden;
}

.log-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 0.2em;
    margin-bottom: 12px;
}

.action-log {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.9rem;
    display: block;
}

/* Custom Scrollbar for Action Log */
.action-log::-webkit-scrollbar {
    width: 6px;
}

.action-log::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.action-log::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.25);
    border-radius: 3px;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.action-log::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.45);
}

.log-entry {
    color: #ccc;
    animation: fadeIn 0.3s;
    margin-bottom: 8px;
}

.log-entry strong {
    color: white;
}

.commands-panel {
    background: rgba(10, 10, 18, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(5px);
    overflow-y: auto;
}

/* Custom Scrollbar for Commands Panel */
.commands-panel::-webkit-scrollbar {
    width: 6px;
}

.commands-panel::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 3px;
}

.commands-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.25);
    border-radius: 3px;
    border: 1px solid rgba(255, 215, 0, 0.1);
}

.commands-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.45);
}

.current-turn-indicator {
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid var(--border2);
    padding: 12px;
    border-radius: 6px;
    text-align: center;
    font-family: 'Rajdhani', sans-serif;
    color: var(--gold);
    margin-bottom: 15px;
}

.current-turn-indicator span {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    margin-top: 4px;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.action-btn {
    background: rgba(20, 20, 30, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 12px;
    border-radius: 6px;
    font-family: 'Orbitron', monospace;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.action-btn:hover:not(:disabled) {
    border-color: white;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.end-turn-btn {
    background: rgba(255, 45, 45, 0.1);
    border-color: var(--red-glow);
    color: var(--red-glow);
    font-weight: 700;
}

.end-turn-btn:hover:not(:disabled) {
    background: rgba(255, 45, 45, 0.25) !important;
    border-color: var(--red-glow) !important;
}

/* BOTTOM: Player Hand Zone */
.game-footer {
    height: 230px;
    background: linear-gradient(0deg, rgba(10, 10, 18, 0.95) 0%, rgba(10, 10, 18, 0.5) 100%);
    border-top: 1px solid rgba(255, 215, 0, 0.08);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 15px;
    position: relative;
    z-index: 20;
    box-sizing: border-box;
}

.hand-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.hand-header {
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    color: var(--text-dim);
    letter-spacing: 0.25em;
    margin-bottom: 10px;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.player-hand {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    height: 160px;
    position: relative;
    width: 100%;
}

/* PREMIUM REDESIGNED GAME CARD */
.game-card {
    width: 130px;
    height: 180px;
    background: linear-gradient(135deg, #161622 0%, #0d0d12 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
    position: absolute;
    bottom: 0;
    transform: translate(var(--card-x, 0px), var(--card-y, 0px)) rotate(var(--card-angle, 0deg));
    transform-origin: bottom center;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease, border-color 0.3s ease;
    user-select: none;
    box-sizing: border-box;
    touch-action: manipulation;
    /* Prevent 300ms tap delay on mobile */
}

.game-card .card-cost {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.75rem;
    background: #12121c;
    color: var(--gold-light);
    border: 1px solid var(--gold);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    z-index: 5;
}

.game-card .card-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    line-height: 1.1;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-top: 4px;
    text-align: center;
    word-wrap: break-word;
}

.game-card .card-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.3;
    text-align: center;
    margin-top: 6px;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-card .card-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.game-card:hover,
.game-card.active {
    transform: translate(var(--card-x, 0px), calc(var(--card-y, 0px) - 10px)) rotate(var(--card-angle, 0deg)) scale(1.05);
    z-index: 9500 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.game-card:hover .card-actions,
.game-card.active .card-actions {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Card design modifiers based on type */
.game-card.card-attack {
    border-color: rgba(255, 45, 45, 0.3);
    background: linear-gradient(135deg, #221212 0%, #0d0606 100%);
}

.game-card.card-attack:hover,
.game-card.card-attack.active {
    border-color: var(--red-glow);
    box-shadow: 0 15px 30px rgba(255, 45, 45, 0.35), 0 0 20px rgba(255, 45, 45, 0.25);
}

.game-card.card-defence {
    border-color: rgba(0, 255, 136, 0.3);
    background: linear-gradient(135deg, #122218 0%, #060d09 100%);
}

.game-card.card-defence:hover,
.game-card.card-defence.active {
    border-color: #00FF88;
    box-shadow: 0 15px 30px rgba(0, 255, 136, 0.35), 0 0 20px rgba(0, 255, 136, 0.25);
}

.game-card.card-claim-l1 {
    border-color: rgba(0, 170, 255, 0.3);
    background: linear-gradient(135deg, #121a2c 0%, #06090f 100%);
}

.game-card.card-claim-l1:hover,
.game-card.card-claim-l1.active {
    border-color: var(--blue-glow);
    box-shadow: 0 15px 30px rgba(0, 170, 255, 0.35), 0 0 20px rgba(0, 170, 255, 0.25);
}

.game-card.card-claim-l2 {
    border-color: rgba(255, 204, 0, 0.3);
    background: linear-gradient(135deg, #241e12 0%, #0f0c07 100%);
}

.game-card.card-claim-l2:hover,
.game-card.card-claim-l2.active {
    border-color: var(--yellow);
    box-shadow: 0 15px 30px rgba(255, 204, 0, 0.35), 0 0 20px rgba(255, 204, 0, 0.25);
}

.game-card.card-claim-l3 {
    border-color: rgba(255, 45, 45, 0.3);
    background: linear-gradient(135deg, #241212 0%, #0f0707 100%);
}

.game-card.card-claim-l3:hover,
.game-card.card-claim-l3.active {
    border-color: var(--red-glow);
    box-shadow: 0 15px 30px rgba(255, 45, 45, 0.35), 0 0 20px rgba(255, 45, 45, 0.25);
}

.game-card.card-claim-l4 {
    border-color: rgba(255, 215, 0, 0.4);
    background: linear-gradient(135deg, #2a1f0a 0%, #120d04 100%);
}

.game-card.card-claim-l4:hover,
.game-card.card-claim-l4.active {
    border-color: var(--gold);
    box-shadow: 0 15px 30px rgba(255, 215, 0, 0.45), 0 0 25px rgba(255, 215, 0, 0.3);
}

/* Card Selection state */
.game-card.selected-card {
    border-color: var(--gold) !important;
    box-shadow: 0 0 25px var(--gold) !important;
    transform: rotate(var(--card-angle, 0deg)) translate(var(--card-x, 0px), calc(var(--card-y, 0px) - 30px)) scale(1.08) !important;
    z-index: 50 !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Animation Classes */
.game-card.draw-animation {
    animation: drawCardEffect 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes drawCardEffect {
    from {
        transform: translate(0, -50vh) scale(0.2) rotate(-20deg);
        opacity: 0;
    }

    to {
        transform: rotate(var(--card-angle, 0deg)) translate(var(--card-x, 0px), var(--card-y, 0px)) scale(1);
        opacity: 1;
    }
}

.game-card.play-animation {
    transform: translate(0, -35vh) scale(1.2) rotate(0deg) !important;
    opacity: 0;
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s ease;
}

.game-card.waste-animation {
    transform: translate(0, -35vh) scale(0.8) rotate(45deg) !important;
    opacity: 0;
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s ease;
}

/* Turn Transition Overlay */
.turn-transition-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 4, 10, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    backdrop-filter: blur(8px);
}

.turn-transition-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.turn-transition-content {
    background: rgba(15, 15, 25, 0.9);
    border: 2px solid var(--border2);
    border-radius: 12px;
    padding: 30px 60px;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.turn-transition-overlay.visible .turn-transition-content {
    transform: scale(1);
}

.turn-transition-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 2.2rem;
    font-weight: bold;
    margin-bottom: 8px;
    letter-spacing: 0.1em;
}

.turn-transition-subtitle {
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

/* ============================================================
   MOBILE LANDSCAPE — complete responsive overhaul
   Target: phones in landscape (max-width 1024px)
   ============================================================ */
@media (max-width: 1024px) and (orientation: landscape) {

    /* ── Header ── */
    .game-header {
        height: 44px;
        padding: 0 8px;
        flex-shrink: 0;
    }

    .players-roster {
        gap: 6px;
        padding: 2px 0;
    }

    .roster-card {
        padding: 3px 7px;
        gap: 5px;
        border-radius: 4px;
    }

    .roster-name {
        font-size: 0.7rem;
        max-width: 55px;
    }

    .roster-stats {
        font-size: 0.6rem;
        gap: 5px;
    }

    .roster-hand {
        margin-left: 3px;
        height: 14px;
        padding-right: 15px;
    }

    .mini-card-back {
        width: 8px;
        height: 12px;
        margin-left: -5px;
    }

    .hand-count-badge {
        width: 11px;
        height: 11px;
        font-size: 0.45rem;
    }

    /* ── Game Table (3-column grid: chronicle | board | commands) ── */
    .game-table {
        grid-template-columns: 130px 1fr 130px;
        /* Let game-table grow taller than the viewport so board is fully scrollable */
        height: calc(100vh - 44px - 125px);
        padding: 4px 6px;
        gap: 6px;
        flex-shrink: 0;
        /* Allow the center column to be scrolled, side panels stay fixed */
        overflow: visible;
    }

    .table-side-panel {
        padding-top: 0;
        overflow: hidden;
        /* Keep side panels anchored — they don't scroll */
        position: sticky;
        top: 0;
        align-self: start;
        max-height: calc(100vh - 44px - 125px);
    }

    /* ── Chronicle (left panel) ── */
    .action-log-wrap {
        height: 100%;
        padding: 6px;
    }

    .log-title {
        font-size: 0.5rem;
        margin-bottom: 3px;
        letter-spacing: 0.1em;
    }

    .action-log {
        font-size: 0.65rem;
    }

    /* ── Commands panel (right panel) ── */
    .commands-panel {
        padding: 6px;
    }

    .sidebar-title {
        font-size: 0.6rem;
        margin-bottom: 5px;
        padding-bottom: 3px;
    }

    .current-turn-indicator {
        padding: 5px;
        margin-bottom: 6px;
        font-size: 0.6rem;
    }

    .current-turn-indicator span {
        font-size: 0.8rem;
        margin-top: 2px;
    }

    .action-buttons {
        gap: 5px;
    }

    .action-btn {
        padding: 7px 6px;
        font-size: 0.58rem;
        border-radius: 4px;
        letter-spacing: 0.05em;
        touch-action: manipulation;
    }

    /* ── Board area (center column) — scrollable ── */
    .table-center {
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        /* Smooth momentum scrolling on iOS */
        /* Give enough height so the full board + deck zone fits */
        max-height: calc(100vh - 44px - 125px);
        scroll-behavior: smooth;
    }

    .board-area {
        flex: none;
        /* Don't stretch — let board be its natural size */
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 4px 0 8px;
    }

    .empire-triangle {
        transform: none;
        width: 100%;
        max-width: 360px;
        margin: 0 auto;
    }

    /* Compact board segments */
    .empire-triangle .level-1 .segment {
        width: 46px;
        height: 36px;
    }

    .empire-triangle .level-2 .segment {
        width: 56px;
        height: 42px;
    }

    .empire-triangle .level-3 .segment {
        width: 66px;
        height: 48px;
    }

    .empire-triangle .level-4 .segment {
        width: 130px;
        height: 54px;
    }

    .empire-triangle .segment div {
        font-size: 0.42rem !important;
        line-height: 1;
    }

    .empire-triangle .segment.claimed .segment-owner {
        font-size: 0.35rem;
        padding: 0 2px;
        margin-top: 1px;
    }

    .empire-triangle .triangle-level {
        gap: 3px;
        margin-bottom: 3px;
    }

    /* ── Deck zone ── */
    .table-cards-zone {
        gap: 10px;
        margin-top: 4px;
    }

    .deck-pile,
    .active-card-slot,
    .discard-pile {
        width: 62px;
        height: 84px;
        border-radius: 4px;
    }

    .deck-label {
        font-size: 0.48rem;
    }

    .active-card-slot span,
    .discard-pile span {
        font-size: 0.44rem;
    }

    /* ── Footer / Player Hand ── */
    .game-footer {
        height: 125px;
        padding-bottom: 4px;
        flex-shrink: 0;
    }

    .hand-header {
        font-size: 0.5rem;
        margin-bottom: 3px;
    }

    .player-hand {
        height: 90px;
    }

    /* ── Cards in hand ── */
    .game-card {
        width: 75px;
        height: 98px;
        padding: 6px;
        border-radius: 5px;
    }

    .game-card .card-cost {
        width: 15px;
        height: 15px;
        font-size: 0.48rem;
        top: -4px;
        right: -4px;
    }

    .game-card .card-title {
        font-size: 0.55rem;
    }

    .game-card .card-desc {
        font-size: 0.48rem;
        line-height: 1.1;
        margin-top: 2px;
    }

    .game-card .card-actions {
        margin-top: 3px;
        gap: 3px;
    }

    /* Tappable buttons */
    .game-card .card-actions button {
        font-size: 0.52rem !important;
        padding: 4px 2px !important;
        min-height: 20px;
        border-radius: 3px !important;
        touch-action: manipulation;
    }

    /* Hover & active tap state */
    .game-card:hover,
    .game-card.active {
        transform: translate(var(--card-x, 0px), calc(var(--card-y, 0px) - 12px)) rotate(var(--card-angle, 0deg)) scale(1.08);
        z-index: 9500 !important;
    }

    .game-card.active .card-actions {
        opacity: 1 !important;
        pointer-events: auto !important;
    }
}

/* ── Rotate Overlay (shown in portrait) ── */
.rotate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 99999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.rotate-icon {
    margin-bottom: 24px;
    animation: rotatePhone 2s infinite ease-in-out;
}

@keyframes rotatePhone {
    0% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(90deg);
    }

    100% {
        transform: rotate(90deg);
    }
}

/* Portrait Mobile: show rotate prompt, hide game */
@media (max-width: 1024px) and (orientation: portrait) {
    .game-container {
        display: none !important;
    }

    .rotate-overlay {
        display: flex;
    }
}

/* --- SEGMENT HIGHLIGHTING --- */
.board-dimmed .segment {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(80%);
}

.board-dimmed .segment.highlight-active {
    opacity: 1;
    pointer-events: auto;
    filter: grayscale(0%);
    animation: glowPulse 1.5s infinite;
}

@keyframes glowPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

.segment.highlight-active[data-level="1"] {
    box-shadow: 0 0 30px var(--blue-glow);
    border-color: var(--blue-glow);
    z-index: 10;
}

.segment.highlight-active[data-level="2"] {
    box-shadow: 0 0 30px var(--yellow);
    border-color: var(--yellow);
    z-index: 10;
}

.segment.highlight-active[data-level="3"] {
    box-shadow: 0 0 30px var(--red-glow);
    border-color: var(--red-glow);
    z-index: 10;
}

.segment.highlight-active[data-level="4"] {
    box-shadow: 0 0 40px var(--gold);
    border-color: var(--gold);
    z-index: 10;
}

/* --- ATTACK & DEFENSE OVERLAY --- */
.attack-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: none;
    /* Flex when active */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

.attack-overlay.flash-win {
    animation: flashGold 1s ease-out;
}

.attack-overlay.flash-lose {
    animation: flashRed 1s ease-out;
}

@keyframes flashGold {
    0% {
        background: rgba(255, 215, 0, 0.8);
    }

    100% {
        background: rgba(0, 0, 0, 0.85);
    }
}

@keyframes flashRed {
    0% {
        background: rgba(255, 45, 45, 0.8);
    }

    100% {
        background: rgba(0, 0, 0, 0.85);
    }
}

.timer-ring-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin-bottom: 30px;
}

.timer-ring-svg {
    transform: rotate(-90deg);
}

.timer-ring-circle {
    fill: transparent;
    stroke: #00FF88;
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 440;
    /* 2 * PI * 70 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 1s linear;
}

.timer-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
}

.pulsing-text {
    animation: textPulse 1.5s infinite;
    font-family: 'Cinzel Decorative', serif;
    font-size: 2rem;
    color: var(--gold);
    text-align: center;
    margin-bottom: 10px;
}

@keyframes textPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.95);
    }
}

.defense-cards-container {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 800px;
}

.defense-card-option {
    background: #1a1a24;
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    text-align: center;
    width: 160px;
}

.defense-card-option.valid-defense {
    border-color: var(--gold);
}

.defense-card-option.valid-defense:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 15px var(--gold);
}

.defense-card-option.invalid-defense {
    opacity: 0.5;
    pointer-events: none;
    border-color: var(--red);
}

.attack-details {
    text-align: center;
    margin-bottom: 20px;
    background: rgba(255, 45, 45, 0.1);
    padding: 15px 30px;
    border-radius: 10px;
    border: 1px solid var(--red-glow);
}

.attack-details h3 {
    color: var(--red-glow);
    font-family: 'Orbitron', monospace;
    margin-bottom: 5px;
}

.attack-details p {
    font-size: 1.2rem;
}

/* --- SPLIT SCREEN BIDDING --- */
.split-bid-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    /* Flex when active */
    background: #000;
}

.split-half {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 40px;
    transition: opacity 0.5s, filter 0.5s;
}

.split-left {
    background: linear-gradient(135deg, rgba(30, 30, 40, 1) 0%, rgba(10, 10, 15, 1) 100%);
}

.split-right {
    background: linear-gradient(-135deg, rgba(30, 30, 40, 1) 0%, rgba(10, 10, 15, 1) 100%);
}

.lightning-divider {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.5s ease;
    background: #fff;
    box-shadow: 0 0 15px 5px var(--blue-glow), 0 0 30px var(--blue);
    animation: crackle 0.1s infinite;
}

@keyframes crackle {
    0% {
        opacity: 1;
        transform: translateX(-50%) scaleX(1);
    }

    25% {
        opacity: 0.8;
        transform: translateX(calc(-50% - 2px)) scaleX(1.2);
    }

    50% {
        opacity: 1;
        transform: translateX(calc(-50% + 2px)) scaleX(0.8);
    }

    75% {
        opacity: 0.9;
        transform: translateX(calc(-50% - 1px)) scaleX(1.5);
    }

    100% {
        opacity: 1;
        transform: translateX(calc(-50% + 1px)) scaleX(1);
    }
}

.bid-player-info {
    text-align: center;
    margin-bottom: 30px;
}

.bid-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 15px;
    border: 3px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.bid-name {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    font-weight: bold;
}

.bid-tokens-live {
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    color: var(--gold);
    margin-top: 10px;
}

.bid-tokens-live.danger {
    color: var(--red);
}

.bid-input-box {
    margin-bottom: 20px;
    text-align: center;
}

.bid-amount-display {
    font-size: 3rem;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    margin: 20px 0;
    min-height: 60px;
}

.bid-controls-btn {
    padding: 10px 20px;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    cursor: pointer;
    border-radius: 5px;
    margin: 0 5px;
}

.bid-controls-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

.confirm-bid-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid #00FF88;
    color: #00FF88;
    cursor: pointer;
    border-radius: 5px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: bold;
}

.confirm-bid-btn.confirmed {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--gold);
    color: var(--gold);
}

/* Card flip animation */
.bid-card-flip-container {
    perspective: 1000px;
    width: 120px;
    height: 160px;
    margin: 0 auto;
}

.bid-card-flipper {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.bid-card-flipper.flipped {
    transform: rotateY(180deg);
}

.bid-card-front,
.bid-card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--gold);
}

.bid-card-front {
    background: repeating-linear-gradient(45deg, #111, #111 10px, #222 10px, #222 20px);
}

.bid-card-back {
    background: #1a1a24;
    transform: rotateY(180deg);
    font-size: 3rem;
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    color: var(--gold);
}

.bid-winner-glow .bid-avatar {
    box-shadow: 0 0 30px #00FF88;
    border-color: #00FF88 !important;
}

.bid-loser-glow .bid-avatar {
    box-shadow: 0 0 30px var(--red-glow);
    border-color: var(--red-glow) !important;
}

.bid-loser-half {
    filter: grayscale(80%) brightness(0.6);
}

.bid-segment-info {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 30px;
    border-radius: 10px;
    border: 1px solid var(--gold);
    color: white;
}

.bid-result-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 30;
    font-family: 'Cinzel Decorative', serif;
    font-size: 3.5rem;
    font-weight: 900;
    text-shadow: 0 0 20px #000;
    display: none;
    text-align: center;
    width: 100%;
    pointer-events: none;
}

.bid-result-text.win {
    color: #00FF88;
}

.bid-result-text.defended {
    color: var(--gold);
}

.bid-continue-btn {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    padding: 15px 40px;
    font-size: 1.2rem;
    background: var(--gold);
    color: black;
    border: none;
    cursor: pointer;
    border-radius: 5px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: bold;
    display: none;
}

/* ============================================================
   DEFENSE SELECTION MODAL
   ============================================================ */
.defense-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(16px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.defense-modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.defense-modal-inner {
    background: linear-gradient(145deg, #0d0d1a, #1a0a0a);
    border: 1px solid rgba(255, 45, 45, 0.5);
    border-radius: 20px;
    padding: 36px;
    max-width: 860px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    box-shadow: 0 0 60px rgba(255, 45, 45, 0.25);
    transform: scale(0.92) translateY(20px);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.defense-modal-overlay.visible .defense-modal-inner {
    transform: scale(1) translateY(0);
}

.defense-modal-attacker-banner {
    width: 100%;
    background: rgba(255, 45, 45, 0.12);
    border: 1px solid rgba(255, 45, 45, 0.4);
    border-radius: 10px;
    padding: 14px 24px;
    text-align: center;
}

.dmod-attacker-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    color: var(--red-glow);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.dmod-attacker-name {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: white;
}

.defense-modal-attack-card {
    background: rgba(255, 45, 45, 0.08);
    border: 1px solid rgba(255, 45, 45, 0.35);
    border-radius: 12px;
    padding: 16px 28px;
    text-align: center;
    width: 100%;
    max-width: 420px;
}

.dmod-attack-card-name {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--red-glow);
    letter-spacing: 0.1em;
    margin-bottom: 4px;
}

.dmod-attack-card-power {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.dmod-attack-card-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1.4;
}

.defense-modal-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 1.5rem;
    color: var(--gold);
    text-align: center;
    margin: 0;
}

.defense-modal-subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    color: var(--text-dim);
    text-align: center;
    margin: 0;
}

.defense-modal-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    width: 100%;
}

.dmod-card-option {
    background: linear-gradient(145deg, #111120, #1a1a2e);
    border: 2px solid rgba(0, 200, 130, 0.5);
    border-radius: 12px;
    padding: 18px 16px;
    width: 160px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.dmod-card-option:hover {
    transform: translateY(-6px) scale(1.03);
    box-shadow: 0 12px 30px rgba(0, 255, 136, 0.3);
    border-color: rgba(0, 255, 136, 0.9);
}

.dmod-card-shield {
    font-size: 2rem;
    margin-bottom: 8px;
}

.dmod-card-name {
    font-family: 'Orbitron', monospace;
    font-size: 0.62rem;
    color: #00FF88;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.dmod-card-power-badge {
    font-family: 'Orbitron', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    background: rgba(0, 255, 136, 0.15);
    border-radius: 8px;
    padding: 4px 12px;
    display: inline-block;
    margin-bottom: 6px;
}

.dmod-card-desc {
    font-size: 0.7rem;
    color: var(--text-dim);
    line-height: 1.3;
}

.dmod-no-defense {
    text-align: center;
    padding: 24px;
    color: var(--text-dim);
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.1rem;
}

.dmod-no-defense .dmod-no-def-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

.defense-modal-skip-btn {
    background: rgba(255, 45, 45, 0.12);
    border: 1px solid rgba(255, 45, 45, 0.45);
    color: var(--red-glow);
    padding: 14px 32px;
    border-radius: 8px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: background 0.2s, box-shadow 0.2s;
    margin-top: 4px;
}

.defense-modal-skip-btn:hover {
    background: rgba(255, 45, 45, 0.28);
    box-shadow: 0 0 16px rgba(255, 45, 45, 0.3);
}

/* ============================================================
   BID WAR ENHANCEMENTS
   ============================================================ */
.bid-top-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: rgba(0, 0, 0, 0.88);
    border-bottom: 1px solid rgba(255, 215, 0, 0.3);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.bid-war-label {
    font-family: 'Orbitron', monospace;
    font-size: 0.72rem;
    color: var(--gold);
    letter-spacing: 0.25em;
    white-space: nowrap;
}

.bid-segment-info-inline {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bid-seg-divider {
    color: var(--text-dim);
}

.bid-highest-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', monospace;
}

.bid-highest-label {
    font-size: 0.62rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
}

.bid-highest-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--gold);
}

.bid-highest-value.bump {
    animation: valueBump 0.4s ease;
}

@keyframes valueBump {
    0% {
        transform: scale(1)
    }

    50% {
        transform: scale(1.4);
        color: #00FF88
    }

    100% {
        transform: scale(1)
    }
}

.bid-highest-leader {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    color: #aaa;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bid-timer-ring-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.bid-timer-svg {
    position: absolute;
    inset: 0;
    transform: rotate(-90deg);
}

.bid-timer-track {
    fill: transparent;
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 5;
}

.bid-timer-fill {
    fill: transparent;
    stroke: #00FF88;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 213.6;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
}

.bid-timer-fill.urgent {
    stroke: var(--red-glow);
    animation: timerUrgentPulse 0.5s infinite alternate;
}

@keyframes timerUrgentPulse {
    from {
        opacity: 1
    }

    to {
        opacity: 0.35
    }
}

.bid-timer-num {
    font-family: 'Orbitron', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    z-index: 1;
    position: relative;
}

.bid-active-indicator {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 255, 136, 0.15);
    border: 1px solid #00FF88;
    color: #00FF88;
    font-family: 'Orbitron', monospace;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    padding: 6px 16px;
    border-radius: 20px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
}

.bid-active-indicator.active {
    opacity: 1;
    animation: indicatorPulse 1.2s infinite;
}

@keyframes indicatorPulse {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(0, 255, 136, 0.35)
    }

    50% {
        box-shadow: 0 0 20px rgba(0, 255, 136, 0.75)
    }
}

.fold-bid-btn {
    margin-top: 10px;
    padding: 12px 30px;
    font-size: 0.95rem;
    background: rgba(255, 45, 45, 0.1);
    border: 1px solid var(--red-glow);
    color: var(--red-glow);
    cursor: pointer;
    border-radius: 5px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    letter-spacing: 0.08em;
    transition: background 0.2s, box-shadow 0.2s;
    display: block;
    width: 100%;
}

.fold-bid-btn:hover:not(:disabled) {
    background: rgba(255, 45, 45, 0.25);
    box-shadow: 0 0 15px rgba(255, 45, 45, 0.3);
}

.fold-bid-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.split-half.turn-inactive {
    filter: brightness(0.4) grayscale(40%);
    pointer-events: none;
}

.split-half {
    transition: filter 0.4s ease;
}

.split-left,
.split-right {
    padding-top: 100px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 340px;
}

.toast {
    background: rgba(12, 12, 22, 0.96);
    backdrop-filter: blur(12px);
    border-radius: 10px;
    padding: 14px 18px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    color: white;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    border-left: 4px solid var(--gold);
    animation: toastSlideIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.4;
}

.toast.toast-attack {
    border-color: var(--red-glow);
}

.toast.toast-defense {
    border-color: #00FF88;
}

.toast.toast-bid {
    border-color: var(--gold);
}

.toast.toast-win {
    border-color: #00FF88;
}

.toast.toast-info {
    border-color: var(--blue-glow);
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.toast-msg {
    color: #aaa;
    font-size: 0.85rem;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(120%);
        opacity: 0
    }

    to {
        transform: translateX(0);
        opacity: 1
    }
}

.toast.toast-exit {
    animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1
    }

    to {
        transform: translateX(120%);
        opacity: 0
    }
}

@media (max-width:1024px) and (orientation:landscape) {
    .defense-modal-inner {
        padding: 20px;
        gap: 14px;
    }

    .defense-modal-title {
        font-size: 1.1rem;
    }

    .dmod-card-option {
        width: 130px;
        padding: 14px 10px;
    }

    .bid-top-banner {
        padding: 8px 14px;
        gap: 10px;
    }

    .bid-highest-value {
        font-size: 1.1rem;
    }

    .split-left,
    .split-right {
        padding-top: 90px;
    }

    .bid-timer-ring-wrap {
        width: 60px;
        height: 60px;
    }

    .bid-timer-num {
        font-size: 0.9rem;
    }

    .bid-active-indicator {
        top: 72px;
        font-size: 0.55rem;
        padding: 5px 12px;
    }
}


/* ============================================================
   TIMER RING FIX � overrides previous declaration
   Positioned absolutely, centred on the divider, immune to crackle
   ============================================================ */
.bid-timer-ring-wrap {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90px !important;
    height: 90px !important;
    background: rgba(4, 4, 14, 0.97) !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: 2px solid rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.9), 0 0 0 3px rgba(0, 0, 0, 0.6) !important;
    z-index: 15 !important;
    animation: none !important;
}

/* SVG fills the wrap perfectly */
.bid-timer-svg {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    transform: rotate(-90deg) !important;
    animation: none !important;
}

/* Number centred over svg */
.bid-timer-num {
    position: relative !important;
    z-index: 2 !important;
    font-family: 'Orbitron', monospace !important;
    font-size: 1.15rem !important;
    font-weight: 700 !important;
    color: white !important;
    animation: none !important;
    user-select: none;
}

/* Keep crackle ONLY on the line itself, not its children */
.lightning-divider {
    display: block !important;
    /* not flex � timer is a sibling now */
    pointer-events: none !important;
}

/* Timer circumference: 2 * PI * 34 = 213.63 */
.bid-timer-fill {
    stroke-dasharray: 213.6 !important;
}

/* Mobile override for timer */
@media (max-width: 1024px) and (orientation: landscape) {
    .bid-timer-ring-wrap {
        width: 64px !important;
        height: 64px !important;
    }

    .bid-timer-num {
        font-size: 0.85rem !important;
    }
}

/* ============================================================
   CHRONICLE � info log entry style
   ============================================================ */
.log-entry:has(span[style*='blue-glow']) {
    border-left: 3px solid var(--blue-glow);
    padding-left: 8px;
    background: rgba(0, 170, 255, 0.05);
    border-radius: 0 4px 4px 0;
    margin-left: -8px;
}

/* ============================================================
   MOBILE RESPONSIVE FIXES � Bid War & Defense Modal
   Target: phones in landscape (= 768px height or = 850px width)
   ============================================================ */

/* --- PORTRAIT: force landscape rotation message --- */
@media (max-width: 768px) and (orientation: portrait) {
    .split-bid-overlay {
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: #000;
    }

    .split-bid-overlay .split-half,
    .split-bid-overlay .lightning-divider,
    .split-bid-overlay .bid-top-banner {
        display: none !important;
    }

    .split-bid-overlay::before {
        content: "? Rotate device to landscape to bid";
        font-family: 'Orbitron', monospace;
        font-size: 1rem;
        color: var(--gold);
        text-align: center;
        padding: 24px;
        letter-spacing: 0.1em;
    }
}

/* --- LANDSCAPE PHONE: small-screen bid war layout --- */
@media (max-width: 900px) and (orientation: landscape) {

    /* Make the overlay scroll if needed */
    .split-bid-overlay {
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Compress top banner into single tight row */
    .bid-top-banner {
        padding: 6px 10px !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }

    .bid-war-label {
        font-size: 0.55rem !important;
        letter-spacing: 0.12em !important;
        white-space: nowrap;
    }

    .bid-segment-info-inline {
        font-size: 0.72rem !important;
        gap: 4px !important;
    }

    .bid-highest-wrap {
        gap: 4px !important;
    }

    .bid-highest-label {
        font-size: 0.5rem !important;
    }

    .bid-highest-value {
        font-size: 0.95rem !important;
    }

    .bid-highest-leader {
        font-size: 0.7rem !important;
        max-width: 80px !important;
    }

    /* Shrink split halves padding drastically */
    .split-half {
        padding: 8px 10px !important;
        justify-content: flex-start !important;
    }

    /* Account for banner height (~44px on mobile) */
    .split-left,
    .split-right {
        padding-top: 52px !important;
    }

    /* Player info block: tighten */
    .bid-player-info {
        margin-bottom: 8px !important;
    }

    .bid-avatar {
        width: 44px !important;
        height: 44px !important;
        font-size: 1rem !important;
        margin-bottom: 6px !important;
    }

    .bid-name {
        font-size: 0.9rem !important;
    }

    .bid-tokens-live {
        font-size: 0.75rem !important;
        margin-top: 4px !important;
    }

    /* Shrink card flip area */
    .bid-card-flip-container {
        width: 64px !important;
        height: 86px !important;
        margin: 0 auto 6px !important;
    }

    .bid-card-back {
        font-size: 1.6rem !important;
    }

    /* Bid amount display */
    .bid-amount-display {
        font-size: 1.5rem !important;
        margin: 8px 0 !important;
        min-height: 36px !important;
    }

    /* Bid control buttons: compact */
    .bid-controls-btn {
        padding: 6px 10px !important;
        font-size: 0.85rem !important;
        margin: 0 2px !important;
    }

    /* Confirm & Fold buttons */
    .confirm-bid-btn {
        padding: 9px 18px !important;
        font-size: 0.85rem !important;
    }

    .fold-bid-btn {
        padding: 7px 18px !important;
        font-size: 0.8rem !important;
        margin-top: 5px !important;
    }

    /* "YOUR TURN TO BID" indicator */
    .bid-active-indicator {
        top: 52px !important;
        font-size: 0.45rem !important;
        padding: 4px 10px !important;
        letter-spacing: 0.1em !important;
    }

    /* Timer ring: shrink for mobile */
    .bid-timer-ring-wrap {
        width: 52px !important;
        height: 52px !important;
    }

    .bid-timer-num {
        font-size: 0.8rem !important;
    }

    .bid-input-box {
        margin-bottom: 6px !important;
    }
}

/* --- VERY SMALL LANDSCAPE (e.g. iPhone SE / small Android) --- */
@media (max-width: 680px) and (orientation: landscape) {
    .bid-name {
        font-size: 0.75rem !important;
    }

    .bid-avatar {
        width: 36px !important;
        height: 36px !important;
    }

    .bid-amount-display {
        font-size: 1.2rem !important;
    }

    .bid-controls-btn {
        padding: 5px 7px !important;
        font-size: 0.75rem !important;
    }

    .confirm-bid-btn {
        padding: 7px 12px !important;
        font-size: 0.75rem !important;
    }

    .fold-bid-btn {
        padding: 5px 12px !important;
        font-size: 0.72rem !important;
    }

    .split-half {
        padding: 5px 6px !important;
    }

    .split-left,
    .split-right {
        padding-top: 46px !important;
    }

    .bid-card-flip-container {
        width: 52px !important;
        height: 70px !important;
    }

    .bid-card-back {
        font-size: 1.2rem !important;
    }

    .bid-top-banner {
        padding: 4px 8px !important;
    }

    .bid-segment-info-inline {
        font-size: 0.62rem !important;
    }

    .bid-highest-value {
        font-size: 0.8rem !important;
    }
}

/* ============================================================
   MOBILE FIXES � Defense Modal
   ============================================================ */
@media (max-width: 900px) and (orientation: landscape) {
    .defense-modal-overlay {
        align-items: flex-start;
        overflow-y: auto;
    }

    .defense-modal-inner {
        padding: 14px 12px !important;
        gap: 10px !important;
        max-height: 100vh;
        overflow-y: auto;
    }

    .defense-modal-title {
        font-size: 1rem !important;
    }

    .defense-modal-subtitle {
        font-size: 0.8rem !important;
    }

    .dmod-attacker-name {
        font-size: 1.1rem !important;
    }

    .dmod-card-option {
        width: 110px !important;
        padding: 10px 8px !important;
    }

    .dmod-card-shield {
        font-size: 1.4rem !important;
        margin-bottom: 4px !important;
    }

    .dmod-card-power-badge {
        font-size: 1rem !important;
        padding: 2px 8px !important;
    }

    .defense-modal-skip-btn {
        padding: 10px 18px !important;
        font-size: 0.85rem !important;
    }
}

/* ============================================================
   MOBILE FIXES � Toast Notifications
   ============================================================ */
@media (max-width: 768px) {
    .toast-container {
        bottom: 12px !important;
        right: 8px !important;
        left: 8px !important;
        max-width: none !important;
    }

    .toast {
        font-size: 0.82rem !important;
        padding: 10px 12px !important;
    }
}


/* ============================================================
   WIN SCREEN OVERLAY & MODAL
   ============================================================ */
.win-screen-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 4, 10, 0.95);
    backdrop-filter: blur(20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

.win-screen-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.win-screen-inner {
    background: linear-gradient(145deg, #0d0d1a, #110722);
    border: 2px solid var(--gold);
    border-radius: 24px;
    padding: 40px;
    max-width: 680px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    box-shadow: 0 0 80px rgba(229, 169, 30, 0.25);
    transform: scale(0.9) translateY(40px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 12010;
}

.win-screen-overlay.visible .win-screen-inner {
    transform: scale(1) translateY(0);
}

.win-crown-icon {
    font-size: 4.5rem;
    animation: crownBounce 2.5s infinite ease-in-out, crownGlow 2.5s infinite ease-in-out;
}

@keyframes crownBounce {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    50% {
        transform: translateY(-12px) rotate(4deg);
    }
}

@keyframes crownGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 12px rgba(229, 169, 30, 0.4));
    }

    50% {
        filter: drop-shadow(0 0 30px rgba(229, 169, 30, 0.85));
    }
}

.win-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 900;
    text-align: center;
    background: linear-gradient(180deg, #FFFFFF 0%, var(--gold-light) 40%, var(--gold) 70%, var(--gold-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.1em;
    margin: 0;
}

.win-subtitle {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    margin-top: -12px;
    text-align: center;
}

.winner-announcement {
    flex-shrink: 0;
    background: rgba(229, 169, 30, 0.06);
    border: 1px solid rgba(229, 169, 30, 0.3);
    border-radius: 18px;
    padding: 24px 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 480px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(229, 169, 30, 0.08);
}

.winner-announcement::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent 0%, rgba(229, 169, 30, 0.08) 35%, transparent 70%);
    animation: winSpin 8s linear infinite;
    pointer-events: none;
}

@keyframes winSpin {
    100% {
        transform: rotate(360deg);
    }
}

.winner-avatar {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: white;
    border: 3px solid;
    z-index: 1;
    box-shadow: 0 0 20px currentColor;
    background: rgba(0, 0, 0, 0.4);
}

.winner-name {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 700;
    z-index: 1;
    text-shadow: 0 0 15px currentColor;
}

.winner-score {
    font-family: 'Orbitron', monospace;
    font-size: 1.15rem;
    color: var(--gold-light);
    letter-spacing: 0.1em;
    z-index: 1;
    font-weight: bold;
}

.leaderboard-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.3em;
    margin-top: 10px;
    margin-bottom: 0;
    text-transform: uppercase;
}

.leaderboard-list {
    flex-shrink: 0;
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leaderboard-row {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px 24px;
    gap: 16px;
    transition: background 0.2s, transform 0.2s;
}

.leaderboard-row:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateX(4px);
    border-color: rgba(255, 255, 255, 0.12);
}

.leaderboard-rank {
    font-family: 'Orbitron', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-dim);
    width: 25px;
    text-align: center;
}

.leaderboard-rank.rank-1 {
    color: var(--gold);
    text-shadow: 0 0 10px rgba(229, 169, 30, 0.5);
}

.leaderboard-rank.rank-2 {
    color: #A0A0A0;
}

.leaderboard-rank.rank-3 {
    color: #CD7F32;
}

.leaderboard-pcolor {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 10px currentColor;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.leaderboard-pname {
    font-family: 'Rajdhani', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    flex-grow: 1;
    letter-spacing: 0.02em;
}

.leaderboard-status {
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    font-weight: bold;
    text-transform: uppercase;
}

.leaderboard-status.status-alive {
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #4ade80;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.1);
}

.leaderboard-status.status-bankrupt {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #f87171;
    text-decoration: line-through;
    opacity: 0.8;
}

.leaderboard-pscore {
    font-family: 'Orbitron', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    min-width: 40px;
    text-align: right;
}

.win-actions {
    flex-shrink: 0;
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 540px;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
}

.win-action-btn {
    flex: 1;
    min-width: 150px;
    padding: 14px 24px;
    border-radius: 8px;
    font-family: 'Orbitron', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    text-transform: uppercase;
}

.rematch-btn {
    background: linear-gradient(135deg, rgba(229, 169, 30, 0.22), rgba(229, 169, 30, 0.08));
    border: 1px solid rgba(229, 169, 30, 0.65);
    color: var(--gold-light);
}

.rematch-btn:hover {
    background: linear-gradient(135deg, rgba(229, 169, 30, 0.42), rgba(229, 169, 30, 0.15));
    border-color: var(--gold);
    box-shadow: 0 0 25px rgba(229, 169, 30, 0.45);
    transform: translateY(-2px);
}

.setup-btn {
    background: rgba(0, 170, 255, 0.08);
    border: 1px solid rgba(0, 170, 255, 0.45);
    color: var(--blue-glow);
}

.setup-btn:hover {
    background: rgba(0, 170, 255, 0.2);
    border-color: var(--blue-glow);
    box-shadow: 0 0 25px rgba(0, 170, 255, 0.35);
    transform: translateY(-2px);
}

.lobby-btn {
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.45);
    color: #c084fc;
}

.lobby-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: #c084fc;
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.35);
    transform: translateY(-2px);
}

@media (max-width: 580px) {
    .win-screen-inner {
        padding: 24px;
        gap: 18px;
    }

    .winner-announcement {
        padding: 16px 24px;
    }

    .winner-name {
        font-size: 1.7rem;
    }

    .leaderboard-row {
        padding: 10px 16px;
        gap: 10px;
    }

    .leaderboard-pname {
        font-size: 1.1rem;
    }

    .win-actions {
        flex-direction: column;
        width: 100%;
    }

    .win-action-btn {
        width: 100%;
    }
}


/* ============================================================
   SPECTATOR & ROOM BADGE STYLES
   ============================================================ */
.spectator-indicator {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translate(-50%, 0);
    background: rgba(0, 170, 255, 0.12);
    border: 1px solid rgba(0, 170, 255, 0.35);
    box-shadow: 0 0 20px rgba(0, 170, 255, 0.2);
    color: #00AAFF;
    padding: 8px 18px;
    border-radius: 30px;
    font-family: 'Orbitron', monospace;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(12px);
}

.spectator-indicator .spec-dot {
    color: #00AAFF;
    font-size: 1.1rem;
    animation: pulseSpecDot 1.5s infinite ease-in-out;
}

@keyframes pulseSpecDot {

    0%,
    100% {
        opacity: 0.3;
        transform: scale(0.9);
    }

    50% {
        opacity: 1;
        transform: scale(1.1);
        text-shadow: 0 0 8px #00AAFF;
    }
}

.host-room-badge {
    position: fixed;
    top: 15px;
    right: 20px;
    background: rgba(255, 215, 0, 0.08);
    border: 1px solid rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.15);
    color: var(--gold-light);
    padding: 8px 16px;
    border-radius: 20px;
    font-family: 'Orbitron', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(12px);
    cursor: pointer;
    transition: all 0.2s ease;
}

.host-room-badge:hover {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--gold);
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.3);
    transform: translateY(-1px);
}

.host-room-badge span:last-child {
    color: #fff;
    letter-spacing: 0.15em;
    font-weight: 900;
}

/* Spectator Read-Only Overlay Styles */
body.spectator-active .play-btn,
body.spectator-active .waste-btn,
body.spectator-active .segment,
body.spectator-active #btn-buy-flag,
body.spectator-active #btn-pass,
body.spectator-active #btn-end-game,
body.spectator-active .rematch-btn {
    pointer-events: none !important;
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

body.spectator-active .segment {
    cursor: default !important;
    opacity: 1 !important;
}

/* ======================== ALLIANCE CHAT WIDGET ======================== */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Rajdhani', sans-serif;
}

/* Chat Toggle Button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(17, 17, 19, 0.85);
    border: 1px solid var(--border);
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.15);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.chat-toggle-btn:hover {
    transform: scale(1.08) rotate(5deg);
    border-color: var(--blue-glow);
    box-shadow: 0 0 25px rgba(0, 170, 255, 0.3);
}

.chat-icon {
    font-size: 1.6rem;
}

/* Chat Badge */
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff2d2d;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 3px 7px;
    border-radius: 10px;
    min-width: 15px;
    text-align: center;
    box-shadow: 0 0 10px rgba(255, 45, 45, 0.6);
    display: none;
}

/* Chat Panel Drawer */
.chat-panel {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 320px;
    height: 400px;
    background: rgba(11, 11, 13, 0.95);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(15px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
    transform: scale(1);
    opacity: 1;
}

.chat-panel.collapsed {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

/* Header */
.chat-header {
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 0.15em;
    font-weight: bold;
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.2s;
}

.chat-close-btn:hover {
    color: #ff5555;
}

/* Messages List */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-messages::-webkit-scrollbar {
    width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.15);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.3);
}

/* Chat Message Bubbles */
.chat-msg-bubble {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    animation: slideUpFade 0.3s ease;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg-sender {
    font-size: 0.75rem;
    margin-bottom: 3px;
    font-weight: 600;
}

.chat-msg-text {
    font-size: 0.85rem;
    padding: 8px 12px;
    border-radius: 12px;
    line-height: 1.35;
    word-break: break-word;
}

/* Self alignment */
.chat-msg-bubble.self {
    align-self: flex-end;
}

.chat-msg-bubble.self .chat-msg-sender {
    display: none;
    /* Hide our own name badge */
}

.chat-msg-bubble.self .chat-msg-text {
    background: rgba(0, 170, 255, 0.15);
    border: 1px solid rgba(0, 170, 255, 0.3);
    color: #fff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 0 10px rgba(0, 170, 255, 0.05);
}

/* Others alignment */
.chat-msg-bubble.other {
    align-self: flex-start;
}

.chat-msg-bubble.other .chat-msg-text {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    border-bottom-left-radius: 2px;
}

/* System Notifications */
.chat-system-message {
    font-size: 0.75rem;
    color: var(--yellow);
    opacity: 0.75;
    text-align: center;
    font-style: italic;
    margin: 4px 0;
    letter-spacing: 0.05em;
    animation: fadeIn 0.4s ease;
}

/* Input Area */
.chat-input-area {
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.4);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

#chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 8px 12px;
    color: white;
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

#chat-input:focus {
    outline: none;
    border-color: var(--blue-glow);
}

.chat-send-btn {
    background: rgba(0, 170, 255, 0.15);
    border: 1px solid var(--blue-glow);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    font-family: 'Orbitron', sans-serif;
    transition: all 0.2s;
}

.chat-send-btn:hover {
    background: rgba(0, 170, 255, 0.3);
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.25);
}

/* ==========================================================================
   CARD CLICK OVERLAY SYSTEM
   ========================================================================== */

.card-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 4, 10, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 9000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.card-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

body.card-overlay-open .game-footer {
    z-index: 9500 !important;
}

/* Card overlay-active styles removed, behavior now fully handled via CSS :hover */

/* ===== LIGHT MODE OVERRIDES — Game Page ===== */
[data-theme="light"] .game-container {
    background: radial-gradient(circle at 50% 50%, #EDE7DB 0%, #DDD5C5 100%);
}

[data-theme="light"] .game-header {
    background: rgba(237, 231, 219, 0.85);
    border-bottom-color: rgba(165, 117, 12, 0.15);
}

[data-theme="light"] .roster-card {
    background: rgba(245, 240, 232, 0.8);
    border-color: rgba(165, 117, 12, 0.15);
}

[data-theme="light"] .roster-card.active-turn {
    background: rgba(255, 215, 0, 0.08);
}

[data-theme="light"] .roster-name {
    color: #1A1408;
}

[data-theme="light"] .action-log-wrap,
[data-theme="light"] .commands-panel {
    background: rgba(237, 231, 219, 0.6);
    border-color: rgba(165, 117, 12, 0.2);
}

[data-theme="light"] .log-entry {
    color: #3A3020;
}

[data-theme="light"] .log-entry strong {
    color: #1A1408;
}

[data-theme="light"] .action-btn {
    background: rgba(237, 231, 219, 0.7);
    border-color: rgba(165, 117, 12, 0.25);
    color: #1A1408;
}

[data-theme="light"] .action-btn:hover:not(:disabled) {
    background: rgba(165, 117, 12, 0.1);
    border-color: rgba(165, 117, 12, 0.5);
    color: #1A1408;
    box-shadow: 0 0 10px rgba(165, 117, 12, 0.1);
}

[data-theme="light"] .game-footer {
    background: linear-gradient(0deg, rgba(237, 231, 219, 0.98) 0%, rgba(237, 231, 219, 0.5) 100%);
    border-top-color: rgba(165, 117, 12, 0.1);
}

/* ── Game Cards: use rich saturated colors so they pop on the light background ── */

/* Default / unknown card type */
[data-theme="light"] .game-card {
    background: linear-gradient(145deg, #2A2240 0%, #1A1530 100%);
    border: 2px solid rgba(255, 215, 0, 0.45);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
}

[data-theme="light"] .game-card .card-title {
    color: #FFFFFF;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .game-card .card-desc {
    color: rgba(255, 255, 255, 0.72);
}

[data-theme="light"] .game-card .card-cost {
    background: rgba(0, 0, 0, 0.55);
    color: #FFD700;
    border-color: rgba(255, 215, 0, 0.7);
}

/* ATTACK — deep crimson red */
[data-theme="light"] .game-card.card-attack {
    background: linear-gradient(145deg, #7A1010 0%, #550A0A 100%);
    border: 2px solid rgba(255, 68, 68, 0.75);
    box-shadow: 0 6px 20px rgba(200, 0, 0, 0.3);
}

[data-theme="light"] .game-card.card-attack:hover,
[data-theme="light"] .game-card.card-attack.active {
    border-color: #FF4444;
    box-shadow: 0 12px 30px rgba(255, 45, 45, 0.5), 0 0 18px rgba(255, 45, 45, 0.3);
}

[data-theme="light"] .game-card.card-attack .card-cost {
    background: rgba(100, 0, 0, 0.7);
    border-color: #FF4444;
}

/* DEFENCE — deep emerald green */
[data-theme="light"] .game-card.card-defence {
    background: linear-gradient(145deg, #0B5E28 0%, #063D18 100%);
    border: 2px solid rgba(0, 255, 136, 0.65);
    box-shadow: 0 6px 20px rgba(0, 150, 80, 0.3);
}

[data-theme="light"] .game-card.card-defence:hover,
[data-theme="light"] .game-card.card-defence.active {
    border-color: #00FF88;
    box-shadow: 0 12px 30px rgba(0, 255, 136, 0.5), 0 0 18px rgba(0, 255, 136, 0.3);
}

[data-theme="light"] .game-card.card-defence .card-cost {
    background: rgba(0, 60, 20, 0.7);
    border-color: #00FF88;
}

/* CLAIM L1 — deep ocean blue */
[data-theme="light"] .game-card.card-claim-l1 {
    background: linear-gradient(145deg, #0A3A6B 0%, #061F40 100%);
    border: 2px solid rgba(0, 200, 255, 0.65);
    box-shadow: 0 6px 20px rgba(0, 100, 200, 0.3);
}

[data-theme="light"] .game-card.card-claim-l1:hover,
[data-theme="light"] .game-card.card-claim-l1.active {
    border-color: #00CCFF;
    box-shadow: 0 12px 30px rgba(0, 170, 255, 0.5), 0 0 18px rgba(0, 170, 255, 0.3);
}

[data-theme="light"] .game-card.card-claim-l1 .card-cost {
    background: rgba(0, 30, 80, 0.7);
    border-color: #00CCFF;
}

/* CLAIM L2 — rich dark amber/saffron */
[data-theme="light"] .game-card.card-claim-l2 {
    background: linear-gradient(145deg, #6B4500 0%, #3D2600 100%);
    border: 2px solid rgba(255, 200, 0, 0.7);
    box-shadow: 0 6px 20px rgba(180, 120, 0, 0.3);
}

[data-theme="light"] .game-card.card-claim-l2:hover,
[data-theme="light"] .game-card.card-claim-l2.active {
    border-color: #FFCC00;
    box-shadow: 0 12px 30px rgba(255, 200, 0, 0.5), 0 0 18px rgba(255, 200, 0, 0.3);
}

[data-theme="light"] .game-card.card-claim-l2 .card-cost {
    background: rgba(60, 35, 0, 0.7);
    border-color: #FFCC00;
}

/* CLAIM L3 — dark blood red */
[data-theme="light"] .game-card.card-claim-l3 {
    background: linear-gradient(145deg, #6B0808 0%, #3D0404 100%);
    border: 2px solid rgba(255, 80, 80, 0.65);
    box-shadow: 0 6px 20px rgba(160, 0, 0, 0.3);
}

[data-theme="light"] .game-card.card-claim-l3:hover,
[data-theme="light"] .game-card.card-claim-l3.active {
    border-color: #FF4444;
    box-shadow: 0 12px 30px rgba(255, 45, 45, 0.5), 0 0 18px rgba(255, 45, 45, 0.3);
}

[data-theme="light"] .game-card.card-claim-l3 .card-cost {
    background: rgba(70, 0, 0, 0.7);
    border-color: #FF4444;
}

/* CLAIM L4 — rich dark gold / imperial */
[data-theme="light"] .game-card.card-claim-l4 {
    background: linear-gradient(145deg, #5A3E00 0%, #3A2800 100%);
    border: 2px solid rgba(255, 215, 0, 0.8);
    box-shadow: 0 6px 20px rgba(200, 160, 0, 0.35), 0 0 12px rgba(255, 215, 0, 0.15);
}

[data-theme="light"] .game-card.card-claim-l4:hover,
[data-theme="light"] .game-card.card-claim-l4.active {
    border-color: #FFD700;
    box-shadow: 0 12px 30px rgba(255, 215, 0, 0.55), 0 0 22px rgba(255, 215, 0, 0.3);
}

[data-theme="light"] .game-card.card-claim-l4 .card-cost {
    background: rgba(60, 40, 0, 0.7);
    border-color: #FFD700;
}

/* Hover lift on all cards */
[data-theme="light"] .game-card:hover,
[data-theme="light"] .game-card.active {
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
}

/* Selected card glow override */
[data-theme="light"] .game-card.selected-card {
    border-color: #FFD700 !important;
    box-shadow: 0 0 28px rgba(255, 215, 0, 0.7) !important;
}

[data-theme="light"] .current-turn-indicator span {
    color: #1A1408;
}

[data-theme="light"] .turn-transition-overlay {
    background: rgba(245, 240, 232, 0.88);
}

[data-theme="light"] .turn-transition-content {
    background: rgba(237, 231, 219, 0.97);
}

/* Inactive player turn lock */
body.not-my-turn .board-area,
body.not-my-turn .action-buttons button:not(#chat-toggle-btn),
body.not-my-turn .player-hand {
    pointer-events: none;
    opacity: 0.75;
    filter: grayscale(15%);
    transition: all 0.3s ease;
}

/* ============================================================
   ALLIANCE CHAT WIDGET — In-Game Messaging
   ============================================================ */

/* ── Container ── */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* ── Floating Toggle Button ── */
.chat-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(255, 215, 0, 0.35);
    background: linear-gradient(135deg, rgba(15, 15, 25, 0.95) 0%, rgba(25, 20, 40, 0.95) 100%);
    backdrop-filter: blur(12px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(255, 215, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 10;
}

.chat-toggle-btn:hover {
    border-color: rgba(255, 215, 0, 0.6);
    box-shadow:
        0 6px 25px rgba(0, 0, 0, 0.6),
        0 0 25px rgba(255, 215, 0, 0.15);
    transform: scale(1.08);
}

.chat-toggle-btn:active {
    transform: scale(0.96);
}

.chat-icon {
    font-size: 1.6rem;
    filter: drop-shadow(0 0 4px rgba(255, 215, 0, 0.3));
    line-height: 1;
}

/* ── Unread Badge ── */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff2d2d 0%, #cc0000 100%);
    color: #fff;
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    box-shadow: 0 2px 8px rgba(255, 45, 45, 0.5);
    animation: badgePulse 1.5s ease-in-out infinite;
}

@keyframes badgePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* ── Chat Panel ── */
.chat-panel {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 340px;
    height: 420px;
    background: linear-gradient(145deg, rgba(12, 12, 20, 0.97) 0%, rgba(18, 14, 30, 0.97) 100%);
    border: 1px solid rgba(255, 215, 0, 0.12);
    border-radius: 12px;
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.6),
        0 0 30px rgba(255, 215, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.3s ease;
    transform-origin: bottom right;
}

.chat-panel.collapsed {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.85) translateY(10px);
    pointer-events: none;
}

/* ── Chat Header ── */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(255, 215, 0, 0.04);
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    flex-shrink: 0;
}

.chat-header-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: var(--gold-light, #ffd700);
    text-shadow: 0 0 6px rgba(255, 215, 0, 0.2);
}

.chat-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim, #888);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.chat-close-btn:hover {
    background: rgba(255, 45, 45, 0.15);
    border-color: rgba(255, 45, 45, 0.4);
    color: #ff5555;
}

/* ── Messages Area ── */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.15);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.3);
}

/* System message */
.chat-system-message {
    text-align: center;
    font-family: 'Orbitron', monospace;
    font-size: 0.6rem;
    color: rgba(255, 215, 0, 0.35);
    letter-spacing: 0.1em;
    padding: 6px 12px;
    border: 1px dashed rgba(255, 215, 0, 0.1);
    border-radius: 6px;
    background: rgba(255, 215, 0, 0.02);
}

/* ── Message Bubbles ── */
.chat-msg-bubble {
    max-width: 85%;
    animation: msgSlideIn 0.25s ease-out;
}

.chat-msg-bubble.self {
    align-self: flex-end;
}

.chat-msg-bubble.other {
    align-self: flex-start;
}

@keyframes msgSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg-sender {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
    padding-left: 2px;
}

.chat-msg-bubble.self .chat-msg-sender {
    text-align: right;
    padding-right: 2px;
    padding-left: 0;
}

.chat-msg-text {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.88rem;
    line-height: 1.4;
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 10px;
    word-break: break-word;
}

.chat-msg-bubble.self .chat-msg-text {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(200, 160, 0, 0.08) 100%);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-bottom-right-radius: 3px;
}

.chat-msg-bubble.other .chat-msg-text {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 3px;
}

/* ── Input Area ── */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid rgba(255, 215, 0, 0.08);
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: #e0e0e0;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#chat-input:focus {
    border-color: rgba(255, 215, 0, 0.3);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.08);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.2);
    font-style: italic;
}

.chat-send-btn {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(200, 160, 0, 0.1) 100%);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 8px 16px;
    color: var(--gold-light, #ffd700);
    font-family: 'Orbitron', monospace;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.25) 0%, rgba(200, 160, 0, 0.18) 100%);
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.12);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

/* ── Light Theme Overrides ── */
[data-theme="light"] .chat-toggle-btn {
    background: linear-gradient(135deg, rgba(237, 231, 219, 0.97) 0%, rgba(230, 220, 200, 0.97) 100%);
    border-color: rgba(180, 140, 50, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 10px rgba(180, 140, 50, 0.1);
}

[data-theme="light"] .chat-toggle-btn:hover {
    border-color: rgba(180, 140, 50, 0.7);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2), 0 0 20px rgba(180, 140, 50, 0.15);
}

[data-theme="light"] .chat-panel {
    background: linear-gradient(145deg, rgba(245, 240, 230, 0.98) 0%, rgba(237, 231, 219, 0.98) 100%);
    border-color: rgba(180, 140, 50, 0.2);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 20px rgba(180, 140, 50, 0.05);
}

[data-theme="light"] .chat-header {
    background: rgba(180, 140, 50, 0.06);
    border-bottom-color: rgba(180, 140, 50, 0.15);
}

[data-theme="light"] .chat-header-title {
    color: #8B6914;
}

[data-theme="light"] .chat-close-btn {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.03);
    color: #888;
}

[data-theme="light"] .chat-close-btn:hover {
    background: rgba(255, 45, 45, 0.1);
    border-color: rgba(255, 45, 45, 0.3);
    color: #cc3333;
}

[data-theme="light"] .chat-system-message {
    color: rgba(139, 105, 20, 0.5);
    border-color: rgba(139, 105, 20, 0.15);
    background: rgba(139, 105, 20, 0.03);
}

[data-theme="light"] .chat-msg-text {
    color: #2a2a2a;
}

[data-theme="light"] .chat-msg-bubble.self .chat-msg-text {
    background: linear-gradient(135deg, rgba(180, 140, 50, 0.12) 0%, rgba(160, 120, 40, 0.08) 100%);
    border-color: rgba(180, 140, 50, 0.2);
}

[data-theme="light"] .chat-msg-bubble.other .chat-msg-text {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .chat-input-area {
    background: rgba(0, 0, 0, 0.03);
    border-top-color: rgba(180, 140, 50, 0.1);
}

[data-theme="light"] #chat-input {
    background: rgba(255, 255, 255, 0.7);
    border-color: rgba(0, 0, 0, 0.12);
    color: #2a2a2a;
}

[data-theme="light"] #chat-input:focus {
    border-color: rgba(180, 140, 50, 0.4);
    box-shadow: 0 0 8px rgba(180, 140, 50, 0.1);
}

[data-theme="light"] #chat-input::placeholder {
    color: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .chat-send-btn {
    background: linear-gradient(135deg, rgba(180, 140, 50, 0.15) 0%, rgba(160, 120, 40, 0.1) 100%);
    border-color: rgba(180, 140, 50, 0.35);
    color: #8B6914;
}

[data-theme="light"] .chat-send-btn:hover {
    background: linear-gradient(135deg, rgba(180, 140, 50, 0.25) 0%, rgba(160, 120, 40, 0.18) 100%);
    border-color: rgba(180, 140, 50, 0.55);
}

/* ── Landscape Mobile Chat Adjustments ── */
@media (max-width: 1024px) and (orientation: landscape) {
    .chat-widget {
        bottom: 8px;
        right: 8px;
    }

    .chat-toggle-btn {
        width: 42px;
        height: 42px;
    }

    .chat-icon {
        font-size: 1.2rem;
    }

    .chat-badge {
        min-width: 16px;
        height: 16px;
        font-size: 0.55rem;
        top: -3px;
        right: -3px;
    }

    .chat-panel {
        bottom: 52px;
        width: 280px;
        height: 260px;
        border-radius: 8px;
    }

    .chat-header {
        padding: 8px 12px;
    }

    .chat-header-title {
        font-size: 0.6rem;
    }

    .chat-close-btn {
        width: 22px;
        height: 22px;
        font-size: 0.7rem;
    }

    .chat-messages {
        padding: 8px;
        gap: 6px;
    }

    .chat-system-message {
        font-size: 0.5rem;
        padding: 4px 8px;
    }

    .chat-msg-sender {
        font-size: 0.6rem;
    }

    .chat-msg-text {
        font-size: 0.75rem;
        padding: 5px 8px;
    }

    .chat-input-area {
        padding: 6px 10px;
        gap: 6px;
    }

    #chat-input {
        font-size: 0.75rem;
        padding: 5px 8px;
    }

    .chat-send-btn {
        padding: 5px 10px;
        font-size: 0.55rem;
    }
}

/* Mobile responsive adjustments for Chat Widget */
@media (max-width: 600px) {
    .chat-widget {
        bottom: 12px;
        right: 12px;
    }

    .chat-toggle-btn {
        width: 52px;
        height: 52px;
    }

    .chat-icon {
        font-size: 1.4rem;
    }

    .chat-panel {
        bottom: 64px;
        width: calc(100vw - 24px);
        height: 320px;
        border-radius: 8px;
    }

    .chat-messages {
        padding: 10px;
        gap: 8px;
    }

    .chat-msg-text {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .chat-input-area {
        padding: 8px 12px;
    }

    #chat-input {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .chat-send-btn {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
}

/* ============================================================
   MUSIC TOGGLE BUTTON
   ============================================================ */
.music-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--toggle-bg, rgba(255, 215, 0, 0.08));
    border: 1px solid var(--toggle-border, rgba(255, 215, 0, 0.35));
    border-radius: 50px;
    color: var(--toggle-text, #E5A91E);
    font-family: 'Orbitron', monospace;
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.music-toggle-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--toggle-shadow, rgba(255, 215, 0, 0.2));
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: inherit;
}

.music-toggle-btn:hover::before {
    opacity: 1;
}

.music-toggle-btn:hover {
    box-shadow: 0 0 16px var(--toggle-shadow, rgba(255, 215, 0, 0.2));
    transform: translateY(-1px);
}

.music-toggle-btn:active {
    transform: scale(0.96);
}

.music-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.music-toggle-btn:hover .music-icon {
    transform: scale(1.2);
}

.music-label {
    font-size: 0.55rem;
}

/* Playing state — subtle glow pulse animation */
.music-toggle-btn.playing {
    border-color: var(--gold, #E5A91E);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
    animation: musicPulse 2s ease-in-out infinite;
}

@keyframes musicPulse {

    0%,
    100% {
        box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.3), 0 0 40px rgba(255, 215, 0, 0.1);
    }
}

/* Light mode overrides */
[data-theme="light"] .music-toggle-btn {
    background: var(--toggle-bg, rgba(165, 117, 12, 0.1));
    border-color: var(--toggle-border, rgba(165, 117, 12, 0.45));
    color: var(--toggle-text, #7a5500);
}

[data-theme="light"] .music-toggle-btn:hover {
    box-shadow: 0 0 16px var(--toggle-shadow, rgba(165, 117, 12, 0.25));
}

[data-theme="light"] .music-toggle-btn.playing {
    border-color: var(--gold-dark, #A6750C);
    box-shadow: 0 0 12px rgba(165, 117, 12, 0.2);
}

/* Mobile landscape responsive */
@media (max-width: 1024px) and (orientation: landscape) {
    .music-toggle-btn {
        padding: 4px 10px;
        font-size: 0.45rem;
        gap: 4px;
    }

    .music-icon {
        width: 14px;
        height: 14px;
    }

    .music-label {
        font-size: 0.4rem;
    }
}

/* ============================================================
   SETTINGS PANEL & DROPDOWN
   ============================================================ */
.settings-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.settings-toggle-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(255, 215, 0, 0.35);
    background: linear-gradient(135deg, rgba(15, 15, 25, 0.85) 0%, rgba(25, 20, 40, 0.85) 100%);
    color: #ffd700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(8px);
}

.settings-toggle-btn:hover {
    border-color: rgba(255, 215, 0, 0.6);
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.25);
    transform: scale(1.05);
}

.settings-toggle-btn:hover .settings-icon {
    transform: rotate(45deg);
}

.settings-icon {
    transition: transform 0.4s ease;
}

.settings-panel {
    position: absolute;
    top: 50px;
    right: 0;
    width: 260px;
    padding: 16px;
    background: linear-gradient(145deg, rgba(12, 12, 20, 0.96) 0%, rgba(18, 14, 30, 0.96) 100%);
    border: 1px solid rgba(255, 215, 0, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 10100;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.25s ease;
    transform-origin: top right;
}

.settings-panel.collapsed {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.9) translateY(-10px);
    pointer-events: none;
}

.settings-title {
    font-family: 'Orbitron', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: #ffd700;
    margin: 0;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 215, 0, 0.1);
    text-transform: uppercase;
}

.settings-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-label {
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: #bbb;
    letter-spacing: 0.05em;
}

.settings-panel .theme-toggle-btn,
.settings-panel .music-toggle-btn,
.settings-panel .sfx-toggle-btn {
    margin: 0;
    width: auto;
    flex-grow: 0;
}

/* Light Theme Overrides */
[data-theme="light"] .settings-toggle-btn {
    border-color: rgba(180, 140, 50, 0.4);
    background: linear-gradient(135deg, rgba(245, 240, 230, 0.9) 0%, rgba(235, 225, 210, 0.9) 100%);
    color: #8B6914;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .settings-panel {
    background: linear-gradient(145deg, rgba(255, 252, 245, 0.98) 0%, rgba(245, 238, 225, 0.98) 100%);
    border-color: rgba(180, 140, 50, 0.25);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .settings-title {
    color: #8B6914;
    border-bottom-color: rgba(180, 140, 50, 0.15);
}

[data-theme="light"] .settings-label {
    color: #555;
}

/* SFX toggle button style */
.sfx-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(0, 170, 255, 0.08);
    border: 1px solid rgba(0, 170, 255, 0.4);
    border-radius: 50px;
    color: #00e5ff;
    font-family: 'Orbitron', monospace;
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    text-transform: uppercase;
    backdrop-filter: blur(8px);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.sfx-toggle-btn:hover {
    border-color: rgba(0, 170, 255, 0.7);
    box-shadow: 0 0 16px rgba(0, 170, 255, 0.25);
    transform: translateY(-1px);
}

.sfx-toggle-btn:active {
    transform: scale(0.96);
}

.sfx-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sfx-label {
    font-size: 0.55rem;
}

[data-theme="light"] .sfx-toggle-btn {
    background: rgba(0, 120, 200, 0.08);
    border-color: rgba(0, 120, 200, 0.45);
    color: #007799;
}