:root {
    --primary-color: #d86c8f;
    --secondary-color: #fce4ec;
    --text-color: #4a3b32;
    --bg-color: #f5f0e6;
    --water-color: #81d4fa;
    --gauge-green: #4caf50;
    --gauge-yellow: #ffeb3b;
    --gauge-red: #f44336;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none; /* スマホでのテキスト選択防止 */
}

body {
    font-family: 'Zen Maru Gothic', sans-serif;
    background-color: #333;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    touch-action: none; /* デフォルトのスワイプ操作などを無効化 */
}

/* スマホ縦画面を想定したコンテナ */
#app-container {
    width: 100%;
    max-width: 450px; /* タブレット等で見てもスマホサイズに制限 */
    height: 100%;
    max-height: 900px;
    background-color: var(--bg-color);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    /* 上下30pxの余白をpaddingで確保 */
    padding: 30px 0;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex: 1;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 30px; /* padding-topを考慮 */
    bottom: 30px; /* padding-bottomを考慮 */
    left: 0;
    overflow: hidden;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* 共通ボタンレイアウト */
.btn {
    display: inline-block;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 2px rgba(0,0,0,0.2);
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.link-btn {
    background-color: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    font-size: 1rem;
    padding: 10px 20px;
    display: block;
    margin-bottom: 15px;
}

/* オープニング画面 */
#opening-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(to bottom, #fff0f5, #ffe4e1);
    z-index: 10;
}

.opening-content {
    text-align: center;
    z-index: 2;
    padding: 20px;
}

.game-title {
    font-size: 3rem;
    color: var(--primary-color);
    text-shadow: 2px 2px 0px white, -2px -2px 0px white, 2px -2px 0px white, -2px 2px 0px white;
    margin-bottom: 10px;
    line-height: 1.2;
}

.game-copy {
    font-size: 1.2rem;
    margin-bottom: 40px;
    font-weight: bold;
}

.menu-links {
    margin-top: 30px;
}

#opening-bg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    opacity: 0.6;
    background-image: url('../assets/images/opening_bg.png');
    background-size: cover;
    background-position: center;
}

/* ゲーム画面 */
#game-screen {
    background-color: var(--bg-color);
    position: relative;
}

/* ラスト10秒の赤色アラート演出 */
#game-screen.rush-mode::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 0, 0, 0.25);
    pointer-events: none;
    z-index: 100;
    animation: alert-pulse 0.8s infinite alternate;
}

@keyframes alert-pulse {
    0% { opacity: 0.1; }
    100% { opacity: 1; }
}

/* ----- ゲーム画面 ----- */
#game-bg-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/play_bg.png');
    z-index: 0; /* 背景が前面に出るように変更 */
    opacity: 0.6; /* 少し透過させて上の要素やゲームエリアを見やすくする */
    pointer-events: none; /* クリックの邪魔にならないようにする */
    background-size: cover;
    background-position: center;
}

.ui-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    position: relative;
    z-index: 10;
}

.icon-btn {
    background-color: white;
    border: 2px solid #5d4037;
    border-radius: 8px;
    padding: 5px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
}

.icon-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

.timer-box, .score-box {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    border: 2px solid #5d4037;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.timer-box.rush {
    color: var(--gauge-red);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.game-area {
    position: relative;
    flex: 1;
    width: 100%;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* パワーゲージ */
#power-gauge-container {
    position: absolute;
    bottom: 140px; /* 竿とプールの干渉を避けて上へ */
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    display: none; /* ドラッグ中のみ表示 */
    border: 2px solid white;
    pointer-events: none;
    z-index: 10;
}

#power-gauge-bar {
    width: 0%;
    height: 100%;
    background-color: var(--gauge-green);
    transition: background-color 0.1s, width 0.1s;
}

/* 右上のトレイ */
#tray-container {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 80px;
    background-color: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    padding: 5px;
    border: 2px solid var(--text-color);
    max-height: 50%;
    overflow: hidden;
    pointer-events: none;
}

/* 釣り上げたときのお祝いエフェクト */
#celebration-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    text-align: center;
    pointer-events: none;
    display: none; /* opacityではなくdisplayで切り替える */
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#celebration-overlay.active {
    display: flex; /* クラス付与時に表示 */
    animation: celebrate-pop 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#celebration-img {
    width: 150px;
    height: 150px;
    object-fit: contain;
    filter: drop-shadow(0px 10px 15px rgba(0,0,0,0.4));
}

#celebration-score {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ffeb3b;
    text-shadow: 2px 2px 0 #5d4037, -2px -2px 0 #5d4037, 2px -2px 0 #5d4037, -2px 2px 0 #5d4037;
    margin-top: -20px;
}

@keyframes celebrate-pop {
    0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
    15% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
    25% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
    85% { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
    100% { transform: translate(-50%, -100%) scale(0.5); opacity: 0; }
}

.tray-title {
    font-size: 0.8rem;
    text-align: center;
    border-bottom: 1px solid var(--text-color);
    margin-bottom: 5px;
}

#tray-items {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.tray-item {
    width: 20px;
    height: 20px;
    border-radius: 50%;
}

/* 大げさな釣り竿ベース（キャンバス描画に切り替えたため非表示） */
#rod-base {
    display: none;
}

.rod-handle {
    width: 60px;
    height: 60px;
    background-color: #8d6e63;
    border-radius: 30px 30px 0 0;
    border: 4px solid #5d4037;
    border-bottom: none;
}

/* リザルト画面 */
#result-screen {
    background-color: var(--secondary-color);
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.result-content {
    text-align: center;
    width: 90%;
    max-height: 90%;
    background-color: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.result-content h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

.final-score {
    font-size: 1.8rem;
    font-weight: bold;
    margin-bottom: 20px;
}

#showcase-container {
    flex: 1;
    background-color: #ffe0b2; /* お盆の色 */
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 20px;
    min-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 10px;
    justify-content: center;
    border: 4px solid #8d6e63;
}

.showcase-item {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: white;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    position: relative;
}

/* ひっぱった時のエフェクト用 */
.pulling {
    cursor: grabbing !important;
}

/* ランキング画面 */
#ranking-screen {
    background-color: var(--secondary-color);
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.ranking-content {
    text-align: center;
    width: 90%;
    max-height: 90%;
    background-color: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.ranking-content h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

#ranking-list {
    list-style: none;
    text-align: left;
    margin: 0 auto;
    width: 100%;
    max-width: 300px;
    padding: 0;
}

#ranking-list li {
    font-size: 1.2rem;
    padding: 10px;
    border-bottom: 1px dashed #ccc;
    display: flex;
    justify-content: space-between;
}

#ranking-list li:nth-child(1) { font-weight: bold; color: #d4af37; font-size: 1.5rem; }
#ranking-list li:nth-child(2) { font-weight: bold; color: #c0c0c0; }
#ranking-list li:nth-child(3) { font-weight: bold; color: #cd7f32; }

/* お菓子がぷるんとするアニメーションクラス */
.jiggle {
    animation: jiggle 0.4s ease-in-out;
}

@keyframes jiggle {
    0% { transform: scale(1); }
    25% { transform: scale(1.2, 0.8); }
    50% { transform: scale(0.8, 1.2); }
    75% { transform: scale(1.1, 0.9); }
    100% { transform: scale(1); }
}
