* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Mincho ProN', 'Yu Mincho', 'MS Mincho', serif;
    min-height: 100vh;
    padding: 0;
    position: relative;
}

/* 背景レイヤー */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #c1272d 0%, #f8d7da 50%, #ffffff 100%);
    background-size: 200% 200%;
    z-index: -1;
    transition: all 0.5s ease;
}

/* DJ版再生時のノリノリ背景 */
body.dj-mode::before {
    background: linear-gradient(135deg, #c1272d 0%, #d4af37 25%, #c1272d 50%, #d4af37 75%, #c1272d 100%);
    background-size: 400% 400%;
    animation: djPulse 2s ease-in-out infinite;
}

@keyframes djPulse {
    0%, 100% {
        background-position: 0% 50%;
        filter: brightness(1);
    }
    25% {
        filter: brightness(1.1);
    }
    50% {
        background-position: 100% 50%;
        filter: brightness(1);
    }
    75% {
        filter: brightness(1.1);
    }
}

/* ヘッダー */
.site-header {
    width: 100%;
    background: #1f2937;
    padding: 12px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 0;
    border-radius: 0;
    border: none;
    border-bottom: 3px solid #d4af37;
}

.header-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: white;
    font-size: 1.1em;
    font-weight: 600;
    gap: 12px;
    transition: opacity 0.3s;
}

.header-link:hover {
    opacity: 0.8;
}

.header-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.container {
    background: linear-gradient(to bottom, #fffef9 0%, #ffffff 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(193, 39, 45, 0.3);
    max-width: 900px;
    width: 100%;
    border: 3px solid #d4af37;
    margin: 30px auto;
}

h1 {
    text-align: center;
    color: #c1272d;
    font-size: 2.5em;
    margin-bottom: 10px;
    letter-spacing: 0.1em;
    text-shadow: 2px 2px 4px rgba(212, 175, 55, 0.3);
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 0.9em;
}

.canvas-wrapper {
    position: relative;
    display: inline-block;
    margin: 0 auto;
    display: block;
    width: fit-content;
}

#canvas {
    display: block;
    background: #f5f3ed;
    background-image: 
        linear-gradient(to bottom, rgba(250, 248, 240, 0.5), rgba(245, 243, 237, 1)),
        repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(200,180,150,0.1) 59px, rgba(200,180,150,0.1) 60px);
    cursor: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border: 2px solid #d4b896;
}

#cursorCanvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    cursor: none;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 25px;
    align-items: center;
}

.controls-row {
    display: flex;
    gap: 15px;
    width: 100%;
    max-width: 700px;
    justify-content: center;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
    padding: 10px 15px;
    border-radius: 10px;
    border: 2px solid #d4af37;
    flex: 0 1 auto;
    min-width: fit-content;
}

.color-group {
    gap: 15px;
}

.color-buttons {
    display: flex;
    gap: 10px;
    flex: 1;
}

label {
    font-weight: bold;
    color: #555;
    font-size: 0.9em;
}

input[type="range"] {
    width: 120px;
    cursor: pointer;
}

.color-group {
    gap: 15px;
}

.color-buttons {
    display: flex;
    gap: 10px;
}

.color-btn {
    padding: 8px 16px;
    font-size: 0.9em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-weight: bold;
    border: 2px solid transparent;
}

.color-btn[data-color="#000000"] {
    background: #000000;
    color: white;
}

.color-btn[data-color="#000000"]:hover {
    background: #333333;
}

.color-btn[data-color="#c1272d"] {
    background: #c1272d;
    color: white;
}

.color-btn[data-color="#c1272d"]:hover {
    background: #a02025;
}

.color-btn.active {
    border-color: #d4af37;
    box-shadow: 0 0 0 2px #d4af37;
    transform: scale(1.05);
}

.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    width: 100%;
    max-width: 500px;
    flex-wrap: wrap;
}

button {
    padding: 12px 25px;
    font-size: 1em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

button:active {
    transform: translateY(0);
}

.btn-clear {
    background: linear-gradient(135deg, #c1272d 0%, #a02025 100%);
    color: white;
    border: 2px solid #8b1c1f;
}

.btn-clear:hover {
    background: linear-gradient(135deg, #a02025 0%, #8b1c1f 100%);
}

.btn-gif {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    border: 2px solid #7d3c98;
}

.btn-gif:hover {
    background: linear-gradient(135deg, #8e44ad 0%, #7d3c98 100%);
}

.btn-download {
    background: linear-gradient(135deg, #d4af37 0%, #b8960f 100%);
    color: white;
    border: 2px solid #9a7f0a;
}

.btn-download:hover {
    background: linear-gradient(135deg, #b8960f 0%, #9a7f0a 100%);
}

.btn-share {
    background: linear-gradient(135deg, #165e1c 0%, #0d4011 100%);
    color: white;
    border: 2px solid #0a2e0d;
}

.btn-share:hover {
    background: linear-gradient(135deg, #0d4011 0%, #0a2e0d 100%);
}

.value-display {
    min-width: 35px;
    text-align: center;
    font-weight: bold;
    color: #333;
}

.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #c1272d 0%, #a02025 100%);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 1em;
    box-shadow: 0 4px 12px rgba(193, 39, 45, 0.5);
    border: 2px solid #d4af37;
    z-index: 2000;
    transition: bottom 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.toast.show {
    bottom: 30px;
}

/* BGMトグルボタン */
.bgm-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c1272d 0%, #8b0000 100%);
    border: 3px solid #d4af37;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(193, 39, 45, 0.4);
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bgm-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(193, 39, 45, 0.6);
}

.bgm-toggle:active {
    transform: scale(0.95);
}

.bgm-toggle.playing {
    background: linear-gradient(135deg, #d4af37 0%, #b8941e 100%);
    border-color: #c1272d;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
    }
    50% {
        box-shadow: 0 6px 25px rgba(212, 175, 55, 0.8);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    #canvas {
        max-width: 100%;
        height: auto;
    }

    .controls {
        flex-direction: column;
    }

    .control-group {
        width: 100%;
        justify-content: space-between;
    }
}
