/* Multiplayer Lobby Styles */

/* Country flag display (SVG) */
.country-flag {
    display: inline-block;
    width: 20px;
    height: 15px;
    object-fit: cover;
    vertical-align: middle;
    margin-left: 0.3rem;
    border-radius: 2px;
}

/* Hero buttons layout */
.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* Lobby Modal Overlay */
.lobby-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.lobby-modal {
    background-color: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 440px;
    width: 90%;
    overflow: visible;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lobby-modal h2 {
    margin-bottom: 1.25rem;
    text-align: center;
    font-size: 1.3rem;
}

.lobby-modal h3 {
    margin: 1.25rem 0 0.75rem 0;
    font-size: 1rem;
}

.lobby-select,
.lobby-input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--dark-bg);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.lobby-select:focus,
.lobby-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Custom Dropdown (cdd) */
.cdd-wrap {
    position: relative;
    width: 100%;
}

.cdd-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.8rem;
    background: var(--dark-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
    gap: 8px;
}

.cdd-trigger:hover {
    border-color: var(--primary-color);
}

.cdd-trigger.open {
    border-color: var(--primary-color);
}

.cdd-trigger.open svg {
    transform: rotate(180deg);
}

.cdd-trigger svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.cdd-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cdd-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 4px 0;
}

.cdd-option {
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: background 0.15s;
    margin: 0 4px;
    border-radius: 6px;
}

.cdd-option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.cdd-option.selected {
    background: rgba(59, 130, 246, 0.15);
    color: var(--primary-color);
    font-weight: 600;
}

/* Host controls custom dropdown sizing */
.host-game-controls .cdd-trigger {
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
}

.host-game-controls .cdd-option {
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.lobby-code-input {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.lobby-modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.lobby-modal-actions button {
    flex: 1;
}

.game-settings-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

/* Waiting Room */
.lobby-waiting-room {
    position: relative;
    min-height: 100vh;
    background-color: var(--dark-bg);
    z-index: 1000;
    padding-top: 95px;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-left: 1rem;
    padding-right: 1rem;
}

.lobby-header {
    width: 100%;
    max-width: 500px;
    padding: 1rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.lobby-header h2 {
    font-size: 1.15rem;
    margin: 0;
    white-space: nowrap;
}

.lobby-code-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.lobby-code {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--primary-color);
    letter-spacing: 0.15em;
    font-family: 'Courier New', monospace;
}

.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

.lobby-content {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0 0 1rem 0;
}

.lobby-players-section,
.lobby-settings-section {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
}

.lobby-players-section h3,
.lobby-settings-section h3 {
    margin-bottom: 0.75rem;
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-card {
    background-color: var(--dark-bg);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border: 1px solid var(--border-color);
}

.player-card:hover {
    border-color: var(--primary-color);
}

.player-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: bold;
    flex-shrink: 0;
}

.player-info {
    flex: 1;
    min-width: 0;
}

.player-name {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.player-device {
    font-size: 0.8rem;
    flex-shrink: 0;
    opacity: 0.7;
}

.player-rank {
    margin-top: 0.15rem;
}

.lobby-mode-rank {
    margin-top: 0.15rem;
    margin-bottom: 0;
}

.player-team {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.1rem;
}

.player-status {
    color: var(--danger-color);
    font-size: 0.75rem;
    margin-top: 0.1rem;
}

.ready-indicator {
    color: var(--success-color);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.settings-display {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.65rem;
    background-color: var(--dark-bg);
    border-radius: 6px;
    font-size: 0.9rem;
}

.setting-label {
    font-weight: 500;
}

.setting-value {
    color: var(--primary-color);
    font-weight: 600;
}

.no-settings {
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem;
    font-size: 0.9rem;
}

.lobby-actions {
    width: 100%;
    max-width: 500px;
    padding: 0.5rem 0 2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.add-bot-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 500px;
    padding: 0 0 0.25rem 0;
}

.add-bot-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.add-bot-difficulties {
    display: flex;
    gap: 0.35rem;
    flex: 1;
}

.add-bot-diff-btn {
    flex: 1;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.add-bot-diff-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background-color: rgba(43, 135, 218, 0.08);
}

.add-bot-diff-btn:active {
    transform: scale(0.96);
}

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

/* Countdown Overlay */
.countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.countdown-display {
    text-align: center;
}

.countdown-number {
    font-size: 10rem;
    font-weight: bold;
    color: var(--primary-color);
    animation: countdownPulse 1s ease-in-out;
}

@keyframes countdownPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Live Scoreboard Overlay */
.live-scoreboard-overlay {
    position: fixed;
    top: 130px;
    right: 20px;
    z-index: 1001;
}

.live-scoreboard-overlay.live-scoreboard-left {
    right: auto;
    left: 20px;
}

.live-scoreboard {
    background-color: rgba(22, 33, 62, 0.95);
    border-radius: 12px;
    padding: 1rem;
    min-width: 250px;
    border: 2px solid var(--border-color);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.live-scoreboard h4 {
    margin-bottom: 1rem;
    text-align: center;
    color: var(--primary-color);
}

#live-scores-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

.score-entry.leading {
    background-color: rgba(43, 135, 218, 0.3);
    border: 2px solid var(--primary-color);
    transform: scale(1.05);
}

.score-entry.finished {
    opacity: 0.7;
}

.score-entry.you .username {
    color: var(--primary-color);
    font-weight: 700;
}

.score-entry.opponent .username {
    color: var(--text-secondary, #94a3b8);
}

.score-entry .you-tag {
    font-size: 0.7em;
    opacity: 0.7;
    font-weight: 400;
}

.score-entry .rank {
    font-weight: bold;
    margin-right: 0.5rem;
}

.score-entry .username {
    flex: 1;
    font-weight: 500;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

.score-entry .username .player-title {
    font-size: 0.55rem;
    padding: 2px 5px;
    line-height: 1;
    display: inline-block;
    vertical-align: middle;
    transform: translateY(1px);
}

.score-entry .score {
    color: var(--primary-color);
    font-weight: 600;
    margin-left: 0.5rem;
}

.score-entry .status-icon {
    color: var(--success-color);
    font-size: 1.2rem;
    margin-left: 0.5rem;
}

/* Multiplayer Results */
.mp-results {
    padding: 2rem 1rem;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.mp-results.visible {
    opacity: 1;
    transform: translateY(0);
}

.mp-results-header {
    margin-bottom: 1.5rem;
}

.mp-results-game-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.mp-results-title {
    font-size: 1.6rem;
    font-weight: 700;
}

/* Format Progress (multi-round) */
.format-progress {
    margin-top: 0.5rem;
    text-align: center;
}

.format-label {
    font-size: 0.95rem;
    color: var(--primary-color);
    font-weight: 600;
}

.format-wins {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.format-player-wins {
    white-space: nowrap;
}

.format-series-winner {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success-color);
    margin-top: 0.5rem;
}

/* Winner Spotlight */
.mp-winner-spotlight {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.mp-winner-crown {
    font-size: 2rem;
    color: #ffd700;
    line-height: 1;
    margin-bottom: 0.25rem;
    filter: drop-shadow(0 2px 6px rgba(255, 215, 0, 0.4));
}

.mp-winner-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffd700 0%, #ffb700 100%);
    color: #1a1a2e;
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 16px rgba(255, 215, 0, 0.25);
}

.mp-winner-name {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}

.mp-winner-score {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 0.25rem;
}

.mp-winner-accuracy {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

/* Podium */
.mp-podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 0.75rem;
    margin: 0 auto 2rem;
    min-height: 200px;
}

.mp-podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 110px;
}

.mp-podium-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 0.5rem;
}

.mp-podium-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--card-bg);
    border: 2.5px solid var(--place-color);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.35rem;
}

.mp-podium-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
}

.mp-podium-score {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
}

.mp-podium-accuracy {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.mp-podium-bar {
    width: 100%;
    border-radius: 8px 8px 0 0;
    background: var(--place-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mp-podium-place-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1a1a2e;
}

.mp-podium-1 .mp-podium-bar {
    height: 100px;
}

.mp-podium-2 .mp-podium-bar {
    height: 72px;
}

.mp-podium-3 .mp-podium-bar {
    height: 48px;
}

.mp-podium-1 .mp-podium-avatar {
    width: 48px;
    height: 48px;
    font-size: 1.15rem;
}

/* Rankings Card */
.mp-rankings-card {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin: 0 auto 1.5rem;
    max-width: 460px;
    border: 1px solid var(--border-color);
}

.mp-rankings-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.75rem;
    text-align: left;
}

.mp-rank-row {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.25rem;
    border-radius: 6px;
    background-color: rgba(255, 255, 255, 0.03);
}

.mp-rank-row:last-child {
    margin-bottom: 0;
}

.mp-rank-pos {
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 28px;
    color: var(--text-secondary);
}

.mp-rank-name {
    flex: 1;
    font-size: 0.9rem;
}

.mp-rank-score {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 600;
}

.mp-rank-accuracy {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-left: 0.75rem;
    min-width: 36px;
    text-align: right;
}

.mp-rank-top-1 {
    background-color: rgba(255, 215, 0, 0.1);
}

.mp-rank-top-1 .mp-rank-pos {
    color: #ffd700;
}

.mp-rank-top-2 {
    background-color: rgba(168, 180, 192, 0.08);
}

.mp-rank-top-2 .mp-rank-pos {
    color: #a8b4c0;
}

.mp-rank-top-3 {
    background-color: rgba(205, 127, 50, 0.08);
}

.mp-rank-top-3 .mp-rank-pos {
    color: #cd7f32;
}

.mp-rank-abandoned {
    opacity: 0.45;
}

.mp-rank-left {
    color: #dc3545 !important;
    font-style: italic;
}

/* Actions */
.mp-results-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.mp-results-actions .btn {
    min-width: 100px;
    padding: 0.6rem 1.5rem;
}

/* Report Player Button */
.mp-report-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    margin-left: 0.5rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.mp-rank-row:hover .mp-report-btn {
    opacity: 1;
}

.mp-report-btn:hover {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

/* Report Modal */
.report-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10010;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.report-modal {
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border-color, #333);
    border-radius: 12px;
    width: 380px;
    max-width: 90vw;
    overflow: hidden;
}

.report-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color, #333);
}

.report-modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.report-modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.report-modal-close:hover {
    color: var(--text-primary);
}

.report-modal-body {
    padding: 1rem 1.25rem;
}

.report-modal-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.report-reasons {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.report-reason-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
}

.report-reason-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.report-reason-option input[type="radio"] {
    accent-color: #dc3545;
}

.report-details {
    width: 100%;
    background: var(--bg-primary, #0f1724);
    border: 1px solid var(--border-color, #333);
    border-radius: 6px;
    color: var(--text-primary, #e0e0e0);
    padding: 0.5rem;
    font-size: 0.85rem;
    resize: vertical;
    font-family: inherit;
}

.report-details:focus {
    outline: none;
    border-color: var(--primary-color, #6366f1);
}

.report-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color, #333);
}

.btn-danger {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-danger:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Between-round overlay (auto-advance series) */
.between-round-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.between-round-overlay.visible {
    opacity: 1;
    transform: scale(1);
}

.br-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
    padding: 2rem;
}

.br-round-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.br-round-winner {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 0.25rem;
}

.br-winner-score {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.br-series-scores {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.br-series-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.br-score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
}

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

.br-score-wins {
    font-weight: 700;
    color: var(--primary-color);
}

.br-next-round {
    margin-top: 0.5rem;
}

.br-next-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.br-countdown {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

/* Player actions (kick/swap buttons) */
.player-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    flex-shrink: 0;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-danger:hover {
    background-color: #c82333;
}

.kick-btn {
    padding: 0.3rem 0.5rem !important;
    font-size: 0.85rem !important;
    font-weight: bold;
    min-width: 28px;
    line-height: 1;
}

/* 2v2 Team Layout */
.lobby-teams-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border-color);
}

.team-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 0.75rem;
    align-items: stretch;
}

/* 3 teams: bottom row centered, team matches top row column width */
.lobby-teams-section[data-num-teams="3"] .team-row:last-child {
    display: flex;
    justify-content: center;
}

.lobby-teams-section[data-num-teams="3"] .team-row:last-child .team-column {
    flex: 0 1 calc(50% - 1.5rem);
}

.team-column {
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.team-header {
    text-align: center;
    font-size: 0.95rem;
    padding: 0.5rem;
    border-radius: 6px;
    margin-bottom: 0.6rem;
}

.team-1-header {
    background-color: rgba(43, 135, 218, 0.2);
    color: #5dade2;
    border: 2px solid rgba(43, 135, 218, 0.4);
}

.team-2-header {
    background-color: rgba(220, 53, 69, 0.2);
    color: #ec7063;
    border: 2px solid rgba(220, 53, 69, 0.4);
}

.team-3-header {
    background-color: rgba(46, 204, 113, 0.2);
    color: #58d68d;
    border: 2px solid rgba(46, 204, 113, 0.4);
}

.team-4-header {
    background-color: rgba(241, 196, 15, 0.2);
    color: #f4d03f;
    border: 2px solid rgba(241, 196, 15, 0.4);
}

/* N teams handled by .team-row grid layout */

.team-vs {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--text-secondary);
    padding-top: 2.5rem;
}

.team-swap-btn {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.85rem !important;
    font-weight: bold;
    min-width: 26px;
}

.empty-team {
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem;
    font-size: 0.85rem;
    font-style: italic;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
}

/* Drag and Drop for Team Assignment */
.team-draggable[draggable="true"] {
    cursor: grab;
    transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
    user-select: none;
}

.team-draggable[draggable="true"]:active {
    cursor: grabbing;
}

.team-draggable.dragging {
    opacity: 0.4;
    transform: scale(0.95);
}

.team-drop-zone {
    min-height: 60px;
    flex: 1;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    border-radius: 8px;
    border: 2px solid transparent;
}

.team-drop-zone.drag-over {
    background-color: rgba(43, 135, 218, 0.1);
    border-color: var(--primary-color);
}

.team-1 .team-drop-zone.drag-over {
    background-color: rgba(43, 135, 218, 0.15);
    border-color: #5dade2;
}

.team-2 .team-drop-zone.drag-over {
    background-color: rgba(220, 53, 69, 0.15);
    border-color: #ec7063;
}

.team-3 .team-drop-zone.drag-over {
    background-color: rgba(46, 204, 113, 0.15);
    border-color: #58d68d;
}

.team-4 .team-drop-zone.drag-over {
    background-color: rgba(241, 196, 15, 0.15);
    border-color: #f4d03f;
}

/* Team colors */
.team-1-color {
    color: #5dade2;
}

.team-2-color {
    color: #ec7063;
}

.team-3-color {
    color: #58d68d;
}

.team-4-color {
    color: #f4d03f;
}

/* Live scoreboard team groups */
.team-score-group {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.team-score-group.team-leading {
    background-color: rgba(43, 135, 218, 0.15);
    border: 1px solid rgba(43, 135, 218, 0.3);
}

.team-score-header {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

/* Team Results Banner */
/* Team Results */
.team-results-section {
    margin-bottom: 1.5rem;
}

.team-results-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 420px;
    margin: 0 auto;
}

.team-result-row {
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    border: 1.5px solid var(--border-color);
    gap: 0.75rem;
}

.team-result-row.team-winner {
    border-color: #ffd700;
    background-color: rgba(255, 215, 0, 0.06);
}

.team-result-pos {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 20px;
}

.team-result-row.team-winner .team-result-pos {
    color: #ffd700;
}

.team-result-label {
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 60px;
}

.team-result-players {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.team-result-score {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: right;
    white-space: nowrap;
}

.team-result-row.team-winner .team-result-score {
    color: #ffd700;
}

.team-winner-tag {
    font-size: 0.65rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffd700, #ffb700);
    color: #1a1a2e;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* MVP Banner */
.mvp-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background-color: rgba(255, 215, 0, 0.06);
    border: 1px solid rgba(255, 215, 0, 0.2);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    text-align: center;
    margin: 0.75rem auto 1.5rem;
    max-width: 420px;
}

.mvp-label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #ffd700;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.mvp-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mvp-score {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
}

/* Team badge in rankings */
.player-team-badge {
    font-size: 0.8rem;
    font-weight: bold;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin: 0 0.5rem;
}

.player-team-badge.team-1-color {
    background-color: rgba(43, 135, 218, 0.2);
}

.player-team-badge.team-2-color {
    background-color: rgba(220, 53, 69, 0.2);
}

/* Host game controls in waiting room */
.host-game-controls {
    width: 100%;
    max-width: 500px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.host-control-row {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.host-control-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.host-control-row .form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    display: block;
}

.host-game-controls .lobby-select,
.host-game-controls .lobby-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
}

#host-game-settings-container {
    margin-top: 0.75rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

#host-game-settings-container .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

#host-game-settings-container .form-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: block;
}

/* Disconnected / Abandoned players */
.score-entry.disconnected {
    opacity: 0.5;
}

.score-entry.disconnected .score {
    color: #dc3545;
    font-style: italic;
}

.disconnected-icon {
    color: #dc3545 !important;
}

/* (old ranking-row.abandoned removed - now uses mp-rank-abandoned) */

/* Wider layout for team mode */
.lobby-content-teams {
    max-width: 750px;
}

.host-controls-wide {
    max-width: 750px;
}

.lobby-content-teams ~ .lobby-actions {
    max-width: 750px;
}

/* Player card overflow fix */
.player-card {
    overflow: hidden;
}

.player-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Clickable player cards for host */
.player-card-manageable {
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.player-card-manageable:hover {
    border-color: var(--primary-color);
    background-color: rgba(43, 135, 218, 0.05);
}

/* Inline Remove Bot button */
.remove-bot-btn {
    background: rgba(220, 53, 69, 0.15);
    color: #ec7063;
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
    margin-left: auto;
}

.remove-bot-btn:hover {
    background: rgba(220, 53, 69, 0.3);
    border-color: rgba(220, 53, 69, 0.6);
    color: #f5b7b1;
}

/* Player action dropdown */
.player-action-dropdown {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    min-width: 130px;
    animation: dropdownFadeIn 0.12s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.player-action-dropdown .dropdown-item {
    display: block;
    width: 100%;
    padding: 0.55rem 1rem;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.12s;
}

.player-action-dropdown .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.player-action-dropdown .dropdown-host:hover {
    background-color: rgba(43, 135, 218, 0.15);
    color: var(--primary-color);
}

.player-action-dropdown .dropdown-kick {
    color: var(--danger-color, #dc3545);
}

.player-action-dropdown .dropdown-kick:hover {
    background-color: rgba(220, 53, 69, 0.15);
}

/* Responsive Design */
@media (max-width: 768px) {
    .team-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    .lobby-teams-section[data-num-teams="3"] .team-row:last-child {
        max-width: 100%;
    }

    .team-vs {
        padding-top: 0;
        font-size: 1.2rem;
    }

    .team-results-grid {
        max-width: 100%;
    }

    .lobby-waiting-room {
        padding-top: 75px;
    }

    .lobby-header {
        flex-direction: column;
        text-align: center;
    }

    .lobby-content {
        max-width: 100%;
    }

    .lobby-players-section,
    .lobby-settings-section {
        padding: 0.75rem;
    }

    .host-game-controls {
        max-width: 100%;
        padding: 0.6rem;
    }

    .host-control-row {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 0.4rem;
    }

    .host-control-row .form-group {
        min-width: 0;
    }

    .host-control-row .form-group label {
        font-size: 0.7rem;
        margin-bottom: 0.15rem;
    }

    .host-game-controls .cdd-trigger {
        padding: 0.35rem 0.5rem;
        font-size: 0.78rem;
    }

    .host-game-controls .cdd-option {
        padding: 0.35rem 0.5rem;
        font-size: 0.78rem;
    }

    .add-bot-bar {
        max-width: 100%;
    }

    .lobby-actions {
        max-width: 100%;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-buttons button {
        width: 100%;
    }

    .live-scoreboard-overlay {
        position: static;
        margin: 1rem auto 0.75rem auto;
        max-width: 800px;
        padding: 0 1rem;
        z-index: auto;
    }

    .live-scoreboard {
        min-width: auto;
        padding: 0.75rem;
        border-radius: 10px;
    }

    .live-scoreboard h4 {
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }

    #live-scores-list {
        gap: 0.35rem;
    }

    .score-entry {
        padding: 0.35rem 0.5rem;
        font-size: 0.9rem;
    }

    .score-entry.leading {
        transform: none;
    }

    .mp-podium {
        gap: 0.5rem;
    }

    .mp-podium-slot {
        flex: 0 0 90px;
    }

    .mp-winner-score {
        font-size: 1.4rem;
    }

    .countdown-number {
        font-size: 6rem;
    }

    .lobby-modal {
        width: 95%;
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .lobby-code {
        font-size: 1rem;
    }

    .player-icon {
        width: 30px;
        height: 30px;
        font-size: 0.85rem;
    }

    .countdown-number {
        font-size: 4rem;
    }
}
