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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --grade-excellent: #10b981;
    --grade-good: #3b82f6;
    --grade-average: #f59e0b;
    --grade-poor: #ef4444;
}



body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
    position: relative;
}

.helpButton {
    /* Position it relative to the nearest positioned ancestor (which is .container) */
    position: absolute;
    /* Position from the top right corner */
    top: 10px;
    right: 10px;
    
    /* Subtle button styling */
    width: 25px; /* Set a fixed width and height for the circle */
    height: 25px; 
    border: 1px solid #ccc; /* Subtle gray border */
    border-radius: 50%; /* Makes it circular */
    
    /* Center the question mark text inside the circle */
    display: flex;
    justify-content: center; /* Horizontal center */
    align-items: center; /* Vertical center */
    
    /* Other visual styles */
    font-size: 14px; /* Adjust as needed */
    font-weight: bold;
    cursor: pointer; /* Indicates it's interactive */
    background-color: var(--bg); /* Light background for subtle effect */
    color: var(--text); /* Darker text color */
}

header {
    text-align: center;
    padding: 1.5rem 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 2rem;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.letters-container {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.letter-tile {
    width: 50px;
    height: 50px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative; /* Add this */
}

/* Add these new styles */
.letter-main {
    display: block;
}

.letter-score {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
}

.instructions {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

.words-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.word-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    text-align: center;
    text-transform: uppercase;
    font-weight: 600;
    transition: border-color 0.2s;
}

.word-input:focus {
    outline: none;
    border-color: var(--primary);
}

.word-input.valid {
    border-color: var(--success);
}

.word-input.invalid {
    border-color: var(--error);
}

.word-input.cannot-form {
    border-color: var(--warning);
}

/* Shake animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-2px); }
    20%, 40%, 60%, 80% { transform: translateX(2px); }
}

.shake {
    animation: shake 0.5s;
}


.word-input:disabled {
    background: var(--bg);
    cursor: not-allowed;
}

.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--text-light);
    cursor: not-allowed;
}

.btn-share {
    width: 100%;
    padding: 1rem;
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-share:hover {
    background: var(--primary);
    color: white;
}

.btn-share:active {
    transform: scale(0.98);
}

.btn-share.hidden {
    display: none;
}

.results {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.results.hidden {
    display: none;
}

.score-display {
    text-align: center;
    margin-bottom: 1.5rem;
}

.total-score {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.grade-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.5rem;
    text-transform: uppercase;
}

.grade-excellent { background: var(--grade-excellent); color: white; }
.grade-good { background: var(--grade-good); color: white; }
.grade-average { background: var(--grade-average); color: white; }
.grade-poor { background: var(--grade-poor); color: white; }

.word-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg);
    border-radius: 8px;
    border-left: 4px solid transparent;
}

.word-result.valid {
    border-left-color: var(--success);
}

.word-result.invalid {
    border-left-color: var(--error);
}

.word-result-text {
    font-weight: 600;
    font-size: 1.1rem;
}

.word-result-score {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
}

.error-message {
    padding: 1rem;
    background: #fee;
    color: var(--error);
    border-radius: 8px;
    margin-top: 1rem;
    text-align: center;
}

.loading {
    text-align: center;
    color: var(--text-light);
    padding: 2rem;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.leaderboard-rank {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.2rem;
    min-width: 2rem;
}

.leaderboard-player {
    flex: 1;
    margin: 0 1rem;
}

.leaderboard-score {
    font-weight: 700;
    font-size: 1.1rem;
}

.history-item {
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-date {
    font-weight: 600;
    color: var(--text);
}

.history-words {
    color: var(--text-light);
    font-size: 0.9rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.grade-distribution {
    margin-top: 2rem;
}

.grade-bar {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.grade-label {
    width: 100px;
    font-weight: 600;
    font-size: 0.9rem;
}

.grade-bar-bg {
    flex: 1;
    height: 30px;
    background: var(--bg);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.grade-bar-fill {
    height: 100%;
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Instructions Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.overlay-content h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
    text-align: center;
}

.instructions-section {
    margin-bottom: 1.5rem;
}

.instructions-section h3 {
    color: var(--text);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.instructions-section p {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

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

.score-tier {
    display: block;
    padding: 0.5rem;
    background: var(--bg);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text);
}

.grade-examples {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

#close-instructions {
    margin-top: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state p {
    font-size: 1.1rem;
}

#results-content .results {
    display: block;
}

#results-content .btn-share {
    margin-top: 1.5rem;
}

.score-info {
    margin: 1rem 0;
    background: var(--bg);
    border-radius: 8px;
}

.score-info.hidden {
    display: none;
}

.score-summary {
    text-align: center;
}

.score-label {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-right: 0.5rem;
}

.score-value {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.2rem;
}

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

.grade-thresholds.hidden {
    display: none;
}

.threshold-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-radius: 6px;
}

.threshold-item .grade-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
}

.threshold-value {
    color: var(--text);
    font-weight: 600;
    font-size: 0.9rem;
}
.max-possible {
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Profile Button */
.profile-button {
    position: absolute;
    left: 0;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.profile-button:hover {
    border-color: var(--primary);
}
/* Help Button */
.help-button {
    position: absolute;
    right: 0;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
}

.help-button:hover {
    border-color: var(--primary);
}

.profile-icon-default {
    color: var(--text);
}

.help-icon-default {
    color: var(--text);
}

.profile-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-photo.hidden {
    display: none;
}

/* Close button for overlays */
.close-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--text-light);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-overlay:hover {
    background: var(--bg);
    color: var(--text);
}

/* Profile States */
.profile-state {
    text-align: center;
}

.profile-state.hidden {
    display: none;
}

/* Auth Buttons */
.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.auth-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.auth-button:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.auth-button.google:hover {
    border-color: #4285F4;
}

.auth-button.apple {
    background: #000;
    color: white;
    border-color: #000;
}

.auth-button.apple:hover {
    background: #333;
}

.auth-note {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 1rem;
}

/* Profile Header */
.profile-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.profile-large-photo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
}

.profile-info {
    flex: 1;
    text-align: left;
}

.profile-email {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Profile Section */
.profile-section {
    margin-bottom: 2rem;
    text-align: left;
}

.profile-section h3 {
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.75rem;
}

.display-name-input {
    display: flex;
    gap: 0.5rem;
}

.display-name-input input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text);
}

.display-name-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-small {
    padding: 0.75rem 1.5rem;
    white-space: nowrap;
}

.input-note {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.success-message {
    padding: 0.75rem;
    background: #d1fae5;
    color: #065f46;
    border-radius: 6px;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.success-message.hidden {
    display: none;
}

.btn-secondary {
    width: 100%;
    padding: 1rem;
    background: transparent;
    color: var(--error);
    border: 2px solid var(--error);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--error);
    color: white;
}
/* Dark mode - automatically applies based on system preference */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card-bg: #1e293b;
        --text: #f1f5f9;
        --text-light: #94a3b8;
        --border: #334155;
        --primary: #818cf8;
        --primary-dark: #6366f1;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .letter-tile {
        width: 40px;
        height: 40px;
    }
    
    .letter-tile .letter-main {
        font-size: 1.2rem !important;
    }
    
    .letter-tile .letter-score {
        font-size: 0.6rem !important;
        bottom: 0px;
        right: 2px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
