:root {
    --reseda-green: #797d62ff;
    --moss-green: #9b9b7aff;
    --desert-sand: #d9ae94ff;
    --peach-yellow: #f1dca7ff;
    --sunglow: #ffcb69ff;
    --persian-orange: #d08c60ff;
    --beaver: #997b66ff;
}

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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, var(--reseda-green), var(--moss-green));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    cursor: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><circle cx="10" cy="10" r="5" fill="rgba(241,220,167,0.8)" stroke="rgba(121,125,98,0.8)" stroke-width="2"/></svg>') 10 10, auto;
}

/* Click Effect Sprite Animation */
.click-effect {
    position: fixed;
    width: 40px;
    height: 40px;
    pointer-events: none;
    z-index: 9999;
    animation: clickFade 0.66s ease-out forwards;
}

@keyframes clickFade {
    0% { opacity: 1; transform: scale(0.5); }
    50% { opacity: 0.8; transform: scale(1.2); }
    100% { opacity: 0; transform: scale(1); }
}

/* Landing Page Styles */
.landing-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    color: white;
    text-align: center;
    padding: 20px;
}

.landing-page h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    color: var(--peach-yellow);
}

.selection-container {
    background: rgba(255,255,255,0.15);
    padding: 0;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(31,38,135,0.37);
    border: 1px solid rgba(255,255,255,0.18);
    margin-bottom: 20px;
    overflow: hidden;
}

.config-section {
    padding: 25px 30px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.config-section:last-child {
    border-bottom: none;
}

.config-section h3 {
    font-size: 1.3rem;
    color: var(--peach-yellow);
    margin-bottom: 15px;
    text-align: center;
    font-weight: bold;
}

.config-section.band-section {
    background: linear-gradient(45deg, rgba(255,203,105,0.1), rgba(208,140,96,0.1));
}

.config-section.range-section {
    background: linear-gradient(45deg, rgba(217,174,148,0.1), rgba(241,220,167,0.1));
}

.config-section.options-section {
    background: linear-gradient(45deg, rgba(155,155,122,0.1), rgba(121,125,98,0.1));
}

.config-section.controls-section {
    background: linear-gradient(45deg, rgba(153,123,102,0.1), rgba(121,125,98,0.1));
}

/* Landing Page Form Controls */
.slider-container {
    margin: 0;
}

.all-words-btn {
    background: rgba(255,255,255,0.2) ;
    border: 2px solid rgba(255,255,255,0.3) ;
    border-radius: 8px ;
    padding: 8px 12px ;
    font-size: 1rem ;
    color: var(--peach-yellow) ;
    text-align: center ;
    width: 80px ;
    height: 44px ; /* Match input height */
    cursor: pointer ;
    transition: all 0.3s ease ;
    font-family: inherit ;
    font-weight: bold ;
    /* Override Tailwind completely */
    -webkit-appearance: none ;
    background-image: none ;
    text-transform: none ;
    margin: 0 ;
    box-sizing: border-box ;
}

.all-words-btn:focus {
    outline: none ;
    border-color: var(--sunglow) ;
    background: rgba(255,255,255,0.3) ;
}

.all-words-btn:hover {
    background: rgba(255,255,255,0.3) ;
    border-color: rgba(255,203,105,0.6) ;
}

.all-words-btn::placeholder {
    color: rgba(255,255,255,0.7) ;
}

.floating-settings-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    color: var(--peach-yellow);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.landing-header {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.vintage-settings-btn {
    background: rgba(255,255,255,0.15) ;
    backdrop-filter: blur(10px) ;
    border: 2px solid rgba(255,255,255,0.25) ;
    border-radius: 12px ;
    padding: 12px 16px ;
    color: var(--peach-yellow) ;
    font-size: 1.1rem ;
    cursor: pointer ;
    transition: all 0.3s ease ;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2) ;
    display: inline-flex ;
    align-items: center ;
    justify-content: center ;
    gap: 8px ;
    /* Override Tailwind */
    -webkit-appearance: none ;
    background-image: none ;
    text-transform: none ;
    margin: 0 ;
    min-height: auto ;
}

.vintage-settings-btn:hover {
    background: rgba(255,255,255,0.25) ;
    border-color: var(--sunglow) ;
    color: var(--sunglow) ;
    transform: scale(1.05) ;
    box-shadow: 0 6px 20px rgba(255,203,105,0.3) ;
}

.vintage-settings-btn:active {
    transform: scale(1.02) ;
}

.vintage-settings-btn i {
    transition: transform 0.3s ease;
}

.vintage-settings-btn:hover i {
    transform: rotate(90deg);
}

.slider-container label {
    display: block;
    margin-bottom: 10px;
    font-size: 1rem;
    color: white;
}

.range-input-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    justify-content: center;
    flex-wrap: wrap;
}

.range-input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.range-input-group label {
    font-size: 0.9rem;
    color: var(--peach-yellow);
    margin-bottom: 0;
}

.range-input {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1rem;
    color: white;
    text-align: center;
    width: 80px;
    transition: all 0.3s ease;
}

.range-input:focus {
    outline: none;
    border-color: var(--sunglow);
    background: rgba(255,255,255,0.3);
}

.range-input::placeholder {
    color: rgba(255,255,255,0.7);
}

.range-separator {
    font-size: 1.2rem;
    color: var(--peach-yellow);
    font-weight: bold;
}

.range-values {
    margin: 10px 0;
    font-size: 1.1rem;
    color: var(--sunglow);
}

.range-progress-bar {
    width: 100%;
    height: 20px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    margin: 15px 0;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.3);
}

.range-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sunglow), var(--persian-orange));
    border-radius: 10px;
    transition: all 0.3s ease;
    position: relative;
}

.range-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.7);
    z-index: 2;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}

.checkbox-container label {
    font-size: 1rem;
    color: white;
    cursor: pointer;
}

.tier-dropdown {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.tier-dropdown:focus {
    outline: none;
    border-color: var(--sunglow);
}

.tier-dropdown option {
    background: var(--beaver);
    color: white;
}

.game-options-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    align-items: center;
    width: 100%;
}

.option-divider {
    width: 2px;
    height: 60px;
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.3), transparent);
    border-radius: 2px;
}

.tier-select {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tier-select label {
    font-size: 1rem;
    color: white;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: rgba(255,255,255,0.2);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.custom-checkbox.checked {
    background: var(--sunglow);
    border-color: var(--sunglow);
}

.custom-checkbox.checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.start-button {
    background: linear-gradient(45deg, var(--persian-orange), var(--beaver));
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    margin: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.start-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, var(--sunglow), var(--persian-orange));
}

/* Game Page Layout */
.game-page {
    display: none;
    height: 100vh;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Score Bar - Fixed to center stars properly */
.score-bar {
    background: linear-gradient(90deg, var(--reseda-green), var(--beaver));
    color: white;
    padding: 15px;
    text-align: center;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Menu controls positioned absolutely to not affect centering */
.menu-controls {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 10px;
    align-items: center;
}

.mobile-menu-toggle {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
}

/* Stars counter - now truly centered */
.stars-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.8rem;
    color: var(--sunglow);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.mobile-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 10px;
    right: 10px;
    background: rgba(0,0,0,0.95);
    border-radius: 10px;
    padding: 15px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.mobile-menu.active {
    display: block;
}

.mobile-menu-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.mobile-menu-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.menu-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

.menu-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.menu-btn.exit {
    background: linear-gradient(45deg, #ff6b6b, #ee5a52);
    border: 1px solid rgba(255,107,107,0.8);
}

.menu-btn.exit:hover {
    background: linear-gradient(45deg, #ff5252, #d32f2f);
}

/* Audio Controls for Settings */
.audio-controls {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Further reduced gap for more compact layout */
    align-items: center;
    min-width: 140px;
}

/* Gameplay Settings Section Styling */
.settings-section.gameplay-section {
    background: linear-gradient(45deg, rgba(255,203,105,0.1), rgba(208,140,96,0.1));
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.volume-slider {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--sunglow);
    border-radius: 50%;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--sunglow);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.volume-label {
    font-size: 0.7rem;
    color: white;
    min-width: 20px;
    text-align: center;
}

/* Toggle Controls */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.info-icon {
    width: 16px;
    height: 16px;
    background: var(--peach-yellow);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: var(--beaver);
    cursor: help;
    position: relative;
}

.info-tooltip {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1001;
}

.info-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid rgba(0,0,0,0.9);
}

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

.toggle-switch {
    position: relative;
    width: 50px;
    height: 25px;
    background: rgba(255,255,255,0.3);
    border-radius: 25px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: var(--sunglow);
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 21px;
    height: 21px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.toggle-switch.active .toggle-slider {
    transform: translateX(25px);
}

.toggle-label {
    font-size: 0.8rem;
    color: white;
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal h2 {
    margin-bottom: 20px;
    text-align: center;
    color: var(--peach-yellow);
    font-size: 1.5rem;
}

.modal-content {
    background: linear-gradient(135deg, var(--reseda-green), var(--moss-green));
    margin: 3% auto;
    padding: 15px;
    border-radius: 15px;
    width: 90%;
    max-width: 480px; /* Slightly more compact */
    color: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    max-height: 85vh;
    overflow-y: auto;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px; /* Further reduced gap for more compact layout */
}

.settings-section {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px; /* Further reduced padding */
}

.settings-section h3 {
    color: var(--peach-yellow);
    margin-bottom: 8px;
    font-size: 1rem; /* Slightly smaller heading */
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 6px 0; /* Reduced margin */
    gap: 8px; /* Reduced gap */
}

.settings-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    margin: 10px 0;
}

.settings-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    background: linear-gradient(45deg, var(--desert-sand), var(--peach-yellow));
}

/* Enhanced Hotkeys Layout */
.hotkeys-layout {
    display: flex;
    gap: 12px; /* Further reduced gap for more compact layout */
    align-items: flex-start;
    justify-content: space-between;
    margin: 10px 0; /* Reduced margin */
}

.hotkeys-left {
    flex: 1; /* Audio control takes 1/2 of space */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px; /* Reduced gap */
}

.hotkeys-right {
    flex: 1; /* Answer options take 1/2 of space */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px; /* Reduced gap */
}

.hotkeys-left h4,
.hotkeys-right h4 {
    color: var(--peach-yellow);
    font-size: 0.9rem; /* Slightly smaller heading */
    margin: 0;
    text-align: center;
}

.hotkeys-divider {
    width: 2px;
    min-height: 80px; /* Further reduced for more compact layout */
    background: linear-gradient(180deg, transparent, rgba(255,255,255,0.3), transparent);
    border-radius: 2px;
    flex-shrink: 0;
}

.audio-hotkey-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.audio-hotkey-container .hotkey-btn {
    min-width: 80px;
    min-height: 40px;
    max-width: 120px;
    padding: 8px 16px;
    aspect-ratio: auto; /* Override square aspect ratio for audio button */
}

.hotkey-label {
    font-size: 0.9rem;
    color: white;
    text-align: center;
}

/* Numpad-style hotkey layout */
.hotkeys-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px; /* Reduced gap for more compact layout */
    max-width: 220px; /* Slightly reduced for more compact layout */
}

.hotkey-btn {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.3);
    padding: 6px; /* Reduced padding */
    border-radius: 6px;
    color: white;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem; /* Slightly smaller font */
    transition: all 0.3s ease;
    aspect-ratio: 1;
    width: auto;
    height: auto;
    min-width: 45px; /* Slightly smaller buttons */
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hotkey-btn:focus {
    border-color: var(--sunglow);
    background: rgba(255,255,255,0.3);
    outline: none;
}

.hotkey-btn.listening {
    border-color: var(--persian-orange);
    background: rgba(255, 152, 0, 0.2);
    animation: pulse 1s infinite;
}

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

.close-btn {
    background: linear-gradient(45deg, var(--persian-orange), var(--beaver));
    color: white;
    border: none;
    padding: 10px 20px; /* Reduced padding */
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem; /* Slightly smaller font */
    margin: 15px auto 0; /* Reduced margin */
    display: block;
    transition: all 0.3s ease;
}

.close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.star-icon {
    color: var(--sunglow);
    font-size: 1.8rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* Mascot Positioning */
.mascot-icon {
    position: fixed;
    width: 150px;
    height: 150px;
    opacity: 1;
    visibility: visible;
    transition: all 0.3s ease;
    z-index: 100;
    pointer-events: none;
}

.mascot-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.mascot-container {
    position: absolute; /* Absolute positioning to follow page scroll */
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(200px, 25vh, 280px); /* Larger size for better visibility */
    height: clamp(200px, 25vh, 280px);
    pointer-events: none; /* Don't interfere with character clicks */
    z-index: 0; /* Behind all character containers (which have z-index 1+) */
    /* NOTE: Current mascot (walk.gif) has character at bottom of image. 
       Positioning is now handled entirely by JavaScript relative to active character. */
}

#mascotImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none; /* Ensure no click interference */
}

/* Enhanced Characters Row with better border */
.characters-row {
    height: clamp(200px, 28vh, 320px); /* Increased height for better spacing */
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, rgba(217,174,148,0.3), rgba(241,220,167,0.3));
    padding: clamp(20px, 5vh, 40px) 0; /* Increased vertical padding */
    border-bottom: 4px solid transparent;
    border-image: linear-gradient(90deg, var(--desert-sand), var(--peach-yellow), var(--desert-sand)) 1;
    box-shadow: 
        inset 0 -3px 6px rgba(0,0,0,0.1),
        0 2px 8px rgba(0,0,0,0.15);
}

.character-container {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(241,220,167,0.9));
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    transition: all 0.5s ease;
    min-width: 120px;
    max-width: 200px;
    height: clamp(120px, 18vh, 180px); /* Responsive container height */
    border: 3px solid transparent;
    padding: clamp(8px, 1.5vh, 12px);
    box-sizing: border-box;
}

.character-container.active {
    border-color: var(--sunglow);
    transform: scale(1.3);
    z-index: 10;
    box-shadow: 0 12px 30px rgba(255, 203, 105, 0.4);
    left: 50% ;
    transform: translateX(-50%) scale(1.3);
    background: linear-gradient(145deg, rgba(255,203,105,0.9), rgba(241,220,167,0.95));
}

.character-container.next {
    transform: scale(1.0);
    opacity: 0.9;
    z-index: 5;
    border-color: var(--desert-sand);
}

.character-container.upcoming {
    transform: scale(0.8);
    opacity: 0.7;
    z-index: 1;
    border-color: rgba(155,155,122,0.5);
}

.pinyin {
    font-size: 0.9rem;
    color: var(--beaver);
    margin-bottom: 5px;
    text-align: center;
    word-wrap: break-word;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.pinyin.hidden {
    opacity: 0;
    height: 0;
    margin: 0;
}

.chinese-char {
    font-size: 2rem;
    font-weight: bold;
    color: var(--reseda-green);
    text-align: center;
    word-wrap: break-word;
    line-height: 1.2;
}

.character-container.active .chinese-char {
    font-size: 2.5rem;
    color: var(--beaver);
}

/* Options Container */
.options-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, rgba(155,155,122,0.1), rgba(121,125,98,0.1));
    position: relative; /* For positioning the voice button */
    overflow: visible; /* Ensure the voice button is not clipped */
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 15px;
    width: min(80vw, 800px);
    height: min(65vh, 520px);
    position: relative; /* For positioning the voice button within the grid */
    overflow: visible; /* Ensure the voice button is not clipped */
}

.option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    padding: 20px 15px;
    min-height: 100px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.option-btn span {
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    text-align: center;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    max-width: 100%;
}

.option-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.25);
}

/* Tier Colors */
.tier-bronze {
    background: linear-gradient(145deg, var(--beaver), var(--reseda-green));
    border: 3px solid var(--moss-green);
}

.tier-silver {
    background: linear-gradient(145deg, var(--moss-green), var(--desert-sand));
    border: 3px solid var(--peach-yellow);
}

.tier-gold {
    background: linear-gradient(145deg, var(--sunglow), var(--persian-orange));
    border: 3px solid var(--sunglow);
    animation: goldGlow 2s ease-in-out infinite alternate;
}

@keyframes goldGlow {
    from { box-shadow: 0 6px 20px rgba(255, 203, 105, 0.4); }
    to { box-shadow: 0 8px 30px rgba(255, 203, 105, 0.6); }
}

.progress-bar {
    position: absolute;
    bottom: 5px;
    left: 10px;
    right: 10px;
    height: 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sunglow), var(--persian-orange));
    border-radius: 6px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-count {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: bold;
}

.hotkey {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    z-index: 10;
}

/* Voice Replay Button */
.voice-replay-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, var(--sunglow), var(--persian-orange));
    border: 3px solid var(--peach-yellow);
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000; /* Higher z-index to ensure visibility */
}

.voice-replay-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(255,203,105,0.4);
    background: linear-gradient(145deg, var(--persian-orange), var(--sunglow));
}

.voice-replay-btn:active {
    transform: translateY(0) scale(0.95);
}

.voice-replay-btn i {
    transition: transform 0.3s ease;
}

.voice-replay-btn:hover i {
    transform: scale(1.1);
}

/* Game Animations */
@keyframes correct {
    0% { transform: scale(1); }
    25% { transform: scale(1.1); background: var(--sunglow); box-shadow: 0 0 20px var(--sunglow); }
    50% { transform: scale(1.2) rotate(5deg); }
    75% { transform: scale(1.1) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes shake {
    0% { transform: translateX(0) rotate(0deg); }
    10% { transform: translateX(-8px) rotate(-3deg); }
    20% { transform: translateX(8px) rotate(3deg); }
    30% { transform: translateX(-6px) rotate(-2deg); }
    40% { transform: translateX(6px) rotate(2deg); }
    50% { transform: translateX(-4px) rotate(-1deg); }
    60% { transform: translateX(4px) rotate(1deg); }
    70% { transform: translateX(-2px) rotate(-0.5deg); }
    80% { transform: translateX(2px) rotate(0.5deg); }
    90% { transform: translateX(-1px) rotate(-0.25deg); }
    100% { transform: translateX(0) rotate(0deg); }
}

@keyframes slideLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-200px); opacity: 0; }
}

@keyframes floatUp {
    from { 
        transform: translateY(0) scale(1); 
        opacity: 1; 
    }
    to { 
        transform: translateY(-50px) scale(1.2); 
        opacity: 0; 
    }
}

@keyframes newWordEntry {
    0% { 
        transform: scale(0) rotateY(90deg); 
        opacity: 0; 
    }
    50% { 
        transform: scale(1.1) rotateY(0deg); 
        opacity: 1; 
    }
    100% { 
        transform: scale(1) rotateY(0deg); 
        opacity: 1; 
    }
}

@keyframes tierUp {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.2) rotate(10deg); box-shadow: 0 0 30px currentColor; }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes starShoot {
    0% { 
        transform: scale(0) rotate(0deg); 
        opacity: 0; 
        color: var(--sunglow);
    }
    30% { 
        transform: scale(1.5) rotate(180deg); 
        opacity: 1; 
        color: var(--sunglow);
        text-shadow: 0 0 20px var(--sunglow);
    }
    70% { 
        transform: scale(2) rotate(360deg) translateY(-30px); 
        opacity: 1; 
        color: var(--persian-orange);
        text-shadow: 0 0 30px var(--sunglow);
    }
    100% { 
        transform: scale(1) rotate(540deg) translateY(0px); 
        opacity: 1; 
        color: var(--sunglow);
    }
}

.correct-animation { animation: correct 0.8s ease; }
.shake-animation { animation: shake 0.8s ease; }
.slide-left { animation: slideLeft 0.5s ease; }
.float-up { animation: floatUp 1s ease; }
.new-word-entry { animation: newWordEntry 0.8s ease; }
.tier-up { animation: tierUp 0.8s ease; }
.star-shoot { animation: starShoot 1.2s ease; }

/* Responsive Mobile Styles - Enhanced for Pixel 7a */
@media (max-width: 768px) {
    .score-bar {
        font-size: 1.2rem;
        padding: 10px;
    }

    .menu-controls { display: none; }
    .mobile-menu-toggle { display: block; }
    
    .stars-counter { font-size: 1.5rem; }
    .star-icon { font-size: 1.3rem; }

    .characters-row {
        height: clamp(180px, 25vh, 240px); /* Increased mobile height for better spacing */
        padding: clamp(15px, 4vh, 25px) 10px; /* Increased mobile vertical padding */
    }

    .mascot-icon {
        right: 10px;
        height: 70%;
    }

    .character-container {
        min-width: 90px;
        max-width: 130px;
        height: clamp(90px, 15vh, 130px); /* Responsive mobile container height */
        padding: clamp(6px, 1.2vh, 10px);
    }

    .character-container.active {
        transform: translateX(-50%) scale(1.1);
        z-index: 100;
    }

    .character-container.next {
        transform: scale(0.8);
        opacity: 0.8;
        z-index: 5;
    }

    .character-container.upcoming {
        transform: scale(0.6);
        opacity: 0.6;
        z-index: 1;
    }

    .pinyin { font-size: 0.8rem; }
    .chinese-char { font-size: 1.5rem; }
    .character-container.active .chinese-char { font-size: 1.8rem; }

    /* Enhanced mobile options grid for better spacing */
    .options-grid {
        width: 95vw;
        height: 420px;
        gap: 12px;
        grid-template-rows: repeat(4, minmax(95px, 1fr));
    }
    
    .option-btn {
        font-size: 0.85rem;
        padding: 12px 8px;
        min-height: 95px;
        max-height: 110px;
    }

    .option-btn span {
        font-size: clamp(0.75rem, 1.8vw, 1rem);
        line-height: 1.1;
    }
    
    /* Landing page mobile adjustments */
    .landing-page {
        padding: 10px;
        min-height: 100vh;
    }

    .landing-page h1 {
        font-size: 2rem;
        margin-bottom: 1.5rem;
    }

    .selection-container {
        padding: 20px;
        margin-bottom: 15px;
        width: 100%;
        max-width: 90vw;
    }

    .range-input-container { gap: 10px; }
    .range-input { width: 70px; padding: 6px 8px; font-size: 0.9rem; }
    .slider-container { margin: 15px 0; }
    .slider-container label { font-size: 1rem; margin-bottom: 8px; }
    .range-values { font-size: 1rem; }
    .tier-select { margin: 15px 0; }
    .tier-select label { font-size: 1rem; }
    .tier-dropdown { padding: 6px 10px; font-size: 0.9rem; width: 100%; max-width: 200px; }

    .start-button {
        padding: 12px 25px;
        font-size: 1rem;
        margin: 8px;
        width: calc(100% - 16px);
        max-width: 300px;
    }

    .modal-content {
        width: 95%;
        max-width: none;
        margin: 5% auto;
        padding: 20px;
    }

    .hotkey-setting {
        margin: 8px 0;
        padding: 6px;
        font-size: 0.8rem;
    }

    .hotkey-input {
        width: 60px;
        padding: 4px 6px;
        font-size: 0.7rem;
    }

    .toggle-container {
        flex-direction: column;
        gap: 4px;
        align-items: center;
    }

    /* Mobile adjustments */
    @media (max-width: 768px) {
        .landing-header {
            top: 15px;
            right: 15px;
        }
        
        .vintage-settings-btn {
            padding: 10px 12px ;
            font-size: 1rem ;
        }
    }

    /* Mobile adjustments for floating button */
    @media (max-width: 768px) {
        .floating-settings-btn {
            top: 15px;
            right: 15px;
            width: 45px;
            height: 45px;
            font-size: 1.1rem;
        }
    }
    
    .toggle-label { font-size: 0.7rem; }
    .toggle-switch { width: 40px; height: 20px; }
    .toggle-slider { width: 16px; height: 16px; top: 2px; left: 2px; }
    .toggle-switch.active .toggle-slider { transform: translateX(20px); }
    .mascot-icon { width: 110px; height: 110px; }
    .hotkey { width: 18px; height: 18px; font-size: 0.6rem; top: 3px; right: 3px; }
    .mobile-menu-row { gap: 8px; }
    .audio-controls { min-width: 120px; }
    .volume-container { flex-direction: column; gap: 4px; }
    
    /* Mobile voice replay button */
    .voice-replay-btn {
        width: 45px;
        height: 45px;
        bottom: 15px;
        right: 15px;
        font-size: 1.1rem;
    }
}