:root {
    --primary-color: #E0E0E0;
    --background-color: #121212;
    --accent-color: #FFFFFF;
    --rod-color-start: #F2D4C2; /* 肌色・明 */
    --rod-color-end: #E6BBA9;   /* 肌色・暗 */
    --cap-color-start: #DDA0DD; /* ピンクがかった紫・明 */
    --cap-color-end: #C17EAD;   /* ピンクがかった紫・暗 */
}

body {
    background-color: var(--background-color);
    color: var(--primary-color);
    font-family: 'Shippori Mincho', serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    overflow: hidden;
    text-align: center;
}

#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 90vh;
    width: 90vw;
    max-width: 600px;
}

/* --- 物語とメッセージ --- */
#story-container {
    opacity: 0;
    animation: fadeIn 2s ease-out forwards;
}

.story-text {
    margin: 0.2em 0;
    font-size: 1.1rem;
}

#mood-message {
    margin-top: 1.5em;
    font-size: 0.9rem;
    color: #A0A0A0;
    opacity: 0;
    animation: fadeIn 2s 1s ease-out forwards;
}

/* --- ながみねの棒 --- */
#rod-container {
    position: relative;
    width: 100%;
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

#nagamine-rod-assembly {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#nagamine-rod {
    width: 18px;
    height: 45vh; /* 高さをビューポート基準に変更 */
    background: linear-gradient(to bottom, var(--rod-color-start), var(--rod-color-end));
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s ease-out, box-shadow 0.3s ease;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    animation: idle-sway 8s ease-in-out infinite;
    margin-bottom: -15px; /* ボールと少し重ねる */
    position: relative; /* z-indexを有効にするため */
    z-index: 10;
}

#balls-container {
    display: flex;
    position: relative;
    z-index: 5;
}

.ball {
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 50% 40%, var(--rod-color-start), var(--rod-color-end));
    border-radius: 50%;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.2), 0 5px 10px rgba(0, 0, 0, 0.4);
}

.ball:first-child {
    margin-right: -18px; /* ボール同士を重ねる */
}

#balls-container.jiggling {
    animation: jiggle-effect 0.3s ease-in-out;
}

#nagamine-rod:hover {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

#nagamine-rod.clicked {
    animation: click-effect 0.2s ease-out;
}

#nagamine-rod.fulfilled {
    cursor: default;
    animation: none; /* アイドルアニメーションを停止 */
}

#rod-cap {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 16px;
    background: linear-gradient(to bottom, var(--cap-color-start), var(--cap-color-end));
    border-radius: 12px 12px 4px 4px;
    box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
}

#nagamine-rod-assembly.shaking {
    animation: climax-shake 1.2s ease-in-out;
}

#nagamine-rod-assembly.drooped {
    animation: boron-droop 1s ease-out forwards;
}


/* --- 情報とリセットボタン --- */
#info-container {
    opacity: 0;
    animation: fadeIn 2s 2s ease-out forwards;
}

#reset-button {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px 20px;
    font-family: 'Shippori Mincho', serif;
    cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
    margin-top: 1em;
}

#reset-button:hover {
    background-color: var(--primary-color);
    color: var(--background-color);
}

/* --- アニメーション定義 --- */
@keyframes idle-sway {
    0%, 100% { transform: rotate(-0.5deg); }
    50% { transform: rotate(0.5deg); }
}

@keyframes climax-shake {
    0%, 100% { transform: translate(0, 0) rotate(0); }
    10% { transform: translate(-6px, 0) rotate(-2.5deg); }
    20% { transform: translate(6px, 0) rotate(2.5deg); }
    30% { transform: translate(-6px, 0) rotate(-2.5deg); }
    40% { transform: translate(6px, 0) rotate(2.5deg); }
    50% { transform: translate(-4px, 0) rotate(-1.5deg); }
    60% { transform: translate(4px, 0) rotate(1.5deg); }
    70% { transform: translate(-2px, 0) rotate(0); }
}

@keyframes boron-droop {
    to {
        transform: translateY(10px) rotate(3deg);
    }
}

@keyframes jiggle-effect {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    50% { transform: translateX(3px); }
    75% { transform: translateX(-2px); }
}

@keyframes click-effect {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.hidden {
    display: none !important;
}

/* --- 白いまろやかな液体（感情の光）のエフェクト --- */
#emission-effect-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* クリックを透過させる */
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 5px;
    height: 5px;
    background-color: var(--accent-color);
    border-radius: 50%;    opacity: 0.9;
    box-shadow: 0 0 8px var(--accent-color);
}

/* --- 最後のメッセージ --- */
#final-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    opacity: 0;
    background-color: var(--background-color);
    padding: 0 20px;
    z-index: 20; /* 棒の前面に表示 */
}

#final-message.show {
    animation: fadeIn 2s 1s ease-out forwards;
}
