/* ========================================
   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
   ========================================== */

/* The wrapper centres whatever is inside it. */
.drawing-area-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    padding: 10px 0;
    box-sizing: border-box;
}

/* The drawing area is a positioned container. Its size is
   set by HanziHelper.createWriter() at runtime. */
.drawing-area {
    position: relative;
}

/* The Mi Zi Ge grid sits behind Hanzi Writer's SVG.
   The helper sets these styles inline too, but the CSS
   here is a fallback. */
.mizige-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* ===== 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);
}

/* ==========================================
   STROKE HINT
   ========================================== */

.stroke-hint {
    text-align: center;
    padding: 8px 12px;
    margin-top: 8px;
    background: #e8f4f8;
    border: 1px solid #bee3f8;
    border-radius: 6px;
    font-size: 13px;
    color: #2c5282;
    line-height: 1.5;
}

.stroke-hint .hint-icon {
    font-size: 16px;
    margin-right: 6px;
}

.stroke-hint .hint-text {
    font-weight: 500;
}

/* ===== 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 {
    margin: 16px auto;
    padding: 0;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    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;
    }
    
    .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;
    }
}

/* ==========================================
   CHARACTER BOXES (Combinations & Sentences)
   ========================================== */

.character-boxes-container {
    margin: 12px 0;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
}

.character-boxes-label {
    font-size: 14px;
    color: #495057;
    margin-bottom: 10px;
    font-weight: 500;
}

.character-boxes-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 4px 0;
}

.character-box {
    position: relative;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ced4da;
    border-radius: 8px;
    background: #ffffff;
    font-size: 32px;
    color: #2c3e50;
    cursor: default;
    transition: all 0.2s ease;
    user-select: none;
}

.character-box.clickable {
    cursor: pointer;
}

.character-box.clickable:hover {
    border-color: #3498db;
    background: #f0f8ff;
    transform: translateY(-2px);
}

.character-box.current {
    border-color: #3498db;
    background: #e8f4fe;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.character-box.drawn {
    border-color: #2ecc71;
    background: #f0fff4;
    color: #27ae60;
}

.character-box-char {
    font-weight: 500;
}

.draw-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 16px;
    background: #ffffff;
    border-radius: 50%;
    padding: 2px 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.character-boxes-progress {
    margin-top: 10px;
    font-size: 13px;
    color: #7f8c8d;
}

.completed-char {
    display: inline-block;
    margin: 0 4px;
    color: #27ae60;
    font-weight: 500;
}

/* Small screens: shrink the boxes so long sentences fit */
@media (max-width: 480px) {
    .character-box {
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    .character-boxes-row {
        gap: 6px;
    }
}