body {
    margin: 0;
    padding: 0;
    text-align: center;
    background: #1a1a2e; /* より落ち着いたダークな背景色 */
    color: #e0e0e0; /* 背景に合わせてテキストカラーを調整 */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* より読みやすいフォントスタック */
    display: flex; /* flexboxで中央配置を容易にする */
    flex-direction: column; /* 縦方向に並べる */
    align-items: center; /* 水平方向の中央揃え */
    min-height: 100vh; /* ビューポートの高さに合わせて最低高さを設定 */
    justify-content: center; /* 垂直方向の中央揃え */
    box-sizing: border-box; /* paddingやborderをwidth/heightに含める */
    overflow: hidden;
}

body.shake {
  animation: shakeBody 0.4s ease-in-out;
}

/* 全体のコンテナを調整 */
#container {
    position: relative; /* 子要素のabsolute配置の基準 */
    display: flex; /* flexboxに変更して内部要素の配置を制御 */
    flex-direction: column; /* 縦方向に並べる */
    align-items: center; /* 水平方向の中央揃え */
    width: 100%;
    /* コンテナの高さはcanvas-wrapperに依存させるか、明示的に設定 */
    /* 例えば、min-height: 550px; (canvas + pointer + padding + margin) など */
}

#canvas-wrapper {
    max-width: 90%; /* 小さい画面でのオーバーフローを防ぐ */
    width: 450px; /* ある程度の固定幅を設定 */
    background-color: #2e2e4a; /* コンテナの背景色 */
    margin: 20px; /* 上下のマージンと左右中央揃え */
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4); /* より強い影 */
}

#wheel {
    border: none; /* JavaScriptで描画するのでCSSのborderは不要 */
    display: block; /* canvasの下にできる余白を削除 */
    margin: 20px auto; /* 上下のマージンと左右中央揃え */
    max-width: 100%; /* 親要素に合わせて縮小 */
    height: auto; /* アスペクト比を維持 */
    z-index: 10;
    position: relative;
}

textarea {
    width: calc(100% - 20px); /* 親要素の幅に合わせて調整、padding分を考慮 */
    max-width: 380px; /* 固定幅の上限を設定 */
    height: 120px; /* 高さを少し増やす */
    margin-top: 15px; /* マージンを調整 */
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #4a4a6e; /* 枠線の色 */
    border-radius: 5px;
    background-color: #3a3a5e; /* 背景色 */
    color: #e0e0e0; /* テキストカラー */
    font-size: 16px;
    resize: vertical; /* 垂直方向のみリサイズ可能にする */
    box-sizing: border-box; /* paddingやborderをwidth/heightに含める */
}

textarea::placeholder {
    color: #a0a0b0; /* プレースホルダーの色 */
}

button {
    margin-top: 10px;
    padding: 12px 25px; /* パディングを少し増やす */
    font-size: 20px; /* フォントサイズを大きくする */
    cursor: pointer;
    background-color: #8b0000; /* より目立つ赤色 */
    color: white;
    border: none;
    border-radius: 6px;
    transition: background-color 0.3s ease, transform 0.1s ease; /* ホバーアニメーション */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:hover {
    background-color: #b30000; /* ホバー時の色 */
    transform: translateY(-2px); /* 少し浮き上がる */
}

button:disabled {
    background-color: #555555; /* 無効時の色 */
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* 共通のバナー・画像スタイル */
.result-banner, .result-image {
    position: absolute; /* 親(#container)に対して絶対配置 */
    display: none; /* 初期は非表示 */
    font-weight: bold;
    color: white;
    /* ★変更点★ 背景を透過 */
    background-color: transparent; 
    padding: 10px 20px;
    border-radius: 10px;
    white-space: nowrap; /* テキストの折り返しを防ぐ */
    text-align: center;
    pointer-events: none; /* クリックイベントを無視 */
    z-index: 100; /* 他の要素の上に表示 */
    opacity: 0; /* JSでフェードインさせるため */
    animation: none; /* JSで制御するため初期はnone */
}

#winning-banner {
    font-size: 7em; /* 非常に大きく、インパクトを出す */
    bottom: 0;
    transform: translate(30%, -30%);
}

/* うさぴょいバナーのスタイル */
#usapyoi-banner {
    font-size: 5em; /* 適度なサイズ */
    transform: translate(-50%, 50%);
}

/* vs.png 画像要素のスタイル */
#vs-image {
    /* vs.pngは常に中央に配置されるようにCSSで設定 */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* これで画像自身の中心が親要素の中心に */
    max-width: 80%; /* 親要素のサイズに合わせる */
    height: auto;
    object-fit: contain; /* アスペクト比を維持して収まるようにする */
    width: 150px; /* 例: デフォルトの幅 */
}


/* popupアニメーション (変更あり) */
@keyframes popup-winning {
    0% { transform: translate(30%, -30%) scale(0.2); opacity: 0; }
    60% { transform: translate(30%, -30%) scale(1.1); opacity: 1; }
    100% { transform: translate(30%, -30%) scale(1.0); opacity: 1; }
}

@keyframes popup-usapyoi {
    0% { transform: translate(-50%, 50%) scale(0.2); opacity: 0; }
    60% { transform: translate(-50%, 50%) scale(1.1); opacity: 1; }
    100% { transform: translate(-50%, 50%) scale(1.0); opacity: 1; }
}

@keyframes popup-vs {
    0% {
        transform: translate(calc(-50% + 100px), calc(-50% - 100px)) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}
@keyframes shakeBody {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-2px, 1px); }
    40%  { transform: translate(2px, -1px); }
    60%  { transform: translate(-1px, 2px); }
    80%  { transform: translate(1px, -2px); }
    100% { transform: translate(0, 0); }
}


/* h1タグのスタイルも追加して、見た目を統一 */
h1 {
    color: #f0f0f0; /* 見出しの色 */
    margin-bottom: 20px;
    font-size: 2.5em; /* 見出しのサイズ */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5); /* 軽い影 */
}

/* スマートフォン向けの調整 */
@media (max-width: 600px) {
    #winning-banner {
        font-size: 48px; /* 小さい画面ではフォントサイズを縮小 */
        width: 90vw; /* 横幅も調整 */
        /* transform: translate(0, 0); は残しておく */
    }
    #usapyoi-banner {
        font-size: 2em; /* 小さい画面ではフォントサイズを縮小 */
        /* transform: translate(0, 0); は残しておく */
    }
    #vs-image {
        width: 100px; /* 小さい画面では画像サイズを縮小 */
    }
    /* #usapyoi-banner, #winning-banner には translate を明示的に設定しない */
    /* top/left/right/bottom の値で位置を制御し、transformはスケールのみにする */
}

.effect-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#gachapin {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translate(-60%, -110%) rotate(-40deg);
  width: 250px;
  opacity: 0;
  z-index: 0; /* ルーレットの後ろになるように調整 */
  pointer-events: none;
}

@keyframes popup-gachapin {
  0% {
    transform: translate(-60%, -110%) rotate(-40deg);
    opacity: 0;
  }
  70% {
    transform: translate(-90%, -150%) rotate(-40deg);
    opacity: 1;
  }
  100% {
    transform: translate(-85%, -145%) rotate(-40deg);
    opacity: 1;
  }
}