@font-face {
    font-family: 'LettersLine';
    src: url('./letters_line.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'LettersNoLine';
    src: url('./letters_noLine.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Mitimasu';
    src: url('./mitimasu.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Mplus2Light';
    src: url('./Mplus2-Light.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

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

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin-top: 30px;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
}

select.form-control {
    cursor: pointer;
}

textarea.form-control {
    resize: vertical;
}

input[type="range"].form-control {
    padding: 5px 10px;
    cursor: pointer;
}

#opacityValue, #letterSpacingValue, #wordSpacingValue {
    font-weight: normal;
    color: #3498db;
}

.translation-section {
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.translation-pair {
    margin-bottom: 20px;
    padding: 15px;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.english-text {
    font-size: 18px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 8px;
    line-height: 1.4;
}

.japanese-text {
    font-size: 12px;
    color: #000;
    line-height: 1.5;
    padding-left: 10px;
    border-left: 3px solid #007bff;
}

.loading-text {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.toggle-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    color: #555;
    margin-bottom: 0;
}

.toggle-checkbox {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 24px;
    background-color: #ccc;
    border-radius: 12px;
    margin-right: 10px;
    transition: background-color 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: white;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-checkbox:checked + .toggle-slider {
    background-color: #007bff;
}

.toggle-checkbox:checked + .toggle-slider::before {
    transform: translateX(26px);
}

.form-text {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

.preview-section {
    margin: 30px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.preview-section h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.preview-box {
    min-height: 100px;
    padding: 20px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 48px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
    /* 4線フォントの重複を防ぐ */
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.preview-box.mixed-font .english-text.letters_line {
    font-family: 'LettersLine', monospace;
    display: inline-block;
    /* 4線の重複を防ぐ */
    background-clip: padding-box;
    -webkit-background-clip: padding-box;
}

.preview-box.mixed-font .english-text.letters_noline {
    font-family: 'LettersNoLine', monospace;
}

.preview-box.mixed-font .japanese-text {
    font-family: 'Mplus2Light', sans-serif;
}

.preview-box.mixed-font .japanese-translation {
    font-family: 'Mplus2Light', sans-serif;
    font-size: 15px !important;
    display: block;
    line-height: 1.2;
    background: none !important; /* 4線を表示しない */
}

/* 4線背景用のラッパー */
.line-wrapper {
    position: relative;
    display: block;
    width: 100%;
    line-height: 1.8;
}

/* 4線を背景として表示 */
.line-wrapper.with-lines {
    background-image: 
        linear-gradient(to bottom, #CCCCCC 1px, transparent 1px),
        linear-gradient(to bottom, #CCCCCC 1px, transparent 1px),
        linear-gradient(to bottom, #CCCCCC 1px, transparent 1px),
        linear-gradient(to bottom, #CCCCCC 1px, transparent 1px);
    background-size: 
        100% 1.8em,
        100% 1.8em,
        100% 1.8em,
        100% 1.8em;
    background-position:
        0 calc(0.12em),
        0 calc(0.48em),
        0 calc(0.82em),
        0 calc(1.15em);
    background-repeat: repeat-y;
}

/* テキストを前面に表示 */
.line-wrapper .english-text {
    position: relative;
    z-index: 2;
}

/* フォールバック用 */
.preview-box.letters-line {
    font-family: 'LettersLine', monospace;
}

.preview-box.letters-noline {
    font-family: 'LettersNoLine', monospace;
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

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

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    font-size: 14px;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.translation-status {
    font-size: 0.9em;
    margin-top: 5px;
    padding: 5px 10px;
    border-radius: 4px;
    display: none;
}

.translation-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.translation-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.translation-status.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    display: block;
}

@media (max-width: 600px) {
    .container {
        margin-top: 10px;
        padding: 15px;
    }
    
    h1 {
        font-size: 24px;
    }
}