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

:root {
    --bg-gradient-start: #667eea;
    --bg-gradient-end: #764ba2;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #333;
    --text-muted: #666;
    --accent: #667eea;
    --accent-hover: #5568d3;
    --btn-ghost-bg: #ffffff;
    --btn-ghost-color: #667eea;
    --modal-bg: #ffffff;
    --input-border: #ccd2ea;
    --shadow: rgba(0, 0, 0, 0.3);
    --loading-ring-color: #666;
}

[data-theme="dark"] {
    --bg-gradient-start: #2d2a4a;
    --bg-gradient-end: #1a1830;
    --card-bg: rgba(40, 38, 60, 0.95);
    --text-primary: #e8e6f0;
    --text-muted: #a8a4c0;
    --accent: #8b7dd4;
    --accent-hover: #a89ee8;
    --btn-ghost-bg: rgba(255, 255, 255, 0.12);
    --btn-ghost-color: #c4b8f0;
    --modal-bg: #2a2840;
    --input-border: #4a4660;
    --shadow: rgba(0, 0, 0, 0.5);
    --loading-ring-color: rgba(255, 255, 255, 0.75);
}

/* Plain loading ring for stats modals */
.loading-ring-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    padding: 20px;
}
.loading-ring {
    width: 40px;
    height: 40px;
    border: 3px solid var(--input-border);
    border-top-color: var(--loading-ring-color);
    border-radius: 50%;
    animation: loading-ring-spin 0.8s linear infinite;
}
@keyframes loading-ring-spin {
    to { transform: rotate(360deg); }
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    color: var(--text-primary);
}

.header-buttons {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
}

.my-progress-btn {
    background: var(--btn-ghost-bg);
    color: var(--btn-ghost-color);
    border: 2px solid var(--accent);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
}

.my-progress-btn:hover {
    background: var(--accent);
    color: #fff;
}

.auth-login-btn {
    background: var(--btn-ghost-bg);
    color: var(--btn-ghost-color);
    border: 2px solid var(--accent);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
}

.auth-login-btn:hover {
    background: var(--accent);
    color: #ffffff;
}

.theme-toggle-btn {
    background: var(--btn-ghost-bg);
    color: var(--btn-ghost-color);
    border: 2px solid var(--accent);
    width: 44px;
    height: 44px;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.theme-toggle-btn:hover {
    background: var(--accent);
    color: #fff;
}

.theme-toggle-btn svg {
    width: 22px;
    height: 22px;
}

/* User dropdown panel (top-right, vertical stack) */
.user-menu-wrap {
    position: relative;
}

.user-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--modal-bg);
    border: 2px solid var(--accent);
    border-radius: 12px;
    box-shadow: 0 10px 40px var(--shadow);
    padding: 8px 0;
    z-index: 2100;
    flex-direction: column;
}

.user-dropdown-panel.open {
    display: flex;
}

.user-dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 12px 20px;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
}

.user-dropdown-item:hover {
    background: rgba(102, 126, 234, 0.15);
}

.user-dropdown-item.user-dropdown-logout {
    border-top: 1px solid var(--input-border);
    margin-top: 4px;
    padding-top: 12px;
    color: var(--accent);
}

/* Logo */
.logo-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
}

.logo-image {
    height: 100px;
    width: auto;
    max-width: 90vw;
    object-fit: contain;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
}

/* Bees Background */
.bees-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* Hide bees on practice/test screens */
.bees-container.hidden {
    display: none !important;
}


.bee {
    position: absolute;
    width: 30px;
    height: 20px;
    animation: flyAround 30s infinite linear;
    animation-play-state: running;
    opacity: 0.7;
    z-index: 1;
    will-change: transform;
}

/* Bee body - striped yellow and black */
.bee::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(to right, 
            #FFD700 0%, #FFD700 20%,
            #000 20%, #000 30%,
            #FFD700 30%, #FFD700 50%,
            #000 50%, #000 60%,
            #FFD700 60%, #FFD700 80%,
            #000 80%, #000 90%,
            #FFD700 90%, #FFD700 100%
        );
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Bee wings - animated flapping */
.bee::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 16px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flapWings 0.1s infinite ease-in-out;
    box-shadow: 
        -8px 0 0 rgba(255, 255, 255, 0.6),
        8px 0 0 rgba(255, 255, 255, 0.6),
        0 0 8px rgba(255, 255, 255, 0.4);
    z-index: -1;
}

/* Wing flapping animation */
@keyframes flapWings {
    0%, 100% {
        transform: translateX(-50%) scaleY(1) rotate(0deg);
    }
    50% {
        transform: translateX(-50%) scaleY(0.3) rotate(5deg);
    }
}

/* Bee flying around the screen - slower speed, proper orientation */
@keyframes flyAround {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    10% {
        transform: translate(15vw, -10vh) rotate(25deg);
    }
    20% {
        transform: translate(30vw, 5vh) rotate(45deg);
    }
    30% {
        transform: translate(50vw, -15vh) rotate(65deg);
    }
    40% {
        transform: translate(70vw, 10vh) rotate(90deg);
    }
    50% {
        transform: translate(85vw, -5vh) rotate(115deg);
    }
    60% {
        transform: translate(70vw, 20vh) rotate(135deg);
    }
    70% {
        transform: translate(50vw, 15vh) rotate(155deg);
    }
    80% {
        transform: translate(30vw, 25vh) rotate(180deg);
    }
    90% {
        transform: translate(15vw, 10vh) rotate(200deg);
    }
    100% {
        transform: translate(0, 0) rotate(360deg);
    }
}

/* Bee flying from left to right (at startup, from off-screen) - slower, proper orientation */
@keyframes flyLeftToRight {
    0% {
        transform: translate(-10vw, 0) rotate(0deg);
    }
    100% {
        transform: translate(120vw, 0) rotate(0deg);
    }
}

/* Bee types - slower speeds */
.bee.flying-left-to-right {
    animation: flyLeftToRight 20s linear;
}

/* Screen Management */
.screen {
    display: none;
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px var(--shadow);
    backdrop-filter: blur(10px);
}

/* Auth Modal */
.auth-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.auth-modal.active {
    display: flex;
}

.auth-modal-content {
    background: var(--modal-bg);
    width: min(420px, 92vw);
    border-radius: 16px;
    padding: 26px 28px 28px;
    position: relative;
    box-shadow: 0 20px 60px var(--shadow);
}

.auth-close-btn {
    position: absolute;
    top: 10px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-primary);
}

.auth-title {
    text-align: center;
    color: var(--accent);
    margin-bottom: 18px;
}

.auth-form-group {
    margin-bottom: 14px;
}

.auth-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.auth-form-group input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--input-border);
    font-size: 1em;
    background: var(--modal-bg);
    color: var(--text-primary);
}

.auth-signup-hint {
    text-align: center;
    margin: 8px 0 12px;
    color: var(--accent);
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.auth-signup-hint:hover {
    color: var(--accent-hover);
}

.my-progress-stats p {
    margin: 10px 0;
    color: var(--text-primary);
}
.my-progress-stats p strong {
    color: var(--accent);
}
.my-progress-stats .my-progress-current {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--input-border);
}
.my-progress-stats .my-progress-hint {
    margin-top: 14px;
    font-size: 0.9em;
    color: var(--text-muted);
}
.my-progress-stats .my-progress-last-date {
    font-size: 0.9em;
    color: var(--text-muted);
    margin-top: 2px;
}

.auth-submit-btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.home-logo {
    display: block;
    width: 30%;
    max-width: 120px;
    height: auto;
    margin: 10px auto 18px;
}

.title {
    font-size: 2.5em;
    color: var(--accent);
    text-align: center;
    margin-bottom: 10px;
    font-weight: 700;
}

#homeScreen .title {
    margin-top: 8px;
}

.subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 30px;
    font-size: 1.1em;
}

.selection-group {
    margin-bottom: 30px;
}

.selection-group h2 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 1.3em;
}

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

button {
    padding: 15px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: white;
}

button.clicked {
    border: 3px solid #000 !important;
    outline: 2px solid #000 !important;
    outline-offset: -2px !important;
}

.level-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex: 1;
    min-width: 120px;
}

.level-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.level-btn.selected {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.6);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

.type-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    flex: 1;
    min-width: 120px;
}

.type-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.type-btn.selected {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.6);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

.mode-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    flex: 1;
    min-width: 120px;
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
}

.mode-btn.selected {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.6);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

.timer-btn {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    flex: 1;
    min-width: 150px;
    padding: 20px 30px;
    font-size: 1.2em;
}

.timer-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(250, 112, 154, 0.4);
}

.timer-btn:active,
.timer-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

.back-btn {
    background: #666;
    padding: 20px 40px;
    font-size: 1.2em;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(102, 102, 102, 0.4);
    transition: all 0.3s ease;
    font-weight: 600;
    color: white;
    border: none;
    cursor: pointer;
}

/* Back button in action-buttons container */
.action-buttons .back-btn {
    flex: 2;
    min-width: 0;
}

/* Back button standalone (for other screens) */
.back-btn:not(.action-buttons .back-btn) {
    margin-top: 20px;
    width: 100%;
}

.back-btn:hover {
    background: #555;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 102, 102, 0.6);
}

.back-btn:active,
.back-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

/* Upload Section */
.upload-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.upload-btn {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    padding: 15px 30px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: white;
    text-align: center;
    display: inline-block;
    min-width: 200px;
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(17, 153, 142, 0.4);
}

.upload-btn:active,
.upload-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

.upload-status {
    color: #667eea;
    font-weight: 600;
    font-size: 0.9em;
    min-height: 20px;
}

.upload-status.success {
    color: #38ef7d;
}

.upload-status.error {
    color: #f5576c;
}

.custom-lists-hint {
    margin-bottom: 1em;
    color: var(--text-muted);
    font-size: 0.95em;
}

.custom-list-file-input {
    width: 100%;
    padding: 8px 0;
    cursor: pointer;
}

/* Streak modal */
.streak-content {
    text-align: center;
    margin: 1em 0;
}
.streak-content p {
    margin: 0.5em 0;
    color: var(--text-primary);
}
.streak-number {
    font-size: 3em;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.2em !important;
}
.streak-hint {
    font-size: 0.9em;
    color: var(--text-muted);
    margin-top: 12px;
}
.streak-last {
    margin-top: 12px;
    font-size: 0.95em;
}
.streak-last strong {
    color: var(--accent);
}

/* Achievements modal */
.achievements-content {
    max-height: 360px;
    overflow-y: auto;
    margin: 1em 0;
}
.achievements-summary {
    text-align: center;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 12px;
}
.achievements-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.achievement-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--input-border);
}
.achievement-unlocked {
    background: rgba(102, 126, 234, 0.12);
    border-color: var(--accent);
}
.achievement-locked {
    opacity: 0.7;
    color: var(--text-muted);
}
.achievement-icon {
    font-size: 1.4em;
    flex-shrink: 0;
}
.achievement-unlocked .achievement-icon {
    color: var(--accent);
}
.achievement-text {
    flex: 1;
}
.achievement-desc {
    font-size: 0.9em;
    color: var(--text-muted);
}
.achievement-unlocked .achievement-desc {
    color: var(--text-primary);
}

/* Achievement earned toast (top right) */
.achievement-toast {
    display: none;
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 6px 24px var(--shadow);
    z-index: 2500;
    cursor: pointer;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95em;
    max-width: 260px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.achievement-toast.show {
    display: flex;
}
.achievement-toast:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 28px var(--shadow);
}
.achievement-toast-icon {
    font-size: 1.3em;
    color: #ffd700;
}
.achievement-toast-text {
    flex: 1;
}

/* Words Wrong modal */
.words-wrong-content {
    max-height: 280px;
    overflow-y: auto;
    margin: 1em 0;
    text-align: left;
}
.words-wrong-count {
    margin-bottom: 10px;
    color: var(--text-primary);
}
.words-wrong-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.words-wrong-list li {
    padding: 6px 10px;
    border-bottom: 1px solid var(--input-border);
    color: var(--text-primary);
}
.words-wrong-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.words-wrong-btn {
    flex: 1;
    min-width: 120px;
}
.words-wrong-clear {
    background: transparent;
    color: var(--accent);
    border: 2px solid var(--accent);
}
.words-wrong-clear:hover {
    background: var(--accent);
    color: #fff;
}

.upload-hint {
    text-align: center;
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
    font-style: italic;
}

/* Manage Words Button */
.manage-words-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    width: 100%;
    margin-top: 10px;
}

.manage-words-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.manage-words-btn:active,
.manage-words-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

/* Level Management */
.level-management {
    background: rgba(102, 126, 234, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 2px solid rgba(102, 126, 234, 0.3);
}

.level-management h2 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.word-count {
    color: #666;
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: 600;
}

.word-count span {
    color: #667eea;
    font-size: 1.2em;
}

.management-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.delete-btn {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    padding: 15px 30px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    color: white;
    border: none;
    min-width: 150px;
}

.delete-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.delete-btn:active,
.delete-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

/* Progress Bar */
.progress-bar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 25px;
    border-radius: 12px;
    text-align: center;
    font-size: 1.4em;
    font-weight: 600;
    margin-bottom: 30px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Timer Display */
.timer-display {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    font-size: 1.5em;
    font-weight: 700;
    font-variant-numeric: tabular-nums; /* keeps digits same width so timer doesn't shift */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    z-index: 100;
    text-align: center;
    width: calc(100% - 140px); /* Full width minus space for login button (20px margin + 100px button area) */
    max-width: 800px;
    min-width: 300px;
}

.timer-display.warning {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.05);
    }
}

/* Word Section */
.word-section {
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    border: 3px solid #667eea;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
}

.word-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.word-display h2 {
    display: none; /* Hide the word text, only show pronunciation button */
}

/* Pronunciation Button (Hexagon) */
.pronunciation-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    padding: 0;
    margin: 0;
}

.pronunciation-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
    outline: 2px solid #000;
    outline-offset: 2px;
}

.pronunciation-btn:active {
    transform: scale(0.95);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.pronunciation-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.pronunciation-btn svg {
    width: 32px;
    height: 32px;
}

/* Word Buttons Container */
.word-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    margin-bottom: 20px;
}

/* Top row: 3 buttons (button, speaker, button) */
.word-buttons-row-top {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

/* Bottom row: 4 buttons */
.word-buttons-row-bottom {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
}

/* Definition Button */
.definition-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.definition-btn:hover {
    transform: scale(1.1) rotate(-15deg);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
    outline: 2px solid #000;
    outline-offset: 2px;
}

.definition-btn:active {
    transform: scale(0.95);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.definition-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.definition-btn svg {
    width: 32px;
    height: 32px;
}

/* Origin Button */
.origin-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.origin-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
    outline: 2px solid #000;
    outline-offset: 2px;
}

.origin-btn:active {
    transform: scale(0.95);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.origin-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.origin-btn svg {
    width: 32px;
    height: 32px;
}

/* Sentence Button */
.sentence-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.sentence-btn:hover {
    transform: scale(1.1) rotate(-15deg);
    box-shadow: 0 5px 15px rgba(250, 112, 154, 0.4);
    outline: 2px solid #000;
    outline-offset: 2px;
}

.sentence-btn:active {
    transform: scale(0.95);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.sentence-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.sentence-btn svg {
    width: 32px;
    height: 32px;
}

/* Part of Speech Button */
.partofspeech-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.partofspeech-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 5px 15px rgba(48, 207, 208, 0.4);
    outline: 2px solid #000;
    outline-offset: 2px;
}

.partofspeech-btn:active {
    transform: scale(0.95);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.partofspeech-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.partofspeech-btn svg {
    width: 32px;
    height: 32px;
}

/* Synonyms Button */
.synonyms-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.synonyms-btn:hover {
    transform: scale(1.1) rotate(-15deg);
    box-shadow: 0 5px 15px rgba(168, 237, 234, 0.4);
    outline: 2px solid #000;
    outline-offset: 2px;
}

.synonyms-btn:active {
    transform: scale(0.95);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.synonyms-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.synonyms-btn svg {
    width: 32px;
    height: 32px;
}

/* Antonyms Button */
.antonyms-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
    clip-path: polygon(30% 0%, 70% 0%, 100% 50%, 70% 100%, 30% 100%, 0% 50%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.antonyms-btn:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: 0 5px 15px rgba(255, 154, 158, 0.4);
    outline: 2px solid #000;
    outline-offset: 2px;
}

.antonyms-btn:active {
    transform: scale(0.95);
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.antonyms-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: 2px;
}

.antonyms-btn svg {
    width: 32px;
    height: 32px;
}

/* Input Section */
.input-section {
    margin-bottom: 20px;
}

#spellingInput,
#testSpellingInput {
    width: 100%;
    padding: 20px;
    font-size: 1.3em;
    border: 3px solid #667eea;
    border-radius: 10px;
    text-align: center;
    font-family: 'Courier New', monospace;
    transition: all 0.3s ease;
}

#spellingInput:focus,
#testSpellingInput:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.3);
}

/* Action Buttons Container */
.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    width: 100%;
}

/* Submit Button */
.submit-btn {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    padding: 20px 40px;
    font-size: 1.2em;
    border-radius: 50px;
    box-shadow: 0 5px 20px rgba(17, 153, 142, 0.4);
    transition: all 0.3s ease;
    font-weight: 600;
    color: white;
    border: none;
    cursor: pointer;
}

/* Submit button in action-buttons container */
.action-buttons .submit-btn {
    flex: 1;
    min-width: 0;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(17, 153, 142, 0.6);
}

.submit-btn:active,
.submit-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--modal-bg);
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    color: var(--accent);
    margin-bottom: 20px;
    font-size: 2em;
}

.modal-content p {
    margin: 15px 0;
    font-size: 1.2em;
    color: var(--text-primary);
}

.modal-content strong {
    color: var(--accent);
    font-size: 1.3em;
}

.continue-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin-top: 20px;
    width: 100%;
}

.completion-stats {
    margin: 25px 0;
}

.stat-item {
    margin: 15px 0;
    font-size: 1.3em;
    color: #333;
}

.stat-item.percentage {
    font-size: 1.5em;
    font-weight: 600;
    color: #667eea;
    margin-top: 20px;
}

.modal-content .subtitle {
    font-size: 1.1em;
    color: var(--accent);
    font-style: italic;
    margin-bottom: 20px;
}

/* Definition Modal */
.definition-modal {
    max-width: 600px;
}

.definition-modal h2 {
    color: #667eea;
    margin-bottom: 20px;
    font-size: 2.2em;
}

#definitionContent {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
}

#definitionContent .loading {
    text-align: center;
    color: #667eea;
    font-style: italic;
}

.definition-item {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.definition-item:last-child {
    border-bottom: none;
}

.definition-part-of-speech {
    font-style: italic;
    color: #f5576c;
    font-size: 1.1em;
    margin-bottom: 10px;
    font-weight: 600;
}

.definition-meaning {
    color: #333;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 8px;
}

[data-theme="dark"] .definition-meaning {
    color: #fff;
}

.definition-example {
    color: #666;
    font-size: 1em;
    font-style: italic;
    margin-top: 8px;
    padding-left: 15px;
    border-left: 3px solid #667eea;
}

.definition-synonyms {
    margin-top: 10px;
    color: #667eea;
    font-size: 0.95em;
}

.definition-synonyms strong {
    color: #667eea;
    font-size: 1em;
}

/* Origin Modal */
.origin-modal {
    max-width: 600px;
}

.origin-modal h2 {
    color: #4facfe;
    margin-bottom: 20px;
    font-size: 2.2em;
}

#originContent {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
}

#originContent .loading {
    text-align: center;
    color: #4facfe;
    font-style: italic;
}

.origin-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #4facfe;
}

.origin-title {
    font-weight: 600;
    color: #4facfe;
    font-size: 1.2em;
    margin-bottom: 10px;
}

.origin-text {
    color: #333;
    font-size: 1.1em;
    line-height: 1.6;
}

.origin-language {
    color: #f5576c;
    font-weight: 600;
    font-size: 1.1em;
    margin-top: 10px;
}

/* Sentence Modal */
.sentence-modal {
    max-width: 600px;
}

.sentence-modal h2 {
    color: #fa709a;
    margin-bottom: 20px;
    font-size: 2.2em;
}

#sentenceContent {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
}

#sentenceContent .loading {
    text-align: center;
    color: #fa709a;
    font-style: italic;
}

.sentence-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #fa709a;
}

.sentence-example {
    color: #333;
    font-size: 1.2em;
    line-height: 1.8;
    font-style: italic;
    padding: 10px;
    background: white;
    border-radius: 5px;
}

/* Part of Speech Modal */
.partofspeech-modal {
    max-width: 600px;
}

.partofspeech-modal h2 {
    color: #30cfd0;
    margin-bottom: 20px;
    font-size: 2.2em;
}

#partOfSpeechContent {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
}

#partOfSpeechContent .loading {
    text-align: center;
    color: #30cfd0;
    font-style: italic;
}

.partofspeech-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #30cfd0;
}

.partofspeech-type {
    font-weight: 600;
    color: #30cfd0;
    font-size: 1.3em;
    margin-bottom: 10px;
    text-transform: capitalize;
}

/* Synonyms Modal */
.synonyms-modal {
    max-width: 600px;
}

.synonyms-modal h2 {
    color: #a8edea;
    margin-bottom: 20px;
    font-size: 2.2em;
}

#synonymsContent {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
}

#synonymsContent .loading {
    text-align: center;
    color: #a8edea;
    font-style: italic;
}

.synonyms-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #a8edea;
}

.synonyms-list {
    color: #333;
    font-size: 1.2em;
    line-height: 1.8;
    margin-top: 10px;
}

.synonyms-list span {
    display: inline-block;
    margin: 5px 10px 5px 0;
    padding: 5px 10px;
    background: white;
    border-radius: 5px;
    border: 1px solid #a8edea;
}

/* Antonyms Modal */
.antonyms-modal {
    max-width: 600px;
}

.antonyms-modal h2 {
    color: #ff9a9e;
    margin-bottom: 20px;
    font-size: 2.2em;
}

#antonymsContent {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
    text-align: left;
}

#antonymsContent .loading {
    text-align: center;
    color: #ff9a9e;
    font-style: italic;
}

.antonyms-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #ff9a9e;
}

.antonyms-list {
    color: #333;
    font-size: 1.2em;
    line-height: 1.8;
    margin-top: 10px;
}

.antonyms-list span {
    display: inline-block;
    margin: 5px 10px 5px 0;
    padding: 5px 10px;
    background: white;
    border-radius: 5px;
    border: 1px solid #ff9a9e;
}

/* Continue Progress Modal */
.continue-modal {
    max-width: 500px;
    text-align: center;
}

.continue-modal h2 {
    color: #4facfe;
    margin-bottom: 20px;
    font-size: 2.2em;
}

.continue-modal p {
    color: #333;
    font-size: 1.2em;
    margin-bottom: 30px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-buttons .continue-btn,
.modal-buttons .cancel-btn {
    padding: 15px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.modal-buttons .continue-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.modal-buttons .continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 172, 254, 0.4);
}

.modal-buttons .cancel-btn {
    background: linear-gradient(135deg, #f5576c 0%, #f093fb 100%);
    color: white;
}

.modal-buttons .cancel-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(245, 87, 108, 0.4);
}

.continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.continue-btn:active,
.continue-btn:focus {
    border: 3px solid #000;
    outline: 2px solid #000;
    outline-offset: -2px;
}

/* Success Message */
/* Success Modal */
.success-modal {
    z-index: 2000;
    background: rgba(0, 0, 0, 0.7);
}

.success-modal-content {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    text-align: center;
    padding: 60px 80px;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(17, 153, 142, 0.5);
    animation: successPopIn 0.3s ease;
}

.success-modal-content h2 {
    color: white;
    font-size: 3em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.success-modal-content p {
    color: white;
    font-size: 1.5em;
    margin: 0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

@keyframes successPopIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Voice Selection */
.voice-selection {
    position: fixed;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 180px;
}

.voice-selection label {
    font-size: 0.9em;
    color: #333;
    font-weight: 600;
}

.voice-selection select {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 5px;
    font-size: 0.9em;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.voice-selection select:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

/* Speed Control */
.speed-control {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 200px;
}

.speed-control label {
    font-size: 0.9em;
    color: #333;
    font-weight: 600;
}

.speed-control input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e0e0e0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
}

.speed-control input[type="range"]::-webkit-slider-thumb:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.speed-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #667eea;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.speed-control input[type="range"]::-moz-range-thumb:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.speed-control #speedValue,
.speed-control #speedValueTest {
    font-size: 0.9em;
    color: #667eea;
    font-weight: 600;
    text-align: center;
}

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

    .title {
        font-size: 2em;
    }


    .button-group {
        flex-direction: column;
    }

    button {
        width: 100%;
    }

    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-buttons .back-btn,
    .action-buttons .submit-btn {
        width: 100%;
        padding: 15px 30px;
        font-size: 1em;
        position: relative;
        bottom: auto;
        right: auto;
    }
    
    .word-section {
        padding: 20px;
    }

    .timer-display {
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        right: 100px;
        width: calc(100% - 120px);
        max-width: none;
        min-width: 200px;
        font-size: 1.2em;
        padding: 10px 20px;
    }
}

