/* CSS Variables */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --bg-card: #1e1e1e;
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    
    --accent-primary: #e63946;
    --accent-secondary: #f4a261;
    --accent-gold: #ffd700;
    
    --success: #2ecc71;
    --error: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    
    --green-box: #538d4e;
    --yellow-box: #b59f3b;
    --red-box: #c9453a;
    --gray-box: #3a3a3c;
    
    --border-color: #333333;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    
    --font-tamil: 'Noto Sans Tamil', sans-serif;
    --font-eng: 'Outfit', sans-serif;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    
    --transition: 0.2s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: var(--font-eng);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    background-image: 
        radial-gradient(ellipse at top, rgba(230, 57, 70, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(244, 162, 97, 0.05) 0%, transparent 50%);
}

/* App Container */
.app-container {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left, .header-right {
    flex: 1;
    display: flex;
}

.header-right {
    justify-content: flex-end;
}

.header-center {
    flex: 2;
    text-align: center;
}

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

.logo-main {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Main Game Container */
.game-container {
    flex: 1;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Lyrics Section */
.lyrics-section {
    width: 100%;
}

.lyrics-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.lyrics-header {
    background: linear-gradient(135deg, var(--accent-primary), #c92a37);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lyrics-icon {
    font-size: 1.1rem;
}

.lyrics-content {
    padding: 1.5rem;
    font-family: var(--font-tamil);
    font-size: 1.25rem;
    line-height: 2;
    text-align: center;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lyrics-content p {
    white-space: pre-line;
}

.loading-text {
    color: var(--text-muted);
    font-family: var(--font-eng);
    font-size: 1rem;
}

/* Attempts Section */
.attempts-section {
    display: flex;
    justify-content: center;
}

.attempts-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
}

.attempt-box {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    flex-shrink: 0;
    animation: popIn 0.3s ease;
}

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

.attempt-box.correct {
    background: var(--green-box);
}

.attempt-box.wrong {
    background: var(--red-box);
}

.attempt-box.clue {
    background: var(--yellow-box);
}

/* Clues Section */
.clues-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.clues-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.clues-remaining {
    color: var(--accent-secondary);
    font-size: 0.8rem;
}

.clues-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.clue-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.6rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-transform: capitalize;
}

.clue-btn:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--accent-secondary);
    color: var(--text-primary);
}

.clue-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.clue-btn.used {
    background: var(--yellow-box);
    border-color: var(--yellow-box);
    color: var(--text-primary);
}

.revealed-clues {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.revealed-clue {
    background: rgba(181, 159, 59, 0.15);
    border: 1px solid var(--yellow-box);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.revealed-clue .clue-label {
    color: var(--accent-secondary);
    font-weight: 600;
    text-transform: capitalize;
}

.revealed-clue .clue-value {
    color: var(--text-primary);
    font-family: var(--font-tamil);
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

.search-container {
    width: 100%;
    position: relative;
}

.song-input {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    font-family: var(--font-eng);
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    color: var(--text-primary);
    transition: var(--transition);
}

.song-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(230, 57, 70, 0.2);
}

.song-input::placeholder {
    color: var(--text-muted);
}

/* Dropdown */
.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-top: 0.5rem;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 50;
    box-shadow: var(--shadow-lg);
}

.dropdown.show {
    display: block;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.dropdown-item:hover,
.dropdown-item.selected {
    background: var(--bg-tertiary);
}

.dropdown-item .song-eng {
    font-weight: 500;
    color: var(--text-primary);
}

.dropdown-item .song-movie {
    font-size: 0.85rem;
    color: var(--accent-secondary);
    margin-left: 0.25rem;
}

.dropdown-item .song-movie.highlight {
    color: var(--accent-gold);
    font-weight: 600;
}

.dropdown-item.movie-match {
    border-left: 3px solid var(--accent-gold);
}

.dropdown-item .song-tamil {
    font-family: var(--font-tamil);
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
    display: block;
    margin-top: 0.25rem;
}

.dropdown-empty {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-eng);
    background: linear-gradient(135deg, var(--accent-primary), #c92a37);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tries-remaining {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Game Over Section */
.game-over-section {
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.result-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.result-card h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.result-card.win h2 {
    color: var(--success);
}

.result-card.lose h2 {
    color: var(--error);
}

.result-song {
    margin: 1rem 0;
}

.result-song .song-title-eng {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-secondary);
}

.result-song .song-title-tamil {
    font-family: var(--font-tamil);
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.result-boxes {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.result-boxes .box {
    width: 36px;
    height: 36px;
    border-radius: 6px;
}

.share-section {
    margin: 1rem 0;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-eng);
    background: var(--success);
    border: none;
    border-radius: var(--border-radius);
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.next-game-timer {
    margin-top: 1.5rem;
    color: var(--text-muted);
}

.next-game-timer p {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    font-variant-numeric: tabular-nums;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlide 0.3s ease;
}

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

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--accent-primary);
}

.modal-content h3 {
    margin: 1rem 0 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* How to Play */
.how-to-play ul {
    list-style: none;
    margin: 1rem 0;
}

.how-to-play li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.result-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.result-legend p {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
}

.box {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-block;
}

.box.green {
    background: var(--green-box);
}

.box.red {
    background: var(--red-box);
}

.box.yellow {
    background: var(--yellow-box);
}

.tip {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(244, 162, 97, 0.1);
    border: 1px solid var(--accent-secondary);
    border-radius: var(--border-radius-sm);
    font-size: 0.85rem;
}

.spelling-note {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.feedback {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

.feedback a {
    color: var(--info);
    text-decoration: none;
    font-weight: 600;
}

.feedback a:hover {
    text-decoration: underline;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.stat-item {
    padding: 0.75rem 0.5rem;
    background: var(--bg-tertiary);
    border-radius: var(--border-radius-sm);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.distribution {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dist-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dist-num {
    width: 20px;
    font-weight: 600;
    font-size: 0.9rem;
}

.dist-bar {
    height: 24px;
    background: var(--gray-box);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 24px;
    transition: width 0.5s ease;
}

.dist-bar.highlight {
    background: var(--green-box);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--bg-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 300;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .header {
        padding: 0.75rem 1rem;
    }
    
    .logo-main {
        font-size: 1.25rem;
    }
    
    .game-container {
        padding: 1rem;
        gap: 1rem;
        padding-bottom: 250px; /* Extra space for keyboard */
    }
    
    .lyrics-content {
        font-size: 1.1rem;
        padding: 1rem;
    }
    
    .clues-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .input-section {
        position: relative;
        z-index: 10;
    }
    
    .dropdown {
        max-height: 200px;
    }
}
