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

body {
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    padding: 10px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    background-color: white;
    border: 3px solid #000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Top Bar */
.top-bar {
    background-color: #FFED4E;
    border-bottom: 3px solid #000;
    display: flex;
    align-items: center;
    padding: 8px;
    gap: 5px;
    flex-wrap: wrap;
}

.text-name {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    font-size: 18px;
    font-weight: bold;
    border: 2px solid #000;
    background-color: #FFED4E;
}

.btn-icon {
    width: 50px;
    height: 50px;
    font-size: 24px;
    border: 2px solid #000;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.btn-icon:hover {
    background-color: #e0e0e0;
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

.btn-prepare-active {
    background-color: #90EE90;
    color: green;
    font-weight: bold;
}

/* Control Bar */
.control-bar {
    background-color: #d3d3d3;
    border-bottom: 3px solid #000;
    padding: 8px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-row-1 {
    margin-bottom: 0;
}

.control-row-2 {
    /* Second row styles */
}

/* Desktop: Single row layout */
@media (min-width: 769px) {
    .control-bar {
        display: flex;
        align-items: center;
        gap: 5px;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .control-row {
        display: contents; /* Makes children behave as direct children of control-bar */
    }
    
    .control-row-1 {
        margin-bottom: 0;
    }
}

.btn-control {
    height: 45px;
    padding: 8px 12px;
    font-size: 18px;
    border: 2px solid #000;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.btn-control:hover {
    background-color: #e0e0e0;
    transform: scale(1.05);
}

.btn-control:active {
    transform: scale(0.95);
}

.btn-horen {
    background-color: #ADD8E6;
    font-weight: bold;
}

.btn-play {
    background-color: #90EE90;
    font-weight: bold;
}

.btn-pause {
    background-color: #FFE4B5;
    font-weight: bold;
}

.btn-stop {
    background-color: #FFB6C6;
    font-weight: bold;
}

.btn-repeat {
    background-color: #DDA0DD;
    font-weight: bold;
}

.position-display {
    background-color: white;
    border: 2px solid #000;
    padding: 8px 15px;
    font-size: 16px;
    font-weight: bold;
    min-width: 80px;
    text-align: center;
}

.jump-input {
    width: 70px;
    height: 45px;
    padding: 8px;
    font-size: 16px;
    border: 2px solid #000;
    text-align: center;
}

.jump-input::-webkit-inner-spin-button,
.jump-input::-webkit-outer-spin-button {
    opacity: 1;
}

/* Text Area */
.text-area {
    padding: 20px;
    font-size: 18px;
    line-height: 1.8;
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    outline: none;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.text-area:focus {
    background-color: #fffef0;
}

/* Highlighted Word */
.highlight {
    background-color: #FFFF00;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

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

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

.modal-content {
    background-color: white;
    border: 3px solid #000;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideDown 0.3s;
}

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

.modal-header {
    background-color: #FFED4E;
    padding: 15px 20px;
    border-bottom: 2px solid #000;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.modal-body {
    padding: 25px;
}

.setting-group {
    margin-bottom: 25px;
}

.setting-group label {
    display: block;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.speed-label {
    font-size: 24px;
    user-select: none;
}

#speedSlider {
    flex: 1;
    height: 8px;
    border-radius: 5px;
    outline: none;
    background: linear-gradient(to right, #90EE90, #FFD700, #FF6B6B);
    cursor: pointer;
}

#speedSlider::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4A90E2;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s;
}

#speedSlider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#speedSlider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #4A90E2;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s;
}

#speedSlider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.speed-value {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #4A90E2;
    padding: 10px;
    background-color: #F0F8FF;
    border-radius: 5px;
    border: 2px solid #4A90E2;
}

.setting-hint {
    text-align: center;
    font-size: 13px;
    color: #666;
    margin-top: 8px;
    font-style: italic;
}

.voice-select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #4A90E2;
    border-radius: 5px;
    background-color: white;
    cursor: pointer;
    font-family: Arial, sans-serif;
}

.voice-select:focus {
    outline: none;
    border-color: #2E5C8A;
    box-shadow: 0 0 5px rgba(74, 144, 226, 0.5);
}

.voice-info {
    margin-top: 8px;
    padding: 8px;
    background-color: #F0F8FF;
    border-radius: 4px;
    font-size: 13px;
    color: #4A90E2;
    text-align: center;
}

.voice-selection {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.voice-btn {
    flex: 1;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: bold;
    border: 3px solid #ccc;
    background-color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.voice-btn:hover {
    background-color: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.voice-btn.active {
    background-color: #4A90E2;
    color: white;
    border-color: #4A90E2;
    transform: scale(1.05);
}

.voice-btn:active {
    transform: scale(0.98);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        border-width: 2px;
    }
    
    .control-bar {
        padding: 5px;
    }
    
    .control-row {
        gap: 3px;
    }
    
    .control-row-1 {
        margin-bottom: 5px;
    }
    
    .top-bar, .control-bar {
        padding: 5px;
        gap: 3px;
    }
    
    .text-name {
        min-width: 150px;
        font-size: 16px;
        padding: 10px;
    }
    
    .btn-icon {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .btn-control {
        height: 40px;
        padding: 6px 10px;
        font-size: 16px;
    }
    
    .position-display {
        font-size: 14px;
        padding: 6px 10px;
        min-width: 70px;
    }
    
    .jump-input {
        width: 60px;
        height: 40px;
        font-size: 14px;
    }
    
    .text-area {
        font-size: 16px;
        padding: 15px;
        min-height: 300px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .text-name {
        width: 100%;
        min-width: unset;
    }
    
    .btn-icon {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .btn-control {
        height: 38px;
        padding: 5px 8px;
        font-size: 14px;
    }
    
    .text-area {
        font-size: 15px;
        padding: 10px;
        line-height: 1.6;
    }
    
    .modal-content {
        width: 95%;
    }
    
    .modal-header {
        padding: 12px 15px;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 20px 15px;
    }
}

/* Disabled state */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
    background-color: inherit;
}