/* Capital Race - Classical Political Arena Styling */
:root {
    /* Color Palette - Classical Political Arena */
    --bg-primary: #0D0D0D;
    --bg-secondary: #1A1A1A;
    --bg-tertiary: #252525;

    /* Primary palette from logo */
    --accent-gold: #D4AF37;
    --accent-gold-dim: #B8860B;
    --accent-gold-bright: #FFD700;
    --accent-burgundy: #722F37;
    --accent-teal: #2A4858;

    /* Action colors */
    --accent-red: #C0392B;
    --accent-blue: #2980B9;
    --accent-green: #27AE60;
    --accent-purple: #8E44AD;

    --text-primary: #FFFFF0;
    --text-secondary: #D4D4C8;
    --text-muted: #8A8A7A;

    /* Glass effects */
    --glass-bg: rgba(26, 26, 26, 0.9);
    --glass-border: rgba(212, 175, 55, 0.25);
    --glass-glow: rgba(212, 175, 55, 0.15);

    /* Card Game Layout Dimensions */
    --card-width-sm: 90px;
    --card-height-sm: 126px;
    --card-width-lg: 130px;
    --card-height-lg: 182px;

    /* Z-Indices */
    --z-card: 10;
    --z-modal: 1000;
    --z-tooltip: 2000;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    /* Game feel */
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: url('assets/unified_background.jpg') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* === LOBBY SCREEN === */
#lobby-screen {
    display: none;
    flex-direction: column;
    align-items: center;
    /* justify-content: center;  <-- Removed to avoid cutting off top content on overflow */
    height: 100vh;
    /* Constrain to viewport height */
    overflow-y: auto;
    /* Allow scrolling within the lobby screen */
    padding: 20px;
}

#lobby-screen.active {
    display: flex;
}

.lobby-container {
    max-width: 480px;
    width: 100%;
    margin: auto;
    /* Vertically and horizontally centers content if space permits, top-aligns if scrolling */
    padding: 20px 0;
    /* Ensure some spacing at top/bottom when scrolling */
}

/* Logo Styling */
.game-logo {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.8s ease;
}

.logo-image {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.5));
    animation: logoGlow 3s ease-in-out infinite;
}

@keyframes logoGlow {

    0%,
    100% {
        filter: drop-shadow(0 0 30px rgba(212, 175, 55, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 50px rgba(212, 175, 55, 0.8));
    }
}

.game-logo h1 {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #FFFFFF;
    text-shadow:
        0 0 20px rgba(255, 215, 0, 0.8),
        0 0 40px rgba(255, 215, 0, 0.6),
        0 0 60px rgba(255, 215, 0, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.8);
    margin-bottom: 12px;
    white-space: nowrap;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
}

/* --- Layout Grid --- */
#game-screen {
    display: none;
    height: 100vh;
    padding: 0;
    grid-template-rows: auto 1fr;
    gap: 0;
    background: url('assets/unified_background.jpg') no-repeat fixed;
    background-position: calc(50% + 150px) center;
    background-size: cover;
}

#game-screen.active {
    display: grid;
}

/* --- Game Header Bar --- */
.game-header-bar {
    display: grid;
    grid-template-columns: 300px 1fr;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 100%);
    border-bottom: 1px solid var(--glass-border);
    min-height: 90px;
    gap: 0;
}

.header-center {
    display: flex;
    justify-content: center;
    align-items: center;
    grid-column: 2;
}

/* --- Audio Controls --- */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    right: 20px;
    top: 20px;
    z-index: 100;
}

.audio-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(26, 26, 26, 0.8));
    border: 1px solid var(--glass-border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.audio-btn:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.25), rgba(26, 26, 26, 0.95));
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
    transform: scale(1.05);
}

/* === CARD PREVIEW MODAL === */
.card-preview-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: var(--z-tooltip);
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.98), rgba(37, 37, 37, 0.95));
    border: 2px solid var(--accent-gold);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(212, 175, 55, 0.3);
    backdrop-filter: blur(20px);
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    animation: fadeInScale 0.2s ease;
    pointer-events: none;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.card-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--glass-border);
}

#card-preview-player-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

#card-preview-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.card-preview-list {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.card-preview-list .card {
    width: 110px;
    height: 154px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.card-preview-list .card:hover {
    transform: scale(1.1) !important;
    z-index: 100;
}


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

.audio-btn.muted {
    background: linear-gradient(135deg, rgba(192, 57, 43, 0.2), rgba(26, 26, 26, 0.8));
    border-color: rgba(192, 57, 43, 0.5);
}

.audio-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.3));
}

.audio-btn.muted .audio-icon {
    filter: drop-shadow(0 0 5px rgba(192, 57, 43, 0.4));
}

.volume-control {
    display: flex;
    align-items: center;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: all 0.3s ease;
}

.audio-controls:hover .volume-control {
    opacity: 1;
    max-width: 120px;
}

.volume-slider {
    width: 100px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, var(--accent-gold-dim), var(--accent-gold));
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-gold);
    border: 2px solid var(--bg-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    background: var(--accent-gold-bright);
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
}

.volume-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-gold);
    border: 2px solid var(--bg-primary);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
    transition: all 0.2s ease;
}

.volume-slider::-moz-range-thumb:hover {
    background: var(--accent-gold-bright);
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
}


/* --- Main Content: Sidebar + Play Area --- */
.game-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: 100%;
    overflow: hidden;
}

/* --- Character Sidebar --- */
.character-sidebar {
    background: linear-gradient(180deg, rgba(13, 13, 13, 0.98) 0%, rgba(20, 20, 20, 0.95) 100%);
    border-right: 1px solid var(--glass-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}



.character-panel {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(26, 26, 26, 0.95));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Large Character Image - Full rectangular display */
.character-portrait {
    width: 100%;
    aspect-ratio: 9/16;
    border-radius: 12px;
    object-fit: contain;
    border: 3px solid var(--accent-gold);
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.3);
    margin-bottom: 16px;
}

.character-details {
    text-align: center;
    margin-bottom: 16px;
}

.character-player-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 4px;
}

.character-name {
    font-size: 1.1rem;
    color: var(--accent-purple);
    font-weight: 600;
    margin-bottom: 8px;
}

.character-level {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.2), rgba(192, 57, 43, 0.1));
    border-radius: 20px;
    border: 1px solid var(--accent-gold-dim);
}

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

.level-value {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Skill Info Box */
.skill-box {
    background: linear-gradient(135deg, rgba(155, 89, 182, 0.15), rgba(26, 26, 26, 0.9));
    border: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

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

.skill-type-badge {
    font-size: 0.8rem;
    padding: 4px 12px;
    background: rgba(155, 89, 182, 0.25);
    border-radius: 15px;
    color: var(--accent-purple);
    font-weight: 600;
}

.skill-status {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.skill-box.available .skill-status {
    color: var(--accent-green);
}

.skill-box.used .skill-status {
    color: var(--text-muted);
}

.skill-box.used {
    opacity: 0.6;
    border-color: var(--text-muted);
}

.skill-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 8px;
}

.skill-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Turn Indicator */
.turn-indicator-box {
    padding: 12px;
    border-radius: 10px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.turn-indicator-box.your-turn {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.25), rgba(231, 76, 60, 0.15));
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.3);
    animation: turnPulse 1.5s ease-in-out infinite;
}

@keyframes turnPulse {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(243, 156, 18, 0.3);
    }

    50% {
        box-shadow: 0 0 25px rgba(243, 156, 18, 0.5);
    }
}

/* Sidebar Actions */
.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: auto;
}

.btn-block {
    width: 100%;
    padding: 14px;
}

/* --- Compact Opponent Row --- */
.opponents-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 20px;
}

.opponent-board {
    width: 180px;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95), rgba(37, 37, 37, 0.9));
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    display: flex;
    padding: 10px;
    gap: 10px;
    position: relative;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.opponent-board.active-turn {
    border-color: var(--accent-gold);
    box-shadow:
        0 0 15px rgba(212, 175, 55, 0.4),
        inset 0 0 15px rgba(212, 175, 55, 0.1);
    animation: activePulse 2s ease-in-out infinite;
}

@keyframes activePulse {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(212, 175, 55, 0.4), inset 0 0 15px rgba(212, 175, 55, 0.1);
    }

    50% {
        box-shadow: 0 0 25px rgba(212, 175, 55, 0.6), inset 0 0 20px rgba(212, 175, 55, 0.15);
    }
}

.opp-avatar-container {
    position: relative;
    flex-shrink: 0;
}

.opp-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-gold-dim);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.turn-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    color: var(--accent-gold);
    font-size: 1rem;
    text-shadow: 0 0 10px var(--accent-gold);
}

.opp-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.opp-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.opp-character {
    font-size: 0.75rem;
    color: var(--accent-purple);
    font-weight: 600;
    margin-bottom: 2px;
}

.opp-stats {
    display: flex;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.opp-skill {
    display: none;
    /* Hidden in compact mode, shown on hover via tooltip */
}

/* --- Main Game Area --- */
.main-game-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* --- Play Area --- */
.play-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    min-height: 0;
    background-position: center center;
}



.active-play-zone {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 500px;
}

.play-message {
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    padding: 24px 40px;
    border-radius: 16px;
    border: 1px solid var(--accent-gold);
    box-shadow:
        0 0 30px rgba(212, 175, 55, 0.2),
        inset 0 0 30px rgba(212, 175, 55, 0.05);
}

#phase-indicator {
    color: var(--accent-gold);
    font-size: 1.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 8px;
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
}

#phase-indicator .timer-warning {
    color: var(--accent-red);
    font-weight: 700;
    animation: timerPulse 1s ease-in-out infinite;
}

@keyframes timerPulse {

    0%,
    100% {
        text-shadow: 0 0 10px rgba(192, 57, 43, 0.6);
    }

    50% {
        text-shadow: 0 0 20px rgba(192, 57, 43, 0.9);
    }
}

#turn-indicator {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* --- Hand Container --- */
.hand-container {
    background: linear-gradient(to top, rgba(13, 13, 13, 1), rgba(26, 26, 26, 0.95));
    border-top: 1px solid var(--glass-border);
    padding: 20px 40px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    min-height: 200px;
}

.player-hand {
    display: flex;
    justify-content: center;
    gap: -40px;
    height: 160px;
    align-items: flex-end;
}

/* --- Cards in Hand --- */
.player-hand .card {
    margin-left: -40px;
    transition: transform 0.2s ease, margin 0.2s ease;
    transform-origin: bottom center;
}

.player-hand .card:first-child {
    margin-left: 0;
}

.player-hand .card:hover {
    transform: translateY(-35px) scale(1.12) !important;
    z-index: 100;
    margin: 0 15px;
    box-shadow:
        0 0 25px rgba(212, 175, 55, 0.6),
        0 10px 30px rgba(0, 0, 0, 0.5);
}

.my-character-name {
    font-size: 0.9rem;
    color: var(--accent-purple);
    font-weight: 600;
    margin-bottom: 4px;
}

.my-level {
    display: flex;
    align-items: center;
    gap: 6px;
}

.level-icon {
    font-size: 1.1rem;
}

.level-value {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.my-skill-info {
    padding: 10px 12px;
    background: rgba(155, 89, 182, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--accent-purple);
    margin-bottom: 10px;
}

.my-skill-info.used {
    opacity: 0.6;
    border-left-color: var(--text-muted);
}

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

.skill-type-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: rgba(155, 89, 182, 0.2);
    border-radius: 10px;
    color: var(--accent-purple);
}

.skill-status {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.my-skill-info.available .skill-status {
    color: var(--accent-green);
}

.my-skill-info.used .skill-status {
    color: var(--text-muted);
}

.my-skill-info .skill-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 4px;
}

.my-skill-info .skill-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.turn-status {
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
}

.turn-status.your-turn {
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.2), rgba(231, 76, 60, 0.1));
    color: var(--accent-gold);
    animation: turnPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 15px rgba(243, 156, 18, 0.3);
}

.dashboard-center {
    flex: 1;
    display: flex;
    justify-content: center;
    overflow: visible;
}

.player-hand {
    display: flex;
    justify-content: center;
    gap: -40px;
    /* Overlap cards */
    height: 180px;
    /* Fixed height for hand */
    align-items: flex-end;
    padding-bottom: 10px;
}

/* --- Cards in Hand --- */
.player-hand .card {
    margin-left: -40px;
    /* Significant overlap */
    transition: transform 0.2s ease, margin 0.2s ease;
    transform-origin: bottom center;
}

.player-hand .card:first-child {
    margin-left: 0;
}

.player-hand .card:hover {
    transform: translateY(-35px) scale(1.12) !important;
    z-index: 100;
    margin: 0 15px;
    box-shadow:
        0 0 25px rgba(212, 175, 55, 0.6),
        0 10px 30px rgba(0, 0, 0, 0.5);
}

.dashboard-right {
    width: 150px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-bottom: 30px;
}

@keyframes gradientShift {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.tagline {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.lobby-card {
    padding: 40px;
    animation: fadeInUp 0.8s ease;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95), rgba(13, 13, 13, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.lobby-card::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 17px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.4), rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.4));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

@keyframes floatSubtle {

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

    50% {
        transform: translateY(-8px);
    }
}

.lobby-card h2 {
    margin-bottom: 30px;
    font-size: 1.8rem;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(243, 156, 18, 0.3);
}

.player-count-selector {
    margin-bottom: 30px;
}

.player-count-selector label {
    display: block;
    margin-bottom: 15px;
    font-weight: 600;
    color: var(--text-secondary);
}

.number-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.num-btn {
    flex: 1;
    min-width: 50px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.num-btn:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.num-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    box-shadow: 0 0 20px rgba(74, 144, 226, 0.5);
}

.help-text {
    margin-top: 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.player-setup-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.player-setup-item {
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    display: flex;
    gap: 15px;
    align-items: center;
}

.player-setup-item input {
    flex: 1;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.player-setup-item select {
    flex: 1.5;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
}

/* ====== BUTTONS ====== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn:hover::after {
    opacity: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px rgba(74, 144, 226, 0.6),
        0 0 40px rgba(155, 89, 182, 0.4);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    border-color: var(--accent-blue);
    transform: translateY(-3px);
    box-shadow: 0 4px 20px rgba(74, 144, 226, 0.3);
}

.btn-secondary:active {
    transform: translateY(-1px);
}

/* Quick Match accent button */
.btn-accent {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: 2px solid #fbbf24;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

.btn-accent:hover {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 8px 30px rgba(245, 158, 11, 0.6);
    transform: translateY(-3px) scale(1.02);
}

.btn-accent:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-large {
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-skill {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-gold));
    color: white;
}

.btn-skill:hover {
    box-shadow: 0 4px 25px rgba(155, 89, 182, 0.5),
        0 0 30px rgba(243, 156, 18, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* ====== GAME SCREEN ====== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 20px;
}

.header-left h2 {
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.turn-indicator {
    display: flex;
    gap: 10px;
    align-items: center;
}

#current-player-indicator {
    font-weight: 600;
}

.your-turn-highlight {
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
    animation: turnPulse 1.5s ease-in-out infinite;
}

@keyframes turnPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.phase-badge {
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.4s ease;
    box-shadow: 0 2px 10px rgba(74, 144, 226, 0.3);
}

.header-right {
    display: flex;
    gap: 10px;
}

/* Player Boards */
.player-boards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.player-board {
    padding: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 2px solid var(--glass-border);
    border-radius: 12px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.player-board.active-player {
    border-color: var(--accent-gold);
    box-shadow: 0 0 30px rgba(243, 156, 18, 0.4),
        0 0 60px rgba(243, 156, 18, 0.2);
    animation: activePlayerPulse 2s ease-in-out infinite;
}

@keyframes activePlayerPulse {

    0%,
    100% {
        box-shadow: 0 0 30px rgba(243, 156, 18, 0.4), 0 0 60px rgba(243, 156, 18, 0.2);
    }

    50% {
        box-shadow: 0 0 40px rgba(243, 156, 18, 0.6), 0 0 80px rgba(243, 156, 18, 0.3);
    }
}

.player-board.my-board {
    border-color: var(--accent-green);
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.1), var(--glass-bg));
}

.player-board.my-board.active-player {
    border-color: var(--accent-gold);
    background: linear-gradient(135deg, rgba(243, 156, 18, 0.15), rgba(46, 204, 113, 0.1));
}

.player-board-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.character-image {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    object-fit: cover;
    object-position: top;
    border: 3px solid var(--accent-gold);
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4), 0 0 20px rgba(243, 156, 18, 0.2);
    flex-shrink: 0;
    margin-right: 15px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.character-image:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(243, 156, 18, 0.5), 0 0 30px rgba(243, 156, 18, 0.3);
}

.player-info h3 {
    font-size: 1.3rem;
    margin-bottom: 6px;
    font-weight: 700;
}

.character-name {
    font-size: 1rem;
    color: var(--accent-purple);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(155, 89, 182, 0.3);
    margin-bottom: 4px;
}

.character-skill {
    font-size: 0.85rem;
    color: var(--accent-gold);
    font-weight: 600;
    font-style: italic;
    margin-bottom: 4px;
}

.character-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    border-left: 3px solid var(--accent-purple);
    margin-top: 8px;
}

.level-display {
    text-align: right;
}

.level-number {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent-gold), var(--accent-red));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.level-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.player-stats {
    display: flex;
    gap: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Player Hand */
.player-hand-section {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
}

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

.hand-actions {
    display: flex;
    gap: 10px;
}

.player-hand {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    min-height: 200px;
}

/* Cards */
.card {
    width: 140px;
    height: 200px;
    background: white;
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to bottom right,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0) 40%,
            rgba(255, 255, 255, 0.4) 50%,
            rgba(255, 255, 255, 0) 60%,
            rgba(255, 255, 255, 0) 100%);
    transform: rotate(45deg) translateY(100%);
    transition: transform 0.6s ease;
    pointer-events: none;
}

.card:hover::before {
    transform: rotate(45deg) translateY(-100%);
}

.card:hover {
    transform: translateY(-12px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
}

.card.selected {
    transform: translateY(-15px) scale(1.08);
    box-shadow: 0 0 40px var(--accent-gold),
        0 0 80px rgba(243, 156, 18, 0.4);
    border: 3px solid var(--accent-gold);
    animation: selectedPulse 1.5s ease-in-out infinite;
}

@keyframes selectedPulse {

    0%,
    100% {
        box-shadow: 0 0 40px var(--accent-gold), 0 0 80px rgba(243, 156, 18, 0.4);
    }

    50% {
        box-shadow: 0 0 50px var(--accent-gold), 0 0 100px rgba(243, 156, 18, 0.5);
    }
}

.card.playable {
    animation: playableHint 2s ease-in-out infinite;
}

@keyframes playableHint {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }

    50% {
        box-shadow: 0 4px 20px rgba(74, 144, 226, 0.4), 0 0 15px rgba(74, 144, 226, 0.2);
    }
}

.card-suit {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.card-rank {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.card-type {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    flex-grow: 1;
}

.card-effect {
    font-size: 0.75rem;
    color: #666;
    margin-top: auto;
}

.card.hearts {
    border-left: 4px solid var(--hearts);
    color: var(--hearts);
}

.card.diamonds {
    border-left: 4px solid var(--diamonds);
    color: var(--diamonds);
}

.card.clubs {
    border-left: 4px solid var(--clubs);
    color: var(--clubs);
}

.card.spades {
    border-left: 4px solid var(--spades);
    color: var(--spades);
}

.card.joker {
    border-left: 4px solid var(--joker);
    color: var(--joker);
    background: linear-gradient(135deg, #fff, #f3e5f5);
}

.card.image-card {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 2px solid var(--glass-border);
}

.card-effect-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px;
    font-size: 0.75rem;
    text-align: center;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    backdrop-filter: blur(4px);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 40px;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }

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

.modal-content h2 {
    margin-bottom: 15px;
    color: var(--accent-gold);
}

.target-player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.target-player-btn {
    padding: 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.target-player-btn:hover {
    border-color: var(--accent-blue);
    transform: translateX(5px);
}

.target-player-btn.selected {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
}

.target-player-name {
    font-weight: 700;
    font-size: 1.1rem;
}

.target-player-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Action Log */
.action-log-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--glass-border);
    transition: right 0.3s ease;
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.action-log-panel.active {
    right: 0;
}

.log-header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.action-log-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}



/* Vote Buttons */
.vote-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
}

.btn-vote {
    flex: 1;
    padding: 20px;
    font-size: 1.1rem;
}

.btn-vote-yes {
    background: var(--accent-green);
    color: white;
}

.btn-vote-no {
    background: var(--accent-red);
    color: white;
}

/* Win Screen */
.win-screen {
    text-align: center;
}

.win-screen h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

.winner-text {
    font-size: 1.5rem;
    margin-bottom: 30px;
    color: var(--accent-gold);
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

@keyframes bounce {

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

    50% {
        transform: translateY(-10px);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-logo h1 {
        font-size: 2.5rem;
    }

    .player-boards {
        grid-template-columns: 1fr;
    }

    .card {
        width: 120px;
        height: 170px;
    }

    .action-log-panel {
        width: 100%;
        right: -100%;
    }

    .modal-content {
        padding: 20px;
    }
}

/* Card Selection in Modals */
.card-select-list {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 20px 0;
}

.card-select-item {
    position: relative;
}

.card-checkbox {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    cursor: pointer;
}

/* ====== ONLINE MULTIPLAYER STYLES ====== */

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: pulse 2s infinite;
}

.connection-status.connected .status-dot {
    background: var(--accent-green);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Lobby Options */
.lobby-options {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.divider {
    text-align: center;
    position: relative;
    margin: 10px 0;
}

.divider span {
    background: var(--bg-tertiary);
    padding: 0 15px;
    color: var(--text-muted);
    position: relative;
    z-index: 1;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--glass-border);
}

.join-room-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#room-code-input {
    width: 100%;
    padding: 15px;
    background: var(--bg-secondary);
    border: 2px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.2rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
}

#room-code-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

/* Room Info */
.room-info {
    margin-bottom: 30px;
}

.room-code-display {
    text-align: center;
}

.room-code-display label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.code-container {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.room-code {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 5px;
    color: var(--accent-gold);
    background: var(--bg-tertiary);
    padding: 15px 30px;
    border-radius: 10px;
    border: 2px solid var(--accent-gold);
}

/* Player List */
.player-list-section {
    margin-bottom: 30px;
}

.player-list-section h3 {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.online-player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.player-list-item {
    padding: 15px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

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

.player-list-item.host {
    border-color: var(--accent-gold);
    background: rgba(243, 156, 18, 0.1);
}

.player-list-item.disconnected {
    opacity: 0.5;
}

.player-list-name {
    font-weight: 600;
    color: var(--text-primary);
}

.player-list-badge {
    padding: 4px 12px;
    background: var(--accent-gold);
    color: var(--bg-primary);
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.player-list-status {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Lobby Actions */
.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 30px;
}

/* Waiting State */
.waiting-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.waiting-overlay.active {
    display: flex;
}

.waiting-content {
    text-align: center;
    padding: 40px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
}

.waiting-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.waiting-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Hidden Card (for other players' hands) */
.card.hidden {
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
    border: 2px dashed var(--glass-border);
    cursor: not-allowed;
}

.card.hidden * {
    display: none;
}

.card.hidden::after {
    content: '🂠';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    opacity: 0.3;
}

/* =========================================
   MOBILE RESPONSIVE REDESIGN
   ========================================= */

/* Mobile-specific variables */
:root {
    --mobile-header-height: 60px;
    --bottom-sheet-peek: 70px;
}

/* Base Mobile Adjustments */
@media (max-width: 768px) {
    body {
        /* Prevent elastic scrolling on mobile */
        overscroll-behavior-y: none;
    }

    /* --- LOBBY MOBILE --- */
    .lobby-container {
        padding: 10px;
        width: 100%;
    }

    .game-logo h1 {
        font-size: 2rem;
        letter-spacing: 2px;
    }

    .logo-image {
        width: 100px;
        height: 100px;
    }

    .lobby-card {
        padding: 20px;
        margin-bottom: 20px;
    }

    .lobby-options {
        gap: 15px;
    }

    .btn-large {
        padding: 15px;
        font-size: 1.1rem;
    }

    #room-code-input {
        font-size: 1.5rem;
    }

    /* --- GAME LAYOUT MOBILE --- */
    #game-screen {
        grid-template-rows: var(--mobile-header-height) 1fr;
        height: 100vh;
        height: 100dvh;
        /* Dynamic viewport height */
        overflow: hidden;
    }

    /* Header */
    .game-header-bar {
        grid-template-columns: auto 1fr auto;
        padding: 10px 15px;
        min-height: var(--mobile-header-height);
        background: rgba(13, 13, 13, 0.95);
        z-index: 50;
        border-bottom: 1px solid var(--glass-border);
    }

    /* Hide standard desktop elements in header */
    .header-center {
        display: none;
        /* Move opponents to drawer */
    }

    /* Mobile Hamburger / Opponent Toggle */
    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid var(--glass-border);
        border-radius: 8px;
        color: var(--accent-gold);
        font-size: 1.2rem;
        cursor: pointer;
    }

    .audio-controls {
        position: static;
        margin-left: auto;
        padding: 0;
    }

    .volume-control {
        display: none;
        /* Hide slider on mobile */
    }

    /* Game Content - Stacked */
    .game-content {
        grid-template-columns: 1fr;
        position: relative;
        overflow: hidden;
        height: 100%;
        display: block;
    }

    /* Sidebar - Transform to Bottom Sheet */
    .character-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 90vh;
        /* Max expansion height */
        z-index: 900;
        background: linear-gradient(180deg, #1a1a1a 0%, #0d0d0d 100%);
        border-right: none;
        border-top: 1px solid var(--accent-gold);
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
        box-shadow: 0 -5px 30px rgba(0, 0, 0, 0.7);
        transform: translateY(calc(100% - var(--bottom-sheet-peek)));
        /* Peek state */
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
        padding: 0;
        display: flex;
        flex-direction: column;
        overflow: visible;
    }

    .character-sidebar.open {
        transform: translateY(0);
    }

    /* Drag Handle for Bottom Sheet */
    .sheet-handle {
        width: 100%;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
        background: rgba(255, 255, 255, 0.05);
        border-top-left-radius: 20px;
        border-top-right-radius: 20px;
    }

    .sheet-handle::after {
        content: '';
        width: 40px;
        height: 5px;
        background: rgba(255, 255, 255, 0.3);
        border-radius: 3px;
    }

    /* Mobile Peek Summary (visible when sheet is closed) */
    .mobile-player-summary {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px;
        height: 40px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .mobile-player-summary-info {
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .mobile-player-summary .name {
        font-weight: 700;
        color: var(--accent-gold);
    }

    .mobile-player-summary .level {
        background: var(--accent-red);
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 0.8rem;
        font-weight: bold;
    }

    /* Sidebar content content adjustments */
    .character-panel {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 10px 20px;
        overflow-y: auto;
        flex: 1;
    }

    .character-portrait {
        width: 120px;
        margin: 0 auto 10px;
    }

    .sidebar-actions {
        padding: 20px;
        background: #0d0d0d;
        border-top: 1px solid var(--glass-border);
        margin-top: auto;
    }

    /* Play Area */
    .main-game-area {
        height: calc(100% - var(--bottom-sheet-peek));
        width: 100%;
        position: relative;
    }

    .play-area {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
        height: 50%;
        /* Top half of screen */
    }

    .play-message {
        padding: 15px 20px;
        max-width: 95%;
    }

    #phase-indicator {
        font-size: 1.2rem;
        letter-spacing: 1px;
    }

    #turn-indicator {
        font-size: 0.9rem;
    }

    /* Hand Container - Horizontal Scroll */
    .hand-container {
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 100%;
        height: 45%;
        /* Bottom half of game area */
        padding: 10px 0;
        background: transparent;
        border: none;
        overflow: hidden;
        z-index: 50;
    }

    .player-hand {
        width: 100%;
        height: 100%;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        padding: 20px 20px 40px 20px;
        /* Padding for scroll and pop-up */
        gap: 0;
        -webkit-overflow-scrolling: touch;
    }

    .player-hand::-webkit-scrollbar {
        display: none;
    }

    .player-hand .card {
        width: 100px;
        height: 140px;
        flex-shrink: 0;
        margin-left: -30px;
        /* Overlap */
        transition: transform 0.2s ease, margin 0.2s ease;
    }

    .player-hand .card:first-child {
        margin-left: 0;
    }

    /* On mobile, tap to "focus" (pop up) */
    .player-hand .card.focused,
    .player-hand .card:active {
        transform: translateY(-30px) scale(1.1) !important;
        z-index: 1000;
        margin: 0 15px;
    }

    /* Opponent Drawer (Top) */
    .opponent-drawer {
        display: block !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(13, 13, 13, 0.98);
        z-index: 2000;
        padding: 80px 20px 20px;
        transform: translateY(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    }

    .opponent-drawer.open {
        transform: translateY(0);
    }

    .opponent-drawer-close {
        position: absolute;
        top: 20px;
        right: 20px;
        font-size: 2rem;
        color: var(--accent-gold);
        background: none;
        border: none;
    }

    .opponent-drawer-title {
        position: absolute;
        top: 30px;
        left: 20px;
        font-size: 1.5rem;
        color: var(--text-primary);
        font-weight: bold;
    }

    /* Stack opponents in drawer */
    .opponent-drawer .opponents-row {
        flex-direction: column;
        gap: 15px;
        max-height: 100%;
        overflow-y: auto;
        padding-bottom: 50px;
    }

    .opponent-board {
        width: 100%;
        padding: 15px;
    }

    /* Modals - Full Screen */
    .modal-content {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        padding: 20px;
    }

    .card-select-list {
        flex: 1;
        overflow-y: auto;
        justify-content: flex-start;
    }
}

/* Utilities for JS toggling */
.mobile-hidden {
    display: none !important;
}

.mobile-visible {
    display: none;
}

@media (max-width: 768px) {
    .mobile-visible {
        display: block;
    }

    .desktop-only {
        display: none !important;
    }
}

/* Expandable Hand Drawer - Override previous mobile hand styles */
@media (max-width: 768px) {
    .hand-container {
        height: 70px !important;
        /* Collapsed default */
        padding: 10px 0 !important;
        pointer-events: auto !important;
        transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
        cursor: pointer;
    }

    .hand-container.expanded {
        height: 220px !important;
        padding: 40px 0 10px !important;
        cursor: default;
    }

    /* Toggle Handle Styles */
    .hand-toggle-handle {
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 50px;
        height: 5px;
        background: rgba(255, 255, 255, 0.4);
        border-radius: 3px;
        pointer-events: none;
    }

    /* Card peek mode when collapsed */
    .hand-container:not(.expanded) .player-hand {
        overflow: hidden;
    }

    .hand-container:not(.expanded) .card {
        transform: translateY(calc(100% - 50px)) !important;
    }

    /* When expanded, reset card transforms for full visibility */
    .hand-container.expanded .card:not(.focused) {
        transform: translateY(0) !important;
    }
}

/* --- MOBILE LANDSCAPE REFACTOR --- */
@media (max-width: 932px) and (orientation: landscape) {

    /* 1. Reset Global Mobile Grid */
    #game-screen {
        /* Rows: Top Bar (Compact), Main Area (Play + Hand) */
        grid-template-rows: 50px 1fr !important;
        grid-template-columns: 1fr;
    }

    /* 2. Header / Top Bar */
    .game-header-bar {
        min-height: 50px;
        padding: 0 10px;
        grid-template-columns: 1fr auto !important;
        /* Opponents, Audio */
    }

    /* Show Opponents in Header (Hide Drawer Toggle) */
    .mobile-menu-btn {
        display: none !important;
    }

    .desktop-only {
        display: flex !important;
        /* Force show opponents */
    }

    .header-center {
        display: flex !important;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        align-items: center;
    }

    .opponents-row {
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 0;
        gap: 8px;
    }

    .opponent-board {
        width: auto;
        padding: 4px 10px;
        min-width: 110px;
        height: 42px;
        background: rgba(26, 26, 26, 0.8);
        border: 1px solid var(--glass-border);
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .opp-avatar-container {
        width: 30px;
        height: 30px;
    }

    .opp-avatar {
        width: 30px;
        height: 30px;
        border-width: 1px;
    }

    .opp-info {
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .opp-name {
        font-size: 0.8rem;
        margin-bottom: 0;
    }

    .opp-stats {
        display: flex;
        font-size: 0.7rem;
        gap: 5px;
    }

    .opp-skill {
        display: none !important;
    }

    /* Hide the specific drawer element if it exists */
    .opponent-drawer {
        display: none !important;
    }

    /* 3. Main Game Area */
    .game-content {
        grid-template-columns: 1fr !important;
        /* No Sidebar Column in Grid */
        display: flex;
        flex-direction: column;
    }

    /* 4. Character Info - Floating Transparent Overlay top-left */
    .character-sidebar {
        position: absolute;
        top: 60px;
        left: 20px;
        /* Safe area */
        width: 160px;
        height: auto;
        max-height: calc(100% - 150px);
        background: rgba(13, 13, 13, 0.7);
        border: 1px solid var(--glass-border);
        border-radius: 12px;
        z-index: 100;
        transform: none !important;
        /* Reset bottom sheet transform */
        bottom: auto;
        padding: 10px;
        display: flex;
        flex-direction: column;
        gap: 5px;
        box-shadow: none;
        backdrop-filter: blur(4px);
    }

    .mobile-player-summary {
        display: none !important;
    }

    .sheet-handle {
        display: none !important;
    }

    .character-panel {
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }

    .character-portrait {
        width: 60px;
        margin-bottom: 5px;
        border-width: 2px;
        display: block;
        margin-left: auto;
        margin-right: auto;
    }

    .character-details {
        margin-bottom: 5px;
    }

    .character-player-name {
        font-size: 0.9rem;
    }

    .character-name {
        font-size: 0.85rem;
    }

    .character-level {
        padding: 2px 8px;
    }

    .level-value {
        font-size: 1rem;
    }

    .skill-box {
        display: none;
        /* Hide skill details to save space */
    }

    .sidebar-actions {
        padding: 5px 0;
        background: transparent;
        border: none;
        margin-top: 5px;
        flex-direction: column;
        gap: 5px;
    }

    .btn-block {
        padding: 8px;
        font-size: 0.8rem;
    }

    /* 5. Play Area & Hand */
    .main-game-area {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .play-area {
        flex: 1;
        height: auto;
        padding: 10px 10px 10px 180px;
        /* Padding left to avoid sidebar overlay */
        align-items: center;
        justify-content: center;
    }

    .active-play-zone {
        transform: scale(0.9);
        width: 100%;
        max-width: 600px;
    }

    .play-message {
        padding: 15px 25px;
    }

    #phase-indicator {
        font-size: 1.4rem;
    }

    /* Hand Container */
    .hand-container {
        height: 120px !important;
        /* Fixed height for landscape */
        padding: 5px 0 !important;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.4));
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        position: relative;
        cursor: default !important;
        /* Disable expand pointer */
    }

    .hand-container.expanded {
        height: 120px !important;
        /* Cannot expand in landscape */
        padding: 5px 0 !important;
    }

    .player-hand {
        padding: 10px 20px 10px 20px;
        align-items: flex-end;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .card {
        width: 80px;
        height: 112px;
        margin-left: -20px;
        transform: none !important;
        /* Reset the hiding transform from vertical mobile */
    }

    .hand-container:not(.expanded) .player-hand {
        overflow: visible;
        /* Allow popups */
    }

    .hand-container:not(.expanded) .card {
        transform: none !important;
    }

    .hand-toggle-handle {
        display: none;
    }
}