/* 
  ====================================================================
    Calculatorz Typing Academy - CSS Design System
  ====================================================================
*/

/* Google Fonts & Kruti Dev Webfont CDN */
@import url('https://fonts.googleapis.com/css2?family=Alex+Brush&family=Baloo+2:wght@500;700;800&family=Hind:wght@400;500;600;700&family=Noto+Sans+Devanagari:wght@400;500;700&display=swap');
@import url('https://fonts.cdnfonts.com/css/kruti-dev-010');

/* CSS variables for Theme Control */
:root {
    /* Colors - HSL based */
    --primary-h: 203;  /* Light Blue / Cyan */
    --primary-s: 90%;
    --primary-l: 40%; /* Darker blue for default light theme contrast */
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-light: hsl(var(--primary-h), var(--primary-s), 50%);
    
    --secondary-h: 203; 
    --secondary-s: 85%;
    --secondary-l: 20%;
    --secondary: hsl(var(--secondary-h), var(--secondary-s), var(--secondary-l));
    
    --green: #2ecc71;
    --red: #ff4757;
    --gold: hsl(195, 90%, 35%); /* Darker blue/cyan accent for legibility in default light theme */
    --navy: #0F172A; /* Slate navy */
    --glass: rgba(0, 0, 0, 0.02);

    /* Light Mode Defaults */
    --bg-app: #F5F7FA;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-input: #F1F3F6;
    --border: #DCE1E7;
    --text-main: #2D3748;
    --text-muted: #718096;
    --shadow: rgba(0, 0, 0, 0.06);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-app: #0B0F19; /* Premium slate dark blue */
    --bg-sidebar: #111827;
    --bg-card: #1E293B;
    --bg-input: #0F172A;
    --border: #334155;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --shadow: rgba(0, 0, 0, 0.4);
    --glass: rgba(255, 255, 255, 0.03);
    --primary: hsl(203, 90%, 52%);
    --primary-light: hsl(203, 90%, 65%);
    --gold: #00D2FF; /* Light blue accent for dark mode */
}

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

body {
    font-family: 'Hind', 'Noto Sans Devanagari', sans-serif;
    background: var(--bg-app);
    color: var(--text-main);
    transition: background var(--transition), color var(--transition);
    overflow-x: hidden;
    line-height: 1.5;
}

h1, h2, h3, h4 {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Layout Framework */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.app-sidebar {
    width: 270px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease, background var(--transition);
    z-index: 100;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 107, 0, 0.3);
}

.sidebar-title {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.2;
}

.sidebar-title span {
    color: var(--primary);
    display: block;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 15px 0;
}

.nav-section-title {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    font-weight: 700;
    padding: 15px 20px 5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--transition);
    color: var(--text-main);
    user-select: none;
}

.nav-item:hover {
    background: var(--glass);
    border-left-color: var(--primary-light);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 107, 0, 0.1), transparent);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}

.nav-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Theme Toggle */
.theme-toggle-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

/* Top Navbar */
.app-header {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    padding: 15px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    transition: background var(--transition);
}

.mob-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-main);
    font-size: 1.3rem;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    cursor: pointer;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 15px;
}

.streak-counter {
    background: linear-gradient(135deg, rgba(255, 107, 0, 0.15), rgba(255, 215, 0, 0.05));
    border: 1px solid var(--primary);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-light);
    display: flex;
    align-items: center;
    gap: 6px;
}

.main-link-btn {
    font-size: 0.8rem;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-weight: 600;
    transition: var(--transition);
}

.main-link-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* Content Container */
.app-content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

/* View Pages */
.view-page {
    display: none;
    max-width: 900px;
    margin: 0 auto;
    animation: slideUp 0.35s ease-out;
}

.view-page.active {
    display: block;
}

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

/* Page Headers */
.page-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.page-title span {
    color: var(--primary);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-bottom: 25px;
}

/* Cards & Glassmorphism */
.academy-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px var(--shadow);
    transition: border-color var(--transition), background var(--transition);
}

.academy-card h2 {
    color: var(--primary-light);
    font-size: 1.3rem;
    margin-bottom: 12px;
}

/* Form Controls */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
}

.form-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--text-muted);
}

.form-select, .form-input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

.form-select:focus, .form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 0, 0.15);
}

/* Controls row */
.controls-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: flex-end;
}

/* Timer Group selector */
.timer-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.timer-pill {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.timer-pill:hover, .timer-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    text-align: center;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 107, 0, 0.2);
}

.btn-secondary {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-gold {
    background: linear-gradient(135deg, #B8860B, var(--gold));
    color: #000;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.15);
}

.btn-success {
    background: linear-gradient(135deg, #138808, var(--green));
    color: #fff;
}

.btn-wa {
    background: #128C7E;
    color: #fff;
}

/* Hero Landing Section */
.hero-card {
    background: linear-gradient(135deg, #E2E8F0, #F7FAFC, #EDF2F7);
    border-radius: var(--radius-lg);
    padding: 40px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 25px;
}

[data-theme="dark"] .hero-card {
    background: linear-gradient(135deg, #0e0e30, #22123b, #090915);
}

.hero-card h1 {
    font-size: 2.3rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-card p {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 25px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Stats dashboard grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    text-align: center;
    transition: var(--transition);
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    font-family: 'Baloo 2', cursive;
    color: var(--primary-light);
    line-height: 1.1;
}

.stat-label {
    font-size: 0.76rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Typing Interface Area */
.typing-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px var(--shadow);
}

.typing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 15px;
}

.live-metrics {
    display: flex;
    gap: 20px;
}

.metric-item {
    text-align: center;
}

.metric-val {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: 'Baloo 2', cursive;
    color: var(--primary);
    line-height: 1;
}

.metric-lbl {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.live-timer {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: 'Baloo 2', cursive;
    color: var(--gold);
    line-height: 1;
}

.live-timer.danger {
    color: var(--red);
    animation: timerAlert 0.5s infinite alternate;
}

@keyframes timerAlert {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0.5; transform: scale(1.05); }
}

/* Typing Progress Bar */
.progress-container {
    height: 5px;
    background: var(--bg-input);
    border-radius: 3px;
    margin-bottom: 15px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--gold));
    width: 100%;
    transition: width 0.2s linear;
}

/* Text Passage Display Area */
.passage-display {
    font-size: 1.35rem;
    line-height: 1.9;
    letter-spacing: 0.5px;
    padding: 20px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    min-height: 120px;
    max-height: 250px;
    overflow-y: auto;
    user-select: none;
    word-break: break-word;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: border-color var(--transition);
}

.passage-display:focus-within {
    border-color: var(--primary);
}

/* Character Spans */
.char-span {
    border-radius: 2px;
    transition: background 0.05s;
    font-family: inherit;
}

.char-span.correct {
    color: var(--green);
    background: rgba(46, 204, 113, 0.08);
}

.char-span.wrong {
    color: var(--red);
    background: rgba(255, 71, 87, 0.12);
    text-decoration: underline wavy;
}

.char-span.current {
    background: var(--primary);
    color: #000 !important;
    border-radius: 3px;
    animation: cursorPulse 0.8s infinite;
}

@keyframes cursorPulse {
    0%, 100% { box-shadow: 0 0 0 1px var(--primary); }
    50% { box-shadow: 0 0 0 3px var(--primary-light); }
}

.char-span.pending {
    opacity: 0.6;
}

/* Input Area */
.typing-input {
    width: 100%;
    background: var(--bg-input);
    border: 2px solid var(--border);
    color: var(--text-main);
    padding: 15px;
    border-radius: var(--radius-md);
    font-size: 1.15rem;
    font-family: inherit;
    outline: none;
    resize: none;
    transition: var(--transition);
}

.typing-input:focus {
    border-color: var(--primary);
}

.typing-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-row {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.actions-left, .actions-right {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* font-family rules for Hindi */
.font-mangal {
    font-family: 'Noto Sans Devanagari', 'Hind', sans-serif !important;
}

.font-krutidev {
    font-family: 'Kruti Dev 010', sans-serif !important;
    font-size: 1.55rem !important; /* Krutidev needs slightly larger font size */
    letter-spacing: 0.8px !important;
}

/* Result Overlay modal */
.overlay-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.overlay-modal.show {
    display: flex;
}

.result-card {
    background: linear-gradient(135deg, var(--bg-sidebar), var(--bg-card));
    border: 2px solid var(--primary);
    border-radius: 22px;
    padding: 30px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow-y: auto;
}

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

.result-emoji {
    font-size: 3.2rem;
    margin-bottom: 10px;
    animation: bounce 1.2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.result-title {
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.result-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.result-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.result-stat-item {
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 15px 10px;
}

.result-stat-val {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: 'Baloo 2', cursive;
    background: linear-gradient(135deg, var(--primary), var(--gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.result-stat-lbl {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-top: 3px;
}

.performance-badge {
    padding: 10px 15px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 20px;
}

.perf-legend { background: rgba(255, 215, 0, 0.1); border: 1px solid var(--gold); color: var(--gold); }
.perf-gold { background: rgba(46, 204, 113, 0.1); border: 1px solid var(--green); color: var(--green); }
.perf-regular { background: rgba(255, 107, 0, 0.1); border: 1px solid var(--primary); color: var(--primary); }
.perf-practice { background: rgba(255, 71, 87, 0.1); border: 1px solid var(--red); color: var(--red); }

.result-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Finger guide hand cards */
.hands-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 15px;
}

.hand-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    flex: 1;
    min-width: 250px;
    max-width: 320px;
    text-align: center;
}

.hand-card h4 {
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.finger-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finger-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-app);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    border: 1px solid var(--border);
}

.finger-indicator {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

/* Virtual Keyboard Styling */
.keyboard-container {
    padding: 10px;
    overflow-x: auto;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-bottom: 5px;
}

.kb-key {
    min-width: 38px;
    height: 38px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    transition: var(--transition);
    color: var(--text-main);
    flex-shrink: 0;
    user-select: none;
}

.kb-key.zone-lh { border-color: rgba(74, 158, 255, 0.4); background: rgba(74, 158, 255, 0.04); }
.kb-key.zone-rh { border-color: rgba(255, 74, 158, 0.4); background: rgba(255, 74, 158, 0.04); }
.kb-key.key-home { border-color: var(--gold); background: rgba(255, 215, 0, 0.08); color: var(--gold); }
.kb-key.key-wide { min-width: 58px; }
.kb-key.key-space { min-width: 170px; }
.kb-key.pressed {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: #000 !important;
    transform: scale(0.92);
}
.kb-key.wrong-key-highlight {
    background: var(--red) !important;
    border-color: var(--red) !important;
    color: #fff !important;
    animation: keyShake 0.15s 2;
}

@keyframes keyShake {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-3px); }
}

.keyboard-legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.leg-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.leg-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid var(--border);
}

/* Heatmap Grid */
.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
    gap: 8px;
    margin-top: 15px;
}

.heat-cell {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 5px;
    text-align: center;
    font-weight: 700;
    transition: var(--transition);
}

.heat-cell .letter {
    font-size: 0.95rem;
    color: var(--text-main);
}

.heat-cell .count {
    font-size: 0.65rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Certificate Generator UI */
.cert-preview-card {
    background: var(--bg-sidebar);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#cert-canvas-preview {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 15px rgba(0,0,0,0.25);
    display: none;
}

/* Leaderboard Ranking Table */
.ranking-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    text-align: left;
}

.ranking-table th {
    background: var(--bg-input);
    padding: 12px 16px;
    color: #000000 !important; /* Pure black text by default for light theme */
    font-weight: 800 !important;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

[data-theme="dark"] .ranking-table th {
    color: var(--text-main) !important; /* Off-white text for dark theme */
    font-weight: 700 !important;
}

.ranking-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.ranking-table tr:last-child td {
    border-bottom: none;
}

.ranking-table tr:hover td {
    background: var(--glass);
}

.rank-badge {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.82rem;
}

.rank-1 { background: linear-gradient(135deg, var(--gold), #ffb300); color: #000; }
.rank-2 { background: linear-gradient(135deg, #e2e8f0, #cbd5e1); color: #000; }
.rank-3 { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }

.rank-bar-wrap {
    height: 5px;
    background: var(--bg-input);
    border-radius: 10px;
    margin-top: 5px;
    overflow: hidden;
}

.rank-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--gold));
}

/* Battle Arena Layout */
.battle-setup {
    text-align: center;
    padding: 30px;
}

.vs-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin: 25px 0;
    flex-wrap: wrap;
}

.player-box {
    background: var(--bg-sidebar);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    flex: 1;
    min-width: 150px;
    max-width: 220px;
    text-align: center;
    transition: var(--transition);
}

.player-box.me {
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(255,107,0,0.1);
}

.player-avatar {
    font-size: 3rem;
    margin-bottom: 8px;
}

.player-wpm {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: 'Baloo 2', cursive;
    color: var(--primary);
}

.player-progress-track {
    height: 7px;
    background: var(--bg-app);
    border-radius: 5px;
    margin-top: 10px;
    overflow: hidden;
}

.player-progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.3s ease;
}

.player-box.me .player-progress-fill {
    background: var(--primary);
}

.player-box.opponent .player-progress-fill {
    background: #ff4757;
}

.vs-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary);
    color: #000;
    font-weight: 800;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Baloo 2', cursive;
}

/* Toast Message Notifications */
.toast-msg {
    position: fixed;
    bottom: 90px;
    right: 25px;
    background: var(--bg-card);
    border-left: 4px solid var(--primary);
    color: var(--text-main);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 5px 15px rgba(0,0,0,0.25);
    z-index: 10000;
    font-size: 0.9rem;
    font-weight: 600;
    transform: translateY(15px);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
}

.toast-msg.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-msg.success { border-left-color: var(--green); }
.toast-msg.error { border-left-color: var(--red); }

/* Confetti Particle */
.confetti-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    top: -10px;
    z-index: 9999;
    animation: fall linear forwards;
    pointer-events: none;
}

@keyframes fall {
    to {
        transform: translateY(105vh) rotate(720deg);
    }
}

/* FAQ Accordions */
.faq-item {
    border-bottom: 1px solid var(--border);
    padding: 15px 0;
}

.faq-question {
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-question::after {
    content: '▼';
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.faq-item.open .faq-question::after {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 0;
}

.faq-item.open .faq-answer {
    max-height: 200px;
    margin-top: 8px;
}

/* Responsive Styles */
@media (max-width: 900px) {
    .app-sidebar {
        position: fixed;
        left: -270px;
        top: 0;
        bottom: 0;
        transition: transform 0.3s ease-in-out;
    }
    
    .app-sidebar.open {
        transform: translateX(270px);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }
    
    .mob-menu-btn {
        display: block;
    }
    
    .app-content {
        padding: 15px;
    }
    
    .app-header {
        padding: 10px 15px;
    }
    
    .live-metrics {
        gap: 12px;
    }
    
    .metric-val {
        font-size: 1.3rem;
    }
    
    .live-timer {
        font-size: 1.8rem;
    }
}

/* Paused State Blur Effect */
.passage-display.paused-blur {
    filter: blur(5px) grayscale(50%);
    pointer-events: none;
    user-select: none;
    transition: filter 0.2s ease;
}

/* UPI Donation Box Styling - Contrast-optimized for both light and dark themes */
.upi-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 700;
    transition: var(--transition);
}

.upi-label {
    color: #000000 !important; /* Bold black text by default for label in light theme */
}

[data-theme="dark"] .upi-label {
    color: var(--primary) !important; /* Cyan for label in dark theme */
}

.upi-value {
    color: #000000 !important; /* Bold black text by default for value in light theme */
    font-family: monospace;
    letter-spacing: 0.5px;
}

[data-theme="dark"] .upi-value {
    color: var(--text-main) !important; /* Off-white for value in dark theme */
}

/* Floating Theme Switcher Button - Fixed in bottom-right corner */
.floating-theme-toggle {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 4px 15px var(--shadow);
    z-index: 9999;
    transition: var(--transition);
}

.floating-theme-toggle:hover {
    border-color: var(--primary);
    transform: scale(1.1) rotate(15deg);
    background: var(--bg-input);
}

/* Mobile responsive styles for small devices */
@media (max-width: 600px) {
    .academy-card {
        padding: 15px !important;
        border-radius: var(--radius-md) !important;
    }
    
    .typing-box {
        padding: 15px !important;
        border-radius: var(--radius-md) !important;
    }
    
    .page-title {
        font-size: 1.4rem !important;
    }
    
    .page-subtitle {
        font-size: 0.82rem !important;
        margin-bottom: 15px !important;
    }
    
    .passage-display {
        font-size: 1.15rem !important;
        line-height: 1.7 !important;
        padding: 12px !important;
    }
    
    .typing-input {
        font-size: 1rem !important;
        padding: 10px !important;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .stat-card {
        padding: 10px !important;
    }
    
    .stat-value {
        font-size: 1.5rem !important;
    }
    
    .vs-container {
        gap: 15px !important;
    }
    
    .player-box {
        padding: 12px !important;
    }
    
    .floating-theme-toggle {
        bottom: 15px;
        right: 15px;
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }
    
    .toast-msg {
        bottom: 70px;
        right: 15px;
        left: 15px;
        font-size: 0.82rem;
        padding: 10px 14px;
    }
}

/* Glassmorphic Auth Modal Styles */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, rgba(11, 15, 25, 0.98), rgba(30, 41, 59, 0.98));
    backdrop-filter: blur(15px);
    z-index: 15000; /* Ensure it stays above everything */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.auth-container {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 24px;
    padding: 30px 25px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    color: #F8FAFC;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

[data-theme="light"] .auth-overlay {
    background: linear-gradient(135deg, rgba(245, 247, 252, 0.98), rgba(220, 225, 231, 0.98));
}
[data-theme="light"] .auth-container {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 40px rgba(31, 38, 135, 0.08);
    color: #1E293B;
}

.auth-logo {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 8px;
}

.auth-title {
    font-size: 1.6rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1.5px solid var(--border);
    padding-bottom: 4px;
}

.auth-tab {
    flex: 1;
    text-align: center;
    padding: 8px;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    color: var(--text-muted);
}

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

.auth-form {
    display: none;
    flex-direction: column;
    gap: 12px;
}

.auth-form.active {
    display: flex;
}

.auth-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
}

.auth-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
}

.auth-input {
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    color: var(--text-main);
    padding: 9px 12px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    outline: none;
    transition: var(--transition);
}

.auth-input:focus {
    border-color: var(--primary);
}

.auth-btn-google {
    background: #4285F4;
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 8px;
    transition: var(--transition);
    font-size: 0.9rem;
}

.auth-btn-google:hover {
    background: #357ae8;
    transform: translateY(-1px);
}

.auth-form-row {
    display: flex;
    gap: 12px;
}

.auth-form-row > .auth-form-group {
    flex: 1;
}

.auth-error {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--red);
    color: var(--red);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    display: none;
    text-align: left;
}

.auth-success {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid var(--green);
    color: var(--green);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    display: none;
    text-align: left;
}
