:root {
            --bg-color: #fbfbfd;
            --text-color: #1d1d1f;
            --nav-bg: rgba(255, 255, 255, 0.8);
            --accent-color: #0066cc;
            --btn-primary-bg: #0071e3;
            --btn-secondary-bg: #e8e8ed;
            --danger-color: #ff3b30;
            --success-color: #34c759;
            --card-bg: #ffffff;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: var(--bg-color);
            color: var(--text-color);
            line-height: 1.5;
            padding-bottom: 50px;
            touch-action: manipulation; 
        }

        header {
            position: sticky;
            top: 0;
            width: 100%;
            background-color: var(--nav-bg);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-bottom: 1px solid rgba(0,0,0,0.1);
            z-index: 1000;
        }

        nav {
            max-width: 980px;
            margin: 0 auto;
            display: flex;
            justify-content: center;
            padding: 0 10px;
            overflow-x: auto;
        }

        nav button {
            background: none;
            border: none;
            color: #333;
            font-size: 14px;
            padding: 16px 20px;
            cursor: pointer;
            transition: color 0.3s ease;
            font-weight: 500;
            white-space: nowrap;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
        }

        nav button:hover { color: var(--accent-color); }
        nav button.active { color: var(--accent-color); }

        main {
            max-width: 800px;
            margin: 40px auto;
            text-align: center;
            padding: 20px;
            min-height: 60vh;
        }

        body.is-anki-page main {
            max-width: 1080px;
        }

        .page-content { display: none; animation: fadeIn 0.5s ease; }
        .page-content.active { display: block; }

        [hidden] { display: none !important; }

        @keyframes fadeIn {
            from { opacity: 0; }
            to { opacity: 1; }
        }

        h1 { font-size: 40px; font-weight: 700; margin-bottom: 10px; color: #1d1d1f; }
        h2 { font-size: 28px; font-weight: 600; margin-bottom: 20px; }
        p { font-size: 18px; color: #86868b; }

        .btn {
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 980px;
            font-size: 15px;
            font-weight: 500;
            transition: all 0.1s ease;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            border: none;
            margin: 5px;
            touch-action: manipulation;
            -webkit-tap-highlight-color: transparent;
            user-select: none;
            -webkit-user-select: none;
        }

        .btn:active {
            transform: scale(0.96);
        }

        .btn-primary { background-color: var(--btn-primary-bg); color: white; }
        
        @media (hover: hover) {
            .btn-primary:hover { transform: scale(1.02); box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3); }
            .btn-secondary:hover { background-color: #d2d2d7; transform: scale(1.02); }
            .btn-danger:hover { background-color: #d63229; }
            .btn-outline:hover { border-color: #000; color: #000; }
            .app-card:hover { transform: translateY(-5px); box-shadow: 0 12px 30px rgba(0,0,0,0.1); }
            .contact-card:hover { transform: translateY(-5px); box-shadow: 0 12px 30px rgba(0,0,0,0.1); }
        }

        .btn-secondary { background-color: var(--btn-secondary-bg); color: var(--text-color); }
        .btn-danger { background-color: var(--danger-color); color: white; }
        .btn-outline { background: transparent; border: 1px solid #d2d2d7; color: #86868b; }
        
input[type="text"] {
    padding: 12px 16px;
    margin: 10px 0;
    border: 1px solid #d2d2d7;
            border-radius: 12px;
            font-size: 16px;
            width: 100%;
            box-sizing: border-box;
            background-color: rgba(255,255,255,0.8);
            transition: border-color 0.2s;
}
input[type="text"]:focus { outline: none; border-color: var(--accent-color); }

input[type="search"],
select {
    font: inherit;
}

        .game-logo {
            width: 150px; height: 150px;
            background-color: #eee; border-radius: 28px;
            margin: 0 auto 30px auto; display: flex;
            align-items: center; justify-content: center;
            box-shadow: 0 10px 20px rgba(0,0,0,0.1); object-fit: cover;
        }

        .apps-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
            gap: 20px;
            margin-top: 40px;
        }

        .app-card {
            background: white;
            border-radius: 20px;
            padding: 20px;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 10px rgba(0,0,0,0.05);
            display: flex;
            flex-direction: column;
            align-items: center;
            -webkit-tap-highlight-color: transparent; 
        }

        .app-icon { font-size: 40px; margin-bottom: 10px; }
        .app-title { font-weight: 600; font-size: 16px; color: #1d1d1f; }
        .app-desc { font-size: 12px; color: #86868b; margin-top: 5px; }

        .mc-container {
            max-width: 600px;
            margin: 0 auto;
            background: white;
            border-radius: 24px;
            padding: 30px;
            box-shadow: 0 10px 40px rgba(0,0,0,0.08);
            text-align: left;
        }

        .mc-panel { display: none; flex-direction: column; }
        .mc-panel.active { display: flex; }

        .exam-list-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 16px;
            border-bottom: 1px solid #f0f0f0;
            transition: background 0.2s;
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
            user-select: none; 
        }
        .exam-list-item:active { background-color: #f5f5f7; }
        
        .exam-list-item:last-child { border-bottom: none; }
        
        .timer-display {
            font-family: "SF Mono", "Menlo", monospace;
            font-size: 24px;
            color: #1d1d1f;
            background: #f5f5f7;
            padding: 8px 16px;
            border-radius: 8px;
            margin-bottom: 20px;
            text-align: center;
            display: inline-block;
            user-select: none;
        }

        .big-letter {
            font-size: 120px;
            font-weight: 700;
            color: var(--accent-color);
            line-height: 1;
            margin: 20px 0;
            text-align: center;
            user-select: none;
        }

        .question-meta {
            text-align: center;
            color: #86868b;
            font-size: 18px;
            margin-bottom: 10px;
        }

        .contact-container { display: flex; justify-content: center; margin-top: 40px; }
        .contact-card {
            background-color: #ffffff;
            border: 1px solid rgba(0,0,0,0.05);
            border-radius: 20px; padding: 40px 60px;
            text-decoration: none; color: var(--text-color);
            transition: all 0.3s;
            box-shadow: 0 4px 20px rgba(0,0,0,0.05);
            display: flex; flex-direction: column; align-items: center; gap: 15px;
            -webkit-tap-highlight-color: transparent;
        }
        .mail-icon { width: 48px; height: 48px; stroke: var(--accent-color); fill: none; stroke-width: 1.5; }

#app-anki.active {
    width: 100%;
    margin: 0 auto;
}

.anki-shell {
    max-width: 1040px;
    margin: 0 auto;
    text-align: left;
}

.anki-hero {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    margin-bottom: 22px;
}

.anki-hero h1 {
    margin: 0 0 8px;
    font-size: 38px;
    letter-spacing: 0;
}

.anki-hero p {
    margin: 0;
    max-width: 600px;
    color: #6e6e73;
    font-size: 16px;
    line-height: 1.65;
}

.anki-eyebrow {
    margin: 0 0 6px !important;
    color: var(--accent-color) !important;
    font-size: 13px !important;
    font-weight: 800;
    letter-spacing: 0;
}

.anki-hero-actions,
.anki-form-actions,
.anki-item-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.anki-start-btn,
.anki-close-btn {
    margin: 0;
    white-space: nowrap;
}

.anki-mobile-stats-toggle,
.anki-mobile-library-toggle {
    display: none;
    margin: 0;
}

.anki-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.anki-stat {
    min-height: 118px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.04);
}

.anki-stat span,
.anki-stat small {
    color: #86868b;
    font-size: 12px;
    font-weight: 700;
}

.anki-stat strong {
    color: #1d1d1f;
    font-size: 30px;
    line-height: 1;
    overflow-wrap: anywhere;
}

.anki-limit-stat input {
    width: 92px;
    max-width: 100%;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    background: #fbfbfd;
    color: #1d1d1f;
    font-size: 24px;
    font-weight: 800;
    padding: 6px 8px;
    margin: 0;
}

.anki-workspace {
    display: grid;
    grid-template-columns: minmax(300px, 0.92fr) minmax(360px, 1.08fr);
    gap: 18px;
    align-items: start;
}

.anki-panel {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    padding: 20px;
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.05);
}

.anki-panel-header {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.anki-panel-header h2 {
    margin: 0 0 4px;
    font-size: 20px;
    letter-spacing: 0;
}

.anki-panel-header p {
    margin: 0;
    color: #86868b;
    font-size: 13px;
    line-height: 1.5;
}

.anki-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.anki-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.anki-field span {
    color: #6e6e73;
    font-size: 13px;
    font-weight: 700;
}

.anki-field input,
.anki-textarea,
.anki-import-textarea,
.anki-tool-field input,
.anki-tool-field select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d2d2d7;
    border-radius: 12px;
    background: #fbfbfd;
    color: #1d1d1f;
    font: inherit;
    font-size: 15px;
    padding: 12px;
    margin: 0;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.anki-field input:focus,
.anki-textarea:focus,
.anki-import-textarea:focus,
.anki-tool-field input:focus,
.anki-tool-field select:focus,
.anki-limit-stat input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.12);
}

.anki-field-wide {
    grid-column: 1 / -1;
}

.anki-textarea {
    min-height: 92px;
    resize: vertical;
}

.anki-form-actions {
    margin-top: 14px;
}

.anki-small-btn {
    padding: 7px 11px;
    font-size: 13px;
    margin: 0;
}

.anki-gemini-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    text-decoration: none;
}

.anki-form-message {
    min-height: 20px;
    margin-top: 10px;
    color: #6e6e73;
    font-size: 13px;
    font-weight: 700;
}

.anki-form-message.is-success {
    color: var(--success-color);
}

.anki-form-message.is-error {
    color: var(--danger-color);
}

.anki-form-message.is-muted {
    color: #86868b;
}

.anki-list-tools {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(130px, 0.42fr) auto;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.anki-tool-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.anki-tool-field span {
    color: #6e6e73;
    font-size: 12px;
    font-weight: 800;
}

.anki-tool-field input,
.anki-tool-field select {
    min-height: 40px;
    padding: 9px 11px;
    font-size: 14px;
}

.anki-tool-field select {
    cursor: pointer;
}

.anki-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 560px;
    overflow: auto;
    padding-right: 2px;
}

.anki-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 15px;
    border: 1px solid #ececf1;
    border-radius: 14px;
    background: #fbfbfd;
}

.anki-item-main {
    min-width: 0;
}

.anki-item-topline {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 7px;
}

.anki-next-review {
    color: #86868b;
    font-size: 12px;
    font-weight: 700;
}

.anki-item h3 {
    margin: 0 0 4px;
    color: #1d1d1f;
    font-size: 20px;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.anki-meaning,
.anki-sentence-preview,
.anki-hint-preview {
    margin: 0;
    color: #6e6e73;
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.anki-meaning {
    color: #1d1d1f;
    font-size: 15px;
    font-weight: 700;
}

.anki-chip {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 800;
}

.anki-chip-new {
    background: #eaf2ff;
    color: #0b63d6;
}

.anki-chip-due {
    background: #fff1f0;
    color: #d70015;
}

.anki-chip-learning {
    background: #fff7e6;
    color: #a15c00;
}

.anki-chip-relearning {
    background: #fff1f0;
    color: #b42318;
}

.anki-chip-mastered {
    background: #eaf8ed;
    color: #1f7a34;
}

.anki-item-actions {
    justify-content: flex-end;
}

.anki-item-actions .btn {
    margin: 0;
    padding: 7px 10px;
    font-size: 13px;
    border-radius: 10px;
}

.anki-empty-card {
    border: 1px dashed #d2d2d7;
    border-radius: 14px;
    padding: 30px 18px;
    color: #86868b;
    text-align: center;
    background: #fbfbfd;
}

.anki-empty-card h3 {
    margin: 0 0 8px;
    color: #1d1d1f;
}

.anki-empty-card p {
    margin: 0;
    color: #86868b;
}

.anki-import-panel {
    margin-top: 18px;
}

.anki-import-textarea {
    min-height: 118px;
    resize: vertical;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
}

@media (max-width: 860px) {
    #app-anki.active {
        width: min(100%, calc(100vw - 28px));
    }

    .anki-hero {
        flex-direction: column;
    }

    .anki-hero-actions {
        width: 100%;
    }

    .anki-hero-actions .btn {
        flex: 1 1 160px;
    }

    .anki-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .anki-workspace,
    .anki-form-grid,
    .anki-item,
    .anki-list-tools {
        grid-template-columns: 1fr;
    }

    .anki-item-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 520px) {
    nav {
        justify-content: flex-start;
        scrollbar-width: none;
    }

    nav::-webkit-scrollbar {
        display: none;
    }

    main {
        padding: 14px;
    }

    .anki-hero h1 {
        font-size: 32px;
    }

    .anki-mobile-stats-toggle {
        display: inline-flex;
        align-self: flex-start;
        order: -1;
        padding: 7px 12px;
        font-size: 13px;
    }

    .anki-stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .anki-stat {
        min-height: 96px;
        padding: 10px;
        border-radius: 14px;
    }

    .anki-stat strong {
        font-size: 24px;
    }

    .anki-stat span,
    .anki-stat small {
        font-size: 11px;
        line-height: 1.25;
    }

    .anki-limit-stat input {
        width: 100%;
        font-size: 20px;
        padding: 5px 6px;
    }

    .anki-stat-secondary {
        display: none;
    }

    body.show-anki-extra-stats .anki-stat-secondary {
        display: flex;
    }

    .anki-mobile-library-toggle {
        display: inline-flex;
        width: 100%;
        margin: 0 0 12px;
    }

    .anki-list-panel {
        display: none;
    }

    body.show-anki-library .anki-list-panel {
        display: block;
    }

    .anki-panel {
        padding: 16px;
    }
}
