@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;700&display=swap');

:root {
    --primary: #1DB954;
    --primary-hover: #1ed760;
    --bg-dark: #090909;
    --card-bg: rgba(255, 255, 255, 0.05);
    --text-main: #ffffff;
    --text-dim: #b3b3b3;
    --error: #ff4d4d;
    --success: #1DB954;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 0;
    overflow-x: hidden;
}

.background-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 50% -20%, #1db95433 0%, transparent 50%),
        radial-gradient(circle at 0% 100%, #1db9541a 0%, transparent 40%);
    z-index: -1;
}

.container {
    width: 90%;
    max-width: 520px;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

header h1 span {
    color: var(--primary);
}

header p {
    color: var(--text-dim);
    font-size: 1rem;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

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

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.search-box {
    position: relative;
}

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.11);
}

.results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: #1a1a1a;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

.result-item {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.result-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.result-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.difficulty-selector {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}

.diff-btn {
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: var(--text-dim);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s;
}

.diff-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.diff-btn.active {
    background: var(--primary);
    color: black;
    border-color: var(--primary);
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    border: none;
    border-radius: 12px;
    color: black;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

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

.secondary-btn {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1px solid var(--primary);
    border-radius: 12px;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}

.secondary-btn:hover:not(:disabled) {
    background: rgba(29, 185, 84, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.15);
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
}

.hidden {
    display: none !important;
}

/* ====== GAME ====== */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 8px;
}

.question-counter {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.06);
    padding: 6px 12px;
    border-radius: 20px;
}

.playing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 14px;
    border-radius: 20px;
}

.wave-container {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 16px;
}

.wave {
    width: 3px;
    background: var(--primary);
    border-radius: 2px;
    animation: wave-anim 1s ease-in-out infinite;
}

.wave:nth-child(2) {
    animation-delay: .15s
}

.wave:nth-child(3) {
    animation-delay: .3s
}

.wave:nth-child(4) {
    animation-delay: .45s
}

.wave:nth-child(5) {
    animation-delay: .6s
}

@keyframes wave-anim {

    0%,
    100% {
        height: 4px;
    }

    50% {
        height: 16px;
    }
}

.progress-bar-container {
    width: 100%;
    height: 7px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: var(--primary);
    transition: width 0.08s linear;
}

.time-info {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 1.4rem;
}

.options-grid {
    display: grid;
    gap: 10px;
}

.option-btn {
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    text-align: left;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
    transform: translateX(4px);
}

.option-btn.correct {
    background: var(--success);
    color: black;
    border-color: var(--success);
}

.option-btn.wrong {
    background: var(--error);
    border-color: var(--error);
}

/* ====== QUESTION TRACKER ====== */
.question-tracker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 1.4rem;
}

.tracker-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.12);
    color: var(--text-dim);
    transition: all 0.35s;
}

.tracker-dot.active {
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.15);
}

.tracker-dot.dot-correct {
    background: var(--success);
    color: black;
    border-color: var(--success);
}

.tracker-dot.dot-wrong {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* ====== RESULT SCREEN ====== */
.result-hero {
    text-align: center;
    margin-bottom: 1.5rem;
}

.result-emoji {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
}

.result-hero h2 {
    font-size: 1.75rem;
    margin-bottom: 0.3rem;
}

.result-hero p {
    color: var(--text-dim);
    font-size: 1rem;
}

.score-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.score-box {
    padding: 1.2rem;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--glass-border);
}

.score-box span {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
}

.score-box label {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.correct-box {
    background: rgba(29, 185, 84, 0.12);
    border-color: rgba(29, 185, 84, 0.3);
}

.correct-box span {
    color: var(--success);
}

.wrong-box {
    background: rgba(255, 77, 77, 0.12);
    border-color: rgba(255, 77, 77, 0.3);
}

.wrong-box span {
    color: var(--error);
}

.answer-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
    padding-right: 6px;
}

/* Custom Scrollbar for Answer Summary */
.answer-summary::-webkit-scrollbar {
    width: 6px;
}

.answer-summary::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
}

.answer-summary::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 8px;
}

.answer-summary::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover);
}

.summary-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    font-size: 0.9rem;
}

.summary-correct {
    background: rgba(29, 185, 84, 0.15);
    border-color: rgba(29, 185, 84, 0.3);
}

.summary-wrong {
    background: rgba(255, 77, 77, 0.15);
    border-color: rgba(255, 77, 77, 0.3);
}

.summary-num {
    width: 22px;
    text-align: center;
    font-weight: 700;
    color: var(--text-dim);
    flex-shrink: 0;
}

.summary-track {
    flex: 1;
    color: #ffffff;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.summary-icon {
    flex-shrink: 0;
}

/* ====== LOADING TRIVIA ====== */
#loading-trivia {
    text-align: center;
    font-size: 0.9rem;
    font-style: italic;
    color: var(--text-dim);
    margin-top: 16px;
    display: none;
    letter-spacing: 0.05em;
}

.fade-anim {
    animation: fadeInOut 0.75s ease-in-out;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateY(-4px);
    }

    20% {
        opacity: 1;
        transform: translateY(0);
    }

    80% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(4px);
    }
}

/* ====== REPLAY BUTTON ====== */
.replay-icon-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
    margin-left: 8px;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(29, 185, 84, 0.1);
}

.replay-icon-btn svg {
    width: 16px;
    height: 16px;
}

.replay-icon-btn:hover {
    background: rgba(29, 185, 84, 0.25);
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 0 10px rgba(29, 185, 84, 0.3);
}

/* ====== NOTE OVERLAY ====== */
.note-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    /* Initially disabled */
}

.note-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.note-card {
    background: rgba(255, 255, 255, 0.05); /* Glass effect */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    width: 90%;
    max-width: 440px;
    padding: 3rem 2.5rem 2.5rem; /* Increased padding */
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    transform: scale(0.9) rotate(2deg);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-main);
    text-align: center;
}

.note-overlay.visible .note-card {
    transform: scale(1) rotate(-1deg);
}

.note-card::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 12px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.note-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #aaa;
    transition: color 0.2s;
}

.note-close-btn:hover {
    color: #666;
}

.note-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.note-text {
    font-family: 'Caveat', cursive;
    font-size: 2rem;
    color: var(--text-main);
    line-height: 1.6; /* Improved line spacing */
    min-height: 80px;
    margin-bottom: 2rem;
}

.note-close-action-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--primary);
    border-radius: 12px;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.note-close-action-btn:hover {
    background: rgba(29, 185, 84, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(29, 185, 84, 0.15);
}


.ink-letter {
    display: inline-block;
    opacity: 0;
    transform: translateX(-4px) rotate(-2deg);
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: pre-wrap;
    /* Preserve spaces */
}

.ink-letter.visible {
    opacity: 1;
    transform: translateX(0) rotate(0);
}

.ink-word {
    display: inline-block;
    white-space: nowrap;
}

/* ====== SPOTLIGHT OVERLAY ====== */
.spotlight-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.spotlight-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.spotlight-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 0 15px var(--primary);
    text-align: center;
    animation: pulseText 1.5s infinite;
    padding: 0 20px;
}

@keyframes pulseText {
    0% {
        opacity: 0.6;
        transform: scale(0.98);
        text-shadow: 0 0 10px var(--primary);
    }

    50% {
        opacity: 1;
        transform: scale(1.02);
        text-shadow: 0 0 25px var(--primary);
    }

    100% {
        opacity: 0.6;
        transform: scale(0.98);
        text-shadow: 0 0 10px var(--primary);
    }
}