:root {
    --primary: #5E81F4;
    --secondary: #FF9F3F;
    --correct: #4CAF50;
    --incorrect: #F44336;
    --background: #F7F9FC;
    --card-bg: #FFFFFF;
    --text: #2E3A59;
}

body {
    font-family: 'HiraKakuProN-W3', sans-serif;
    max-width: 400px;
    margin: 0 auto;
    padding: 15px;
    background-color: var(--background);
    color: var(--text);
    overflow-x: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    gap: 0px;
    height: 550px; /* 全体の高さを固定 */
    overflow: hidden; /* はみ出し防止 */
}

.celebration-area {
    height: 150px;
    margin: 0;
    position: relative;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.card-container {
    perspective: 900px;
    height: 120px;
    margin: 10px 0;
}

.card {
    width: calc(100% - 20px); /* 左右に10pxの余裕 */
    margin: 0 auto; /* 中央揃え */
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.5s;
    cursor: pointer;
    border-radius: 15px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    background: var(--card-bg);
    border: 2px solid #e0e0e0; /* 境界線を明確に */
}

.card.flipped {
    transform: rotateY(180deg);
}

.card .front, .card .back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center; /* 上下中央 */
    text-align: center; /* 左右中央 */
    font-size: 24px; /* 適切なサイズに */
    font-weight: bold;
    padding: 10px; /* 余白調整 */
    margin: 5;
    box-sizing: border-box; /* paddingを含めたサイズ計算 */
}

.card .back {
    transform: rotateY(180deg);
}

.answer-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.answer-btn {
    padding: 20px 10px;
    font-size: 22px;
    border: none;
    border-radius: 12px;
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.answer-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 5px;
}

.main-button {
    padding: 15px 30px;
    font-size: 20px;
    border: none;
    border-radius: 10px;
    background-color: var(--secondary);
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.sub-button {
    padding: 15px 30px;
    font-size: 20px;
    border: 3px solid var(--secondary);
    border-radius: 10px;
    background-color: white;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.main-button:hover, .sub-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

/* アニメーション */
@keyframes bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-30px) scale(1.2); }
}

@keyframes explode {
    0% { transform: scale(0); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

@keyframes fireworks {
    0% { transform: translate(0, 0) scale(0); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(1); opacity: 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.celebration-effect {
    position: absolute;
    font-size: 52px;
    font-weight: bold;
    animation: bounce 0.8s ease infinite, float 3s ease-in-out infinite;
    color: var(--secondary);
    text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
    white-space: nowrap;
    z-index: 20;
}

.star-burst {
    position: absolute;
    font-size: 80px;
    animation: explode 1.5s ease-out forwards;
    color: #FFD700;
    z-index: 15;
    text-shadow: 0 0 10px rgba(255,215,0,0.7);
}

.firework {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: fireworks 1.5s ease-out forwards;
    box-shadow: 0 0 10px 2px currentColor;
}

.confetti {
    position: absolute;
    width: 15px;
    height: 15px;
    animation: float 3s ease-in-out infinite;
    opacity: 0.8;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 10px 5px rgba(255,159,63,0.5); }
    50% { box-shadow: 0 0 20px 10px rgba(255,159,63,0.8); }
}

.glow-effect {
    animation: glow 1.5s ease-in-out infinite alternate;
}