* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

:root {
    --primary: #B31B1B;
    --primary-dark: #800000;
    --secondary: #2a2a2e;
    --accent: #FFD700;
    --text: #F0F0F0;
    --bg: #121212;
    --panel: #1E1E1E;
    --border: #444;
    --rarity-0: #cccccc;
    --rarity-00: #B22222;
    --rarity-000: #FFD700;
    --sin-wrath-bg: rgba(129,44,33,255);
    --sin-lust-bg: rgba(177,97,46,255);
    --sin-sloth-bg: rgba(226,136,3,255);
    --sin-gluttony-bg: rgba(106, 190, 48, 255);
    --sin-gloom-bg: rgba(45,102,116,255);
    --sin-pride-bg: rgba(22,81,131,255);
    --sin-envy-bg: rgba(128, 0, 128, 255);
    --connected: #4caf50;
    --disconnected: #f44336;
    --warning: #ff9800;
    --ready: #4caf50;
    --drafting: #2196F3;
    --hover: #ffeb3b;
}

body {
    background-color: var(--bg);
    background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.05) 1px, transparent 0);
    background-size: 20px 20px;
    color: var(--text);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}
.hidden {
    display: none !important;
}
header {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 20px;
    position: relative;
}

h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 10px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo {
    width: 50px;
    height: auto;
    vertical-align: middle;
    margin-right: 15px;
    margin-bottom: 8px;
}

p {
    color: #aaa;
    font-size: 1.1rem;
}

h2 {
    font-size: 2.2rem;
    font-weight: 700;
    margin: 20px 0;
    color: var(--accent);
    border-bottom: 1px solid var(--accent);
    padding-bottom: 10px;
    text-align: center;
}

h3 {
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 15px;
}

h4 {
    font-size: 1.2rem;
    color: #ccc;
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    padding-bottom: 5px;
}

.card {
    background: rgba(20, 20, 22, 0.7);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn {
    padding: 15px 30px;
    border: 2px solid transparent;
    border-radius: 8px;
    background-image: linear-gradient(45deg, var(--primary-dark), var(--primary));
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    background-image: linear-gradient(45deg, var(--primary), #ff4d4d);
}

.btn:disabled {
    background: #444;
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-primary {
    background-image: linear-gradient(45deg, #FFC107, var(--accent));
    color: #000;
}

.btn-primary:hover:not(:disabled) {
    background-image: linear-gradient(45deg, var(--accent), #fff200);
}

.btn-secondary {
    background-image: linear-gradient(45deg, #333, #555);
}
.btn-secondary:hover:not(:disabled) {
    background-image: linear-gradient(45deg, #444, #666);
}

.btn-large {
    padding: 18px 35px;
    font-size: 1.3rem;
}

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

#main-page {
    text-align: center;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.top-left-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.korean-toggle-container {
    background: rgba(30, 30, 30, 0.8);
    border-radius: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.korean-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
    margin: 0;
}

.korean-toggle-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.korean-toggle-text {
    user-select: none;
    white-space: nowrap;
}


.logo {
    width: 150px;
    height: 150px;
    margin: 0 auto 20px;
    background: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    animation: none;
}

.logo img {
    max-width: 100%;
    height: auto;
    /* Remove glow effect from logo */
    animation: none;
}

.welcome-text {
    font-size: 1.2rem;
    line-height: 1.8;
    margin-bottom: 40px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.action-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.action-card {
    background: var(--panel);
    border-radius: 15px;
    padding: 30px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    overflow: hidden;
}

.action-card:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.4s ease-in-out;
    transform-origin: left;
}

.action-card:hover:before {
    transform: scaleX(1);
}

.action-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.action-icon {
    font-size: 3rem;
    color: var(--accent);
}

.action-title {
    font-size: 1.6rem;
    color: var(--text);
}

.action-description {
    font-size: 1rem;
    line-height: 1.6;
    flex-grow: 1;
    color: #aaa;
}

.lobby-options {
    background: rgba(0,0,0,0.2);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
}

.lobby-access {
    background: rgba(30,30,30,0.8);
    border-radius: 15px;
    padding: 30px;
    margin: 40px auto;
    max-width: 600px;
    border: 1px solid var(--accent);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.2);
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 1rem;
    color: #ccc;
    text-transform: uppercase;
    letter-spacing: 1px;
}

input, select {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    background: #111;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 1.1rem;
    transition: all 0.2s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
}

.role-options {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.role-option {
    flex: 1;
    text-align: center;
    padding: 15px;
    background: #222;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.role-option.selected {
    background: var(--primary);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.role-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #111;
}

.btn-ready {
    background-image: linear-gradient(45deg, #1D976C, #93F9B9) !important;
    color: black !important;
}

.btn-ready:disabled {
    opacity: 0.8;
}

.status-ready {
    background: var(--ready) !important;
}
.lobby-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    align-items: center;
    gap: 20px;
    background: var(--secondary);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    position: relative;
    border: 1px solid var(--border);
}

.lobby-info > div {
    text-align: center;
}

.timer-display {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent);
    padding: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    margin-top: 10px;
    min-width: 140px;
    text-align: center;
    transition: all 0.3s ease;
}

.timer-display.reserve-active {
    color: var(--warning);
    animation: pulse-warning 1.5s infinite;
}

.draft-player-column.draft-active, .draft-interaction-hub.draft-active {
    box-shadow: 0 0 25px var(--accent);
    border: 2px solid var(--accent);
    transform: scale(1.01);
}

/* Red shine for draft-active elements during ban phases */
.draft-ban-phase .draft-player-column.draft-active, 
.draft-ban-phase .draft-interaction-hub.draft-active {
    box-shadow: 0 0 25px var(--primary);
    border: 2px solid var(--primary);
}

/* Your Side Indicator */
.your-side-indicator {
    color: var(--accent);
    font-size: 0.9rem;
    margin-left: 8px;
    animation: gentle-pulse 2s infinite;
}

@keyframes gentle-pulse {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1);
    }
    50% { 
        opacity: 0.7; 
        transform: scale(1.1);
    }
}

@keyframes selection-glow {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
}

@keyframes selection-glow-red {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(179, 27, 27, 0.6);
    }
    50% { 
        box-shadow: 0 0 20px rgba(179, 27, 27, 0.8);
    }
}

/* Enhanced turn indication with stronger glow effect */
.draft-player-column.draft-active {
    animation: active-glow 1.5s ease-in-out infinite alternate;
}

/* Red animated glow for draft-active elements during ban phases */
.draft-ban-phase .draft-player-column.draft-active {
    animation: active-glow-red 1.5s ease-in-out infinite alternate;
}

@keyframes active-glow {
    0% { 
        box-shadow: 0 0 25px var(--accent);
        border: 2px solid var(--accent);
    }
    100% { 
        box-shadow: 0 0 35px var(--accent), 0 0 60px rgba(255, 140, 0, 0.3);
        border: 2px solid var(--accent);
    }
}

@keyframes active-glow-red {
    0% { 
        box-shadow: 0 0 25px var(--primary);
        border: 2px solid var(--primary);
    }
    100% { 
        box-shadow: 0 0 35px var(--primary), 0 0 60px rgba(179, 27, 27, 0.3);
        border: 2px solid var(--primary);
    }
}
.role-option i {
    font-size: 2rem;
    margin-bottom: 10px;
    color: var(--accent);
}

.participant.current-user {
    background: var(--primary-dark);
    border: 2px solid var(--accent);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

#lobby-view, #roster-builder-page {
    display: none;
}

.code-display {
    font-family: monospace;
    font-size: 2rem;
    letter-spacing: 6px;
    padding: 12px 25px;
    background: #000;
    border-radius: 8px;
    color: var(--accent);
    border: 1px solid var(--accent);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
    transition: filter 0.3s ease;
    user-select: none; /* Make non-selectable */
    cursor: pointer; /* Show it's clickable */
}

.code-display:hover {
    background: #1a1a1a;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4);
}

.code-display.hidden {
    filter: blur(6px);
    user-select: none;
}

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

#toggle-code-visibility {
    padding: 10px 12px;
}


.participants {
    display: flex;
    gap: 15px;
    font-size: 1.1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.participant {
    background: #333;
    padding: 10px 20px;
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.3s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.participant:hover {
    transform: translateY(-5px);
}

.back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
}

.phase-section {
    flex: 1;
    min-width: 300px;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4); filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4)); }
    70% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.7)); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.4)); }
}

@keyframes pulse-warning {
    0% { box-shadow: 0 0 5px 0px var(--warning); }
    50% { box-shadow: 0 0 15px 5px var(--warning); }
    100% { box-shadow: 0 0 5px 0px var(--warning); }
}

.player-area {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.player-panel {
    flex: 1;
    min-width: 280px;
    background: var(--secondary);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    position: relative;
}

.player-panel.locked::after {
    content: 'LOCKED';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--accent);
    font-weight: bold;
    z-index: 5;
    border-radius: 10px;
    backdrop-filter: blur(2px);
}


.controls {
    display: flex;
    justify-content: space-around; 
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    position: relative; /* keep buttons above locked overlay */
    z-index: 6;       /* keep buttons above locked overlay */
    flex-wrap: wrap;  /* prevent buttons from overflowing container */
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.player-name {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent);
}

.player-status {
    background: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
}

/* Compact Pick/Ban List */
.compact-id-list {
    margin: 10px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fill, 100px);
    gap: 8px;
    min-height: 90px;
    align-content: start;
    max-height: 40vh;
    overflow-y: auto;
    justify-content: center;
}

.compact-id-list.section2-picks {
    border: 2px dashed var(--accent);
    background: rgba(255, 215, 0, 0.05);
}

.compact-id-list .id-item {
    padding: 0;
    background: transparent;
    border: none;
    cursor: default;
    width: 100px; /* Constrain item to grid column size */
    max-width: 100px; /* Prevent expansion */
}
.compact-id-list .id-item .id-name {
    display: none;
}
.compact-id-list .id-item .id-icon {
    width: 100%; /* Fill the container completely */
    height: 100%; /* Fill the container completely */
    aspect-ratio: 1 / 1;
    border-radius: 6px; /* Slightly smaller than container */
    border: none; /* Border handled by container */
    max-width: none; /* Remove constraints to fill container */
    object-fit: cover; /* Ensure image fits properly */
    transition: all 0.2s ease;
}

.id-item {
    position: relative;
    padding: 0; /* Remove padding so image fills container */
    margin: 0;
    background: transparent; /* No background since we're going image-only */
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 0; /* Remove gap for image-only layout */
    cursor: pointer;
    transition: all 0.3s, border-color 0.3s;
    border: 2px solid var(--border); /* Default border for all items */
    width: 100px; /* Match image size */
    height: 100px; /* Match image size */
    overflow: hidden; /* Ensure clean borders */
}

/* Hide ID names by default - show only images */
.id-item .id-name {
    display: none;
}

/* ID icons get consistent sizing */
.id-item .id-icon {
    width: 100%;
    height: 100%;
    border-radius: 6px; /* Slightly smaller radius than container */
    border: none; /* Remove border since container handles it */
    object-fit: cover;
    transition: transform 0.2s ease;
}

.id-item.rarity-0 { border-left-color: var(--rarity-0); }
.id-item.rarity-00 { border-left-color: var(--rarity-00); }
.id-item.rarity-000 { border-left-color: var(--rarity-000); }

.id-item:hover {
    transform: scale(1.05);
}

/* === SIMPLE HOVER SYSTEM === */
/* All ID items now use consistent image-only layout with scale hover */
.id-item:hover,
.id-item.hovered {
    transform: scale(1.05);
}

/* Selected ID items get a prominent gold border by default */
.id-item.selected {
    border: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); /* Gold glow effect */
    animation: selection-glow 2s ease-in-out infinite; /* Animated glow */
    position: relative;
    z-index: 2; /* Ensure glow appears above adjacent items */
}

/* Draft phase specific border colors */
.draft-ban-phase .id-item.selected {
    border: 3px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(179, 27, 27, 0.6); /* Red glow effect */
    animation: selection-glow-red 2s ease-in-out infinite; /* Animated red glow */
    position: relative;
    z-index: 2;
}

.draft-pick-phase .id-item.selected {
    border: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); /* Gold glow effect */
    animation: selection-glow 2s ease-in-out infinite; /* Animated glow */
    position: relative;
    z-index: 2;
}

/* Compact contexts - maintain existing scale effect */
.compact-id-list .id-item:hover .id-icon,
.compact-id-list .id-item.hovered .id-icon {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Final picks/bans - maintain existing scale effect */
.final-picks .id-item:hover .id-icon,
.final-picks .id-item.hovered .id-icon,
.final-bans .id-item:hover .id-icon,
.final-bans .id-item.hovered .id-icon {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Sinner grouped roster - maintain existing scale effect */
.sinner-grouped-roster .id-item:hover,
.sinner-grouped-roster .id-item.hovered {
    transform: scale(1.05);
    z-index: 2;
    transition: transform 0.2s ease;
}

/* Disable conflicting transforms for compact contexts */
.compact-id-list .id-item:hover,
.final-picks .id-item:hover,
.final-bans .id-item:hover,
.compact-id-list .id-item.hovered,
.final-picks .id-item.hovered,
.final-bans .id-item.hovered {
    transform: none !important;
}

.shared-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0.85;
    z-index: 2;
    border: 1px solid #fff;
}

.id-icon {
    width: 100%;
    height: 100%;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: none; /* Border handled by container */
    /* Subtle inner/outer shadow to give images a carded feel */
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05), 0 0 6px rgba(0,0,0,0.45);
}

.id-name {
    flex-grow: 1;
    font-size: 0.95rem;
    font-weight: 500;
    min-height: 2.5em; 
    display: flex;
    align-items: center;
    line-height: 1.25;
    /* Keep single-line with ellipsis to avoid height jumps */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.roster-selection {
    display: grid;
    grid-template-columns: repeat(auto-fill, 100px); /* Fixed width for image-only layout */
    gap: 8px;
    margin-top: 15px;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    justify-content: center; /* Center the grid */
}

.counter {
    text-align: center;
    margin: 10px 0;
    font-size: 1.1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.counter strong {
    color: var(--accent);
    font-size: 1.3rem;
}

.roster-complete {
    background: rgba(0, 100, 0, 0.3);
    padding: 10px;
    border-radius: 5px;
    text-align: center;
    margin-top: 10px;
    font-weight: bold;
    border: 1px solid rgba(0, 200, 0, 0.3);
}

.status-ready { background: var(--ready) !important; color: #fff !important; }
.status-drafting { background: var(--drafting) !important; color: #fff !important; }
.status-waiting { background: #a0a0a0 !important; color: #fff !important; }

.connection-status {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    color: #000;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    background: var(--disconnected);
    transition: background-color 0.3s;
}
.connection-status.connecting { background: var(--warning); }
.connection-status.connected { background: var(--connected); }


.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    background: var(--primary);
    border-radius: 8px;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    max-width: 90%;
    text-align: center;
}

.notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(10px);
}

#completed-view { text-align: center; display: none; }

.final-rosters-container {
    display: flex;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.final-player-panel {
    flex: 1;
    min-width: 400px;
    max-width: 500px;
    background: var(--panel);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
}

.final-player-panel h2 { font-size: 1.8rem; }
.final-player-panel h3 {
    font-size: 1.2rem;
    margin-top: 20px;
    color: #ccc;
    border-top: 1px solid var(--border);
    padding-top: 15px;
}
.final-player-panel h4 {
    font-size: 1.1rem;
    color: var(--accent);
    margin-top: 15px;
    margin-bottom: 5px;
    border-bottom: none;
    padding-bottom: 0;
}

.final-picks, .final-bans {
    display: grid;
    grid-template-columns: repeat(auto-fill, 100px); /* Fixed 100px columns to match ID size */
    gap: 8px;
    margin-top: 15px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
    justify-content: center; /* Center the grid when not completely filled */
}
.final-picks .id-item, .final-bans .id-item {
    padding: 0;
    background: transparent;
    border: none;
    width: 100px; /* Match grid column width */
    height: 100px; /* Square aspect ratio */
    display: flex;
    align-items: center;
    justify-content: center;
}
.final-picks .id-item .id-name, .final-bans .id-item .id-name {
    display: none;
}
.final-picks .id-item .id-icon, .final-bans .id-item .id-icon {
    width: 100px; /* Fixed size to match container */
    height: 100px; /* Fixed size to match container */
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    border: none; /* Border handled by container */
    object-fit: cover;
    transition: all 0.2s ease;
}

.final-bans .id-item .id-icon {
    filter: grayscale(80%);
    opacity: 0.7;
}

#restart-draft { margin: 20px auto; }

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-bottom: 20px;
}
.filter-group { flex: 1; min-width: 150px; }
.filter-label { display: block; margin-bottom: 5px; font-size: 0.9rem; color: #ccc; }

/* --- NEW EGO BAN STYLES --- */
.ego-ban-layout {
    display: flex;
    flex-direction: column; /* Mobile first */
    gap: 20px;
}

#ego-ban-main-panel {
    flex: 3;
    background: var(--panel);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

#ego-ban-side-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#ego-ban-player-bans-section, #opponent-roster-display {
    background: var(--secondary);
    padding: 20px;
    border-radius: 10px;
    border-top: 4px solid var(--accent);
}

/* Optimize opponent roster layout in EGO ban phase */
#opponent-roster-display .sinner-grouped-roster {
    max-height: 400px; /* Increased height for better visibility */
}

#opponent-roster-display .sinner-id-container {
    /* Use fixed 100px grid columns, left-aligned */
    grid-template-columns: repeat(auto-fill, 100px);
    gap: 8px;
    justify-content: start; /* Stack to the left instead of stretching */
}

#opponent-roster-display .id-item {
    /* Fixed 100px sizing, no expansion */
    width: 100px;
    height: 100px;
    min-width: 100px;
    max-width: 100px;
}

#opponent-roster-display .id-item .id-icon {
    /* Consistent 100px sizing for all contexts */
    width: 100px;
    height: 100px;
    object-fit: cover;
}

#current-player-ego-bans {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 240px;
}

#current-player-ego-bans .banned-ego-item {
    text-decoration: none;
    background: var(--primary-dark);
    border: 1px solid var(--border);
}

.ego-ban-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); /* more compact */
    gap: 10px; /* more compact */
    max-height: 70vh; 
    overflow-y: auto;
    padding: 10px;
}

.ego-item {
    background: var(--panel);
    border-radius: 8px;
    padding: 8px; /* more compact */
    display: flex;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid var(--border);
    border-left-width: 5px;
    position: relative;
}

.ego-item:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border-color: var(--primary); /* Always red since EGO is only interactive during ban phase */
}

.ego-item.hovered {
    border-color: var(--primary) !important; /* Always red since EGO is only interactive during ban phase */
    box-shadow: 0 0 10px var(--primary);
}

.ego-item.banned {
    opacity: 0.5;
    cursor: not-allowed;
    background: #222;
}

.ego-item.banned::after {
    content: '\f05e'; /* ban icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: var(--primary);
    background: rgba(0,0,0,0.4);
    border-radius: 8px;
}

.ego-header {
    display: flex;
    justify-content: flex-end;
    font-weight: bold;
    margin-bottom: 5px;
}

.ego-rarity {
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(0,0,0,0.2);
    color: #fff;
}

.ego-name {
    color: var(--text);
    font-size: 1.0rem; /* more compact */
    font-weight: bold;
    flex-grow: 1;
    min-height: 2.5em;
    display: flex;
    align-items: center;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.banned-egos-display {
    background: var(--panel);
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.banned-egos-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.banned-ego-item {
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text);
    border: 1px solid transparent;
}
.banned-ego-item .rarity {
    font-weight: bold;
    margin-right: 5px;
    background: rgba(0,0,0,0.2);
    padding: 2px 4px;
    border-radius: 3px;
    color: #fff;
}
.banned-ego-item .name { text-decoration: line-through; }
/* --- END NEW EGO BAN STYLES --- */


/* Roster Builder Styles */
#roster-builder-page .card {
    display: flex;
    flex-direction: column; /* Default to stacked layout */
    gap: 20px;
}

.builder-content-wrapper {
    display: flex;
    flex-direction: column; /* Stack panels by default */
    gap: 20px;
}

.builder-sinner-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.sinner-nav-btn {
    padding: 6px 10px; /* Reduced vertical padding */
    font-size: 0.9rem; /* Reduced font size */
    flex-grow: 1; /* Allow buttons to grow and fill space */
    text-align: center;
    background: var(--secondary);
    border: 1px solid var(--border);
}

.sinner-nav-btn.selected {
    background: var(--primary);
    color: var(--accent);
    border-bottom: 4px solid var(--accent);
    border-left: 1px solid var(--border);
}

.builder-main-panel { 
    background: rgba(0,0,0,0.2);
    padding: 15px;
    border-radius: 10px;
}
.builder-side-panel { 
    background: var(--secondary); 
    padding: 20px; 
    border-radius: 10px; 
    align-self: stretch;
}

.builder-id-pool {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
}

#builder-roster-code {
    word-wrap: break-word;
    background: #111;
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    min-height: 50px;
    margin-top: 10px;
}
.roster-code-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.roster-code-actions input { flex-grow: 1; }
.roster-code-actions .btn { padding: 14px; }

.roster-load-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
}

/* NEW: Universal Grouped Roster View Styles */
.sinner-grouped-roster {
    display: flex;
    flex-direction: column;
    gap: 5px; /* Tighter space between sinner rows */
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.sinner-grouped-roster .sinner-header {
    height: 0;
    border-bottom: 1px solid var(--border);
    margin: 4px 0; /* Reduced margin */
    padding: 0;
}
.sinner-grouped-roster .sinner-id-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, 100px);
    gap: 5px;
    justify-content: center;
}
/* Style the id-item when it's inside the new container */
.sinner-grouped-roster .id-item {
    padding: 0; /* Remove padding so image fills container */
    background: transparent;
    border: 2px solid var(--border); /* Default border */
    border-radius: 8px;
    gap: 0;
    width: 100px;
    height: 100px;
    overflow: hidden;
    transition: all 0.2s ease;
}
.sinner-grouped-roster .id-item .id-name {
    display: none; /* Hide the name */
}
.sinner-grouped-roster .id-item .id-icon {
    width: 100%; /* Fill container completely */
    height: 100%; /* Fill container completely */
    max-width: none; /* Remove size constraints */
    max-height: none; /* Remove size constraints */
    border-radius: 6px; /* Slightly smaller than container */
    object-fit: cover; /* Ensure image fits properly */
}

/* Selected items in sinner grouped roster get prominent gold border */
.sinner-grouped-roster .id-item.selected {
    border: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); /* Gold glow effect */
    animation: selection-glow 2s ease-in-out infinite; /* Animated glow */
    position: relative;
    z-index: 2;
}

/* Draft phase specific border colors for sinner grouped roster */
.draft-ban-phase .sinner-grouped-roster .id-item.selected {
    border: 3px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(179, 27, 27, 0.6); /* Red glow effect */
    animation: selection-glow-red 2s ease-in-out infinite; /* Animated red glow */
    position: relative;
    z-index: 2;
}

.draft-pick-phase .sinner-grouped-roster .id-item.selected {
    border: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); /* Gold glow effect */
    animation: selection-glow 2s ease-in-out infinite; /* Animated glow */
    position: relative;
    z-index: 2;
}

/* Draft phase specific border colors for final picks/bans sections */
.draft-ban-phase .final-picks .id-item.selected,
.draft-ban-phase .final-bans .id-item.selected {
    border: 3px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(179, 27, 27, 0.6); /* Red glow effect */
    animation: selection-glow-red 2s ease-in-out infinite; /* Animated red glow */
    position: relative;
    z-index: 2;
}

/* Red border around banned IDs windows during draft */
.draft-ban-phase #p1-id-bans,
.draft-ban-phase #p2-id-bans {
    border: 2px solid var(--primary);
    border-radius: 8px;
}

/* Red border around banned IDs in completed view and draft - persistent styling */
.final-bans,
#p1-id-bans,
#p2-id-bans {
    border: 2px solid var(--primary) !important;
    border-radius: 8px !important;
}

.draft-pick-phase .final-picks .id-item.selected,
.draft-pick-phase .final-bans .id-item.selected {
    border: 3px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6); /* Gold glow effect */
    animation: selection-glow 2s ease-in-out infinite; /* Animated glow */
    position: relative;
    z-index: 2;
}

/* --- Triptych Layout --- */
.triptych-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.draft-player-column {
    flex: 1;
    min-width: 250px;
    background: var(--secondary);
    padding: 15px;
    border-radius: 10px;
    border: 1px solid var(--border);
    height: 100%;
    transition: all 0.3s ease;
}

.reserve-timer-display {
    background: rgba(0,0,0,0.2);
    color: var(--warning);
    padding: 5px 10px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
    margin: 10px 0;
    font-size: 1rem;
}

.draft-interaction-hub {
    flex: 2;
    min-width: 400px;
    background: var(--panel);
    padding: 20px;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.draft-pool-container {
    margin-bottom: 20px;
}

.draft-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}
/* Responsive tweaks */
@media (max-width: 1200px) {
    #main-page { max-width: 100%; padding: 0 10px; }
    .action-container { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
    .draft-interaction-hub { min-width: 320px; }
}

@media (max-width: 992px) {
    .player-area { flex-direction: column; }
    .draft-interaction-hub, .draft-player-column { min-width: unset; width: 100%; }
    .triptych-layout { flex-direction: column; }
    .ego-ban-layout { flex-direction: column; }
    .builder-content-wrapper { flex-direction: column; }
    .filter-bar { gap: 10px; padding: 10px; }
    .controls { gap: 8px; }
}

@media (max-width: 768px) {
    h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); }
    h2 { font-size: clamp(1.4rem, 3.5vw, 1.8rem); }
    .btn { padding: 12px 18px; font-size: 1rem; }
    .controls .btn { min-width: 120px; }
    .id-icon { width: 100px; height: 100px; }
    .id-name { font-size: 0.9rem; }
    .roster-selection { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .builder-id-pool { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
    .draft-interaction-hub { padding: 15px; }
    
    /* Adjust compact ID list for smaller screens */
    .compact-id-list {
        grid-template-columns: repeat(auto-fill, 90px);
    }
}

@media (max-width: 576px) {
    body { padding: 12px; }
    .top-left-controls { top: 10px; left: 10px; }
    .btn-small { padding: 6px 10px; font-size: 0.85rem; }
    .roster-load-form { flex-direction: column; align-items: stretch; }
    .roster-load-form input { width: 100%; }
    .filter-group { min-width: 120px; }
    .slider-row { grid-template-columns: 26px 1fr 22px; }
    
    /* Further adjust for very small screens */
    .compact-id-list {
        grid-template-columns: repeat(auto-fill, 70px);
    }
}
.modal-content {
    background: var(--panel);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    border: 1px solid var(--accent);
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.2);
    width: 90%;
    max-width: 600px;
    position: relative;
}

.modal-content .close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2.5rem;
    color: #fff;
    cursor: pointer;
    line-height: 1;
}

.rules-content {
    text-align: left;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 15px;
}
.rules-content p {
    margin-bottom: 1em;
}

.coin {
    width: 100px;
    height: 100px;
    margin: 20px auto;
    perspective: 1000px;
}
.coin-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    background-image: linear-gradient(45deg, #FFC107, var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #000;
    box-shadow: 0 0 20px var(--accent);
}
.coin-inner::before {
    content: '\f51e'; /* coins icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
}
.coin.flipping .coin-inner {
    animation: spin 1.5s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
@keyframes spin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(1080deg); }
}
#coin-flip-status {
    font-size: 1.5rem;
    margin-bottom: 20px;
    min-height: 50px;
}
#turn-choice-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* --- Join Lobby Area --- */
#join-lobby-card .action-title {
    text-align: center;
    border-bottom: none;
    margin-bottom: 0;
}
#join-lobby-card .join-tabs {
    margin-top: 15px;
}

.join-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.join-tab-btn {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.1rem;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    flex-grow: 1;
}
.join-tab-btn:hover {
    color: #fff;
}
.join-tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.join-tab-content {
    display: none;
    flex-grow: 1;
}
.join-tab-content.active {
    display: block;
}

.public-lobbies-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.public-lobbies-header h4 {
    margin: 0;
    border: none;
    padding: 0;
    text-align: left;
}

#public-lobbies-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    text-align: left;
    padding: 5px;
}

.public-lobby-item {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr auto;
    gap: 15px;
    align-items: center;
    padding: 15px;
    background: var(--secondary);
    border-radius: 8px;
    border-left: 4px solid var(--accent);
    transition: background-color 0.2s;
}
.public-lobby-item:hover {
    background: #3a3a3e;
}

.lobby-item-name {
    font-weight: bold;
    font-size: 1.1rem;
}
.lobby-item-players {
    color: #ccc;
}
.lobby-item-players i {
    margin-right: 5px;
}
.lobby-item-mode {
    font-style: italic;
    color: #ddd;
}


#draft-status-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99;
    background: rgba(30, 30, 30, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
    border-radius: 12px;
    padding: 20px;
    width: auto;
    min-width: 380px;
    max-width: 450px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    text-align: left;
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.status-text {
    flex-grow: 1;
}

#draft-status-panel #current-phase {
    font-size: 1.4rem;
    margin: 0 0 8px 0;
    padding: 0;
    border: none;
    color: var(--accent);
    font-weight: 700;
}

#draft-status-panel #draft-action-description {
    font-size: 1.0rem;
    color: #ddd;
    min-height: 0;
    margin: 0;
    line-height: 1.4;
}

.status-timer {
    text-align: center;
}

#draft-status-panel .timer-display {
    margin: 0;
    font-size: 2.2rem;
}

#draft-status-panel #ref-timer-control {
    padding: 8px 10px;
    font-size: 0.9rem;
}


.advanced-random-container {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 20px;
}

#advanced-random-options {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
}

#advanced-random-options h4 {
    margin-top: 0;
    text-align: center;
}

#advanced-random-options p {
    font-size: 0.9rem;
    text-align: center;
    margin-bottom: 15px;
}

#sinner-sliders-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 10px;
}

.sinner-slider-group {
    display: grid;
    grid-template-columns: 70px 1fr; /* Sinner name, then sliders */
    gap: 10px;
    align-items: center;
}
.sinner-slider-group label {
    font-size: 1rem;
    font-weight: bold;
}
.slider-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.slider-row {
    display: grid;
    grid-template-columns: 30px 1fr 25px;
    gap: 8px;
    align-items: center;
    font-size: 0.9rem;
}
.slider-value {
    font-weight: bold;
    color: var(--accent);
    text-align: right;
}

.advanced-random-summary {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-weight: bold;
}

/* Dark scrollbars (right side) to match theme */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
*::-webkit-scrollbar-track {
    background: #1a1a1a;
}
*::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 8px;
    border: 2px solid #1a1a1a;
}
*::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* Firefox scrollbar */
* {
    scrollbar-color: #333 #1a1a1a;
    scrollbar-width: thin;
}

/* Improve keyboard focus visibility without white outlines */
.btn:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid rgba(255, 215, 0, 0.6);
    outline-offset: 2px;
}

/* Dark themed sliders */
.slider-row input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: #333;
    border-radius: 4px;
    outline: none;
}
.slider-row input[type="range"]::-ms-fill-lower,
.slider-row input[type="range"]::-ms-fill-upper {
    background: #333;
    border: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #000;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}
.slider-row input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #000;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(255, 215, 0, 0.4);
}
.slider-row input[type="range"]::-ms-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid #000;
    cursor: pointer;
}
.slider-row input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: #333;
    border-radius: 4px;
}
.slider-row input[type="range"]::-moz-range-track {
    height: 6px;
    background: #333;
    border-radius: 4px;
}
.slider-row input[type="range"]::-ms-track {
    height: 6px;
    background: #333;
    border-radius: 4px;
    border-color: transparent;
    color: transparent;
}

/* Tooltip Style */
#id-tooltip {
    position: fixed;
    background-color: rgba(0, 0, 0, 0.95);
    color: var(--accent);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    font-size: 0.95rem;
    font-weight: bold;
    z-index: 10001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    max-width: 300px;
    overflow-wrap: anywhere;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}


/* Medium screens and up */
@media (min-width: 992px) {
    .ego-ban-layout {
        flex-direction: row;
        align-items: flex-start;
    }
    
    /* Optimize EGO ban layout proportions */
    #ego-ban-main-panel {
        flex: 2; /* Reduced from 3 to give more space to side panel */
    }
    
    #ego-ban-side-panel {
        flex: 1.2; /* Increased from 1 to give more room for roster display */
        min-width: 350px; /* Ensure minimum width for roster visibility */
    }
    
    #roster-builder-page .card {
        flex-direction: row;
    }
    .builder-sinner-nav {
        flex-direction: column;
        flex-wrap: nowrap;
        flex: 0 0 130px; /* Fixed width for the sinner nav */
        gap: 4px; /* Reduced gap */
    }
    .sinner-nav-btn {
        text-align: left;
    }
    .sinner-nav-btn.selected {
         border-bottom: 1px solid var(--border);
         border-left: 4px solid var(--accent);
    }
    .builder-content-wrapper {
        flex: 1;
        display: flex;
        flex-direction: row;
    }
    .builder-main-panel { 
        flex: 2; 
        min-width: 350px; 
    }
    .builder-side-panel { 
        flex: 1;
        min-width: 280px; 
    }
}

/* Large screens */
@media (min-width: 1400px) {
    .builder-side-panel {
        flex: 1.2;
    }
    .draft-player-column {
        flex: 1;
    }
    .draft-interaction-hub {
        flex: 2.5;
    }
}

@media (max-width: 991px) {
    .triptych-layout {
        flex-direction: column;
    }
    .draft-player-column, .draft-interaction-hub {
        width: 100%;
    }
}


@media (max-width: 768px) {
    .container { max-width: 100%; }
    .action-container {
        grid-template-columns: 1fr;
    }
    .final-player-panel { min-width: 100%; }
    .lobby-info { flex-direction: column; gap: 20px; }
    h1 { font-size: 2.5rem; }
    .code-display { font-size: 1.5rem; letter-spacing: 4px; }
    .role-options { flex-direction: column; }
    .phase-container, .player-area { flex-direction: column; }
    .connection-status { top: 5px; right: 5px; font-size: 0.8rem; padding: 5px 10px; }
    #draft-status-panel { bottom: 10px; right: 10px; left: 10px; width: auto; max-width: none; }
    .public-lobby-item { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }
    .public-lobby-item .btn { grid-column: 2 / 3; grid-row: 1 / 3; }
    .top-left-controls { top: 10px; left: 10px; }
}

/* Large screens - even more space optimization for EGO bans */
@media (min-width: 1400px) {
    #ego-ban-side-panel {
        flex: 1.4; /* Even more space for roster on large screens */
        min-width: 400px;
    }
    
    #opponent-roster-display .sinner-id-container {
        grid-template-columns: repeat(auto-fill, 100px); /* Fixed columns, no stretching */
        gap: 12px;
        justify-content: start; /* Stack to the left */
    }
    
    #opponent-roster-display .id-item .id-icon {
        width: 100px;
        height: 100px;
    }
}

/* --- TIMELINE STYLES --- */
.view-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
}
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}
input:checked + .slider {
    background-color: var(--primary);
}
input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}
input:checked + .slider:before {
    transform: translateX(26px);
}
.slider.round {
    border-radius: 34px;
}
.slider.round:before {
    border-radius: 50%;
}

#timeline-view {
    padding: 20px 0;
}

.timeline-container {
    width: 100%;
    max-width: 950px;
    margin: 0 auto;
    position: relative;
    padding: 20px 0;
}

.timeline-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 100%;
    background-image: linear-gradient(to bottom, var(--accent), var(--primary), var(--accent));
    border-radius: 2px;
}

.timeline-event {
    padding: 5px 30px;
    position: relative;
    width: 50%;
    box-sizing: border-box;
    margin-top: -35px;
}

.timeline-container > .timeline-event:first-child {
    margin-top: 0;
}

.timeline-event.p1 { left: 0; }
.timeline-event.p2 { left: 50%; }

.timeline-event::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--panel);
    border: 3px solid var(--accent);
    top: 25px;
    z-index: 1;
}

.timeline-event.p1::after { 
    right: -8px;
}
.timeline-event.p2::after { 
    left: -8px;
}

.event-group-container {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Adds a little space between items in a group */
    margin-top: 10px;
}

.event-card {
    padding: 15px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    position: relative;
}

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

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

.action-type {
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 15px;
}

.event-body {
    display: flex;
    align-items: center;
    gap: 10px;
}

.event-body img {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.target-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.event-card.pick {
    border-left: 4px solid var(--accent);
}
.event-card.pick .action-type {
    color: #000;
    background: var(--accent);
}
.event-card.pick img {
    border: 2px solid var(--accent);
}

.event-card.ban {
    border-left: 4px solid var(--primary);
}
.event-card.ban .action-type {
    color: var(--text);
    background: var(--primary);
}
.event-card.ban .event-body {
    position: relative;
}
.event-card.ban img {
    border: 2px solid var(--primary);
    filter: grayscale(80%);
}
.event-card.ban .event-body::before {
    content: '\f05e';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 30px;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    color: rgba(179, 27, 27, 0.8);
    text-shadow: 0 0 5px black;
    pointer-events: none;
}

@media screen and (max-width: 768px) {
    .timeline-container::before { left: 10px; }
    .timeline-event {
        width: 100%;
        padding-left: 45px;
        padding-right: 0;
    }
    .timeline-event.p1, .timeline-event.p2 { left: 0; }
    .timeline-event::after { left: 2px; }
}

/* --- New Timeline Layout Styles --- */

#timeline-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start; /* Align items to the top */
}

.timeline-roster-panel {
    flex: 1; /* Each roster takes up 1 part of the space */
    min-width: 280px;
    background: var(--panel);
    border-radius: 15px;
    padding: 15px;
    border: 1px solid var(--border);
    
    /* The magic for the sticky effect! */
    position: sticky;
    top: 20px; /* Distance from the top of the viewport when scrolling */
}

.timeline-roster-panel h4 {
    margin-top: 0;
    text-align: center;
    border-bottom: 1px solid var(--accent);
    padding-bottom: 10px;
    color: var(--text);
}

#timeline-view {
    flex: 2; /* The timeline takes up 2 parts, making it the focus */
    width: 100%;
}

.roster-grid-timeline {
    display: grid;
    grid-template-columns: repeat(auto-fill, 70px);
    gap: 8px;
    justify-content: center;
    margin-top: 15px;
    max-height: 80vh; /* Set a max height to allow scrolling within the panel if needed */
    overflow-y: auto;
}


/* --- Responsive Handling for Smaller Screens --- */
@media (max-width: 1200px) {
    #timeline-wrapper {
        flex-direction: column; /* Stack the columns vertically */
    }

    .timeline-roster-panel {
        position: static; /* Disable the sticky effect on small screens */
        width: 100%;
        max-height: 400px; /* Give a reasonable height when stacked */
    }
}
/* --- New Main Menu Styles --- */
.lobby-access-card {
    max-width: 600px;
    margin: 0 auto 40px auto;
}
.lobby-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}
.lobby-controls input {
    flex-grow: 1;
    text-align: center;
}
.advanced-lobby-options {
    margin-top: 20px;
}
.advanced-lobby-options summary {
    cursor: pointer;
    font-weight: bold;
    color: var(--accent);
}
.main-menu-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}
@media (min-width: 992px) {
    .main-menu-split {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- New Analyzer Page Styles --- */
#analyzer-page .card {
    max-width: 800px;
    margin: 20px auto;
}
.analyzer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
#draft-import-code {
    width: 100%;
    min-height: 200px;
    padding: 15px;
    font-family: monospace;
    font-size: 1rem;
    resize: vertical;
    background: #111;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
}
