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

:root {
    --bg-dark: #0a0a0a;
    --bg-lighter: #1a1a1a;
    --bg-card: #252525;
    --accent-primary: #ffffff;
    --accent-secondary: #888888;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --success: #4CAF50;
    --error: #f44336;
    --warning: #ff9800;
    --border-color: #333333;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    width: 100%;
    max-width: 600px;
    text-align: center;
}

/* Logo */
.logo {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
    font-weight: 700;
}

/* Join Box */
.join-box {
    background: var(--bg-lighter);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.join-box input {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    border: 2px solid var(--bg-card);
    border-radius: 10px;
    background: var(--bg-dark);
    color: var(--text-primary);
    margin-bottom: 1rem;
    transition: border-color 0.3s;
}

.join-box input:focus {
    outline: none;
    border-color: var(--accent-cyan);
}

/* Buttons */
.btn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-dark);
}

.btn-primary:hover {
    background: var(--accent-secondary);
    color: var(--text-primary);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: var(--success);
    color: var(--bg-dark);
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-lg {
    padding: 1.5rem 3rem;
    font-size: 1.3rem;
    width: 100%;
    margin: 2rem 0;
}

/* Player List */
.player-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
}

.player-card {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.status-text {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.hidden {
    display: none !important;
}

/* Transition Screen */
#transition-screen {
    background: var(--bg-dark);
}

.transition-content h1 {
    font-size: 4rem;
    color: var(--text-primary);
    margin-bottom: 2rem;
    animation: fadeInScale 0.5s ease-out;
}

.transition-progress {
    width: 300px;
    height: 10px;
    background: var(--bg-card);
    border-radius: 5px;
    margin: 0 auto;
    overflow: hidden;
}

.transition-bar {
    height: 100%;
    background: var(--accent-primary);
    animation: progressBar 3s linear;
}

@keyframes progressBar {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Question Screen */
#question-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-height: 100vh;
    padding: 0;
    justify-content: flex-start;
    overflow: hidden;
}

.question-header {
    padding: 1rem 1rem;
    text-align: center;
    flex-shrink: 0;
}

.progress-bar {
    width: 100%;
    max-width: 600px;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 0.75rem;
}

.time-bar {
    height: 100%;
    background: var(--accent-primary);
    transition: width 0.1s linear;
}

.question-text {
    font-size: 1.3rem;
    margin-bottom: 0.5rem;
    text-align: center;
    font-weight: 600;
    line-height: 1.3;
}

.time-remaining {
    text-align: center;
    font-size: 1.1rem;
    color: var(--accent-primary);
    font-weight: 700;
}

/* Answer Container */
.answer-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow: hidden;
    position: relative;
}

/* True/False Buttons */
.tf-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
    max-width: 900px;
}

.tf-btn {
    min-height: 100px;
    font-size: 1.8rem;
    font-weight: 700;
    border-radius: 12px;
    border: 3px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    background: var(--bg-card);
    color: var(--text-primary);
}

.tf-btn.true:hover:not(:disabled) {
    background: var(--success);
    border-color: var(--success);
}

.tf-btn.false:hover:not(:disabled) {
    background: var(--error);
    border-color: var(--error);
}

.tf-btn:active:not(:disabled) {
    transform: scale(0.95);
}

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

/* Multiple Choice */
.mc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
    max-width: 900px;
}

.mc-btn {
    min-height: 80px;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 12px;
    border: 3px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.mc-btn:hover:not(:disabled) {
    border-color: var(--accent-primary);
    background: var(--bg-lighter);
}

.mc-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.mc-btn.selected {
    border-color: var(--accent-primary);
    background: var(--bg-lighter);
}

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

/* Multiple Select */
.ms-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 900px;
}

.ms-option {
    min-height: 80px;
    padding: 1rem;
    font-size: 1rem;
    border-radius: 12px;
    background: var(--bg-card);
    border: 3px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ms-option input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.ms-option:hover {
    border-color: var(--accent-primary);
}

.ms-option.selected {
    border-color: var(--accent-primary);
    background: var(--bg-lighter);
}

/* Text Input */
.text-input-box {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.text-input-box input {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    border: 3px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    margin-bottom: 1rem;
    text-align: center;
}

.text-input-box input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.text-input-box button {
    width: 100%;
}

/* Ordering */
.ordering-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    width: 100%;
    max-width: 900px;
}

.ordering-items, .ordering-drop-zone {
    min-height: 250px;
    padding: 1rem;
    border-radius: 12px;
    background: var(--bg-card);
    border: 3px solid var(--border-color);
}

.ordering-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-lighter);
    border-radius: 8px;
    cursor: move;
    transition: all 0.2s;
    border: 2px solid var(--border-color);
}

.ordering-item:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
}

.ordering-item.dragging {
    opacity: 0.5;
}

@media (max-width: 768px) {
    .ordering-container {
        grid-template-columns: 1fr;
    }
    
    .ordering-items, .ordering-drop-zone {
        min-height: 150px;
    }
}

/* Waiting Overlay */
.waiting-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.waiting-content {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid var(--bg-lighter);
    border-top-color: var(--accent-cyan);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Result Screen */
.result-content {
    text-align: center;
    animation: fadeInScale 0.5s ease-out;
}

.result-icon {
    font-size: 6rem;
    margin-bottom: 1rem;
}

.result-icon.correct {
    color: var(--success);
}

.result-icon.incorrect {
    color: var(--error);
}

#result-text {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.points-earned {
    font-size: 2rem;
    font-weight: 700;
}

.correct-answer {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 15px;
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .result-icon {
        font-size: 4rem;
    }
    
    #result-text {
        font-size: 1.8rem;
    }
    
    .points-earned {
        font-size: 1.5rem;
    }
}

/* Leaderboard */
.leaderboard-content {
    max-width: 800px;
    margin: 0 auto;
}

.leaderboard-content h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 15px;
    transition: all 0.3s;
    animation: slideIn 0.5s ease-out backwards;
    gap: 1rem;
}

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

.leaderboard-item.rank-1 {
    background: var(--accent-primary);
    color: var(--bg-dark);
    border: 3px solid var(--accent-primary);
}

.leaderboard-item.rank-2 {
    background: var(--bg-card);
    border: 3px solid var(--accent-secondary);
}

.leaderboard-item.rank-3 {
    background: var(--bg-card);
    border: 3px solid var(--border-color);
}

.rank-number {
    font-size: 2rem;
    font-weight: 700;
    min-width: 50px;
}

.player-name {
    flex: 1;
    font-size: 1.5rem;
    font-weight: 600;
}

.player-points {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.old-points {
    transition: all 0.5s;
}

.points-arrow {
    font-size: 1rem;
    opacity: 0.5;
}

.new-points {
    transition: all 0.5s;
}

.points-diff {
    font-size: 1rem;
    color: var(--success);
    font-weight: 600;
}

/* Final Screen */
.final-content {
    max-width: 1000px;
    margin: 0 auto;
    text-align: center;
}

.final-content h1 {
    font-size: 3.5rem;
    margin-bottom: 3rem;
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 2rem;
    margin-bottom: 3rem;
    height: 300px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.podium-bar {
    width: 150px;
    background: var(--bg-card);
    border-radius: 10px 10px 0 0;
    position: relative;
    transition: all 0.5s;
}

.podium-place.first .podium-bar {
    height: 200px;
    background: var(--accent-primary);
}

.podium-place.second .podium-bar {
    height: 150px;
    background: var(--accent-secondary);
}

.podium-place.third .podium-bar {
    height: 100px;
    background: var(--bg-card);
}

.podium-player {
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.medal {
    font-size: 3rem;
    margin-top: 1rem;
}

.final-leaderboard {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

/* Admin Styles */
.admin-body {
    background: var(--bg-dark);
}

.admin-header {
    background: var(--bg-lighter);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.admin-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-panel {
    background: var(--bg-lighter);
    padding: 2rem;
    border-radius: 15px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--bg-card);
}

.admin-player-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.admin-player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 10px;
}

.quiz-select-section {
    margin-bottom: 2rem;
}

.quiz-select-section label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--bg-card);
    border-radius: 8px;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-size: 1rem;
}

.quiz-info {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 10px;
}

.quiz-meta {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.game-status {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 1.5rem 0;
}

.stat-box {
    padding: 1rem;
    background: var(--bg-lighter);
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.admin-leaderboard {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-leaderboard h3 {
    margin-bottom: 1rem;
}

#admin-leaderboard-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .logo {
        font-size: 1.8rem;
    }
    
    #question-screen {
        padding: 0;
    }
    
    .question-header {
        padding: 0.75rem 0.5rem;
    }
    
    .question-text {
        font-size: 1rem;
        margin-bottom: 0.4rem;
        line-height: 1.2;
    }
    
    .time-remaining {
        font-size: 0.9rem;
    }
    
    .progress-bar {
        height: 5px;
        margin-bottom: 0.5rem;
    }
    
    .answer-container {
        padding: 0.75rem;
    }
    
    .tf-buttons,
    .mc-grid,
    .ms-grid {
        gap: 0.5rem;
    }
    
    .tf-btn {
        min-height: 70px;
        font-size: 1.3rem;
    }
    
    .mc-btn {
        min-height: 60px;
        font-size: 0.85rem;
        padding: 0.5rem;
    }
    
    .ms-option {
        min-height: 55px;
        padding: 0.5rem;
        font-size: 0.8rem;
    }
    
    .ms-option input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    
    .text-input-box input {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .admin-container {
        grid-template-columns: 1fr;
    }
    
    .podium {
        height: 200px;
        gap: 1rem;
    }
    
    .podium-bar {
        width: 80px;
    }
    
    .podium-place.first .podium-bar {
        height: 150px;
    }
    
    .podium-place.second .podium-bar {
        height: 110px;
    }
    
    .podium-place.third .podium-bar {
        height: 70px;
    }
    
    .medal {
        font-size: 2rem;
    }
    
    .leaderboard-item {
        padding: 0.75rem;
    }
    
    .rank-number {
        font-size: 1.3rem;
        min-width: 35px;
    }
    
    .player-name {
        font-size: 1rem;
    }
    
    .player-points {
        font-size: 0.85rem;
        flex-direction: column;
        align-items: flex-end;
        gap: 0.15rem;
    }
    
    .points-arrow {
        display: none;
    }
    
    .waiting-content {
        font-size: 0.8rem;
        padding: 0.5rem;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .question-header {
        padding: 0.5rem 0.4rem;
    }
    
    .question-text {
        font-size: 0.9rem;
    }
    
    .time-remaining {
        font-size: 0.8rem;
    }
    
    .tf-btn {
        min-height: 60px;
        font-size: 1.1rem;
    }
    
    .mc-btn {
        min-height: 55px;
        font-size: 0.8rem;
    }
    
    .ms-option {
        min-height: 50px;
        font-size: 0.75rem;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 600px) and (orientation: landscape) {
    .question-header {
        padding: 0.5rem;
    }
    
    .question-text {
        font-size: 0.9rem;
        margin-bottom: 0.3rem;
    }
    
    .time-remaining {
        font-size: 0.8rem;
    }
    
    .tf-btn {
        min-height: 55px;
        font-size: 1.1rem;
    }
    
    .mc-btn {
        min-height: 50px;
        font-size: 0.8rem;
    }
}