:root {
    --primary-color: #3c7db7;
    --secondary-color: #0f4c81;
    --accent-color: #ffa500;
    --background-color: #f8f9fa;
    --chat-bg: #ffffff;
    --user-msg-bg: #e6f2ff;
    --ai-msg-bg: #f0f4f8;
    --text-color: #333333;
    --light-text: #6c757d;
}

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

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.logo {
    width: 100%;
    margin: 0 0 30px 0;
}

.logo-mobile {
    display: none;
    margin: 0 0 10px 0;
}

.logo-desktop {
    display: block;
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    padding-bottom: 30px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Section Styles */
.section {
    display: none;
    min-height: 100vh;
}

.section.active {
    display: block;
}

.section-content {
    background-color: var(--chat-bg);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin-top: 20px;
}

/* Typography */
h1, h2, h3 {
    font-family: 'Orbitron', sans-serif;
    margin-bottom: 20px;
    color: var(--secondary-color);
}

h1 {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 30px;
}

h1 span {
    display: block;
    font-size: 1.8rem;
    color: var(--accent-color);
}

h2 {
    font-size: 1.8rem;
}

.intro {
    font-size: 1.2rem;
    margin: auto;
}

/* Form Styles */
.form-container {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

input[type="text"],
input[type="email"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.btn:hover {
    background-color: var(--secondary-color);
}

.btn.primary {
    width: 100%;
    margin-top: 10px;
    padding: 15px;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Chat Section */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0;
}

.chat-header h1 {
    margin-bottom: 0;
    font-size: 2.25rem;
    padding: 0;
    text-align: right;
}

.chat-header h2 {
    margin-bottom: 0;
    font-size: 1.5rem;
}

.chat-header h2 span {
    font-size: 1rem;
    color: var(--accent-color);
}

.header-controls {
    display: flex;
    align-items: center;
}

.score-container {
    margin: 0 auto;
}

#sound-toggle {
    background-color: transparent;
    padding: 10px 15px;
    border: none;
    cursor: pointer;
    margin: 0 4px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#sound-toggle i {
    font-size: 18px;
    color: #fff;
}

#sound-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.tooltip {
    position: relative;
    display: inline-block;
    margin-left: 5px;
}

.tooltip i {
    color: #fff;
    opacity: 0.8;
    cursor: pointer;
    font-size: 0.85em;
}

.tooltip-text {
    visibility: hidden;
    width: 300px;
    height: 200px;
    background-color: #333;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 1;
    top: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85em;
    line-height: 1.5;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    margin-left: -10px;
    border-width: 0 10px 10px 10px;
    border-style: solid;
    border-color: transparent transparent #333 transparent;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.leaderboard-btn {
    background-color: #8200ff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    margin-left: 10px;
}

.leaderboard-btn:hover {
    background-color: #bf5c5c;
    transform: translateY(-2px);
}

#score-display {
    background-color: #5d4c85;
    color: white;
    padding: 8px 15px;
    margin-bottom: 6px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.9rem;
}

.chat-container {
    height: 1000px;
    display: flex;
    flex-direction: column;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 20px;
}

.message {
    padding: 0 15px;
    border-radius: 10px;
    max-width: 80%;
    margin-bottom: 15px;
    position: relative;
}

.user-message {
    margin-left: auto;
    /*background-color: var(--user-msg-bg);
    color: var(--secondary-color);*/
}

.ai-message {
    background-color: var(--ai-msg-bg);
    margin-right: auto;
}

.message-time {
    font-size: 0.7rem;
    color: var(--light-text);
    text-align: right;
    margin-top: 5px;
}

.input-area {
    display: flex;
    gap: 10px;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.voice-btn, #sound-toggle {
    padding: 12px;
    background-color: var(--accent-color);
    height: 40px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-btn:hover, #sound-toggle:hover {
    background-color: #e69500;
}

/* Audio waveform visualization */
.audio-visualization {
    display: none;
    height: 30px;
    width: calc(100% - 20px);
    position: absolute;
    bottom: 10px;
    left: 10px;
    pointer-events: none;
    z-index: 2;
}

.wave {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    width: 100%;
}

.wave-bar {
    background-color: rgba(130, 0, 255, 0.6);
    width: 3px;
    border-radius: 2px;
    margin: 0 2px;
    animation: wave-animation 1s infinite ease-in-out;
}

.wave-bar:nth-child(1) { animation-delay: 0.0s; height: 10px; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; height: 15px; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; height: 20px; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; height: 12px; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; height: 18px; }
.wave-bar:nth-child(6) { animation-delay: 0.5s; height: 14px; }
.wave-bar:nth-child(7) { animation-delay: 0.6s; height: 22px; }
.wave-bar:nth-child(8) { animation-delay: 0.7s; height: 16px; }
.wave-bar:nth-child(9) { animation-delay: 0.8s; height: 20px; }
.wave-bar:nth-child(10) { animation-delay: 0.9s; height: 15px; }

@keyframes wave-animation {
    0% { transform: scaleY(1); }
    50% { transform: scaleY(0.5); }
    100% { transform: scaleY(1); }
}

.input-container {
    position: relative;
}

.input-row {
    position: relative;
}

/* Final Score */
#final-score {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    border-radius: 10px;
    background-color: #f0f4f8;
}

#score-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
}

.reminder-box {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 8px;
}

.reminder-box a {
    color: white;
    font-weight: bold;
    text-decoration: underline;
}

/* Bookmark reminder */
.bookmark-reminder {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 5px auto;
    padding: 8px 12px;
    /*background-color: rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    border-radius: 6px;*/
    font-size: 0.9rem;
    color: #fff;
}

.bookmark-reminder i {
    margin-left: 8px;
    color: #ffcc00;
}

.bookmark-reminder.hidden {
    display: none;
}

@media (max-width: 768px) {
    .bookmark-reminder {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}

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

/* Loading state for direct URL access */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    font-size: 1.2rem;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 20px;
    margin: 20px 0;
    position: relative;
}

.loading:after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border: 4px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    margin-left: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .section-content {
        padding: 15px;
    }
    
    #message-input {
        margin-bottom: 10px;
        width: calc(100% - 20px);
    }
    
    .button-group {
        width: 100%;
        justify-content: space-between;
    }
    
    #audio-wave {
        bottom: 60px; /* Position above the buttons when in mobile view */
    }
    
    .chat-header {
        padding: 0;
        display: block;
        text-align: center;
    }
    
    .chat-header h1 {
        text-align: center;
    }
    
    .chat-container {
        margin: 10px;
        padding: 0;
    }
    
    .leaderboard-btn, .help-btn, #sound-toggle {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    #score-display {
        font-size: 0.9rem;
        padding: 6px 12px;
    }
    
    .message {
        padding: 10px 0 !important;
        margin-bottom: 8px;
        max-width: 85%;
    }
    
    /* Chat input container improvements */
    .chat-input-container {
        padding: 10px;
    }

    .message-content {
        width: 100%;
        margin-bottom: 8px;
    }
    
    /* Message display improvements */
    .messages-container {
        padding: 0;
        margin: 0 auto;
        max-height: 55vh;
        width: 100%;
    }
    
    /* Button spacing */
    .button-group {
        gap: 5px;
    }
    
    /* Adjust audio wave for better visibility */
    .wave-bar {
        width: 2px;
        margin: 0 1px;
    }
    
    /* Center leaderboard button */
    .leaderboard-btn {
        margin: 0 auto;
        display: block;
    }
    
    /* Make footer links stack vertically */
    footer {
        display: block;
        text-align: center;
    }
    
    footer a {
        display: block;
        margin: 8px 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px !important;
    }
    
    .logo-desktop {
        display: none;
    }
    
    .logo-mobile {
        display: block;
        width: 100%;
        max-width: 220px;
        margin: 0 auto 10px auto;
    }
    
    .chat-header {
        padding: 0;
        display: block;
        text-align: center;
        width: 100%;
    }
    
    .header-left {
        flex-direction: column;
        align-items: center;
        margin: 0 10px;
    }
    
    .form-title {
        margin-bottom: 5px;
    }

    .chat-header h1 {
        margin: 0 5px;
        text-align: center;
    }
    
    .header-controls {
        display: flex;
        justify-content: center;
    }
    
    .chat-container {
        margin: 5px;
        width: 100%;
        padding: 0;
    }
    
    .message-content {
        font-size: 0.9rem;
        width: 100%;
        margin: 8px 0;
    }
    
    /* Make input area stack vertically on mobile */
    .input-row {
        flex-direction: column;
        width: 100%;
    }
    
    .messages-container {
        padding: 0;
        margin: 0 auto;
        max-height: 50vh;
        width: 100%;
        border: none;
        background: none;
    }
    #message-input {
        width: 100%;
        margin-bottom: 10px;
        padding: 15px;
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    /* Place buttons below the input field */
    .button-group {
        display: flex;
        width: 100%;
        justify-content: space-between;
        margin-top: 5px;
    }
    
    .button-group button {
        flex: 1;
        margin: 0 4px;
        padding: 10px;
    }
    
    .voice-btn {
        height: 44px;
    }
    
    #send-btn {
        padding: 10px 15px;
        height: 44px;
    }
    
    /* Further tighten spacing */
    .chat-input-container {
        padding: 10px;
        width: 100%;
    }
    
    /* Make buttons more touch-friendly */
    .button-group button {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Adjust notification for smaller screens */
    .notification {
        max-width: 90%;
        padding: 8px 12px;
        font-size: 0.9rem;
    }
    
    /* Adjust audio wave positioning for stacked layout */
    #audio-wave {
        bottom: 70px;
        width: calc(100% - 20px);
    }
    
    /* Better spacing for messages on small screens */
    .message {
        border-radius: 12px;
        max-width: 100%;
        margin: 0 0 0 12px;
        padding: 0 !important;
    }
    
    /* Center leaderboard button */
    .leaderboard-btn {
        margin: auto;
        display: block;
    }
    
    /* Score display size */
    #score-display {
        font-size: 0.9rem;
        display: block;
        margin: 10px auto;
        text-align: center;
    }

    #questions-remaining, #score-container {
        font-size: 0.8rem;
        margin: auto;
    }
}
