/* Pyramidal Trivia Design System */

:root {
    --bg-dark: #07050f;
    --bg-card: rgba(18, 14, 36, 0.65);
    --border-glass: rgba(255, 255, 255, 0.07);
    --border-glow: rgba(139, 92, 246, 0.25);
    
    --primary: #8b5cf6;       /* Violet */
    --primary-glow: rgba(139, 92, 246, 0.5);
    --secondary: #ec4899;     /* Pink */
    --secondary-glow: rgba(236, 72, 153, 0.5);
    --success: #10b981;       /* Emerald */
    --danger: #ef4444;        /* Red */
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dark: #1f2937;
    
    --font-outfit: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-outfit);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Floating Radial Glow Backgrounds */
.glow-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.glow-bg::before, .glow-bg::after {
    content: '';
    position: absolute;
    width: 40vw;
    height: 40vw;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.18;
}

.glow-bg::before {
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -10%;
    left: -10%;
    animation: floatGlow 12s infinite alternate ease-in-out;
}

.glow-bg::after {
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    bottom: -10%;
    right: -10%;
    animation: floatGlow 15s infinite alternate-reverse ease-in-out;
}

@keyframes floatGlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.15); }
}

/* Layout Container */
.app-container {
    width: 90%;
    max-width: 800px;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
}

/* Header & Typography */
header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.logo {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 40%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo span {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 900;
}

/* Premium Card Layout (Glassmorphism) */
.main-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
}

/* View/Screen Transitions */
.screen {
    opacity: 1;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.hidden {
    display: none !important;
}

/* Buttons Styling */
.btn {
    font-family: var(--font-outfit);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 0.9rem 2rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.primary-btn:active {
    transform: translateY(0);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.btn-glow {
    position: relative;
}

.btn-glow::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    box-shadow: 0 0 20px var(--primary-glow);
    opacity: 0;
    transition: var(--transition-smooth);
    z-index: -1;
}

.btn-glow:hover::after {
    opacity: 1;
}

/* Rules Section */
.intro-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.2rem;
}

.intro-box h2 {
    font-size: 1.8rem;
    font-weight: 700;
}

.tagline {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 500px;
}

.rules-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: left;
    max-width: 600px;
    margin: 0.5rem 0;
}

.rules-card h3 {
    margin-bottom: 0.8rem;
    font-size: 1.15rem;
    color: var(--primary);
    font-weight: 600;
}

.rules-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.rules-card li {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #d1d5db;
}

/* Leaderboard Tables */
.leaderboard-section {
    width: 100%;
    margin-top: 1rem;
}

.leaderboard-section h3 {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-container {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

th, td {
    padding: 1rem 1.2rem;
}

th {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

tr {
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: var(--transition-smooth);
}

tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

td.loading {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}

/* Game Meta Info */
.game-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 1rem;
}

.badge {
    background: rgba(255, 255, 255, 0.07);
    padding: 0.4rem 1rem;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border-glass);
}

.badge.category {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--border-glow);
    color: #a78bfa;
}

/* Word Streaming Ticker */
.question-box-wrapper {
    min-height: 180px;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: flex-start;
}

.question-text {
    font-size: 1.35rem;
    line-height: 1.7;
    font-weight: 400;
    color: #e5e7eb;
    word-spacing: 2px;
}

/* Animated word entries */
.word {
    display: inline-block;
    margin-right: 0.35rem;
    opacity: 0;
    transform: translateY(4px);
    animation: revealWord 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes revealWord {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Controls Area (Buzzer & Answer submission) */
.controls-area {
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#buzzer-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

/* Buzzer Button */
.buzzer-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--secondary) 0%, #db2777 100%);
    border: 4px solid rgba(255, 255, 255, 0.8);
    color: white;
    font-family: var(--font-outfit);
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: 1px;
    cursor: pointer;
    position: relative;
    box-shadow: 0 8px 25px rgba(236, 72, 153, 0.4),
                inset 0 2px 4px rgba(255, 255, 255, 0.4);
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.buzzer-btn:hover {
    transform: scale(1.05);
}

.buzzer-btn:active {
    transform: scale(0.92);
}

/* Buzzer Pulse Ring */
.pulse-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 4px solid var(--secondary);
    animation: pulseBuzzer 2s infinite ease-out;
    opacity: 0.6;
    pointer-events: none;
}

@keyframes pulseBuzzer {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.4); opacity: 0; }
}

.action-helper {
    color: var(--text-muted);
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

/* Input Form & Answer Card */
.answer-card {
    width: 100%;
    max-width: 480px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 18px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.answer-card h3 {
    font-size: 1.1rem;
    text-align: center;
    color: var(--secondary);
    font-weight: 600;
}

/* Answering Countdown Timer Fill */
.timer-bar-container {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 99px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--secondary) 0%, var(--primary) 100%);
    border-radius: 99px;
    transition: width 0.1s linear;
}

#answer-form {
    display: flex;
    gap: 0.5rem;
}

#answer-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: white;
    padding: 0.8rem 1rem;
    font-family: var(--font-outfit);
    font-size: 1rem;
    outline: none;
    transition: var(--transition-smooth);
}

#answer-input:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.25);
}

/* Card rumble animation on buzz */
.buzz-rumble {
    animation: rumble 0.25s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes rumble {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-3px, 0, 0); }
    40%, 60% { transform: translate3d(3px, 0, 0); }
}

/* Round Result Card */
.result-banner {
    text-align: center;
    padding: 1.5rem;
    border-radius: 16px;
    margin-bottom: 0.5rem;
}

.result-banner.success-banner {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.result-banner.fail-banner {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171;
}

#result-title {
    font-size: 1.6rem;
    font-weight: 800;
}

#points-banner {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 0.3rem;
}

.result-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.reveal-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    padding: 1.2rem;
    border-radius: 12px;
}

.reveal-box h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    letter-spacing: 0.5px;
}

.guess-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: #cbd5e1;
}

.answer-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
}

/* Full Question Highlight Reveal */
.full-question-reveal {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-glass);
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.full-question-reveal h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.revealed-text {
    font-size: 1.05rem;
    line-height: 1.6;
    color: #9ca3af;
}

.buzz-word-highlight {
    color: var(--success);
    font-weight: 600;
    border-bottom: 2px dashed rgba(16, 185, 129, 0.4);
    padding-bottom: 1px;
}

.pre-buzz-word {
    color: #f3f4f6; /* brighter white for pre-buzz words */
}

.indicator-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.legend-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-buzz {
    background-color: var(--success);
}

.round-summary {
    text-align: center;
    font-size: 1.1rem;
}

.round-summary strong {
    color: var(--primary);
    font-size: 1.3rem;
}

/* Game Over Card */
.game-over-banner {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.game-over-banner h2 {
    font-size: 2.2rem;
    font-weight: 800;
}

.final-score-text {
    font-size: 1.3rem;
    color: var(--text-muted);
}

.final-score-text span {
    color: var(--secondary);
    font-size: 1.8rem;
    font-weight: 800;
}

.leaderboard-form-card {
    background: rgba(236, 72, 153, 0.05);
    border: 1px solid rgba(236, 72, 153, 0.15);
    border-radius: 18px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.leaderboard-form-card h3 {
    font-weight: 700;
    color: var(--secondary);
}

#leaderboard-form {
    display: flex;
    gap: 0.5rem;
    max-width: 450px;
    margin: 0 auto;
    width: 100%;
}

#username-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    color: white;
    padding: 0.8rem 1rem;
    font-family: var(--font-outfit);
    font-size: 1rem;
    outline: none;
    transition: var(--transition-smooth);
}

#username-input:focus {
    border-color: var(--secondary);
}

/* Footer styling */
footer {
    text-align: center;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.25);
    margin-top: 1rem;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .main-card {
        padding: 1.5rem;
    }
    
    .logo {
        font-size: 1.8rem;
    }
    
    .result-details {
        grid-template-columns: 1fr;
    }
    
    #leaderboard-form, #answer-form {
        flex-direction: column;
    }
}
