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

:root {
    --bg-primary: #0f0f11;
    --bg-secondary: #1a1a1f;
    --bg-tertiary: #242429;
    --accent: #10b981;
    --accent-hover: #34d399;
    --text-primary: #e8e8ed;
    --text-secondary: #9898a0;
    --text-muted: #6b6b73;
    --border: #2a2a30;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
}

body {
    font-family: 'Inter', 'Noto Sans SC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

/* Header */
.header {
    background: rgba(15, 15, 17, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top, 20px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.back-btn:active {
    background: var(--accent);
    color: white;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
}

/* Stats Banner */
.stats-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 0 0 24px 24px;
    padding: 24px 20px;
    padding-top: 20px;
    margin: -1px 0 0;
    position: relative;
    overflow: hidden;
}

.stats-banner::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.stats-banner::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -10%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
    border-radius: 50%;
}

.stats-content {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
}

.stats-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.stats-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

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

.stats-item {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px 14px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.stats-num {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.stats-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
}

/* Category List */
.category-list {
    padding: 20px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px));
    max-width: 900px;
    margin: 0 auto;
}

.category-group {
    margin-bottom: 16px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.category-header:active {
    background: var(--bg-tertiary);
    transform: scale(0.99);
}

.category-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.category-info {
    flex: 1;
    min-width: 0;
}

.category-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.category-count {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.category-arrow {
    color: var(--text-muted);
    transition: transform 0.3s;
    flex-shrink: 0;
}

.category-arrow.open {
    transform: rotate(90deg);
}

/* Sub Category List */
.sub-category-list {
    margin-top: 8px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.sub-category-list.open {
    max-height: 2000px;
    opacity: 1;
}

.sub-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    padding: 4px 0 8px;
}

.sub-category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.sub-category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
}

.sub-category-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    opacity: 0;
    transform: scaleX(0);
    transition: opacity 0.2s, transform 0.2s;
    background: var(--card-color, linear-gradient(90deg, #6366f1, #8b5cf6));
}

.sub-category-card:hover::after,
.sub-category-card:active::after {
    opacity: 1;
    transform: scaleX(1);
}

.sub-category-card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.sub-category-card:active {
    transform: scale(0.97);
}

.sub-category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.sub-category-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.sub-category-count {
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 100px;
    font-weight: 700;
    color: white !important;
    background: rgba(99, 102, 241, 0.8) !important;
}

.sub-category-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Mode Selector Modal */
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-sheet {
    background: var(--bg-secondary);
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 500px;
    padding: 24px 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 20px));
    animation: slideUp 0.3s ease;
}

.modal-header {
    text-align: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.mode-btn {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 16px 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    color: white;
    transition: all 0.2s;
}

.mode-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.mode-btn-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.mode-btn-text {
    flex: 1;
    text-align: left;
}

.mode-btn-label {
    font-size: 16px;
    font-weight: 600;
}

.mode-btn-desc {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 2px;
}

.mode-btn-practice {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.mode-btn-match {
    background: linear-gradient(135deg, #22c55e, #10b981);
}

.mode-btn-sentence {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.modal-cancel {
    width: 100%;
    margin-top: 12px;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .sub-category-grid {
        grid-template-columns: 1fr;
    }
}
