/* Chinese Character Practice App Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
    padding: 30px;
}

.game-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.prompt-section {
    text-align: center;
}

.prompt-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    transition: background 0.3s ease;
}

.pinyin {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 300;
}

.english {
    font-size: 1.2em;
    opacity: 0.95;
}

/* Stats Corner Button */
.stats-corner-btn {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}


.stats-corner-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.stats-icon {
    font-size: 28px;
}

/* Stats Modal */
.stats-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 200;
    animation: fadeIn 0.3s ease;
}

.stats-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.stats-modal-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.85) 100%);
    border-radius: 20px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    box-sizing: border-box;
}

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

.stats-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    font-size: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-close-btn:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: rotate(90deg);
}

.stats-modal-title {
    text-align: center;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2em;
}

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

.stat-card {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-radius: 15px;
    padding: 25px;
    text-align: center;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.2);
}

.stat-card .stat-value {
    font-size: 2.5em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
    margin-bottom: 10px;
}

.stat-card .stat-label {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    font-weight: 600;
}

/* Search Section */
.stats-search-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 2px solid rgba(102, 126, 234, 0.2);
    width: 100%;
    box-sizing: border-box;
}

.search-title {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: 1.2em;
    font-weight: 600;
}

.char-search-input {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    box-sizing: border-box;
}

.char-search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.2);
}

.char-search-input::placeholder {
    color: #999;
}

.search-results {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 10px;
    width: 100%;
    box-sizing: border-box;
}

.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 10px;
}

.search-result-item {
    padding: 15px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    position: relative;
    word-break: break-word;
    overflow: hidden;
}

.search-result-item.studied {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-left: 4px solid #667eea;
}

.search-result-item:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    transform: translateX(5px);
}

.search-result-char {
    font-size: 2em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex-shrink: 0;
    margin-right: 15px;
    min-width: 40px;
}

.search-result-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.search-result-pinyin {
    font-size: 1.2em;
    color: #333;
    font-weight: 600;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-meaning {
    font-size: 0.9em;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.search-no-results {
    text-align: center;
    padding: 20px;
    color: #999;
    font-style: italic;
}


@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.stat-value.milestone {
    animation: pulse 0.5s ease-in-out;
}

.practice-area {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.canvas-wrapper {
    display: flex;
    justify-content: center;
    gap: 30px;
    align-items: flex-start;
}

.canvas-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.canvas-area {
    position: relative;
    display: inline-block;
}

.canvas-container h3 {
    color: #666;
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.canvas-container.hidden {
    display: none;
}

#drawingCanvas {
    border: 2px solid #ddd;
    border-radius: 10px;
    cursor: crosshair;
    touch-action: none;
    background: white;
}

.clear-x-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #ffffff75;
    color: #d1d5db;
    border: none;
    font-size: 48px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    padding-bottom: 5px;
    font-weight: normal;
}

.clear-x-btn:hover {
    color: #9ca3af;
    transform: scale(1.1);
}

#strokeGif {
    width: 300px;
    height: 300px;
    border: 2px solid #ddd;
    border-radius: 10px;
    background: white;
}

.controls-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.canvas-controls {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f3f4f6;
    color: #333;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.difficulty-buttons {
    text-align: center;
    width: 100%;
    max-width: 600px;
}

.difficulty-buttons.hidden {
    display: none;
}

.difficulty-buttons p {
    margin-bottom: 15px;
    color: #666;
    font-weight: 600;
}

.difficulty-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: nowrap;
}

.difficulty-btn {
    padding: 10px 12px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    min-width: 0;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
    position: relative;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.difficulty-btn[data-difficulty="1"] {
    border-color: #ef4444;
    color: #ef4444;
}

.difficulty-btn[data-difficulty="1"]:hover {
    background: #ef4444;
    color: white;
}

.difficulty-btn[data-difficulty="2"] {
    border-color: #f97316;
    color: #f97316;
}

.difficulty-btn[data-difficulty="2"]:hover {
    background: #f97316;
    color: white;
}

.difficulty-btn[data-difficulty="3"] {
    border-color: #f59e0b;
    color: #f59e0b;
}

.difficulty-btn[data-difficulty="3"]:hover {
    background: #f59e0b;
    color: white;
}

.difficulty-btn[data-difficulty="4"] {
    border-color: #84cc16;
    color: #84cc16;
}

.difficulty-btn[data-difficulty="4"]:hover {
    background: #84cc16;
    color: white;
}

.difficulty-btn[data-difficulty="5"] {
    border-color: #10b981;
    color: #10b981;
}

.difficulty-btn[data-difficulty="5"]:hover {
    background: #10b981;
    color: white;
}

/* Hotkey hints */
.hotkey-hint {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 11px;
    margin-left: 8px;
    font-weight: normal;
}

.hotkey-number {
    display: inline-block;
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    width: 16px;
    height: 16px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    font-weight: bold;
    opacity: 0.6;
}

/* Hide hotkey hints on mobile */
@media (max-width: 768px) {
    .hotkey-hint,
    .hotkey-number {
        display: none;
    }
}

/* Debug Button */
.debug-btn {
    position: fixed;
    top: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #333;
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.debug-btn:hover {
    transform: scale(1.1);
    background: #555;
}

/* Debug Modal */
.debug-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 200;
    animation: fadeIn 0.3s ease;
}

.debug-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.debug-modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.debug-close-btn {
    background: white;
    border-radius: 25px;
    width: 40px;
    height: 40px;
    position: absolute;
    top: 35px;
    right: 30px;
    border: none;
    font-size: 30px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
}

.debug-modal-title {
    margin-bottom: 20px;
    font-size: 24px;
    color: #333;
}

.debug-section {
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.debug-section h3 {
    margin-bottom: 15px;
    color: #555;
    font-size: 18px;
}

.debug-info-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #e0e0e0;
}

.debug-info-row:last-child {
    border-bottom: none;
}

.debug-card-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
}

.debug-char {
    font-size: 36px;
    font-weight: bold;
}

.debug-char-small {
    font-size: 20px;
    font-weight: bold;
}

.debug-small {
    font-size: 12px;
    color: #666;
}

.debug-pinyin {
    color: #667eea;
    font-weight: 500;
}

.debug-upcoming-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.debug-upcoming-card:last-child {
    border-bottom: none;
}

.debug-upcoming-number {
    color: #999;
    width: 25px;
}

.debug-stats {
    margin-left: auto;
    font-size: 12px;
    color: #666;
    display: flex;
    gap: 10px;
}

.debug-due {
    background: #ff6b6b;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.debug-in {
    background: #4ecdc4;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
}

.debug-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.debug-category {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
}

.debug-category-count {
    font-size: 24px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.debug-category-label {
    font-size: 12px;
    color: #666;
}

/* Toast notification */
.toast {
    position: fixed;
    top: 30px;
    right: 30px;
    color: white;
    padding: 15px 25px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    transform: translateY(-20px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

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

/* Mobile responsiveness */
@media (max-width: 768px) {
    .canvas-wrapper {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 600px) {
    .stats-corner-btn {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
    }

    .stats-icon {
        font-size: 24px;
    }

    .stats-modal-content {
        padding: 30px 20px;
        width: 95%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .stat-card .stat-value {
        font-size: 2em;
    }
    body {
        align-items: flex-start;
        padding: 10px;
        min-height: 100vh;
    }

    .container {
        padding: 15px;
        margin-top: 0;
    }

    .pinyin {
        font-size: 2em;
    }

    .english {
        font-size: 1em;
    }


    .stat-value {
        font-size: 1.4em;
    }

    .stat-label {
        font-size: 10px;
        letter-spacing: 1px;
    }

    #drawingCanvas,
    #strokeGif {
        width: 250px;
        height: 250px;
    }

    .difficulty-btn {
        padding: 10px 4px;
        font-size: 11px;
        min-height: 44px;
        text-align: center;
    }
}