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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 0;
    color: #333;
    overscroll-behavior: none;
    touch-action: pan-y;
    overflow-x: hidden;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: white;
    border-radius: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    text-align: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    min-height: 600px;
}

/* ツールバー */
.toolbar {
    width: 100%;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    order: 2;
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 5px;
}

.tool-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 500;
    color: #495057;
    flex: 1;
    min-width: auto;
    justify-content: center;
}

.tool-btn:hover {
    background: #f1f3f5;
    border-color: #667eea;
    transform: translateX(5px);
}

.tool-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.tool-btn svg {
    width: 20px;
    height: 20px;
}

.tool-btn span {
    font-size: 0.8rem;
}

/* 線の太さ */
#brush-size {
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #e9ecef;
    outline: none;
    -webkit-appearance: none;
}

#brush-size::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#brush-size::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#brush-size-value {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* カラーパレット */
.color-palette {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.color-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.color-btn.active {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
    transform: scale(1.15);
}

.custom-color {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.custom-color label {
    font-size: 0.9rem;
    color: #495057;
    font-weight: 500;
}

#color-picker {
    width: 60px;
    height: 40px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
}

/* アクションボタン */
.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    width: 100%;
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

.action-btn:hover {
    background: #f1f3f5;
    border-color: #667eea;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#clear-btn:hover {
    border-color: #dc3545;
    color: #dc3545;
}

#save-png:hover {
    border-color: #28a745;
    color: #28a745;
}

#undo-btn:hover {
    border-color: #ffc107;
    color: #ffc107;
}

/* キャンバスエリア */
.canvas-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    order: 1;
    width: 100%;
    min-height: 70vh;
}

.canvas-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    overflow: hidden;
    width: 100%;
}

#drawing-canvas {
    border: 2px solid #e9ecef;
    border-radius: 5px;
    cursor: crosshair;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* フッター */
footer {
    background: #f8f9fa;
    padding: 10px;
    text-align: center;
    color: #6c757d;
    font-size: 0.8rem;
}

footer p {
    margin: 0;
}

/* レスポンシブデザイン - 全デバイスで同じデザイン */
@media (max-width: 1024px) {
    /* タブレットも同じスタイル */
}

/* スマホ版も同じスタイル */
@media (max-width: 768px) {
    /* 全て統一されているので追加のスタイルは不要 */
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    animation: fadeIn 0.5s ease;
}

/* スクロールバーのカスタマイズ */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}