body {
    margin: 0;
    overflow: hidden;
    background-color: #f0f0f0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    touch-action: none;
}

#welcome-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(0,0,0,0.1);
    font-size: 2rem;
    pointer-events: none;
    transition: opacity 0.5s;
    z-index: 1;
}

canvas { display: block; cursor: crosshair; }

/* 右下設定パネル */
#controls-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#toggleControls {
    background: #333;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
}

#controls {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 240px;
    margin-bottom: 5px;
}

#controls.collapsed { display: none; }

.control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#helpBtn {
    background: #555;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 14px;
    cursor: pointer;
}

.control-group { display: flex; flex-direction: column; gap: 4px; }
.switch-label { flex-direction: row; align-items: center; cursor: pointer; font-size: 0.8rem; }
hr { border: 0; border-top: 1px solid #ddd; margin: 2px 0; }

/* 開発者用ビュワー */
#dev-viewer {
    position: fixed;
    top: 0;
    right: 0;
    width: 35%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    z-index: 50;
    border-left: 1px solid #444;
}

#dev-viewer.hidden { display: none; }
.dev-header { display: flex; justify-content: space-between; align-items: center; color: #fff; margin-bottom: 10px; }
#log-container { flex-grow: 1; overflow-y: auto; font-size: 0.65rem; color: #0f0; margin-bottom: 15px; border: 1px solid #444; padding: 10px; line-height: 1.4; white-space: nowrap; }

#downloadBtn { background: #0f0; color: #000; border: none; padding: 12px; font-weight: bold; cursor: pointer; border-radius: 4px; }
#clearBtn { background: #e74c3c; color: white; border: none; padding: 10px; cursor: pointer; border-radius: 4px; margin-top: 5px; }

/* モーダル */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-content h2 { margin-top: 0; border-bottom: 2px solid #333; padding-bottom: 10px; font-size: 1.4rem; }
.help-section { margin-bottom: 15px; }
.help-section h3 { font-size: 0.95rem; color: #e74c3c; margin-bottom: 5px; }
.help-section p, .help-section li { font-size: 0.85rem; color: #444; line-height: 1.5; }
#closeHelp { width: 100%; padding: 12px; background: #333; color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; }

.hidden { display: none !important; }

@media (max-width: 768px) {
    #dev-viewer { width: 100%; height: 40%; top: auto; bottom: 0; }
}