/* ========================================
   GAME STYLES - 拼字乐 (Pīn Zì Lè)
   ======================================== */

/* ===== GAME CONTAINER ===== */
.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ===== CONTROLS ===== */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.stimulus-selector {
    display: flex;
    gap: 8px;
}

.stimulus-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.stimulus-btn.active {
    border-color: #3498db;
    background: #e8f4fe;
    color: #3498db;
}

.stimulus-btn:hover {
    border-color: #3498db;
}

.game-stats {
    display: flex;
    gap: 20px;
    font-weight: bold;
    font-size: 0.95em;
}

/* ===== ITEMS CONTAINER ===== */
.items-container {
    background: white;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    max-height: 500px;
    overflow-y: auto;
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===== ITEM ROW ===== */
.item-row {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: white;
    overflow: hidden;
}

.item-row:hover {
    border-color: #ced4da;
}

.item-row.completed {
    background: #f0fff4;
    border-color: #2ecc71;
    opacity: 0.85;
}

.item-row.drawing {
    border-color: #3498db;
    box-shadow: 0 2px 12px rgba(52, 152, 219, 0.2);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    gap: 10px;
}

.item-prompt {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
}

.prompt-text {
    color: #2c3e50;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ===== CHARACTER DISPLAY ===== */
.character-display {
    display: inline-block;
    min-width: 40px;
    min-height: 40px;
    padding: 4px 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 1.4em;
    font-weight: bold;
    background: #f8f9fa;
    color: #2c3e50;
    transition: all 0.3s ease;
}

.item-row.completed .character-display {
    border-color: #2ecc71;
    background: #f0fff4;
    color: #27ae60;
}

/* ===== COMPLETED DETAILS ===== */
.completed-details {
    padding: 12px 16px;
    border-top: 2px solid #2ecc71;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.detail-row {
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-label {
    font-weight: 600;
    color: #495057;
    min-width: 70px;
}

.detail-value {
    color: #2c3e50;
}

.character-large {
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
}

/* ===== DRAWING CONTENT ===== */
.drawing-content {
    padding: 15px;
    background: #f8f9fa;
    border-top: 2px solid #3498db;
}

.drawing-prompt {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.drawing-canvas-wrapper {
    display: flex;
    justify-content: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 2px solid #ddd;
}

.drawing-canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
}

.drawing-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
}

.clear-btn {
    padding: 8px 20px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: #c0392b;
}

.submit-btn {
    padding: 8px 20px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover {
    background: #27ae60;
}

.drawing-hint {
    text-align: center;
    margin-top: 10px;
    color: #7f8c8d;
    font-size: 0.9em;
}

.drawing-indicator {
    font-size: 0.8em;
    color: #3498db;
    animation: pulse 1s ease-in-out infinite;
}
/* ==========================================
   RELOAD BUTTON
   ========================================== */

.reload-btn {
    display: block;
    margin: 10px auto;
    padding: 8px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.reload-btn:hover {
    background: #2980b9;
}

.reload-btn .icon {
    margin-right: 6px;
}

/* ==========================================
   DRAWING AREA - CENTERING FIX (ADD THIS)
   ========================================== */

/* The wrapper - centers the drawing area */
.drawing-area-wrapper {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    min-height: 320px !important;
    padding: 10px 0 !important;
    box-sizing: border-box !important;
}

/* The drawing area itself */
.drawing-area {
    flex-shrink: 0 !important;
    margin: 0 auto !important;
    position: relative !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

/* The target div inside */
#characters-target,
#combinations-target,
#sentences-target {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    height: 100% !important;
}

/* The SVG inside - fits the container */
#characters-target svg,
#combinations-target svg,
#sentences-target svg {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* Small screens - scale down */
@media (max-width: 420px) {
    .drawing-area-wrapper {
        min-height: 280px !important;
        padding: 5px 0 !important;
    }
    
    .drawing-area {
        transform: scale(0.85) !important;
        transform-origin: center center !important;
    }
}

/* Very small screens */
@media (max-width: 360px) {
    .drawing-area-wrapper {
        min-height: 240px !important;
    }
    
    .drawing-area {
        transform: scale(0.7) !important;
        transform-origin: center center !important;
    }
}

/* ===== SQUARE DRAWING AREA ===== */

.hanzi-writer-container {
    position: relative !important;
    width: 200px !important;
    height: 200px !important;
    display: inline-block !important;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: white;
    overflow: hidden;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.hanzi-writer-container canvas {
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

.mizige-grid {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    pointer-events: none !important;
    z-index: 5 !important;
    width: 100% !important;
    height: 100% !important;
}

.mizige-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 60px;
    color: #ddd;
    pointer-events: none;
    z-index: 2;
    font-weight: bold;
}

.hanzi-writer-container.active {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

.hanzi-writer-container.completed {
    border-color: #2ecc71;
    background: #f0fff4;
}

/* ===== AUDIO BUTTONS ===== */
.audio-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.audio-play-btn {
    padding: 8px 16px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.audio-play-btn:hover {
    background: #219a52;
    transform: scale(1.05);
}

.audio-example-btn {
    padding: 4px 12px;
    background: #8e44ad;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.audio-example-btn:hover {
    background: #7d3c98;
    transform: scale(1.05);
}

/* ===== HINT BUTTONS - SHOW PINYIN, NOT CHARACTERS ===== */

.pinyin-with-hints {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    width: 100%;
}

.hint-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.hint-btn {
    padding: 4px 12px;
    background: #8e44ad;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.hint-btn:hover {
    background: #7d3c98;
    transform: scale(1.05);
}

.hint-btn.pinyin-hint {
    background: #6c5ce7;
}

.hint-btn.pinyin-hint:hover {
    background: #5a4bd1;
}

/* Audio buttons - show pinyin, NOT characters */
.audio-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.audio-example-btn {
    padding: 4px 12px;
    background: #e17055;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.audio-example-btn:hover {
    background: #d63031;
    transform: scale(1.05);
}

/* ===== AUDIO PROMPT - MAIN + EXAMPLE BUTTONS ===== */

.audio-prompt {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    width: 100%;
}

/* Main character play button - BLUE */
.audio-main-buttons {
    display: flex;
    align-items: center;
}

.audio-play-btn-main {
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.audio-play-btn-main:hover {
    background: #2980b9;
    transform: scale(1.05);
}

.audio-play-btn-main:active {
    transform: scale(0.95);
}

/* Example play buttons - GREEN */
.audio-example-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.audio-example-btn-green {
    padding: 6px 14px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.audio-example-btn-green:hover {
    background: #219a52;
    transform: scale(1.05);
}

.audio-example-btn-green:active {
    transform: scale(0.95);
}

/* Label separator */
.audio-prompt-label {
    font-weight: 600;
    color: #7f8c8d;
    font-size: 0.85em;
    margin-right: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .audio-prompt {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .audio-main-buttons {
        justify-content: center;
    }
    
    .audio-example-buttons {
        justify-content: center;
    }
    
    .audio-play-btn-main,
    .audio-example-btn-green {
        width: 100%;
        text-align: center;
    }
}

/* ===== EDIT BUTTON ===== */
.edit-btn {
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
}

.edit-btn:hover:not(:disabled) {
    background: #2980b9;
    transform: scale(1.05);
}

.edit-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===== STATUS INDICATORS ===== */
.status-box {
    display: inline-block;
    min-width: 28px;
    padding: 2px 8px;
    text-align: center;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 0.8em;
    background: white;
}

.char-status.drawn {
    border-color: #2ecc71;
    background: #f0fff4;
    color: #2ecc71;
}

.check-mark {
    font-size: 1.2em;
    color: #2ecc71;
}

/* ===== COMPLETION SCREEN ===== */
.completion-screen {
    text-align: center;
    padding: 40px 20px;
}

.completion-screen .score {
    font-size: 3em;
    color: #2ecc71;
    font-weight: bold;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* ===== FEEDBACK ===== */
.feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3em;
    z-index: 1000;
    padding: 30px 50px;
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    animation: fadeOut 1s ease-out forwards;
}

.feedback.correct {
    background: rgba(46, 204, 113, 0.9);
}

.feedback.incorrect {
    background: rgba(231, 76, 60, 0.9);
}

/* ===== CHARACTER FEEDBACK ===== */
.character-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    display: none;
}

.feedback-content {
    padding: 30px;
    text-align: center;
}

.feedback-content.success {
    border-top: 4px solid #2ecc71;
}

.feedback-content.warning {
    border-top: 4px solid #f39c12;
}

.feedback-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.feedback-icon {
    font-size: 2em;
}

.feedback-title {
    font-size: 1.5em;
    font-weight: bold;
}

.feedback-character {
    font-size: 4em;
    font-weight: bold;
    margin: 15px 0;
    color: #2c3e50;
}

.feedback-details {
    text-align: left;
    padding: 10px 0;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    margin: 10px 0;
}

.feedback-details div {
    padding: 4px 0;
}

.feedback-mistakes {
    color: #e74c3c;
    font-weight: 500;
}

.feedback-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 10px 0;
}

.example-tag {
    background: #e9ecef;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.9em;
    color: #495057;
}

.feedback-continue {
    margin-top: 15px;
    padding: 10px 30px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.feedback-continue:hover {
    background: #2980b9;
    transform: scale(1.05);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .game-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stimulus-selector {
        justify-content: center;
    }
    
    .game-stats {
        justify-content: center;
    }
    
    .item-header {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    
    .item-actions {
        justify-content: space-between;
    }
    
    .character-feedback {
        width: 95%;
        max-width: 400px;
    }
    
    .feedback-character {
        font-size: 3em;
    }
    
    .feedback-content {
        padding: 20px;
    }
    
    .completed-details {
        padding: 10px;
    }
    
    .detail-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    
    .drawing-canvas-wrapper canvas {
        max-width: 100%;
        height: auto;
    }
    
    .audio-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .audio-example-btn {
        text-align: center;
    }
}