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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.game-info {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.score {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 1.1rem;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

button {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

button:active {
    transform: translateY(0);
}

select {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
}

.game-board {
    display: grid;
    gap: 15px;
    justify-content: center;
    margin: 0 auto;
    max-width: 800px;
}

.game-board.easy {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
}

.game-board.medium {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.game-board.hard {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.card {
    width: 120px;
    height: 120px;
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border-radius: 15px;
    cursor: pointer;
    position: relative;
    transition: all 0.6s ease;
    transform-style: preserve-3d;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.card:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

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

.card.matched {
    border: 3px solid #2ECC71 !important;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.5) !important;
}

.card.matched:hover {
    transform: scale(1.05) rotateY(180deg) !important;
}

.card.matched .card-back {
    background: rgba(255, 255, 255, 0.98) !important;
    border: 2px solid #27AE60;
    border-radius: 13px;
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-front {
    background: linear-gradient(145deg, #FF6B6B, #FF8E53);
    color: white;
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.card-back {
    background: white;
    transform: rotateY(180deg);
    padding: 10px;
}

.card-back img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.1));
}

.service-name {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    font-weight: bold;
    color: #333;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-complete {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    margin-top: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.game-complete h2 {
    color: #4ECDC4;
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.game-complete p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.hidden {
    display: none !important;
}

.flip-animation {
    animation: flip 0.6s ease-in-out;
}

@keyframes flip {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(180deg); }
}

.match-animation {
    animation: match 0.8s ease-in-out;
}

@keyframes match {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); background: linear-gradient(145deg, #4ECDC4, #44A08D); }
    100% { transform: scale(0.95); background: linear-gradient(145deg, #4ECDC4, #44A08D); }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .score {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .card {
        width: 80px;
        height: 80px;
    }
    
    .game-board {
        gap: 10px;
    }
    
    .service-name {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .card {
        width: 60px;
        height: 60px;
    }
    
    .game-board {
        gap: 8px;
    }
    
    .service-name {
        font-size: 0.5rem;
    }
}

/* サービス情報ポップアップ */
.service-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-in-out;
}

.popup-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

.popup-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.popup-close:hover {
    background: #f0f0f0;
    color: #333;
}

.popup-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.popup-header img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.popup-header h3 {
    color: #333;
    font-size: 1.5rem;
    margin: 0;
}

.popup-body p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #555;
}

.popup-body strong {
    color: #333;
}

#popup-description {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 10px;
    border-left: 4px solid #4ECDC4;
    margin-top: 10px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
