/* ★ここから追加/修正 */
html, body {
    height: 100%; /* HTMLとBodyが画面の高さいっぱいになるように設定 */
    margin: 0;
    padding: 0;
    overflow: hidden; /* 全体のはみ出しを防止 */
}
/* ★ここまで追加/修正 */

body {
    /* ここにzoomプロパティを追加しました */
    zoom: 0.85; /* 全体を85%に縮小 */
    -moz-transform: scale(0.85); /* Firefox対応 */
    -moz-transform-origin: top left; /* Firefox対応: 左上を基準に縮小 */

    font-family: 'Arial', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f0f0f0;
    user-select: none; /* テキスト選択を無効化 */
    -webkit-tap-highlight-color: transparent; /* タップ時のハイライトを非表示 */
}

.container {
    display: flex;
    flex-direction: column; /* 要素を縦方向に並べる */
    justify-content: space-between; /* 子要素間に均等なスペースを配置 */
    align-items: center;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 90%; /* スマホ画面に合わせて幅を調整 */
    max-width: 450px; /* ある程度の最大幅を設定 */
    box-sizing: border-box; /* paddingを含めて幅を計算 */
    height: 100%; /* 親要素 (body) の高さを100%継承 */
    max-height: 95vh; /* スマホのUIバーなどを考慮して最大高さを設定 */
}

.game-area {
    width: 100%;
    flex-grow: 1; /* 使用可能なスペースを埋めるように伸びる */
    display: flex; /* 内部の table を中央配置するため */
    justify-content: center;
    align-items: center;
}

.table {
    width: 100%; /* game-area の中で横幅いっぱいに */
    background-color: #deb887; /* 薄茶色 */
    border-radius: 10px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3列 */
    grid-template-rows: repeat(5, 1fr); /* 5行 */
    gap: 8px; /* カード間の隙間を少し小さく */
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    aspect-ratio: 3 / 5; /* 縦横比を3:5に固定 */
    max-width: 300px; /* テーブルの最大幅を制限して小さすぎる画面でもカードが大きすぎないように */
    max-height: 500px; /* テーブルの最大高さを制限 */
}

/* カードのスタイルは前回と同じ構造で調整 */
.card {
    width: 100%;
    height: 100%;
    position: relative;
    perspective: 1000px;
    cursor: pointer;
    box-sizing: border-box;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2em; /* スマホ向けに少し調整 */
    font-weight: bold;
}

.card-back {
    background-color: #87ceeb; /* 水色 */
}

.card-front {
    background-color: #f8f8f8;
    color: #333;
    transform: rotateY(180deg);
}

/* ドクロカードの特別な色 */
.card-front.skull {
    color: #dc3545; /* 赤色など目立つ色に */
}

.card.matched {
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 2s, opacity 2s ease-out;
    transform: scale(0);
    pointer-events: none;
}

/* 燃えるようなエフェクト */
.card.burning {
    animation: burnEffect 2s forwards;
    pointer-events: none;
}

@keyframes burnEffect {
    0% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 165, 0, 0.7), 0 0 20px rgba(255, 69, 0, 0.5);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1);
        box-shadow: 0 0 30px rgba(255, 165, 0, 1), 0 0 60px rgba(255, 69, 0, 0.8), 0 0 90px rgba(255, 0, 0, 0.6);
    }
    100% {
        opacity: 0;
        transform: scale(0.5);
        box-shadow: none;
        visibility: hidden;
    }
}

.game-message {
    margin-top: 10px; /* カードエリアとの間隔 */
    margin-bottom: 10px; /* ボタンとの間隔 */
    font-size: 1.8em;
    font-weight: bold;
    color: #007bff;
    text-align: center;
    min-height: 1.8em; /* メッセージの行高分のスペースを確保 */
    width: 100%; /* 横幅いっぱいに広げる */
}

.start-button {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2em;
    font-weight: bold;
    transition: background-color 0.3s ease;
    width: 80%;
    max-width: 200px;
}

/* 花火エフェクトのためのCanvasスタイル */
#fireworksCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000; /* 最前面に表示 */
    pointer-events: none; /* クリックを透過させる */
    display: none; /* 初期は非表示 */
}