/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* Animated background particles */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(120, 119, 198, 0.2) 0%, transparent 50%);
    animation: backgroundShift 20s ease-in-out infinite;
    z-index: 0;
}

@keyframes backgroundShift {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* Game Container */
.game-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    max-width: 600px;
    width: 100%;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.6s ease-out;
}

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

/* Header Row */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 16px;
}

/* Title */
h1 {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    letter-spacing: -0.5px;
}

/* Current Word Container */
#currentWordContainer {
    margin: 24px 0;
}

#currentWordContainer p {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#currentWord {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
    padding: 16px 32px;
    border-radius: 16px;
    background-color: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.2);
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

#currentWord:not(:empty) {
    animation: wordPulse 0.5s ease-out;
}

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

/* Counter Container */
#definitionCounter,
#failCounter {
    font-size: 16px;
    font-weight: 600;
    color: #4b5563;
    padding: 12px 20px;
    border-radius: 12px;
    display: inline-block;
    margin: 0;
}

#definitionCounter {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

#failCounter {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(220, 38, 38, 0.1) 100%);
    color: #dc2626;
}

/* Timer Display */
.timer-display {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    min-width: 80px;
    text-align: center;
    transition: all 0.3s ease;
}

.timer-display.low-time {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    animation: timerPulse 1s ease-in-out infinite;
}

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

@keyframes timeChangeFloat {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px);
    }
}

/* Input Fields */
input {
    width: 100%;
    padding: 16px 20px;
    margin: 16px 0;
    border-radius: 12px;
    border: 2px solid #e5e7eb;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s ease;
    background: #ffffff;
    color: #1f2937;
}

input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    transform: translateY(-2px);
}

input::placeholder {
    color: #9ca3af;
}

/* Buttons Container */
.button-group {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

/* Buttons */
button {
    flex: 1;
    min-width: 140px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

button:hover::before {
    width: 300px;
    height: 300px;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Hint Button */
.hint-button {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.4);
    min-width: 100px;
}

.hint-button:hover {
    box-shadow: 0 6px 20px rgba(251, 191, 36, 0.5);
}

/* New Word Button */
button:last-of-type {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    box-shadow: 0 4px 14px rgba(245, 87, 108, 0.4);
}

button:last-of-type:hover {
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.5);
}

/* Message */
#message {
    margin: 16px 0;
    font-weight: 600;
    font-size: 16px;
    min-height: 24px;
    padding: 12px;
    border-radius: 10px;
    transition: all 0.3s ease;
    animation: messageSlide 0.4s ease-out;
}

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

#message:empty {
    display: none;
}

/* Definition Squares Container */
.square-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 24px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Custom Scrollbar */
.square-container::-webkit-scrollbar {
    width: 8px;
}

.square-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.square-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.square-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

/* Definition Squares */
.square {
    width: 100%;
    min-height: 70px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border: 2px solid rgba(102, 126, 234, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-size: 15px;
    font-weight: 500;
    color: #1f2937;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow-wrap: break-word;
    text-align: center;
    line-height: 1.5;
    position: relative;
}

.square::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.square:hover::before {
    opacity: 1;
}

.square.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* Loading Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Hint Popup */
.hint-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.hint-popup.show {
    opacity: 1;
    visibility: visible;
}

.hint-content {
    background: white;
    border-radius: 20px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.hint-popup.show .hint-content {
    transform: scale(1) translateY(0);
}

.hint-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e5e7eb;
}

.hint-header span:first-child {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hint-timer {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.4);
    animation: timerPulse 1s ease-in-out infinite;
}

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

.hint-text {
    font-size: 16px;
    line-height: 1.6;
    color: #374151;
    text-align: center;
    padding: 20px 0;
    font-style: italic;
}

/* Statistics Popup */
.stats-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.stats-popup.show {
    opacity: 1;
    visibility: visible;
}

.stats-popup-content {
    background: white;
    border-radius: 20px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.stats-popup.show .stats-popup-content {
    transform: scale(1) translateY(0);
}

.stats-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e5e7eb;
}

.stats-popup-header span:first-child {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats-popup-close {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: white;
    border: none;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
    flex: none !important;
    min-width: 24px !important;
}

.stats-popup-close:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
}

.stats-popup-body {
    padding: 20px 0;
}

.stats-toggle-small {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 24px !important;
    height: 36px !important;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
    min-width: 24px;
    max-width: 24px;
}

.stats-toggle-small:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.stats-toggle-small:active {
    transform: scale(0.98);
}

.challenge-toggle-small {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    width: 24px !important;
    height: 36px !important;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
    flex-shrink: 0;
    min-width: 24px;
    max-width: 24px;
}

.challenge-toggle-small:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 3px 10px rgba(245, 158, 11, 0.4);
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
}

.challenge-toggle-small:active {
    transform: scale(0.98);
}

.challenge-toggle-small.active {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
    animation: challengePulse 2s ease-in-out infinite;
}

.daily-challenge-toggle-small {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    width: 24px !important;
    height: 36px !important;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3);
    flex-shrink: 0;
    min-width: 24px;
    max-width: 24px;
}

.daily-challenge-toggle-small:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 3px 10px rgba(139, 92, 246, 0.4);
    background: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
}

.daily-challenge-toggle-small:active {
    transform: scale(0.98);
}

.daily-challenge-toggle-small.active {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
    animation: dailyChallengePulse 2s ease-in-out infinite;
}

@keyframes challengePulse {
    0%, 100% {
        box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
    }
    50% {
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.6);
    }
}

@keyframes dailyChallengePulse {
    0%, 100% {
        box-shadow: 0 2px 6px rgba(5, 150, 105, 0.3);
    }
    50% {
        box-shadow: 0 4px 12px rgba(5, 150, 105, 0.6);
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.3);
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive Design */
@media (max-width: 640px) {
    .game-container {
        padding: 24px;
        border-radius: 20px;
    }
    
    .header-row {
        margin-bottom: 12px;
    }
    
    h1 {
        font-size: 28px;
    }
    
    .stats-toggle-small,
    .daily-challenge-toggle-small {
        width: 22px !important;
        height: 34px !important;
        font-size: 12px;
        min-width: 22px;
        max-width: 22px;
    }
    
    #currentWord {
        font-size: 28px;
        padding: 12px 24px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button {
        width: 100%;
    }
    
    .square-container {
        max-height: 300px;
    }
    
    .hint-content {
        padding: 24px;
    }
    
    .hint-text {
        font-size: 14px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
}

/* Success/Error Message Colors */
#message.success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

#message.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

#message.warning {
    background: rgba(234, 179, 8, 0.1);
    color: #ca8a04;
    border: 1px solid rgba(234, 179, 8, 0.2);
}

/* Difficulty Selector Styling */
.difficulty-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 5px 0 25px 0;
}

.difficulty-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #64748b;
    opacity: 0.8;
}

.difficulty-pills {
    display: flex;
    background: #f1f5f9;
    padding: 5px;
    border-radius: 50px;
    gap: 5px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
    border: 1px solid #e2e8f0;
}

.pill {
    border: none;
    background: transparent;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 700;
    color: #64748b; /* Darkened from #94a3b8 for better legibility */
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 80px;
}

.pill:hover:not(.active) {
    color: #1e293b;
    background: rgba(255, 255, 255, 0.8);
}

.pill.active {
    color: white !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    text-shadow: 0 1px 1px rgba(0,0,0,0.1); /* Added for crisper text */
}

.pill.active[data-value=""] {
    background: #1e293b;
}
.pill.active[data-value="Easy"] {
    background: #059669; /* Slightly deeper green */
}
.pill.active[data-value="Medium"] {
    background: #d97706; /* Slightly deeper amber */
}
.pill.active[data-value="Hard"] {
    background: #b91c1c; /* Deeper crimson for much better contrast */
}

#difficultySelect {
    display: none;
    visibility: hidden;
}