/* ===== CSS Variables ===== */
:root {
    --brand-navy: #1a2b4a;
    --brand-cream: #f5f2eb;
    --accent-amber: #d4a84b;
    --accent-teal: #2d9a8c;
    --accent-purple: #7c5cbf;
    --text-primary: #1a2b4a;
    --text-secondary: #6b7280;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --card-shadow: 0 8px 32px rgba(26, 43, 74, 0.12);
    --card-shadow-hover: 0 12px 48px rgba(26, 43, 74, 0.18);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--brand-navy);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* ===== Join Screen ===== */
.join-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, var(--brand-navy) 0%, #0d1a2d 100%);
    position: relative;
    overflow: hidden;
}

/* Background decoration */
.bg-decoration {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-circle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
}

.bg-circle-1 {
    width: 600px;
    height: 600px;
    background: var(--accent-amber);
    top: -200px;
    right: -200px;
    animation: float 20s ease-in-out infinite;
}

.bg-circle-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-teal);
    bottom: -100px;
    left: -100px;
    animation: float 15s ease-in-out infinite reverse;
}

.bg-circle-3 {
    width: 300px;
    height: 300px;
    background: var(--brand-cream);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-slow 10s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

@keyframes pulse-slow {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.05; }
    50% { transform: translate(-50%, -50%) scale(1.1); opacity: 0.08; }
}

.logo-section {
    text-align: center;
    margin-bottom: 48px;
    position: relative;
    z-index: 1;
}

/* Logo Badge */
.logo-badge {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
    position: relative;
}

.logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 24px;
}

.logo-fallback {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--accent-amber) 0%, #c49a3d 100%);
    border-radius: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 16px 48px rgba(212, 168, 75, 0.4);
}

.logo-icon {
    font-size: 56px;
}

.brand-title {
    font-size: 42px;
    font-weight: 800;
    color: var(--brand-cream);
    margin-bottom: 16px;
    letter-spacing: -1px;
}

.clubhouse-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 24px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-amber);
    letter-spacing: 2px;
    border: 1px solid rgba(212, 168, 75, 0.3);
}

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

/* Join Card */
.join-card {
    background: var(--brand-cream);
    padding: 40px;
    border-radius: 28px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.card-icon {
    width: 40px;
    height: 40px;
    background: var(--brand-navy);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-cream);
}

.code-input-wrapper {
    position: relative;
    margin-bottom: 8px;
}

.code-input-wrapper input {
    width: 100%;
    padding: 24px 20px;
    font-size: 36px;
    font-weight: 800;
    text-align: center;
    letter-spacing: 12px;
    text-transform: uppercase;
    border: none;
    border-radius: 16px;
    background: white;
    color: var(--brand-navy);
    outline: none;
    transition: all 0.3s;
    box-shadow: inset 0 2px 8px rgba(26, 43, 74, 0.08);
}

.code-input-wrapper input:focus {
    box-shadow: inset 0 2px 8px rgba(26, 43, 74, 0.08), 0 0 0 3px var(--accent-amber);
}

.code-input-wrapper input::placeholder {
    color: #d1d5db;
    letter-spacing: 12px;
}

.code-underlines {
    display: none; /* Hidden for now, using solid input */
}

#join-btn {
    width: 100%;
    padding: 20px 32px;
    margin-top: 24px;
    background: linear-gradient(135deg, var(--brand-navy) 0%, #0d1a2d 100%);
    color: var(--brand-cream);
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
    box-shadow: 0 8px 24px rgba(26, 43, 74, 0.3);
}

#join-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(26, 43, 74, 0.4);
}

#join-btn:active {
    transform: translateY(-1px);
}

#join-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.error {
    color: var(--error);
    font-size: 14px;
    font-weight: 600;
    margin-top: 16px;
    min-height: 20px;
    background: rgba(239, 68, 68, 0.1);
    padding: 10px 16px;
    border-radius: 10px;
    display: none;
}

.error:not(:empty) {
    display: block;
}

.footer-text {
    margin-top: 32px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 500;
}

/* ===== Game Screen ===== */
#game-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--brand-cream);
}

/* Header */
.game-header {
    background: linear-gradient(135deg, var(--brand-navy) 0%, #0d1a2d 100%);
    color: white;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logo {
    width: 56px;
    height: 56px;
    background: var(--accent-amber);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(212, 168, 75, 0.4);
}

.header-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 14px;
}

.header-logo-icon {
    font-size: 28px;
}

.event-info h1 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 2px;
    letter-spacing: -0.5px;
}

.event-info p {
    font-size: 14px;
    opacity: 0.7;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    padding: 10px 20px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1.5px;
}

.live-text {
    color: var(--success);
}

.pulse {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
    box-shadow: 0 0 12px var(--success);
}

.game-code-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 3px;
    font-family: monospace;
}

/* Main Content */
.game-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: auto 1fr;
    gap: 24px;
    padding: 28px 40px;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

.game-content section {
    background: white;
    border-radius: 24px;
    padding: 28px;
    box-shadow: var(--card-shadow);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.section-icon {
    width: 40px;
    height: 40px;
    background: var(--brand-navy);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-cream);
}

.section-icon.teams-icon {
    background: var(--accent-purple);
}

.section-icon.activity-icon {
    background: var(--accent-teal);
}

.game-content h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0;
    margin: 0;
}

.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--brand-cream);
    border-top-color: var(--brand-navy);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Leaderboard */
.leaderboard-section {
    grid-column: 1;
    grid-row: 1 / 3;
}

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.player-row {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--brand-cream);
    border-radius: 12px;
    transition: all 0.3s;
}

.player-row.highlight {
    animation: highlight 2s ease-out;
}

@keyframes highlight {
    0% { background: rgba(34, 197, 94, 0.3); transform: scale(1.02); }
    100% { background: var(--brand-cream); transform: scale(1); }
}

.position {
    width: 36px;
    height: 36px;
    background: var(--brand-navy);
    color: white;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    margin-right: 16px;
}

.position.gold { background: var(--accent-amber); }
.position.silver { background: #94a3b8; }
.position.bronze { background: #b45309; }

.player-info {
    flex: 1;
}

.player-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.player-hole {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.player-score {
    text-align: right;
}

.score-strokes {
    font-size: 24px;
    font-weight: 800;
    color: var(--brand-navy);
}

.score-points {
    font-size: 12px;
    color: var(--accent-teal);
    font-weight: 600;
}

.team-badge {
    width: 8px;
    height: 36px;
    border-radius: 4px;
    margin-right: 12px;
}

/* Teams Section */
.teams-section {
    grid-column: 2;
    grid-row: 1;
}

.team-standings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.team-row {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--brand-cream);
    border-radius: 12px;
}

.team-color {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    margin-right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    color: white;
}

.team-info {
    flex: 1;
}

.team-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.team-players {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.team-points {
    font-size: 32px;
    font-weight: 800;
    color: var(--brand-navy);
}

.team-points span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* Activity Feed */
.activity-section {
    grid-column: 2;
    grid-row: 2;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.activity-feed {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    padding: 16px;
    background: var(--brand-cream);
    border-radius: 12px;
    animation: slideIn 0.3s ease-out;
}

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

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

.activity-player {
    font-weight: 700;
    color: var(--text-primary);
}

.activity-time {
    font-size: 12px;
    color: var(--text-secondary);
}

.activity-detail {
    font-size: 14px;
    color: var(--text-secondary);
}

.activity-score {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    margin-left: 8px;
}

.activity-score.birdie { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.activity-score.par { background: rgba(26, 43, 74, 0.1); color: var(--brand-navy); }
.activity-score.bogey { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.activity-score.double { background: rgba(239, 68, 68, 0.15); color: var(--error); }

.no-activity {
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 20px;
}

.no-activity-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-activity p {
    font-size: 15px;
    font-weight: 500;
}

/* Footer */
.game-footer {
    background: var(--brand-navy);
    padding: 16px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    font-weight: 500;
}

.footer-icon {
    font-size: 18px;
}

.leave-btn {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.leave-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .game-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        padding: 16px;
    }
    
    .leaderboard-section {
        grid-column: 1;
        grid-row: 1;
    }
    
    .teams-section {
        grid-column: 1;
        grid-row: 2;
    }
    
    .activity-section {
        grid-column: 1;
        grid-row: 3;
    }
    
    .game-header {
        padding: 16px 20px;
    }
    
    .event-info h1 {
        font-size: 20px;
    }
}

/* ===== TV Mode (Large Screens) ===== */
@media (min-width: 1920px) {
    .game-header {
        padding: 32px 60px;
    }
    
    .event-info h1 {
        font-size: 36px;
    }
    
    .game-content {
        padding: 32px 60px;
        gap: 32px;
    }
    
    .player-row {
        padding: 20px;
    }
    
    .player-name {
        font-size: 20px;
    }
    
    .score-strokes {
        font-size: 32px;
    }
}
