:root { 
    --bg-color: #0d0d0d; 
    --panel-bg: #161616; 
    --accent: #00d1b2; 
    --text-color: #f0f0f0; 
    --danger: #ff4757; 
    --button-height: 55px;
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    background-color: var(--bg-color); 
    color: var(--text-color); 
    margin: 0; padding: 8px; 
    display: flex; flex-direction: column; 
    height: 100vh; box-sizing: border-box; overflow: hidden; 
}

.header { display: flex; gap: 8px; margin-bottom: 8px; flex-shrink: 0; }
.stat-box { background: var(--panel-bg); padding: 8px 12px; border-radius: 12px; border-left: 3px solid var(--accent); flex: 1; }
.stat-label { font-size: 0.6rem; color: #888; margin-bottom: 2px; }
.stat-value { font-size: 1.1rem; font-weight: bold; color: var(--accent); }

.main-container { display: flex; gap: 12px; flex: 1; min-height: 0; width: 100%; flex-direction: row; }

@media (max-width: 768px) {
    .main-container { flex-direction: column; }
    #display-container { min-height: 45vh !important; }
}

#display-container { 
    flex: 2; background: #000; border-radius: 16px; 
    display: flex; position: relative; overflow: hidden; border: 1px solid #222;
    box-sizing: border-box; padding: 25px; cursor: pointer;
}

#display-container.horizontal { writing-mode: horizontal-tb; align-items: flex-start; justify-content: flex-start; }
#display-container.vertical { writing-mode: vertical-rl; align-items: flex-start; justify-content: flex-start; }

#progress-container { position: absolute; bottom: 0; left: 0; width: 100%; height: 5px; background: rgba(255, 255, 255, 0.05); display: none; z-index: 10; pointer-events: none; }
#progress-bar { height: 100%; width: 0%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }

#display-text { 
    font-weight: bold; line-height: 1.7; white-space: pre-wrap; word-break: break-all; 
    font-family: 'Hiragino Mincho ProN', 'MS Mincho', serif; margin: 0; padding: 0; 
    pointer-events: none; display: inline-block; 
}

.horizontal #display-text { text-align: left; width: 100%; }
.vertical #display-text { text-align: left; height: 100%; }

.side-panel { 
    flex: 1; background: var(--panel-bg); padding: 20px; border-radius: 20px; 
    display: flex; flex-direction: column; gap: 12px; overflow-y: auto; -webkit-overflow-scrolling: touch;
}

.preset-group { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.preset-btn { height: 40px; background: #222; color: var(--accent); border: 1px solid var(--accent); border-radius: 8px; cursor: pointer; font-size: 0.75rem; }
.preset-btn.active { background: var(--accent); color: #000; font-weight: bold; }

.load-btn { background: #2a2a2a; color: var(--accent); border: 1px dashed var(--accent); padding: 12px; border-radius: 12px; font-size: 0.85rem; cursor: pointer; text-align: center; font-weight: bold; }
textarea { width: 100%; height: 180px; background: #111; color: white; border: 1px solid #333; padding: 15px; border-radius: 12px; font-size: 16px; box-sizing: border-box; line-height: 1.5; flex-shrink: 0; }

.setting-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.setting-item label { font-size: 0.65rem; color: #777; margin-bottom: 3px; display: block; }
input, select { background: #1a1a1a; color: white; border: 1px solid #333; height: 38px; border-radius: 8px; font-size: 0.85rem; width: 100%; padding: 0 10px; box-sizing: border-box; }

.full-width-slider { margin-top: 5px; padding-bottom: 5px; }
.full-width-slider input[type="range"] { width: 100%; height: 15px; cursor: pointer; accent-color: var(--accent); }

.btn-group { display: flex; gap: 10px; padding-top: 5px; padding-bottom: 150px; }
button.main-action { flex: 2; height: var(--button-height); border-radius: 14px; cursor: pointer; font-size: 1.1rem; font-weight: bold; border: none; }
#start-btn { background: var(--accent); color: #000; }
#start-btn.stop { background: var(--danger); color: white; }
#reset-btn { flex: 1; background: #333; color: white; border: none; border-radius: 14px; font-size: 0.9rem; }

.save-preset-btn {
    width: 100%; padding: 10px; background: #1a1a1a; color: #555;
    border: 1px solid #333; border-radius: 12px; cursor: pointer;
    font-size: 0.8rem; font-weight: bold; transition: all 0.2s;
}
.save-preset-btn:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.save-preset-btn:not(:disabled):hover { background: rgba(0, 209, 178, 0.1); box-shadow: 0 0 10px rgba(0, 209, 178, 0.2); }
