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

body {
    background-image: url('assets/wagashi_bg_1781260408928.png');
    background-size: cover;
    background-position: center;
    background-color: #fce4ec; /* fallback */
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    touch-action: none; /* スマホでのスクロールを防止 */
    padding: 15px; /* 背景が15px分見えるようにする */
    box-sizing: border-box;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 100%;
    max-height: 800px;
    padding: 15px 5px; /* 上下15px、左右5pxの余白 */
    display: flex;
    flex-direction: column;
    background-color: rgba(255, 249, 196, 0.85); /* プレイ画面背景 */
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    border-radius: 15px;
    box-sizing: border-box;
}

#header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px 15px;
    background-color: #ffb74d; /* オレンジっぽい色 */
    border-radius: 10px;
    margin-bottom: 10px;
    color: white;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.info-item {
    font-size: 16px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

#sub-header {
    display: flex;
    justify-content: flex-start; /* 左詰めに変更 */
    gap: 15px; /* ボタン同士の間隔 */
    align-items: center;
    padding: 0 5px;
    margin-bottom: 10px;
}

.sub-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    color: white;
    background-color: #f44336; /* もどるボタンの赤 */
    border: none;
    border-radius: 20px;
    cursor: pointer;
    box-shadow: 0 3px 0 #d32f2f;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

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

#pause-btn {
    background-color: #03a9f4; /* 一時停止の青 */
    box-shadow: 0 3px 0 #0288d1;
}

#next-panel {
    position: absolute;
    top: -40px; /* 元の10pxから50px上へ移動 */
    right: 10px;
    background-color: rgba(255, 249, 196, 0.3); /* 背景の不透明度を30%に変更 */
    border: 2px solid rgba(255, 183, 77, 0.5); /* 枠線も少し透過させると馴染みます */
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    mix-blend-mode: multiply; /* 白背景を完全に透過させるためパネル全体に乗算をかける */
}

#next-canvas {
    width: 52px; /* 35pxの約150%に拡大 */
    height: 105px; /* 70pxの150%に拡大 */
    /* mix-blend-modeは親パネルに移動 */
}

#canvas-wrapper {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    /* overflow: hidden; はみ出しを許可するため削除 */
    position: relative;
    min-height: 0; /* flexbox内で子要素がコンテナを突き破るのを防ぐ */
}

/* 操作ボタンのスタイル */
#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    margin-top: 5px;
}

#left-controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(255, 152, 0, 0.9);
    border: 2px solid #e65100;
    color: white;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 0 #e65100;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

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

.rotate-btn {
    background-color: rgba(76, 175, 80, 0.9);
    border: 2px solid #2e7d32;
    box-shadow: 0 4px 0 #2e7d32;
    width: 60px;
    height: 60px;
    font-size: 14px; /* 元の28pxから半分に縮小 */
}

.rotate-btn:active {
    box-shadow: none;
}

canvas {
    display: block;
}

#game-canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background-color: #fff9c4; /* 乗算で綺麗な黄色になるように単色を指定 */
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    border-radius: 10px;
    border: 3px solid #ffb74d;
    mix-blend-mode: multiply; /* 白背景を透明化し、Wagashiを美しく重ねる魔法の設定 */
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 243, 224, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.overlay h1 {
    color: #e65100;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #fff;
    text-align: center;
}

.overlay p {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #5d4037;
    font-weight: bold;
}

.rules-box {
    background-color: rgba(255, 255, 255, 0.9);
    border: 3px solid #ffb74d;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 25px;
    width: 90%;
    max-width: 320px;
    text-align: left;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.overlay .rules-box p {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: #5d4037;
    font-weight: normal;
    line-height: 1.4;
}

.overlay .rules-box p.rule-title {
    font-weight: bold;
    color: #e65100;
    font-size: 1rem;
    margin-bottom: 8px;
}

.rules-box .highlight {
    color: #f44336;
    font-weight: bold;
    background-color: #ffebee;
    padding: 0 4px;
    border-radius: 4px;
}

.btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    background-color: #ff9800;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    margin-bottom: 15px;
    box-shadow: 0 4px 0 #e65100;
    transition: all 0.1s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    width: 80%;
    max-width: 250px;
}

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

.link-btn {
    background-color: #4caf50;
    box-shadow: 0 4px 0 #388e3c;
}

.link-btn:active {
    box-shadow: none;
}

.hidden {
    display: none !important;
}
