body {
    background:
        linear-gradient(135deg, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0.7) 100%),
        url('/images/jonathan-borba-Lw3wqHyhGzo-unsplash.jpg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: white;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.game-container {
    width: calc(100% - 40px);
    margin: 0 auto;
    padding: 0 20px;
    height: 100vh;
    box-sizing: border-box;
}

#mainSection {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* CD Header */
.cd-header {
    text-align: center;
    padding: 15px 0;
    flex-shrink: 0;
}

.cd-header h1 {
    margin: 0;
    font-size: 40px;
    font-weight: bold;
}

.cd-header .alpha-mode {
    margin: 5px 0 0 0;
    font-size: 19px;
    color: #ffc107;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* 3-Column Main Layout */
.cd-main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    min-height: 0;
}

.cd-footer {
    text-align: center;
    padding: 10px 0;
    flex-shrink: 0;
}

/* Team Columns */
.team-column {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.team-column-content {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px 20px;
    text-align: center;
    width: 100%;
    max-width: 300px;
    transition: all 0.3s;
}

.team-column-content.active {
    background: rgba(255, 255, 255, 0.25);
    border: 3px solid #ffc107;
    box-shadow: 0 0 30px rgba(255, 193, 7, 0.5);
}

.team-column-content.dimmed {
    opacity: 0.4;
}

/* Dynamic team colors for team columns */
.team-column-content[data-team-color] {
    background:
        linear-gradient(135deg, var(--team-color-overlay) 0%, var(--team-color-overlay) 100%),
        rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.team-icon-large {
    font-size: 64px;
    margin-bottom: 15px;
}

.team-name-large {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 15px;
}

.team-status {
    font-size: 19px;
    margin: 15px 0;
    min-height: 2em;
    color: #ffc107;
    font-weight: 600;
}

.team-scramble {
    margin-top: 15px;
}

.scramble-display {
    background: rgba(102, 126, 234, 0.3);
    color: white;
    border: 2px solid rgba(102, 126, 234, 0.6);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.scramble-display.used {
    opacity: 0.5;
    background: rgba(108, 117, 125, 0.3);
    border-color: rgba(108, 117, 125, 0.6);
}

/* Board Container */
.board-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.header-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 10px 15px;
    flex-shrink: 0;
}

/* Lobby Team Selection - Button List Layout */
.team-selection-list {
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vmin, 15px);
    width: min(60vw, calc(100vh - 250px));
    max-height: min(60vw, calc(100vh - 250px));
}

.team-selection-title-header {
    text-align: center;
    padding-bottom: clamp(8px, 1.5vmin, 15px);
}

.team-selection-title-header h1 {
    font-family: 'Pricedown', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: clamp(32px, 4vmin, 64px);
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    margin: 0;
}

.team-selection-button-wrapper {
    width: 100%;
    flex: 1;
    min-height: 0;
}

.team-selection-button {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    padding: clamp(8px, 1.5vmin, 15px) clamp(12px, 2vmin, 20px);
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vmin, 15px);
    cursor: pointer;
    transition: all 0.3s;
    color: white;
    font-size: clamp(14px, 2.5vmin, 20px);
    font-weight: 600;
}

.team-selection-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.team-selection-button:active {
    transform: translateY(0);
}

.team-selection-button:disabled,
.team-selection-button.selected {
    filter: brightness(0.3);
    cursor: not-allowed;
    pointer-events: none;
}

/* Dynamic team colors for buttons */
.team-selection-button[data-team-color] {
    background:
        linear-gradient(135deg, var(--team-color-overlay) 0%, var(--team-color-overlay) 100%),
        rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-color: var(--team-color-overlay);
}

.team-button-icon {
    font-size: clamp(24px, 4vmin, 36px);
    flex-shrink: 0;
}

.team-button-name {
    flex: 1;
    text-align: left;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* QR Modal Overlay */
.team-qr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.team-qr-modal {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    position: relative;
}

.team-qr-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.team-qr-modal-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

.team-qr-modal-title {
    font-size: 28px;
    font-weight: 600;
    color: #333;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.team-qr-modal-title-icon {
    font-size: 40px;
}

.team-qr-modal .qr-code-container {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.team-qr-modal .qr-code-container canvas {
    display: block;
}

.team-qr-modal .invite-url-small {
    text-align: center;
}

.team-qr-modal .invite-url-small a {
    color: #007bff;
    text-decoration: underline;
    font-weight: 600;
    font-size: 16px;
}

.team-qr-modal .invite-url-small a:hover {
    color: #0056b3;
}

.lobby-placeholder {
    text-align: center;
}


.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(15px, 2vmin, 30px);
    width: min(60vw, calc(100vh - 250px));
    height: min(60vw, calc(100vh - 250px));
    aspect-ratio: 1;
}

.board-square {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    text-align: center;
    position: relative;
    aspect-ratio: 1;
    min-width: 0;
    min-height: 0;
    transition: all 0.3s;
}

.board-square.highlighted {
    background: rgba(255, 193, 7, 0.3);
    border-color: #ffc107;
    border-width: 3px;
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.6);
}

.board-square.claimed {
    cursor: not-allowed;
}

/* Dynamic team colors for claimed squares */
.board-square.claimed[data-team-color] {
    background:
        linear-gradient(135deg, var(--team-color-overlay) 0%, var(--team-color-overlay) 100%),
        rgba(255, 255, 255, 0.1);
    border-color: var(--team-color-primary);
    border-width: 3px;
}

/* Fallback colors for teams without color set */
.board-square.team-1:not([data-team-color]) {
    background: rgba(255, 193, 7, 0.3);
    border-color: #ffc107;
}

.board-square.team-2:not([data-team-color]) {
    background: rgba(0, 123, 255, 0.3);
    border-color: #007bff;
}

.board-square.dead-square {
    background: rgba(128, 128, 128, 0.3);
    border-color: #666;
    opacity: 0.6;
}

.category-name {
    font-size: 13px;
    font-weight: bold;
    word-wrap: break-word;
    overflow: hidden;
}

.board-square .team-icon {
    font-size: 32px;
}

.team-display {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin-top: 15px;
}

.team-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px 30px;
    border-radius: 10px;
    text-align: center;
}

.team-card.active {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
}

.team-card .team-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.strike-x {
    font-size: 24px;
    display: inline-block;
    margin: 0 5px;
}

/* Game Over Animations */
@keyframes winnerFlash {
    0%, 100% {
        background: rgba(255, 215, 0, 0.3);
        border-color: #ffd700;
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
    50% {
        background: rgba(255, 215, 0, 0.6);
        border-color: #ffed4e;
        box-shadow: 0 0 50px rgba(255, 215, 0, 1);
    }
}

@keyframes winningSquareFlash {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
        border-color: #ffd700;
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 215, 0, 1);
        border-color: #ffed4e;
        transform: scale(1.05);
    }
}

.game-over-winner {
    animation: winnerFlash 1s ease-in-out infinite;
    border: 3px solid #ffd700 !important;
}

.game-over-loser {
    opacity: 0.6;
}

.game-over-draw {
    animation: winnerFlash 1.5s ease-in-out infinite;
    border: 3px solid #17a2b8 !important;
}

.winning-square {
    animation: winningSquareFlash 1s ease-in-out infinite;
    border-width: 4px !important;
}

/* Challenge Card Overlay */
.challenge-card-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.challenge-card-overlay.hidden {
    display: none !important;
}

.challenge-card-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    padding: 30px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transition: all 0.3s;
}

.challenge-card-content.correct {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: 4px solid #28a745;
}

.challenge-card-content.incorrect {
    border: 4px solid #dc3545;
}

.challenge-card-content h2 {
    margin: 0 0 20px 0;
    font-size: 32px;
    text-align: center;
}

.challenge-media {
    margin: 20px 0;
    width: 100%;
    max-width: 500px;
}

.challenge-media audio {
    width: 100%;
}

.timer-split-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
    max-width: 500px;
    width: 100%;
}

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

.timer-label {
    font-size: 14px;
    color: #fff;
    opacity: 0.7;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.timer {
    font-size: 40px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: #ffc107;
}

.challenge-message {
    margin-top: 20px;
    font-size: 24px;
    text-align: center;
    font-weight: 600;
}

.challenge-message.success {
    color: #28a745;
}

.challenge-message.error {
    color: #dc3545;
}

/* Winner Card Overlay */
.winner-card-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    animation: fadeIn 0.5s ease-in;
}

.winner-card-overlay.hidden {
    display: none !important;
}

.winner-card-content {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-radius: 30px;
    padding: 60px 40px;
    max-width: 700px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(255, 215, 0, 0.6);
    border: 5px solid #ffa500;
    animation: scaleIn 0.5s ease-out;
}

.winner-icon {
    font-size: 8rem;
    margin-bottom: 20px;
    animation: winnerBounce 1s ease-in-out infinite;
}

.winner-title {
    font-size: 4rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.2);
}

.winner-message {
    font-size: 2rem;
    color: #555;
    margin: 0;
}

@keyframes winnerBounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.hidden {
    display: none !important;
}

/* Game Rules Screen */
.game-rules-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    min-height: 600px;
}

/* Hide team columns when rules screen is visible */
body:has(.game-rules-screen:not(.hidden)) .team-column {
    display: none;
}

/* Expand board container to span all 3 columns when rules are visible */
body:has(.game-rules-screen:not(.hidden)) .board-container {
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
}

body:has(.game-rules-screen:not(.hidden)) .game-rules-screen {
    width: 100%;
}

.rules-content {
    width: 100%;
    text-align: center;
}

.rules-content h2 {
    font-size: 48px;
    margin-bottom: 40px;
    color: #fff;
}

.rules-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-bottom: 30px;
}

.rule-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    text-align: left;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.rule-number {
    display: inline-block;
    width: 50px;
    height: 50px;
    line-height: 50px;
    background: #ffc107;
    color: #000;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 15px;
}

.rule-item h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #fff;
}

.rule-item p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

/* Rules Carousel */
.rules-carousel {
    position: relative;
    width: 100%;
    height: 365px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.7);
    padding: 15px;
    border-radius: 20px;
}

.rules-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.5s ease-in-out;
    pointer-events: none;
}

.rules-slide.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    position: relative;
}

.rules-slide.prev {
    transform: translateX(-100%);
}

.rules-slide h3 {
    font-size: 1.6rem;
    color: #000;
    margin-bottom: 15px;
    text-align: center;
}

.rules-slide p {
    font-size: 0.95rem;
    color: #000;
    line-height: 1.5;
    margin-bottom: 12px;
}

.subsection-title {
    font-size: 1.5rem;
    color: #764ba2;
    margin-top: 20px;
    margin-bottom: 15px;
    text-align: left;
    font-weight: bold;
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rules-list .rule-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 12px 15px;
    border: 2px solid rgba(102, 126, 234, 0.3);
}

.rules-list .rule-number {
    flex-shrink: 0;
    width: 35px;
    height: 35px;
    line-height: 35px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: bold;
    margin-bottom: 0;
    text-align: center;
}

.rules-list .rule-item p {
    flex: 1;
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
    color: #000;
}

/* Rules Navigation */
.rules-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 15px;
    padding: 10px 0;
}

.btn-skip {
    font-size: 1rem;
    padding: 10px 20px;
}

.slide-indicators {
    display: flex;
    gap: 10px;
    align-items: center;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.dot.active {
    background: #ffc107;
    transform: scale(1.3);
}

.dot:hover {
    background: rgba(255, 255, 255, 0.6);
}

.nav-buttons {
    display: flex;
    gap: 15px;
}

.nav-buttons .btn {
    min-width: 120px;
    font-size: 1.1rem;
    padding: 10px 20px;
}

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