/* =========================
   Root Variables & Defaults
   ========================= */
:root {
    --bg-main: #0e0e12;
    --bg-panel: rgba(28, 28, 36, 0.85);
    --bg-surface: #1c1c24;
    --bg-surface-alt: #2a2a36;

    --accent: #7dd3fc;
    --danger: #ef4444;

    --text-main: #f1f1f1;
    --text-muted: rgba(255, 255, 255, 0.7);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 12px 32px rgba(0, 0, 0, 0.55);

    --transition-fast: 0.15s ease;
}

/*  ================
    Global Dark Mode
    ================ */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] {
    display: none !important;
}

/*  ==============
    Loading Screen
    ============== */
#loading-screen {
    position: fixed;
    inset: 0;
    background-color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loader-container {
    width: 240px;
    text-align: center;
}

.loading-text {
    margin-bottom: 12px;
    font-size: 1.1rem;
    letter-spacing: 1px;
    opacity: 0.9;
}

.loading-bar {
    width: 100%;
    height: 14px;
    background-color: var(--bg-surface);
    border-radius: 999px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    width: 0;
    background-color: var(--accent);
    border-radius: 999px;
    animation: fillBar 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: 80ms;
}

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

#loading-screen.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
    to { opacity: 0; }
}

/*  ==========
    App Panels
    ========== */
#app {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel {
    width: 100%;
    max-width: 420px;
    padding: 32px 28px;
    background: var(--bg-panel);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(6px);
    box-shadow: var(--shadow-soft);
}

.title {
    text-align: center;
    margin-bottom: 24px;
    font-size: 2rem;
    letter-spacing: 1px;
}

/*  =======
    Buttons
    ======= */
.menu-button {
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    background-color: var(--accent);
    color: var(--bg-main);

    transition:
            transform var(--transition-fast),
            box-shadow var(--transition-fast),
            background-color var(--transition-fast),
            opacity var(--transition-fast);
}

.menu-button:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px rgba(125, 211, 252, 0.4);
}

.menu-button:active {
    transform: translateY(0);
}

.menu-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.menu-button.secondary {
    background-color: var(--bg-surface-alt);
    color: var(--text-main);
}

.menu-button.secondary:hover {
    box-shadow: var(--shadow-soft);
}

.menu-button.danger {
    background-color: var(--danger);
    color: #ffffff;
}

.menu-button.danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

.menu-button.danger:focus-visible {
    outline: 2px solid var(--danger);
    outline-offset: 3px;
}

.menu-button#correct-button {
    background-color: #22c55e;
    color: #062e1a;
}

.menu-button#correct-button:hover {
    box-shadow: 0 6px 20px rgba(34, 197, 94, 0.5);
}

.menu-button#incorrect-button {
    background-color: var(--danger);
    color: white;
}

.menu-button#incorrect-button:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

.menu-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* =====
   Forms
   ===== */
label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 16px 0 4px 0;
    font-size: 0.9rem;
}

select,
input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: none;
    background-color: var(--bg-surface-alt);
    color: var(--text-main);
}

/* ===============
   Gameplay Layout
   =============== */
#gameplay {
    width: 100%;
    height: 100%;
    padding: 16px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* =======
   Top Bar
   ======= */
#top-bar {
    position: relative;
    display: flex;
    align-items: center;
    margin: 40px 0;
}

#teams-bar {
    display: flex;
    gap: 16px;
    margin: 0 auto;
}

.team {
    background-color: var(--bg-surface);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    min-width: 80px;
    text-align: center;
}

.team-name {
    font-size: 0.85rem;
    opacity: 0.85;
}

.team-score {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 2px;
}

.team.active {
    outline: 2px solid var(--accent);
    box-shadow: 0 0 0 4px rgba(125, 211, 252, 0.15);
}

/* ===============
   Settings Button
   =============== */
#settings-button {
    position: absolute;
    right: 2%;
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px;
    cursor: pointer;
    color: var(--text-main);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

#settings-button:hover {
    background-color: var(--bg-surface-alt);
    transform: translateY(-3px);
    color: var(--accent);
}

#settings-button:active {
    transform: translateY(0);
}

/* ================
   Settings Overlay
   ================ */
#settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14, 14, 18, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.2s ease;
}

.settings-content {
    background-color: var(--bg-surface);
    padding: 28px;
    border-radius: 20px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: scaleIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.96); }
    to { transform: scale(1); }
}

#settings-teams {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-team {
    display: grid;
    grid-template-columns: 1fr 80px;
    gap: 10px;
}

/* ==========
   Game Board
   ========== */
#board {
    display: grid;
    gap: 14px;
    flex: 1;
    width: 100%;
    max-width: min(90vw, 1200px);
    max-height: calc(100vh - 140px);
    margin: 0 auto;
    align-content: stretch;
    justify-content: center;
}

/* =====
   Cards
   ===== */
.card {
    position: relative;
    cursor: pointer;
    border-radius: var(--radius-lg);
    background:
            radial-gradient(circle at top left, rgba(255, 255, 255, 0.08), transparent 40%),
            linear-gradient(180deg, #3b82f6, var(--accent));
    box-shadow:
            inset 0 0 0 2px rgba(255, 255, 255, 0.15),
            var(--shadow-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    transition:
            transform var(--transition-fast),
            box-shadow var(--transition-fast),
            filter var(--transition-fast);
}

.card:hover {
    transform: translateY(-3px) scale(1.02);
    filter: brightness(1.05);
}

.card:active {
    transform: scale(0.98);
}

.card.used {
    filter: grayscale(0.6) brightness(0.7);
    opacity: 0.5;
    pointer-events: none;
}

.card-number {
    position: absolute;
    top: 7px;
    left: 10px;
    font-size: 1rem;
    font-weight: 700;
    opacity: 0.8;
}

/* ============
   Card Overlay
   ============ */
#card-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14, 14, 18, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10000;
}

#card-timer {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 16px;
    text-shadow: 0 0 12px rgba(125, 211, 252, 0.6);
    user-select: none;
}

.card-overlay-content {
    background-color: var(--bg-surface);
    padding: 32px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

#card-gibberish {
    font-size: 1.6rem;
    margin-bottom: 24px;
}

#card-answer {
    font-size: 1.2rem;
    margin: 16px 0;
    opacity: 0.9;
}

#answer-controls {
    margin-top: 16px;
 }

#card-answer {
    font-size: 1.2rem;
    margin: 16px 0;
    opacity: 0.9;
}

#card-answer-buttons {
    display: flex;
    gap: 16px;
}

#card-answer-buttons .menu-button {
    flex: 1;
}
