/* Global styles & Variables */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-dark: #090514;
    --bg-darker: #05030c;
    --primary: #511ca8;
    --primary-light: #9b51e0;
    --accent: #ffd35c;
    --text-light: #f5f2fa;
    --text-muted: #a395c9;
    
    /* Neon Color Theory Choice Tones */
    --red-choice: #ff3355;     /* High-energy, warm coral-red */
    --blue-choice: #0088ff;    /* Calming, crisp sky-blue */
    --yellow-choice: #ffcc00;  /* Bright, warm golden-yellow */
    --green-choice: #00cc66;  /* Balanced, fresh emerald-green */
    
    --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    --border-glow: 1px solid rgba(255, 255, 255, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-light) !important;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Background animated gradient */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 20%, rgba(81, 28, 168, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 10%, rgba(155, 81, 224, 0.1) 0px, transparent 40%),
        radial-gradient(at 50% 80%, rgba(9, 5, 20, 0.95) 0px, transparent 100%);
}

/* Header design */
header {
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: var(--border-glow);
    background: rgba(25, 17, 58, 0.5);
    backdrop-filter: blur(10px);
}

.logo {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(45deg, #ffc93c, #ff6b6b, #8644e8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

/* Container */
.container {
    max-width: 1200px;
    width: 90%;
    margin: 2rem auto;
    flex-grow: 1;
}

/* Buttons */
.btn {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: var(--text-light);
    border: none;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(134, 68, 232, 0.4);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(134, 68, 232, 0.6);
}

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

.btn-accent {
    background: linear-gradient(135deg, #ffd35c, var(--accent));
    color: var(--bg-darker);
    box-shadow: 0 4px 15px rgba(255, 201, 60, 0.4);
}

.btn-accent:hover {
    box-shadow: 0 8px 25px rgba(255, 201, 60, 0.6);
}

/* Lobby Screen & Cards */
.card {
    background: rgba(255, 255, 255, 0.05);
    border: var(--border-glow);
    border-radius: 24px;
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow-premium);
    backdrop-filter: blur(20px);
}

.pin-display {
    font-size: 5rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 4px;
    margin: 1.5rem 0;
    text-shadow: 0 0 20px rgba(255, 201, 60, 0.3);
    animation: pulse 2s infinite;
}

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

/* Players Grid */
.players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
}

.player-bubble {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.8rem 1.2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-light) !important;
    border: var(--border-glow);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Host Game Screen */
.question-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.question-text {
    font-size: 2.5rem;
    font-weight: 800;
    margin-top: 1rem;
    line-height: 1.3;
}

.question-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.timer-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 8px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 800;
    transition: border-color 0.3s;
}

.answers-counter {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem 2rem;
    border-radius: 16px;
    border: var(--border-glow);
    text-align: center;
}

.answers-counter-num {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary-light);
}

/* Choices Layout */
.choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.choice-box {
    padding: 2rem;
    border-radius: 16px;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    transition: all 0.2s;
}

.choice-box.red { background-color: var(--red-choice); }
.choice-box.blue { background-color: var(--blue-choice); }
.choice-box.yellow { background-color: var(--yellow-choice); }
.choice-box.green { background-color: var(--green-choice); }

.choice-icon {
    font-size: 2rem;
    opacity: 0.9;
}

.choice-box.dimmed {
    opacity: 0.3;
    transform: scale(0.97);
}

.choice-box.correct-highlight {
    border: 4px solid white;
    box-shadow: 0 0 30px white;
    z-index: 10;
}

/* Stats Chart */
.stats-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 250px;
    margin: 3rem 0;
}

.chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 15%;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 100%;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    transition: height 0.8s cubic-bezier(0.175, 0.885, 0.32, 1);
    min-height: 10px;
    position: relative;
}

.chart-bar.red { background-color: var(--red-choice); }
.chart-bar.blue { background-color: var(--blue-choice); }
.chart-bar.yellow { background-color: var(--yellow-choice); }
.chart-bar.green { background-color: var(--green-choice); }

.chart-count {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

/* Leaderboard Page */
.leaderboard-title {
    font-size: 3rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 3rem;
}

.leaderboard-list {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    min-height: 400px;
}

.leaderboard-item {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: var(--border-glow);
    padding: 1rem 2rem;
    border-radius: 14px;
    height: 65px;
    transition: top 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.leaderboard-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(90deg, rgba(134, 68, 232, 0.25), rgba(70, 23, 143, 0.5));
    border-right: 3px solid var(--primary-light);
    z-index: 0;
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.leaderboard-bar.first-place {
    background: linear-gradient(90deg, rgba(255, 211, 92, 0.35), rgba(216, 158, 0, 0.6));
    border-right: 4px solid var(--accent);
    box-shadow: 0 0 15px rgba(255, 211, 92, 0.4);
}

.leaderboard-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.rank {
    font-size: 1.5rem;
    font-weight: 800;
    width: 40px;
    color: var(--text-light) !important;
}

.rank-1 { color: #ffd700 !important; }
.rank-2 { color: #c0c0c0 !important; }
.rank-3 { color: #cd7f32 !important; }

.nickname {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-light) !important;
}

.score {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent) !important;
}

/* Player/Mobile Join Screen */
.join-container {
    max-width: 450px;
    width: 90%;
    margin: auto;
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 600;
}

.input-field {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
    color: white;
    font-family: inherit;
    transition: all 0.3s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-light);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 15px rgba(134, 68, 232, 0.3);
}

/* Player Gameplay Screen (Mobile Grid) */
.player-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 1rem;
    height: 70vh;
}

.player-btn {
    border: none;
    border-radius: 20px;
    font-size: 4rem;
    cursor: pointer;
    transition: all 0.1s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.player-btn:active {
    transform: scale(0.95);
    filter: brightness(0.9);
}

.player-btn.red { background-color: var(--red-choice); }
.player-btn.blue { background-color: var(--blue-choice); }
.player-btn.yellow { background-color: var(--yellow-choice); }
.player-btn.green { background-color: var(--green-choice); }

/* Player Feedback Screen */
.feedback-screen {
    text-align: center;
    padding: 3rem 1.5rem;
    border-radius: 24px;
    animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.feedback-screen.correct {
    background: rgba(38, 137, 12, 0.1);
    border: 2px solid var(--green-choice);
}

.feedback-screen.incorrect {
    background: rgba(226, 27, 60, 0.1);
    border: 2px solid var(--red-choice);
}

.feedback-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.feedback-screen.correct .feedback-title { color: #4cd137; }
.feedback-screen.incorrect .feedback-title { color: #ff4757; }

.points-earned {
    font-size: 2rem;
    font-weight: 800;
    margin: 1.5rem 0;
}

@keyframes scaleUp {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.feedback-footer {
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 1.2rem;
}
