/* ===== KANJI MODAL ===== */
.hz-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    align-items: center;
    justify-content: center;
    animation: hzFadeIn 0.3s ease;
}

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

.hz-modal-content {
    background: white;
    border-radius: 16px;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: hzSlideUp 0.3s ease;
}

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

.hz-modal-header {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #333;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
}

.hz-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    width: 100%;
    color: #333;
}

.hz-modal-close {
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    color: #333;
    transition: color 0.2s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    position: absolute;
    right: 20px;
}

.hz-modal-close:hover {
    color: #000;
    background: rgba(0,0,0,0.1);
}

.hz-modal-body {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
    background: #f8f9fa;
}

.hz-sentence {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    justify-content: center;
    align-items: flex-start;
}

.hz-char-container {
    text-align: center;
    flex: 0 0 auto;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 150px;
}

.hz-char-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.hz-char-label {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #2c3e50;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Noto Sans JP", "Hiragino Kaku Gothic Pro", sans-serif;
}

.hz-box {
    width: 100px;
    height: 100px;
    border: 3px solid #FFF9C4;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    margin: 0 auto;
    overflow: hidden;
}

.hz-box:hover {
    border-color: #FFD700;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

.hz-char-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

.hz-modal-footer {
    padding: 15px 30px;
    background: #FFF9C4;
    text-align: center;
    border-top: 1px solid #e0e0e0;
}

.hz-modal-footer small {
    color: #666;
    font-size: 13px;
}

/* ===== KANJI TEXT WITH PEN ===== */
.kanji-with-pen {
    display: inline-flex;
    align-items: center;
    margin: 0 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.kanji-with-pen:hover {
    background-color: rgba(255, 215, 0, 0.15);
    transform: translateY(-2px);
}

.kanji-text {
    font-weight: bold;
    color: #2c3e50;
    transition: color 0.2s;
    font-size: 1.1em;
}

.kanji-with-pen:hover .kanji-text {
    color: #FFA500;
}

.hz-pen-icon {
    font-size: 0.9em;
    margin-right: 6px;
    transition: transform 0.2s;
    color: #FFD700;
}

.kanji-with-pen:hover .hz-pen-icon {
    transform: scale(1.2);
}

/* ===== KANA STYLES ===== */
.kana-with-pen {
    display: inline-flex;
    align-items: center;
    margin: 0 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.kana-with-pen:hover {
    background-color: rgba(255, 107, 107, 0.15);
    transform: translateY(-2px);
}

.kana-text {
    font-weight: bold;
    color: #2c3e50;
    transition: color 0.2s;
    font-size: 1.1em;
    font-family: "Hiragino Kaku Gothic Pro", "Meiryo", sans-serif;
}

.kana-with-pen:hover .kana-text {
    color: #FF6B6B;
}

.kana-pen-icon {
    font-size: 0.9em;
    margin-right: 6px;
    transition: transform 0.2s;
    color: #FF6B6B;
}

.kana-with-pen:hover .kana-pen-icon {
    transform: scale(1.2);
}

.kana-modal .hz-modal-header {
    background: linear-gradient(135deg, #FF6B6B, #FF4757);
    color: white;
}

.kana-modal .hz-modal-header h3 {
    color: white;
}

.kana-modal .hz-modal-close {
    color: white;
}

.kana-modal .hz-modal-close:hover {
    color: #FFD43B;
    background: rgba(255,255,255,0.1);
}

.kana-char-label {
    font-size: 48px;
    font-family: "Hiragino Kaku Gothic Pro", "Meiryo", sans-serif;
}

.kana-box {
    width: 120px;
    height: 120px;
    border-color: #ffeaea;
    cursor: default;
}

.kana-box:hover {
    border-color: #ffeaea;
    box-shadow: none;
}

/* ===== KANA FALLBACK STYLES ===== */
.kana-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default !important;
}

.kana-fallback-content {
    text-align: center;
    padding: 10px;
}

.kana-fallback-char {
    font-size: 48px;
    color: #2c3e50;
    margin-bottom: 5px;
    font-family: "Hiragino Kaku Gothic Pro", "Meiryo", sans-serif;
}

.kana-fallback-text {
    font-size: 12px;
    color: #999;
    font-style: italic;
    line-height: 1.3;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .hz-modal-content {
        width: 95%;
        margin: 10px auto;
        max-height: 95vh;
    }
    
    .hz-modal-body {
        padding: 20px;
        max-height: calc(95vh - 140px);
    }
    
    .hz-sentence {
        gap: 15px;
        justify-content: center;
    }
    
    .hz-char-container {
        padding: 15px;
        min-width: 130px;
    }
    
    .hz-box {
        width: 80px;
        height: 80px;
    }
    
    .kana-box {
        width: 90px;
        height: 90px;
    }
    
    .hz-char-label {
        font-size: 28px;
    }
    
    .kana-char-label, .kana-fallback-char {
        font-size: 36px;
    }
    
    .hz-modal-header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 10px;
    }
    
    .hz-modal-header h3 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    .hz-modal-close {
        position: relative;
        right: 0;
        margin-top: 5px;
    }
}

@media (max-width: 480px) {
    .hz-sentence {
        gap: 12px;
    }
    
    .hz-char-container {
        min-width: 110px;
        padding: 12px;
    }
    
    .hz-box {
        width: 70px;
        height: 70px;
    }
    
    .kana-box {
        width: 80px;
        height: 80px;
    }
    
    .hz-char-label {
        font-size: 24px;
    }
    
    .kana-char-label, .kana-fallback-char {
        font-size: 32px;
    }
    
    .kana-fallback-text {
        font-size: 10px;
    }
    
    .kanji-text, .kana-text {
        font-size: 1em;
    }
}

/* ===== UTILITY ===== */
.clickable-kanji, .clickable-kana {
    cursor: pointer;
}

/* Prevent body scroll when modal is open */
body.hz-modal-open {
    overflow: hidden;
}

/* Error styles */
.hz-error {
    color: #f44336;
    padding: 10px;
    text-align: center;
    font-size: 12px;
}