/* GitHub Theme Variables */
:root {
    /* Light theme */
    --bg-color: #ffffff;
    --text-color: #24292f;
    --correct-color: #1a7f37;
    --highlight-color: #0969da;
    --incorrect-color: #cf222e;
    --border-color: #d1d9e0;
    --button-bg: #f6f8fa;
    --button-border: #d1d9e0;
    --correct-flash-bg: rgba(26, 127, 55, 0.2);
    --incorrect-flash-bg: rgba(207, 34, 46, 0.2);
}

[data-theme="dark"] {
    /* Dark theme */
    --bg-color: #0d1117;
    --text-color: #f0f6fc;
    --correct-color: #3fb950;
    --highlight-color: #58a6ff;
    --incorrect-color: #f85149;
    --border-color: #30363d;
    --button-bg: #21262d;
    --button-border: #30363d;
    --correct-flash-bg: rgba(63, 185, 80, 0.2);
    --incorrect-flash-bg: rgba(248, 81, 73, 0.2);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.center-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .center-container {
        padding: 0.5rem;
        justify-content: center;
        padding-top: 2rem;
        padding-bottom: 2rem;
    }
}

.kannada {
    font-size: clamp(2.5rem, 8vw, 4rem);
    margin-bottom: 2rem;
    color: var(--text-color);
    font-weight: 400;
    line-height: 1.2;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: clamp(0.5rem, 2vw, 1rem);
    max-width: 100%;
}

.kannada-char-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.transliteration {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: var(--text-color);
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-weight: 500;
    background: var(--button-bg);
    border: 1px solid var(--button-border);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    min-width: 2rem;
    text-align: center;
    word-break: break-all;
}

@media (max-width: 768px) {
    .kannada {
        margin-bottom: 1.5rem;
        gap: 0.8rem;
    }

    .transliteration {
        font-size: 0.9rem;
        padding: 0.3rem 0.5rem;
        min-width: 1.5rem;
    }
}

.meaning {
    font-size: clamp(1rem, 3vw, 1.2rem);
    margin-bottom: 1rem;
    color: var(--text-color);
    font-weight: 400;
    min-height: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease;
    max-width: 90%;
}

.meaning.show {
    opacity: 1;
    transform: translateY(0);
}

.meaning.completed {
    background: var(--button-bg);
    border: 2px solid var(--correct-color);
    border-radius: 6px;
    padding: 0.8rem 1.5rem;
    color: var(--correct-color);
    font-weight: 500;
}

.hint {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    margin-bottom: 2rem;
    color: var(--incorrect-color);
    font-weight: 500;
    min-height: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s ease;
    background: var(--button-bg);
    border: 2px solid var(--incorrect-color);
    border-radius: 6px;
    padding: 0.6rem 1.2rem;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    max-width: 90%;
}

.hint.show {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {

    .meaning,
    .hint {
        margin-bottom: 1rem;
        padding: 0.6rem 1rem;
    }
}

.input-section input {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    padding: clamp(0.8rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2rem);
    width: min(400px, 90vw);
    max-width: 100%;
    border: 3px solid var(--highlight-color);
    border-radius: 6px;
    text-align: center;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    background: var(--bg-color);
    color: var(--text-color);
    outline: none;
    transition: all 0.2s ease;
    /* Remove cursor completely */
    caret-color: transparent;
}

/* Text selection styling for input */
.input-section input::selection {
    background-color: var(--highlight-color);
    color: var(--bg-color);
}

.input-section input:focus {
    border-color: var(--highlight-color);
    animation: input-pulse 1s infinite;
    /* Keep cursor hidden even when focused */
    caret-color: transparent;
    /* Add subtle glow effect that works with both themes */
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.15);
}

.input-section input::placeholder {
    color: var(--text-color);
    opacity: 0.5;
    font-size: 0.6em;
    /* Make placeholder text smaller */
}

.input-section input.error {
    border-color: var(--incorrect-color) !important;
    animation: none !important;
}

@media (max-width: 768px) {
    .input-section input {
        width: min(350px, 85vw);
    }
}

/* Kannada character states */
.kannada-typed-correct {
    color: var(--correct-color);
    background: var(--button-bg);
    border: 3px solid var(--correct-color);
    border-radius: 6px;
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.6rem, 2vw, 0.8rem);
    margin: 0.2rem;
    display: inline-block;
    min-width: clamp(1.5rem, 4vw, 2rem);
    text-align: center;
}

.kannada-current-char {
    color: var(--highlight-color);
    background: var(--button-bg);
    border: 3px solid var(--highlight-color);
    border-radius: 6px;
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.6rem, 2vw, 0.8rem);
    margin: 0.2rem;
    display: inline-block;
    min-width: clamp(1.5rem, 4vw, 2rem);
    text-align: center;
    animation: char-pulse 1s infinite;
}

.kannada-pending-char {
    color: var(--text-color);
    background: var(--button-bg);
    border: 3px solid var(--button-border);
    border-radius: 6px;
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.6rem, 2vw, 0.8rem);
    margin: 0.2rem;
    display: inline-block;
    min-width: clamp(1.5rem, 4vw, 2rem);
    text-align: center;
    transition: all 0.2s ease;
}

.kannada-skipped-char {
    color: var(--incorrect-color);
    background: var(--button-bg);
    border: 3px solid var(--incorrect-color);
    border-radius: 6px;
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.6rem, 2vw, 0.8rem);
    margin: 0.2rem;
    display: inline-block;
    min-width: clamp(1.5rem, 4vw, 2rem);
    text-align: center;
    opacity: 0.7;
}

/* Character flash animations */
.flash-correct {
    color: var(--correct-color) !important;
    background: var(--correct-flash-bg) !important;
    border-color: var(--correct-color) !important;
    animation: flash-scale 0.2s ease !important;
}

.flash-incorrect {
    color: var(--incorrect-color) !important;
    background: var(--incorrect-flash-bg) !important;
    border-color: var(--incorrect-color) !important;
    animation: flash-scale 0.2s ease !important;
}

@keyframes flash-scale {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes char-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

@keyframes input-pulse {

    0%,
    100% {
        border-color: var(--highlight-color);
    }

    50% {
        border-color: var(--highlight-color);
        opacity: 0.8;
    }
}

@media (max-width: 768px) {

    .kannada-typed-correct,
    .kannada-current-char,
    .kannada-pending-char,
    .kannada-skipped-char {
        padding: 0.4rem 0.6rem;
        margin: 0.1rem;
        min-width: 1.8rem;
        border-radius: 8px;
    }
}

/* Navigation container and button styles */
.nav-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    position: fixed;
    bottom: 2rem;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 0 1rem;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    background: var(--button-bg);
    border: 1px solid var(--button-border);
}

.nav-button:hover {
    animation: char-pulse 1.5s infinite;
}

.nav-button svg {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .nav-container {
        gap: 0.5rem;
        bottom: 1rem;
    }

    .nav-button {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
        gap: 0.4rem;
    }

    .nav-button svg {
        width: 16px;
        height: 16px;
    }

    .nav-button span {
        display: none;
    }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-color);
    border: 1px solid var(--button-border);
    border-radius: 6px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid var(--button-border);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.5rem;
}

.close {
    font-size: 2rem;
    color: var(--text-color);
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
}

.close:hover {
    color: var(--incorrect-color);
}

.modal-body {
    padding: 1.5rem 2rem 2rem;
    color: var(--text-color);
    line-height: 1.6;
}

.modal-body ul {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.modal-body li {
    margin: 0.5rem 0;
}

.modal-body p {
    margin: 1rem 0;
}

.modal-body em {
    color: #6897BB;
    font-style: italic;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 70vh;
    }

    .modal-header {
        padding: 1rem 1.5rem 0.5rem;
    }

    .modal-header h2 {
        font-size: 1.3rem;
    }

    .modal-body {
        padding: 1rem 1.5rem 1.5rem;
    }
}

/* Alphabet modal styles */
.alphabet-content {
    max-width: 800px;
    max-height: 90vh;
}

.alphabet-grid {
    padding: 1rem 2rem 2rem;
}

.alphabet-section {
    margin-bottom: 2rem;
}

.alphabet-section h3 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.2rem;
    border-bottom: 2px solid var(--button-border);
    padding-bottom: 0.5rem;
}

.alphabet-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.letter-item {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--button-bg);
    border: 1px solid var(--button-border);
    border-radius: 6px;
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 500;
    min-width: 3rem;
    text-align: center;
    transition: all 0.3s ease;
}

.letter-item:hover {
    animation: char-pulse 1.5s infinite;
}

@media (max-width: 768px) {
    .alphabet-content {
        max-width: 95%;
        max-height: 85vh;
    }

    .alphabet-grid {
        padding: 1rem 1.5rem 1.5rem;
    }

    .alphabet-section h3 {
        font-size: 1.1rem;
    }

    .alphabet-row {
        gap: 0.3rem;
    }

    .letter-item {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
        min-width: 2.5rem;
    }
}

/* Loading indicator */
.loading-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--highlight-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-text {
    font-size: 1.2rem;
    color: var(--text-color);
    opacity: 0.8;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* History modal styles */
.history-content {
    max-width: 800px;
    max-height: 90vh;
}

.history-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--button-bg);
    border: 1px solid var(--button-border);
    border-radius: 6px;
}

.history-stats p {
    margin: 0;
    font-weight: 500;
    color: var(--text-color);
}

.clear-history-btn {
    background: var(--incorrect-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.3s ease;
}

.clear-history-btn:hover {
    opacity: 0.8;
}

.history-list {
    max-height: 60vh;
    overflow-y: auto;
    padding: 0.5rem;
}

.history-item {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    margin-bottom: 0.5rem;
    background: var(--button-bg);
    border: 1px solid var(--button-border);
    border-radius: 6px;
    transition: all 0.3s ease;
    align-items: center;
}

.history-item:hover {
    animation: char-pulse 1.5s infinite;
}

.history-kannada {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
    text-align: center;
}

.history-transliteration {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 1rem;
    color: var(--highlight-color);
    background: var(--bg-color);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    border: 1px solid var(--button-border);
    text-align: center;
}

.history-meaning {
    font-size: 1rem;
    color: var(--text-color);
    text-align: center;
}

.no-history {
    text-align: center;
    padding: 2rem;
    color: var(--text-color);
    opacity: 0.6;
    font-style: italic;
}

@media (max-width: 768px) {
    .history-content {
        max-width: 95%;
        max-height: 85vh;
    }

    .history-stats {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .history-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        text-align: center;
    }

    .history-kannada {
        font-size: 1.3rem;
    }

    .history-transliteration {
        font-size: 0.9rem;
    }

    .history-meaning {
        font-size: 0.9rem;
    }
}