@import url('https://fonts.googleapis.com/css2?family=Dela+Gothic+One&family=IBM+Plex+Sans:wght@400;600;700&display=swap');

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

body {
    font-family: 'IBM Plex Sans', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    overflow-x: hidden;
    min-height: 100vh;
}

.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(10px, 3vw, 20px);
}

.header {
    text-align: center;
    margin-bottom: clamp(15px, 4vw, 30px);
    position: relative;
}

.header h1 {
    font-family: 'Dela Gothic One', cursive;
    font-size: clamp(1.5rem, 5vw, 3.5rem);
    text-shadow: 4px 4px 0px rgba(0,0,0,0.3);
    animation: slideDown 0.5s ease-out;
    letter-spacing: 1px;
    word-break: break-word;
}

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

.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.3);
    padding: clamp(10px, 2vw, 20px) clamp(15px, 3vw, 30px);
    border-radius: 15px;
    margin-bottom: clamp(15px, 3vw, 30px);
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    flex-wrap: wrap;
    gap: 10px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: fit-content;
}

.stat-label {
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    white-space: nowrap;
}

.stat-value {
    font-size: clamp(1.2rem, 3vw, 2rem);
    font-weight: 700;
    font-family: 'Dela Gothic One', cursive;
}

.timer {
    color: #ffd700;
}

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

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

.level-badge {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: clamp(6px, 1.5vw, 8px) clamp(12px, 3vw, 20px);
    border-radius: 20px;
    font-weight: 600;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    white-space: nowrap;
}

.question-area {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: clamp(15px, 4vw, 30px);
    color: #333;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    margin-bottom: clamp(15px, 3vw, 30px);
}

.question-text {
    font-size: clamp(1.1rem, 3vw, 1.8rem);
    font-weight: 700;
    margin-bottom: 25px;
    color: #667eea;
    text-align: center;
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.6;
}

.word {
    display: inline-block;
    position: relative;
}

.word-translatable {
    cursor: help;
    border-bottom: 2px dotted #764ba2;
    position: relative;
}

.word-translatable:hover .translation-tooltip,
.word-translatable:active .translation-tooltip {
    opacity: 1;
    visibility: visible;
}

.translation-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
    margin-bottom: 5px;
    pointer-events: none;
    z-index: 100;
}

.blank {
    color: #ff4757;
    text-decoration: underline;
    font-weight: 900;
    min-width: clamp(60px, 15vw, 100px);
    display: inline-block;
    text-align: center;
    cursor: help;
    position: relative;
}

.blank.word-translatable:hover .translation-tooltip,
.blank.word-translatable:active .translation-tooltip {
    opacity: 1;
    visibility: visible;
}

.word-highlight {
    background: #ffd700;
    color: #333;
    padding: 2px 8px;
    border-radius: 5px;
    font-weight: 700;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.blank-options-group {
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.blank-options-group.focused {
    transform: scale(1);
    margin-bottom: 15px;
}

.blank-options-group.unfocused {
    opacity: 0.3;
    pointer-events: none;
    transform: scale(0.25);
    transform-origin: center top;
    margin-bottom: -50px;
}

.blank-options-group.unfocused .option-btn {
    padding: clamp(3px, 1vw, 5px);
    font-size: clamp(0.5rem, 1.5vw, 0.6rem);
}

.blank-options-group.unfocused .blank-label {
    font-size: clamp(0.4rem, 1.2vw, 0.5rem);
    margin-bottom: 1px;
}

.blank-options-group.unfocused .options-grid {
    gap: 2px;
}

.blank-label {
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 600;
    color: #667eea;
    margin-bottom: 5px;
    text-align: center;
}

.blank-label .answer-text {
    opacity: 0;
    font-size: 0.1px;
    position: absolute;
    left: -9999px;
}

.blank-label .answer-text.admin-visible {
    opacity: 1;
    font-size: 1rem;
    position: static;
    left: auto;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(6px, 1.5vw, 8px);
}

.option-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: clamp(12px, 3vw, 20px);
    border-radius: 12px;
    font-size: clamp(1rem, 2.5vw, 1.3rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'IBM Plex Sans', sans-serif;
    box-shadow: 0 4px 15px rgba(102,126,234,0.4);
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
}

.option-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102,126,234,0.6);
}

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

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

.option-btn.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    animation: correctPulse 0.5s ease;
}

.option-btn.wrong {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    animation: shake 0.5s ease;
}

.option-btn.selected {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #333;
    font-weight: 700;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.voice-indicator {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background: rgba(102,126,234,0.2);
    border-radius: 10px;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
}

.voice-indicator.listening {
    background: rgba(255,215,0,0.3);
    animation: pulse 1s infinite;
}

.start-screen, .mode-select-screen, .end-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: clamp(15px, 4vw, 20px);
    overflow-y: auto;
}

.start-screen h1, .mode-select-screen h1, .end-screen h1 {
    font-family: 'Dela Gothic One', cursive;
    font-size: clamp(2rem, 8vw, 4rem);
    margin-bottom: clamp(10px, 3vw, 20px);
    text-shadow: 5px 5px 0px rgba(0,0,0,0.3);
    text-align: center;
    word-break: break-word;
}

.start-screen p, .mode-select-screen p {
    font-size: clamp(1rem, 3vw, 1.3rem);
    margin-bottom: clamp(20px, 5vw, 40px);
    text-align: center;
    max-width: 600px;
    line-height: 1.6;
    padding: 0 10px;
}

.player-info {
    margin-bottom: clamp(20px, 4vw, 30px);
    width: 100%;
    max-width: 400px;
}

.player-info label {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin-bottom: 10px;
    display: block;
    text-align: center;
}

.player-name-input {
    padding: clamp(8px, 2vw, 10px) clamp(15px, 3vw, 20px);
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    border-radius: 10px;
    border: 2px solid white;
    background: rgba(255,255,255,0.9);
    text-align: center;
    width: 100%;
    max-width: 300px;
    font-family: 'IBM Plex Sans', sans-serif;
    display: block;
    margin: 0 auto;
}

.high-score-display {
    margin-top: 15px;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    opacity: 0.9;
    text-align: center;
}

.mode-select-container {
    display: flex;
    gap: clamp(10px, 3vw, 20px);
    margin-bottom: clamp(20px, 4vw, 30px);
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 900px;
}

.mode-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: clamp(20px, 4vw, 30px);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    flex: 1 1 250px;
    min-width: 200px;
    max-width: 300px;
}

.mode-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.mode-card.selected {
    border-color: #ffd700;
    background: rgba(255,255,255,0.2);
}

.mode-card h3 {
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    margin-bottom: 10px;
    font-family: 'Dela Gothic One', cursive;
}

.mode-card .multiplier {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: #ffd700;
    font-weight: 700;
    margin: 10px 0;
}

.mode-card p {
    font-size: clamp(0.85rem, 2vw, 1rem);
    line-height: 1.5;
    margin-bottom: 0;
}

.start-btn, .restart-btn, .continue-btn {
    background: white;
    color: #667eea;
    border: none;
    padding: clamp(12px, 3vw, 20px) clamp(40px, 8vw, 60px);
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    font-family: 'Dela Gothic One', cursive;
    text-transform: uppercase;
    min-height: 44px;
}

.start-btn:hover, .restart-btn:hover, .continue-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.4);
}

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

.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: clamp(20px, 4vw, 30px) clamp(40px, 8vw, 60px);
    border-radius: 20px;
    font-size: clamp(1.3rem, 4vw, 2rem);
    font-weight: 700;
    z-index: 999;
    animation: feedbackPop 0.5s ease;
    display: none;
    max-width: 90%;
    text-align: center;
}

@keyframes feedbackPop {
    0% { transform: translate(-50%, -50%) scale(0); }
    60% { transform: translate(-50%, -50%) scale(1.1); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(0,0,0,0.3);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 20px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700, #ffed4e);
    transition: width 0.5s ease;
    box-shadow: 0 0 10px #ffd700;
}

.results-container {
    background: rgba(255,255,255,0.95);
    border-radius: 20px;
    padding: clamp(20px, 5vw, 40px);
    max-width: 90%;
    width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    color: #333;
}

.results-header {
    text-align: center;
    margin-bottom: clamp(15px, 4vw, 30px);
}

.results-header h1 {
    font-size: clamp(1.8rem, 5vw, 3rem) !important;
    color: #667eea;
}

.final-score {
    font-size: clamp(2.5rem, 8vw, 4rem);
    color: #667eea;
    font-family: 'Dela Gothic One', cursive;
    margin: clamp(10px, 3vw, 20px) 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: clamp(10px, 3vw, 20px);
    margin-bottom: clamp(15px, 4vw, 30px);
}

.stat-box {
    background: rgba(102,126,234,0.1);
    padding: clamp(12px, 3vw, 20px);
    border-radius: 10px;
    text-align: center;
}

.stat-box .label {
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    opacity: 0.7;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stat-box .value {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    color: #667eea;
}

.review-section {
    margin-top: clamp(15px, 4vw, 30px);
}

.review-section h3 {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    margin-bottom: clamp(10px, 3vw, 20px);
    color: #667eea;
}

.review-item {
    background: rgba(0,0,0,0.05);
    padding: clamp(10px, 3vw, 15px);
    border-radius: 10px;
    margin-bottom: clamp(10px, 3vw, 15px);
    border-left: 4px solid #667eea;
}

.review-item.correct {
    border-left-color: #38ef7d;
}

.review-item.incorrect {
    border-left-color: #ff4757;
}

.review-sentence {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin-bottom: 10px;
    font-weight: 600;
    word-break: break-word;
}

.review-details {
    font-size: clamp(0.85rem, 2vw, 1rem);
    color: #666;
    word-break: break-word;
}

.review-details .your-answer {
    color: #ff4757;
}

.review-details .correct-answer {
    color: #38ef7d;
}

.hidden {
    display: none !important;
}

.leaderboard-display {
    margin-top: 20px;
    background: rgba(255,255,255,0.1);
    padding: clamp(15px, 3vw, 20px);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    width: 100%;
    max-width: 400px;
}

.leaderboard-display h3 {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    margin-bottom: 15px;
    text-align: center;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255,255,255,0.1);
    padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 15px);
    border-radius: 8px;
    gap: 10px;
}

.leaderboard-entry .rank {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    min-width: 30px;
    flex-shrink: 0;
}

.leaderboard-entry .player-name {
    flex: 1;
    font-weight: 600;
    font-size: clamp(0.9rem, 2vw, 1rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.leaderboard-entry .score {
    font-weight: 700;
    color: #ffd700;
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    flex-shrink: 0;
}

.give-up-btn {
    background: rgba(255, 71, 87, 0.8);
    color: white;
    border: none;
    padding: clamp(8px, 2vw, 10px) clamp(12px, 3vw, 20px);
    border-radius: 8px;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'IBM Plex Sans', sans-serif;
    white-space: nowrap;
    min-height: 40px;
}

.give-up-btn:hover {
    background: rgba(255, 71, 87, 1);
    transform: translateY(-2px);
}

/* Floating Music Player Bubble */
.music-player-bubble {
    position: fixed;
    bottom: clamp(15px, 3vw, 30px);
    left: clamp(15px, 3vw, 30px);
    z-index: 9999;
    animation: floatIn 0.5s ease-out;
}

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

.music-toggle-btn {
    width: clamp(50px, 12vw, 70px);
    height: clamp(50px, 12vw, 70px);
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 4px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: clamp(20px, 5vw, 28px);
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(102, 126, 234, 0.7);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    backdrop-filter: blur(10px);
}

.music-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.4), 0 0 30px rgba(102, 126, 234, 0.5);
}

.music-toggle-btn:active {
    transform: scale(0.95);
}

.music-toggle-btn.playing {
    animation: musicPulse 2s infinite;
}

@keyframes musicPulse {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3), 0 0 20px 10px rgba(102, 126, 234, 0);
    }
}

.play-icon, .pause-icon {
    position: absolute;
    transition: opacity 0.3s ease;
}

.pause-icon {
    font-size: clamp(18px, 4vw, 24px);
}

/* ========== RESPONSIVE BREAKPOINTS ========== */

/* Small phones (320px - 479px) */
@media (max-width: 479px) {
    .stats-bar {
        justify-content: center;
        padding: 12px 10px;
    }

    .stat-item {
        flex: 1 1 45%;
        min-width: 80px;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .mode-select-container {
        flex-direction: column;
        align-items: center;
    }

    .mode-card {
        width: 90%;
        max-width: 90%;
    }

    .mode-card {
        flex: 0 0 auto;          /* ← STOP IT FROM STRETCHING! */
        height: auto;            /* ← Let content determine height */
        min-height: unset;       /* ← Remove any min-height */
    }

    .blank-options-group.unfocused {
        transform: scale(0.25);
        margin-bottom: -140px;
    }
}

/* Medium phones and tablets (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .stats-bar {
        gap: 15px;
    }

    .stat-item {
        flex: 1 1 30%;
    }
}

/* Tablets (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .header h1 {
        font-size: 2.5rem;
    }

    .mode-select-container {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

/* Desktop and larger (1024px+) */
@media (min-width: 1024px) {
    .stats-bar {
        flex-wrap: nowrap;
    }
}

/* Landscape mode adjustments */
@media (max-height: 600px) and (orientation: landscape) {
    .start-screen h1, .mode-select-screen h1, .end-screen h1 {
        font-size: 2rem;
        margin-bottom: 10px;
    }

    .start-screen p, .mode-select-screen p {
        font-size: 0.95rem;
        margin-bottom: 15px;
    }

    .player-info {
        margin-bottom: 15px;
    }

    .mode-select-container {
        gap: 10px;
    }

    .mode-card {
        padding: 15px;
    }

    .start-btn, .restart-btn, .continue-btn {
        padding: 10px 30px;
        font-size: 1.1rem;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .question-text {
        font-size: 1rem;
    }

    .option-btn {
        font-size: 0.95rem;
        padding: 10px;
    }

    .leaderboard-entry .player-name {
        font-size: 0.85rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .option-btn:hover:not(:disabled) {
        transform: none;
    }

    .option-btn:active:not(:disabled) {
        transform: scale(0.97);
    }

    .mode-card:hover {
        transform: none;
    }

    .mode-card:active {
        transform: scale(0.98);
    }
}