/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #333;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    overflow: hidden; /* Prevent scrolling */
    touch-action: none; /* Prevent default touch actions like zoom/scroll */
}

/* Container limits to smartphone aspect ratio, centered */
#game-container {
    position: relative;
    width: 100vw;
    max-width: 500px;
    height: 100vh;
    margin: 0 auto;
    background-color: #f0f8ff;
    overflow: hidden;
    /* 上下30pxの余白設定 (内部的に処理するかパディングで処理) */
    padding: 30px 0; 
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.1); /* 背景画像の視認性を上げるために10%に変更 */
    z-index: 10;
}

#menu-screen {
    background-image: url('../assets/img/open_bgp.png');
    background-size: cover;
    background-position: center;
}

.screen.active {
    display: flex;
}

/* Menu & Game Over content */
.menu-content, .gameover-content {
    background: rgba(255, 255, 255, 0.75);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    width: 80%;
}

h1 {
    font-size: 22px;
    color: #e76f51;
    margin-bottom: 10px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.9), -2px -2px 4px rgba(255, 255, 255, 0.9), 2px -2px 4px rgba(255, 255, 255, 0.9), -2px 2px 4px rgba(255, 255, 255, 0.9); /* 背景が透けても読みやすいように白フチ */
}

h2 {
    font-size: 28px;
    color: #e63946;
    margin-bottom: 15px;
}

.catchphrase {
    font-size: 12px;
    color: #264653;
    margin-bottom: 15px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.9), -1px -1px 2px rgba(255, 255, 255, 0.9);
}

#pause-screen {
    background-color: rgba(0, 0, 0, 0.6); /* ポーズ画面はプレイ中と区別するために黒の半透明 */
    color: white;
}
#pause-screen h1 {
    color: white;
    text-shadow: none;
}

button {
    background-color: #f4a261;
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 0 #e76f51;
    transition: transform 0.1s;
    width: 100%;
}

button:active {
    transform: translateY(4px);
    box-shadow: none;
}

.mode-btn {
    font-size: 14px;
    padding: 10px 15px;
}

.small-btn {
    width: auto;
    font-size: 14px;
    padding: 8px 15px;
    background-color: #2a9d8f;
    box-shadow: 0 4px 0 #21867a;
}

.home-btn {
    display: inline-block;
    padding: 8px 15px;
    background-color: #2a9d8f;
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
}

/* Play Screen */
#play-screen {
    background-image: url('../assets/img/play_bg.png');
    background-size: cover;
    background-position: bottom center;
    z-index: 1; /* canvas goes behind UI */
}

#score-display {
    position: absolute;
    top: 50px;
    left: 20px;
    font-size: 36px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    z-index: 20;
}

#spill-display {
    position: absolute;
    top: 90px;
    left: 20px;
    font-size: 20px;
    font-weight: bold;
    color: #ffb6c1;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    z-index: 20;
}

#time-display {
    position: absolute;
    top: 50px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    color: #ff4500;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
    z-index: 20;
}

#rokutaro-container {
    position: absolute;
    top: 10px; /* 初期位置はtop-uiと重なる可能性がありますがJSで即座に設定されます */
    left: 0;
    width: 60px;
    height: 80px;
    z-index: 20;
}

/* ランキング画面用スタイル */
.tabs {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    background: #f1f1f1;
    border-radius: 10px;
    overflow: hidden;
}

.tab-btn {
    flex: 1;
    background: transparent;
    color: #666;
    box-shadow: none;
    border-radius: 0;
    padding: 10px;
    font-size: 14px;
    transition: all 0.2s;
}

.tab-btn:active {
    transform: none;
}

.tab-btn.active-tab {
    background: #f4a261;
    color: white;
    font-weight: bold;
}

.ranking-list {
    text-align: left;
    max-height: 50vh;
    overflow-y: auto;
    padding-right: 5px;
}

.rank-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 5px;
    border-bottom: 1px solid #ddd;
    font-size: 16px;
}

.rank-number {
    font-weight: bold;
    color: #e76f51;
    width: 30px;
}

.rank-score {
    font-weight: bold;
    font-size: 20px;
    flex: 1;
    text-align: left;
}

.rank-date {
    font-size: 12px;
    color: #888;
}

#rokutaro {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#held-dorayaki {
    position: absolute;
    bottom: -15px; /* 六太郎の足元（下部）に配置 */
    left: 10px;
    width: 40px;
    height: 30px;
    z-index: 19;
    object-fit: contain;
    /* 落ちる時以外は表示されています */
}

/* Effects */
#effect-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 30;
}

.perfect-effect {
    position: absolute;
    color: gold;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 1px 1px 2px black;
    animation: floatUp 1s forwards ease-out;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(-30px) scale(1.5); opacity: 1; }
    100% { transform: translateY(-50px) scale(1); opacity: 0; }
}

/* Matter.js Canvas */
canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
}
