:root {
    --bg-color: #0f172a;
    --card-bg: #ffffff;
    --primary: #6366f1;
    --secondary: #ec4899;
    --accent: #10b981;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --card-width: 180px;
    --card-height: 252px;
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

header {
    text-align: center;
    width: 100%;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
}

.score-board {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 15px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-item .label {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    font-weight: 700;
}

.score-item .value {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
}

main {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-area {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.card-container {
    perspective: 1000px;
}

.card {
    width: var(--card-width);
    height: var(--card-height);
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.card-front {
    background-color: var(--card-bg);
    color: #1e293b;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
    transform: rotateY(0deg);
}

.card-back {
    background-color: #312e81;
    background-image: radial-gradient(circle at 2px 2px, rgba(255,255,255,0.1) 1px, transparent 0);
    background-size: 8px 8px;
    border: 5px solid #fff;
    transform: rotateY(180deg);
}

.card-suit-top {
    text-align: left;
    font-size: 1.5rem;
}

.card-suit-bottom {
    text-align: right;
    font-size: 1.5rem;
    transform: rotate(180deg);
}

.card-value {
    font-size: 4rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.card-front[data-suit="0"] .card-suit-top::after,
.card-front[data-suit="0"] .card-suit-bottom::after { content: "♠"; color: #1e293b; }
.card-front[data-suit="1"] .card-suit-top::after,
.card-front[data-suit="1"] .card-suit-bottom::after { content: "♥"; color: #ef4444; }
.card-front[data-suit="2"] .card-suit-top::after,
.card-front[data-suit="2"] .card-suit-bottom::after { content: "♣"; color: #1e293b; }
.card-front[data-suit="3"] .card-suit-top::after,
.card-front[data-suit="3"] .card-suit-bottom::after { content: "♦"; color: #ef4444; }

.message {
    font-size: 1rem;
    color: var(--text-muted);
    height: 24px;
}

.controls {
    display: flex;
    gap: 20px;
    width: 100%;
}

.btn {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn.primary { background-color: var(--primary); color: white; }
.btn.secondary { background-color: var(--secondary); color: white; }
.btn.accent { background-color: var(--accent); color: white; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.overlay {
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.result-box {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#result-title {
    font-size: 2rem;
    margin-bottom: 10px;
    color: #ef4444;
}

.result-box p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

footer {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 30px;
    margin-top: 40px;
}

.ad-area {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
}

.ad-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.footer-links {
    text-align: center;
    padding-bottom: 20px;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--text);
}

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

.shake {
    animation: shake 0.2s ease-in-out;
}

@keyframes flash-correct {
    0%, 100% { background-color: var(--bg-color); }
    50% { background-color: rgba(16, 185, 129, 0.2); }
}

.flash-correct {
    animation: flash-correct 0.5s ease-out;
}

@keyframes flash-wrong {
    0%, 100% { background-color: var(--bg-color); }
    50% { background-color: rgba(239, 68, 68, 0.2); }
}

.flash-wrong {
    animation: flash-wrong 0.5s ease-out;
}

/* Mobile optimizations */
@media (max-width: 400px) {
    :root {
        --card-width: 150px;
        --card-height: 210px;
    }
    
    .card-value {
        font-size: 3rem;
    }
    
    h1 {
        font-size: 2rem;
    }
}
