* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #333;
    color: #fff;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* スワイプ時のデフォルトスクロールやプルダウンを無効化 */
    overflow: hidden; 
    touch-action: none; 
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #222;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; /* アスペクト比を保持してコンテナに収める（レターボックス化） */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* UIの裏のキャンバスへのタッチを通す */
    display: flex;
    flex-direction: column;
}

#score {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    background: rgba(255, 255, 255, 0.7);
    padding: 5px 15px;
    border-radius: 10px;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto; /* ボタンクリック用 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

.screen h1 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #ffb6c1; /* ケーキっぽく */
    text-shadow: 2px 2px 4px #000;
}

.screen h2 {
    font-size: 48px;
    margin-bottom: 20px;
    color: #ff6b6b;
    text-shadow: 2px 2px 4px #000;
}

.screen p {
    font-size: 18px;
    margin-bottom: 10px;
}

button {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 24px;
    font-weight: bold;
    color: #fff;
    background-color: #ff6b6b;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    transition: transform 0.1s, background-color 0.2s;
}

button:hover {
    background-color: #ff5252;
}

button:active {
    transform: scale(0.95);
}

.clear-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s;
}

.clear-screen.active {
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
    background: rgba(255, 255, 255, 1);
    transition: background 2s ease, opacity 0.3s;
}

.clear-content {
    position: relative;
    z-index: 1;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    background: rgba(255, 255, 255, 0.85); /* 画像と重なっても見やすいように半透明の白背景 */
    padding: 30px 50px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.clear-screen.active .clear-content {
    opacity: 1;
    visibility: visible;
    transition: opacity 1s ease 2s, visibility 0s 2s;
}

.clear-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* 画面いっぱいに広げる（端が見切れる場合はcontainに変更可能） */
    z-index: 0;
    opacity: 0;
    visibility: hidden;
}

.clear-screen.active .clear-image {
    opacity: 1;
    visibility: visible;
    transition: opacity 1s ease 2s, visibility 0s 2s; /* コンテンツと同じタイミングでフェードイン */
}

.clear-candles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
}

.clear-screen.active .clear-candles {
    opacity: 1;
    visibility: visible;
    transition: opacity 1s ease 2s, visibility 0s 2s;
}

.clear-candle-item {
    position: absolute;
    transform: translate(-50%, -100%); /* 足元を基準に配置 */
}

#clear-message {
    font-size: 40px;
    font-weight: bold;
    color: #ff6b6b;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

#clear-score-text {
    font-size: 32px;
    font-weight: bold;
    color: #333;
    margin-bottom: 20px;
}
