:root {
    --theme-color: #A0C6D3;
    --text-color: #333333;
    --bg-color: #F8FBFB;
    --white: #FFFFFF;
    --line-color: #06C755;
    --accent-color: #E29B45;
    --card-bg: #FFE8B0;
}

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

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    text-align: center;
    overflow-x: hidden;
    touch-action: manipulation;
    padding-bottom: 60px;
}

header {
    background-color: var(--theme-color);
    color: var(--white);
    padding: 15px 0;
}

.screen {
    display: none;
    padding: 20px;
    min-height: calc(100vh - 115px);
    flex-direction: column;
    align-items: center;
}

.screen.active { display: flex; }

.hero-image { width: 200px; margin-bottom: 20px; }

.primary-btn, .secondary-btn, .line-btn {
    display: inline-block; padding: 15px 30px; font-size: 1.1rem;
    font-weight: bold; border-radius: 30px; border: none;
    text-decoration: none; margin: 10px 0; width: 80%; max-width: 300px;
    cursor: pointer;
}
.primary-btn { background-color: var(--theme-color); color: var(--white); }
.secondary-btn { background-color: #ddd; color: var(--text-color); }
.line-btn { background-color: var(--line-color); color: var(--white); }

/* ============ ゲームヘッダー（情報表示） ============ */
.game-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    padding: 0 10px;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--theme-color);
    font-size: 1rem;
}

.game-header > div {
    background: var(--white);
    border: 2px solid var(--theme-color);
    border-radius: 10px;
    padding: 6px 12px;
    min-width: 80px;
}

#timer {
    transition: color 0.3s;
}

.timer-warning {
    color: #E74C3C !important;
    animation: timerBlink 0.5s infinite;
}

@keyframes timerBlink {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

/* ============ カードボード ============ */
#card-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    padding: 5px;
    perspective: 800px; /* 3D回転の奥行き設定 */
}

/* ============ カード ============ */
.card {
    position: relative;
    aspect-ratio: 3 / 4;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s;
    transform-style: preserve-3d;
}

/* めくられた時の反転 */
.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* 表面（お惣菜の絵） */
.card-front {
    background-color: var(--white);
    border: 2px solid var(--theme-color);
    transform: rotateY(180deg); /* 最初は裏向き */
}

.card-front img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

.card-front-text {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--theme-color);
    padding: 5px;
    word-break: break-all;
}

/* 裏面（クエスチョンマーク等） */
.card-back {
    background: linear-gradient(135deg, var(--theme-color), #7BAABB);
    border: 2px solid #7BAABB;
}

.card-back img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

.card-back-text {
    font-size: 2rem;
    font-weight: bold;
    color: var(--white);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* マッチ成功時 */
.card.matched .card-inner {
    transform: rotateY(180deg); /* 固定 */
}

.card.matched .card-front {
    border-color: #2ECC71;
    box-shadow: 0 0 12px rgba(46, 204, 113, 0.5);
    animation: matchPop 0.4s ease;
}

@keyframes matchPop {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

/* ミス（一致しなかった時） */
.card.miss .card-inner {
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ============ 広告・その他 ============ */
.ad-space { margin: 20px auto; width: 100%; max-width: 320px; text-align: center; }
.ad-label { font-size: 0.7rem; color: #999; margin-bottom: 5px; }

.ad-placeholder { 
    min-height: 50px; 
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.ad-placeholder table,
.ad-placeholder iframe,
.ad-placeholder div {
    margin: 0 auto !important;
}

.keyword-box {
    background-color: var(--white); border: 3px solid var(--theme-color);
    padding: 20px; font-size: 1.5rem; font-weight: bold;
    color: var(--theme-color); border-radius: 10px; margin: 20px 0;
}
.result-score { font-size: 1.2rem; font-weight: bold; margin: 10px 0; }

.result-detail {
    background: #f0f7fa;
    border-radius: 10px;
    padding: 15px;
    margin: 10px 0;
    font-size: 1rem;
}

.result-detail span {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--theme-color);
}

/* フッター広告 */
#global-footer-ad {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    text-align: center;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    min-height: 50px;
}

/* お知らせモーダル */
#notice-modal { 
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(0,0,0,0.6); z-index: 4000; justify-content: center; align-items: center; 
}
#notice-modal.active { display: flex; }
.notice-content { 
    background: white; padding: 25px; border-radius: 20px; width: 85%; max-width: 350px; 
    text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2); border: 4px solid var(--theme-color); 
}
.notice-content h2 { margin-top: 0; color: #E74C3C; font-size: 1.4rem; }
.notice-content p { font-size: 1rem; line-height: 1.6; color: #555; margin: 20px 0; }
.notice-btn { 
    background-color: var(--theme-color); color: white; border: none; padding: 12px 30px; 
    border-radius: 25px; font-weight: bold; cursor: pointer; font-size: 1rem; transition: transform 0.2s; 
}
.notice-btn:active { transform: scale(0.95); }

/* ゲームスタート説明テキスト */
.game-description {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #555;
    margin-bottom: 15px;
}

@keyframes blink { 0% {opacity: 1;} 50% {opacity: 0.6;} 100% {opacity: 1;} }
