/* Traffic Light Game - Frontend Styles */

* {
    box-sizing: border-box;
}

#tlg-game-container {
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    background: #1a1a1a;
    color: #fff;
    min-height: 100vh;
    position: relative;
}

/* Screen Transitions */
.tlg-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Welcome Screen */
.tlg-welcome-content {
    max-width: 700px;
    text-align: center;
    padding: 40px;
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.tlg-welcome-content h1 {
    font-size: 3em;
    margin: 0 0 10px 0;
    color: #4ade80;
}

.tlg-subtitle {
    font-size: 1.2em;
    color: #a0a0a0;
    margin-bottom: 30px;
}

.tlg-instructions {
    text-align: left;
    background: rgba(255,255,255,0.05);
    padding: 25px;
    border-radius: 15px;
    margin: 30px 0;
}

.tlg-instructions h3 {
    margin-top: 0;
    color: #4ade80;
}

.tlg-instructions ul {
    list-style: none;
    padding: 0;
}

.tlg-instructions li {
    padding: 8px 0;
    padding-left: 30px;
    position: relative;
}

.tlg-instructions li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4ade80;
    font-weight: bold;
    font-size: 1.2em;
}

.tlg-educational-note {
    background: rgba(66, 153, 225, 0.2);
    border-left: 4px solid #4299e1;
    padding: 15px;
    margin-top: 20px;
    border-radius: 5px;
    text-align: left;
}

.tlg-mode-selection {
    margin-top: 30px;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.tlg-btn {
    padding: 15px 40px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tlg-btn-primary {
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #fff;
    box-shadow: 0 4px 15px rgba(74, 222, 128, 0.4);
}

.tlg-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.6);
}

.tlg-btn-secondary {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
}

.tlg-btn-secondary:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

.tlg-btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 5px;
    cursor: pointer;
}

.tlg-btn-small:hover {
    background: rgba(255,255,255,0.2);
}

/* Name Entry Screen */
.tlg-name-content {
    max-width: 500px;
    text-align: center;
    padding: 40px;
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.tlg-name-content h2 {
    color: #4ade80;
    margin-top: 0;
}

#tlg-player-name {
    width: 100%;
    padding: 15px;
    font-size: 1.2em;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    margin: 20px 0;
    text-align: center;
}

#tlg-player-name::placeholder {
    color: rgba(255,255,255,0.5);
}

.tlg-name-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Game Screen - LANDSCAPE LAYOUT */
#tlg-game-screen {
    display: grid;
    grid-template-columns: 1fr 350px;
    grid-template-rows: auto 1fr;
    padding: 0;
    min-height: 100vh;
    width: 100%;
    gap: 0;
}

.tlg-game-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 10;
}

.tlg-player-info {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
    flex-wrap: wrap;
}

.tlg-video-container {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 60px);
}

#tlg-game-video-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tlg-game-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

.tlg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.tlg-game-controls {
    grid-column: 2;
    grid-row: 2;
    padding: 30px 20px;
    background: rgba(0,0,0,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 10;
}

.tlg-intersection-name {
    font-size: 1.2em;
    text-align: center;
    color: #4ade80;
    font-weight: bold;
}

.tlg-press-btn {
    width: 100%;
    max-width: 300px;
    padding: 25px 20px;
    font-size: 1.2em;
    font-weight: bold;
    background: linear-gradient(135deg, #4ade80, #22c55e);
    color: #fff;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(74, 222, 128, 0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
    word-wrap: break-word;
    line-height: 1.4;
}

.tlg-press-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(74, 222, 128, 0.6);
}

.tlg-press-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.tlg-press-btn.pressed {
    background: #6b7280;
    cursor: not-allowed;
}

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

.tlg-countdown {
    font-size: 3em;
    font-weight: bold;
    color: #4ade80;
    margin-top: 10px;
    animation: pulse 0.5s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Result Panel */
.tlg-result-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.tlg-result-content {
    text-align: center;
    padding: 40px;
    max-width: 600px;
}

#tlg-result-icon {
    font-size: 5em;
    margin-bottom: 20px;
    animation: resultAppear 0.5s ease-out;
}

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

#tlg-result-title {
    font-size: 2.5em;
    margin: 0 0 15px 0;
    color: #4ade80;
}

#tlg-result-message {
    font-size: 1.3em;
    margin-bottom: 30px;
    color: #a0a0a0;
}

.tlg-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.tlg-stat {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 10px;
}

.tlg-stat-label {
    display: block;
    font-size: 0.9em;
    color: #a0a0a0;
    margin-bottom: 5px;
}

.tlg-stat-value {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    color: #4ade80;
}

.tlg-result-content .tlg-btn {
    margin: 10px;
}

/* Leaderboard Screen */
.tlg-leaderboard-content {
    max-width: 900px;
    width: 100%;
    padding: 40px;
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.tlg-leaderboard-content h2 {
    text-align: center;
    color: #4ade80;
    font-size: 2.5em;
    margin-top: 0;
}

.tlg-leaderboard {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
}

.tlg-leaderboard thead {
    background: rgba(74, 222, 128, 0.2);
}

.tlg-leaderboard th {
    padding: 15px;
    text-align: left;
    font-weight: bold;
    color: #4ade80;
}

.tlg-leaderboard td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.tlg-leaderboard tr:hover {
    background: rgba(255,255,255,0.05);
}

.tlg-rank {
    font-weight: bold;
    color: #4ade80;
    font-size: 1.2em;
}

.tlg-player {
    font-weight: bold;
}

.tlg-leaderboard-buttons {
    text-align: center;
    margin-top: 30px;
}

/* Loading Indicator */
.tlg-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.tlg-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(74, 222, 128, 0.3);
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.tlg-loading p {
    margin-top: 20px;
    font-size: 1.2em;
}

/* Mobile Optimization - All Screens */
@media screen and (max-width: 768px) {
    .tlg-welcome-content,
    .tlg-name-content {
        padding: 20px;
    }
    
    .tlg-welcome-content h1 {
        font-size: 2em;
    }
    
    .tlg-instructions {
        padding: 15px;
    }
    
    .tlg-btn {
        padding: 12px 30px;
        font-size: 1em;
    }
    
    .tlg-game-header {
        padding: 8px 15px;
        font-size: 0.8em;
    }
    
    .tlg-player-info {
        flex-direction: column;
        gap: 3px;
    }
    
    .tlg-video-container {
        min-height: calc(100vh - 170px);
    }
    
    #tlg-game-video-wrapper,
    #tlg-game-video {
        max-height: calc(100vh - 170px);
    }
    
    .tlg-game-controls {
        padding: 10px 15px;
    }
    
    .tlg-intersection-name {
        font-size: 0.9em;
        margin-bottom: 8px;
    }
    
    .tlg-press-btn {
        padding: 18px 30px;
        font-size: 1.1em;
        max-width: 100%;
    }
    
    .tlg-countdown {
        font-size: 2.5em;
        margin-top: 8px;
    }
    
    #tlg-result-icon {
        font-size: 3em;
    }
    
    #tlg-result-title {
        font-size: 1.8em;
    }
    
    #tlg-result-message {
        font-size: 1.1em;
    }
    
    .tlg-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tlg-leaderboard-content {
        padding: 20px;
    }
    
    .tlg-leaderboard {
        font-size: 0.9em;
    }
    
    .tlg-leaderboard th,
    .tlg-leaderboard td {
        padding: 8px;
    }
}

/* Landscape Mode Optimization for Mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .tlg-screen {
        min-height: auto;
        padding: 10px;
    }
    
    .tlg-welcome-content {
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .tlg-welcome-content h1 {
        font-size: 1.8em;
        margin-bottom: 5px;
    }
    
    .tlg-subtitle {
        font-size: 1em;
        margin-bottom: 15px;
    }
    
    .tlg-instructions {
        padding: 10px;
        margin: 15px 0;
    }
    
    .tlg-game-header {
        padding: 5px 15px;
        font-size: 0.75em;
    }
    
    .tlg-video-container {
        min-height: calc(100vh - 110px);
    }
    
    #tlg-game-video-wrapper,
    #tlg-game-video {
        max-height: calc(100vh - 110px);
    }
    
    .tlg-game-controls {
        padding: 8px 15px;
    }
    
    .tlg-intersection-name {
        font-size: 0.85em;
        margin-bottom: 5px;
    }
    
    .tlg-press-btn {
        padding: 12px 25px;
        font-size: 1em;
    }
    
    .tlg-countdown {
        font-size: 2em;
        margin-top: 5px;
    }
    
    .tlg-result-content {
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Desktop Large Screens - Maximize Video */
@media screen and (min-width: 1200px) {
    #tlg-game-video {
        max-height: calc(100vh - 130px);
    }
    
    .tlg-video-container {
        min-height: calc(100vh - 180px);
    }
}