/*
 * style.css
 * スマートフォン向け9:16比率のレイアウトと、パステルカラーを基調としたデザインを提供します。
 */

/* 全体のリセットとベース設定 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@500;700&display=swap');

body {
    /* パステル調の背景色（画面全体） */
    background-color: #fdf6e3;
    font-family: 'Quicksand', 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* スクロールを無効化 */
    user-select: none; /* テキスト選択を無効化 */
}

/* 9:16比率を維持するラッパー */
#game-wrapper {
    position: relative;
    /* 9:16 = 56.25% : 100% */
    width: 100%;
    max-width: 450px; /* PCなどで広がりすぎないように制限 */
    aspect-ratio: 9 / 16;
    background-color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* 上部UI（スコア・Next表示） */
#game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color: #ffd1dc; /* パステルピンク */
    color: #555;
    font-weight: bold;
    height: 15%; /* 全体の15%の高さ */
    z-index: 10;
}

.score-container, .next-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 4px;
}

#score {
    font-size: 1.5rem;
    color: #ff6b81;
    transition: transform 0.2s ease;
}

/* スコア加算時のアニメーションクラス */
.score-bump {
    animation: bumpScore 0.3s ease-out;
}

@keyframes bumpScore {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: #ff4757; }
    100% { transform: scale(1); }
}

#next-ball-preview {
    width: 32px;
    height: 32px;
    background-color: #ccc; /* プレースホルダー */
    border-radius: 50%;
}

/* ゲーム領域 */
#game-container {
    position: relative;
    flex-grow: 1; /* 残りの高さをすべて占有 */
    background-color: #f0f8ff; /* パステルブルーのコンテナ背景 */
    width: 100%;
}

/* デッドライン（制限ライン） */
#deadline-line {
    position: absolute;
    top: 15%; /* 上から15%の位置をゲームオーバーの基準とする例 */
    left: 0;
    width: 100%;
    height: 2px;
    background-color: transparent;
    border-top: 2px dashed #ff9999; /* パステルレッドの破線 */
    z-index: 5;
    pointer-events: none; /* タップ操作を透過 */
}

/* Canvasの配置用（Matter.jsが生成するcanvas要素に適用） */
#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* スタート画面 */
#game-start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30; /* ゲームオーバー画面よりも前面 */
}

.game-start-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.game-start-content h2 {
    color: #ff6b81;
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.game-start-content p {
    color: #555;
    margin-bottom: 20px;
    font-size: 1rem;
    line-height: 1.5;
}

#start-button {
    background-color: #1e90ff;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#start-button:hover {
    background-color: #1c7ed6;
}

#start-button:active {
    transform: scale(0.98);
}

/* ゲームオーバー画面 */
#game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* 半透明の黒背景 */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20; /* キャンバスやデッドラインより前面に表示 */
}

.game-over-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.game-over-content h2 {
    color: #ff4757;
    margin-bottom: 20px;
    font-size: 2rem;
}

#restart-button {
    background-color: #2ed573;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#restart-button:hover {
    background-color: #26b160;
}

#restart-button:active {
    transform: scale(0.98);
}