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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f9fafb;
    color: #1f2937;
    line-height: 1.6;
    height: 100svh;
    overflow: hidden;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Header */
header {
    text-align: center;
}

.logo-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-header img {
    width: 300px;
}

.logo-icon {
    width: 45px;
    height: 45px;
    object-fit: contain;
    border-radius: 8px;
}

.logo {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffa116 0%, #ff6b00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
}

.tagline {
    color: #6b7280;
    font-size: 1.1rem;
}

/* Views */
.view {
    display: none;
    flex: 1;
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* Problem Container */
.problem-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.problem-content {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    margin: 30px 0;
    border: 1px solid #e5e7eb;
    flex: 1;
    overflow-y: auto;
}

.problem-content h1 {
    color: #ffa116;
    font-size: 1.8rem;
    margin-bottom: 20px;
}

.problem-content p {
    margin-bottom: 15px;
    color: #374151;
}

.problem-content code {
    background-color: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    color: #1f2937;
}

.problem-content pre {
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Courier New', monospace;
}

.problem-content pre code {
    background: none;
    padding: 0;
}

/* Controls */
.controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background-color: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1), 0 -2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 100;
}

.timer {
    font-size: 3rem;
    font-weight: 700;
    color: #ffa116;
    text-align: center;
}

.timer.warning {
    color: #ff4444;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 900px;
}

/* Buttons */
.btn {
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

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

.btn-primary {
    background-color: #ffa116;
    color: #0a0a0a;
}

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

.btn-secondary {
    background-color: #f3f4f6;
    color: #1f2937;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #e5e7eb;
}

.btn-success {
    background-color: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
    transform: translateY(-2px);
}

/* Recording Indicator */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #ff4444;
    font-weight: 600;
    font-size: 1.1rem;
}

.pulse {
    width: 12px;
    height: 12px;
    background-color: #ff4444;
    border-radius: 50%;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

/* Loading View */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 30px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e5e7eb;
    border-top-color: #ffa116;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-container p {
    font-size: 1.2rem;
    color: #6b7280;
}

/* Results View */
.results-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 0;
    text-align: left;
    position: relative;
}

#confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.results-logo {
    /* margin-bottom: 10px; */
}

.results-logo img {
    width: 200px;
    height: auto;
}

.results-container h2 {
    font-size: 2rem;
    color: #6b7280;
    margin-bottom: 10px;
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 50px;
}

.score {
    font-size: 8rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ffa116 0%, #ff8c00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.score-subtitle {
    font-size: 1.2rem;
    color: #6b7280;
    font-weight: 400;
}

/* Percentile */
.percentile {
    text-align: center;
    font-size: 1rem;
    color: #6b7280;
    margin-top: 10px;
    /* font-weight: 600; */
    /* color: #ffa116; */
}

/* Histogram */
.histogram-container {
    width: 100%;
    max-width: 140px;
    margin: 20px 0 60px;
}

.histogram-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.histogram-bars {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 2px;
    height: 50px;
}

.histogram-bar {
    flex: 1 1 0;
    min-width: 0;
    background: linear-gradient(135deg, #ffa116 0%, #ff8c00 100%);
    border-radius: 4px 4px 0 0;
    transition: all 0.5s ease;
    min-height: 2px;
}

.histogram-bar:hover {
    opacity: 0.8;
}

.histogram-bar.current-score {
    position: relative;
    background: linear-gradient(135deg, #ffb84d 0%, #ffa733 100%);
}

.histogram-bar.current-score::before {
    content: '';
    z-index: -1;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50px;
    background-color: #ffa733;
    opacity: 0.2;
}

.histogram-labels {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0px;
}

.bar-label {
    flex: 1 1 0;
    min-width: 0;
    font-size: 0.5rem;
    color: #6b7280;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    writing-mode: vertical-lr;
    text-orientation: mixed;
}

.feedback {
    max-width: 600px;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 30px;
    border: 1px solid #e5e7eb;
    color: #374151;
    white-space: pre-wrap;
    line-height: 1.6;
}

.feedback blockquote {
    position: relative;
    margin: 20px 0;
    padding: 20px 25px;
    background-color: #f9fafb;
    border-left: 4px solid #ffa116;
    font-style: italic;
    color: #374151;
}

.feedback blockquote::before {
    content: '"';
    font-size: 3rem;
    position: absolute;
    left: 10px;
    top: -10px;
    color: #ffa116;
    opacity: 0.3;
    font-family: Georgia, serif;
}

.feedback blockquote::after {
    content: '"';
    font-size: 3rem;
    position: absolute;
    right: 10px;
    bottom: -20px;
    color: #ffa116;
    opacity: 0.3;
    font-family: Georgia, serif;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.modal-content h3 {
    color: #ff4444;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.modal-content p {
    color: #374151;
    margin-bottom: 15px;
}

.modal-content a {
    color: #ffa116;
    text-decoration: none;
}

.modal-content a:hover {
    text-decoration: underline;
}


/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    margin-top: auto;
    color: #6b7280;
}

footer a {
    color: #ffa116;
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

/* How to Play View */
.how-to-play-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    padding: 40px 20px;
}

.instructions {
    text-align: left;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 40px;
    margin: 30px 0;
    border: 1px solid #e5e7eb;
    max-width: 600px;
}

.instructions h2 {
    color: #ffa116;
    font-size: 2rem;
    margin-bottom: 25px;
}

.instructions p {
    color: #374151;
    font-size: 1.1rem;
    margin-bottom: 12px;
    line-height: 1.8;
}

.btn-large {
    padding: 18px 48px;
    font-size: 1.2rem;
}

/* Help Button */
.help-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 200;
}

.help-btn:hover {
    background-color: #e5e7eb;
    transform: scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}


#tryAgainBtn {
    margin: 0 0 20px 0;
    min-width: 300px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .logo-icon {
        width: 38px;
        height: 38px;
    }

    .logo {
        font-size: 2rem;
    }

    .tagline {
        font-size: 1rem;
    }

    .problem-content {
        padding: 20px;
    }

    .problem-content h1 {
        font-size: 1.5rem;
    }

    .timer {
        font-size: 2.5rem;
    }

    .btn {
        padding: 16px 32px;
        font-size: 0.95rem;
    }

    .results-logo img {
        width: 160px;
    }

    .score {
        font-size: 8rem;
    }

    .score-subtitle {
        font-size: 1.1rem;
    }

    .feedback {
        padding: 20px;
    }

    .modal-content {
        padding: 20px;
    }

    .instructions {
        padding: 20px;
    }

    .instructions h2 {
        font-size: 1.6rem;
    }

    .instructions p {
        font-size: 1rem;
    }

    .help-btn {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
        top: 15px;
        right: 15px;
    }
}

@media (max-width: 480px) {
    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .logo {
        font-size: 1.8rem;
    }

    .problem-content h1 {
        font-size: 1.3rem;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
    }

    .btn {
        width: 100%;
    }

    .results-logo img {
        width: 140px;
    }

    .score {
        font-size: 8rem;
    }

    .score-subtitle {
        font-size: 1rem;
    }

    .instructions h2 {
        font-size: 1.4rem;
    }

    .instructions p {
        font-size: 0.95rem;
    }

    .how-to-play-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        text-align: center;
        padding: 0;
    }

    .problem-content pre {
        padding: 10px;
        font-size: 0.8em;
    }
}

.instructions p:last-child {
    margin-bottom: 0;
}
