/* ========================================
   BCG QUIZ – STYLE
   Color Palette from Apogepha branding
   ======================================== */

:root {
    --teal-dark: #0a5e5e;
    --teal-main: #2a8f8f;
    --teal-light: #b8d8d8;
    --teal-bg: #d4e8e8;
    --teal-pale: #e8f2f2;
    --cream: #f0f5f5;
    --dark: #1a3a3a;
    --white: #ffffff;
    --correct: #27ae60;
    --wrong: #c0392b;
    --gold: #f1c40f;
    --silver: #95a5a6;
    --bronze: #cd7f32;
    --shadow: 0 8px 32px rgba(10, 94, 94, 0.15);
    --shadow-lg: 0 16px 48px rgba(10, 94, 94, 0.2);
    --radius: 16px;
    --radius-sm: 10px;
    --font-main: 'Outfit', sans-serif;
    --font-mono: 'Space Mono', monospace;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background: var(--teal-bg);
    color: var(--dark);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Animated Canvas */
#bgCanvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ========== SCREENS ========== */
.screen {
    display: none;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 1.5rem;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

/* ========== CARDS ========== */
.card {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 720px;
    animation: cardIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
    border: 1px solid rgba(255,255,255,0.5);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== USERNAME SCREEN ========== */
.card-username {
    text-align: center;
    max-width: 560px;
}

.rule-icon-styled {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--teal-dark), var(--teal-main));
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.subtitle {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--teal-main);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

.title-main {
    font-size: 2.4rem;
    font-weight: 900;
    color: var(--dark);
    line-height: 1.1;
    margin-bottom: 0.4rem;
}

.tagline {
    font-size: 1.15rem;
    color: var(--teal-main);
    font-weight: 500;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 360px;
    margin: 0 auto;
}

.input-group input {
    font-family: var(--font-main);
    font-size: 1.1rem;
    padding: 0.9rem 1.2rem;
    border: 2px solid var(--teal-light);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    background: var(--white);
    text-align: center;
}

.input-group input:focus {
    border-color: var(--teal-main);
    box-shadow: 0 0 0 4px rgba(42, 143, 143, 0.15);
}

.input-group input::placeholder {
    color: #a0bfbf;
}

/* Buttons */
.btn-primary {
    font-family: var(--font-main);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0.9rem 2rem;
    background: linear-gradient(135deg, var(--teal-dark), var(--teal-main));
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    box-shadow: 0 4px 16px rgba(10, 94, 94, 0.25);
    letter-spacing: 0.02em;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(10, 94, 94, 0.35);
}

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

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

.btn-large {
    font-size: 1.3rem;
    padding: 1.1rem 3rem;
}

.pulse-btn {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(10, 94, 94, 0.25); }
    50% { box-shadow: 0 4px 32px rgba(10, 94, 94, 0.5); }
}

/* Footer Logo */
.footer-logo {
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.apogepha-logo-img {
    max-width: 180px;
    height: auto;
}

.apogepha-text {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--teal-dark);
    letter-spacing: 0.08em;
}

.apogepha-sub {
    font-size: 0.72rem;
    color: var(--teal-main);
    font-weight: 400;
}

/* ========== START SCREEN ========== */
.card-start {
    text-align: center;
    max-width: 620px;
}

.start-content h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 1.5rem;
}

.greeting {
    font-size: 1.1rem;
    color: var(--teal-main);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.rules-box {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.rule {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
    background: var(--teal-pale);
    border-radius: var(--radius-sm);
}

.rule-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    line-height: 1;
}

.timer-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.timer-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    justify-content: center;
    font-size: 0.9rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--white);
}

.badge-gold { background: var(--gold); color: #333; }
.badge-silver { background: var(--silver); }
.badge-bronze { background: var(--bronze); }

/* ========== QUIZ SCREEN ========== */
.quiz-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 2px 12px rgba(10,94,94,0.1);
    margin-bottom: 1rem;
    max-width: 720px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.quiz-progress {
    flex: 1;
}

#q-counter {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--teal-dark);
    margin-bottom: 0.3rem;
    display: block;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--teal-light);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.3rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--teal-dark), var(--teal-main));
    border-radius: 3px;
    transition: width 0.4s ease;
    width: 0%;
}

.quiz-timer {
    display: none;
}

.quiz-score {
    display: none;
}

#screen-quiz {
    flex-direction: column;
    padding-top: 0;
}

.card-quiz {
    max-width: 720px;
    margin: 0 auto;
}

/* Question Layout */
.question-slide {
    animation: slideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.question-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.45;
    margin-bottom: 1.5rem;
}

.question-image {
    width: 100%;
    max-width: 360px;
    max-height: 260px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin: 0 auto 1.5rem;
    display: block;
}

.question-image-small {
    max-width: 240px;
    max-height: 180px;
}

/* Options */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    margin-bottom: 1.5rem;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 1rem 1.2rem;
    background: var(--teal-pale);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    transition: all 0.25s;
    color: var(--dark);
    position: relative;
    overflow: hidden;
}

.option-btn:hover:not(.disabled) {
    border-color: var(--teal-main);
    background: rgba(42, 143, 143, 0.1);
    transform: translateX(4px);
}

.option-btn .option-letter {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--teal-main);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: background 0.3s;
}

.option-btn.selected {
    border-color: var(--teal-main);
    background: rgba(42, 143, 143, 0.15);
}

.option-btn.selected .option-letter {
    background: var(--teal-dark);
    box-shadow: 0 0 0 3px rgba(42, 143, 143, 0.2);
}

.option-btn.correct {
    border-color: var(--correct);
    background: rgba(39, 174, 96, 0.12);
}

.option-btn.correct .option-letter {
    background: var(--correct);
}

.option-btn.wrong {
    border-color: var(--wrong);
    background: rgba(192, 57, 43, 0.08);
}

.option-btn.wrong .option-letter {
    background: var(--wrong);
}

.option-btn.disabled {
    cursor: default;
    pointer-events: none;
}

/* Slider / Estimate Questions */
.slider-container {
    margin-bottom: 1.5rem;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--teal-main);
    margin-bottom: 0.3rem;
    font-weight: 600;
}

.slider-value-display {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 2rem;
    font-weight: 700;
    color: var(--teal-dark);
    margin-bottom: 0.8rem;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--teal-light), var(--teal-main));
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--teal-dark);
    border: 3px solid var(--white);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--teal-dark);
    border: 3px solid var(--white);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    cursor: pointer;
}

.btn-submit-slider {
    display: block;
    margin: 1rem auto 0;
}

/* Feedback */
.feedback {
    text-align: center;
    padding: 0.8rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

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

.feedback.correct {
    background: rgba(39, 174, 96, 0.12);
    color: var(--correct);
}

.feedback.wrong {
    background: rgba(192, 57, 43, 0.08);
    color: var(--wrong);
}

.btn-next {
    display: block;
    margin: 0 auto;
}

/* ========== FINISH SCREEN ========== */
.card-finish {
    text-align: center;
    max-width: 560px;
}

.finish-flag {
    width: 140px;
    height: 140px;
    margin: 0 auto 1.5rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.finish-flag canvas {
    display: block;
    margin: 0 auto;
}

.finish-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark);
    margin-bottom: 0.5rem;
    animation: fadeIn 0.6s ease 0.3s both;
}

.finish-sub {
    font-size: 1.05rem;
    color: var(--teal-main);
    font-weight: 500;
    animation: fadeIn 0.6s ease 0.6s both;
}

/* ========== RANKING SCREEN ========== */
.card-ranking {
    text-align: center;
    max-width: 620px;
}

.card-ranking h2 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.3rem;
    color: var(--dark);
}

.ranking-sub {
    color: var(--teal-main);
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 2rem;
    max-height: 20.5rem;
    overflow-y: auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--teal-main) transparent;
    text-align: left;
}

.ranking-row {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    background: var(--teal-pale);
    border-radius: var(--radius-sm);
    font-weight: 600;
    animation: rankIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
    transition: background 0.2s;
}

.ranking-row.highlight {
    background: rgba(42, 143, 143, 0.18);
    border: 2px solid var(--teal-main);
}

.rank-pos.rank-gold   { background: var(--gold);   color: #333; }
.rank-pos.rank-silver { background: var(--silver); }
.rank-pos.rank-bronze { background: var(--bronze); }

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

.rank-pos {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--teal-main);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 800;
    flex-shrink: 0;
}

.rank-name {
    flex: 1;
    font-size: 0.95rem;
}

.rank-score {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--teal-dark);
    font-size: 0.95rem;
}

.rank-time {
    font-size: 0.75rem;
    color: var(--teal-main);
    min-width: 55px;
    text-align: right;
}

.ranking-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.btn-export {
    background: linear-gradient(135deg, #1a6b3c, #27ae60);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 600px) {
    .card {
        padding: 1.5rem 1.2rem;
        border-radius: 12px;
    }

    .title-main {
        font-size: 1.8rem;
    }

    .card-start h2,
    .card-results h2,
    .card-ranking h2 {
        font-size: 1.5rem;
    }

    .question-text {
        font-size: 1.05rem;
    }

    .quiz-header {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.6rem 0.8rem;
    }

    .quiz-timer {
        font-size: 1.1rem;
    }

    .result-summary {
        flex-direction: column;
        align-items: center;
    }

    .option-btn {
        padding: 0.8rem 1rem;
        font-size: 0.88rem;
    }

    .slider-value-display {
        font-size: 1.6rem;
    }

    .btn-large {
        font-size: 1.1rem;
        padding: 0.9rem 2rem;
    }
}

@media (max-width: 380px) {
    .title-main {
        font-size: 1.5rem;
    }

    .card {
        padding: 1.2rem 1rem;
    }
}

/* Multi-choice columns for 6 options */
.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.options-grid .option-btn {
    flex-direction: column;
    text-align: center;
    padding: 0.8rem;
    gap: 0.4rem;
}

.options-grid .option-letter {
    margin: 0 auto;
}

@media (max-width: 520px) {
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Confetti burst */
.confetti-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 100;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    animation: confettiFall 3s ease-out forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}
