:root {
    --primary: #7EC8E3;
    --primary-dark: #4BA3C7;
    --secondary: #FFB6C1;
    --accent: #98D8AA;
    --accent-yellow: #FFE5A0;
    --bg: #F0F8FF;
    --text: #4A4A6A;
    --text-light: #7A7A9A;
    --card-bg: #FFFFFF;
    --shadow: 0 4px 20px rgba(126, 200, 227, 0.2);
    --radius: 16px;
    --japan-color: #FFD700;
    --correct-color: #98D8AA;
    --wrong-color: #FFB6C1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100dvh;
    width: 100vw;
}

.screen {
    display: none;
    width: 100%;
    height: 100dvh;
    position: fixed;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.screen.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

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

/* スプラッシュ画面 */
#splash-screen {
    background: linear-gradient(135deg, #E8F4FD, #FFF0F5, #F0FFF0);
    justify-content: center;
    align-items: center;
}

.splash-content {
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.globe-icon {
    font-size: 80px;
    animation: spin 10s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

#splash-screen h1 {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--primary-dark);
    line-height: 1.4;
    margin-bottom: 12px;
}

.splash-subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 32px;
}

.btn-start {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 16px 48px;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: inherit;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(75, 163, 199, 0.4);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-start:active {
    transform: scale(0.95);
    box-shadow: 0 3px 10px rgba(75, 163, 199, 0.3);
}

/* マップ画面 */
#map-screen {
    flex-direction: column;
}

.app-header {
    background: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    gap: 8px;
}

.header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.header-stats {
    background: var(--accent-yellow);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.btn-album {
    background: linear-gradient(135deg, #FFE5F0, #FFF0F5);
    border: 2px solid var(--secondary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.2s;
}

.btn-album:active {
    transform: scale(0.95);
}

.btn-back {
    background: var(--bg);
    border: 2px solid var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

#map-container {
    flex: 1;
    width: 100%;
    position: relative;
    z-index: 1;
}

.region-buttons {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    overflow-x: auto;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    -webkit-overflow-scrolling: touch;
}

.region-btn {
    flex-shrink: 0;
    background: var(--bg);
    border: 2px solid transparent;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.region-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.region-btn:active {
    transform: scale(0.95);
}

/* モーダル共通 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(74, 74, 106, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--shadow);
    animation: modalIn 0.3s ease;
    max-height: 85dvh;
    overflow-y: auto;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    z-index: 10;
}

/* Twemoji共通 */
.emoji {
    height: 1em;
    width: 1em;
    vertical-align: -0.1em;
    display: inline-block;
}

/* クイズモーダル */
.quiz-content {
    text-align: center;
}

.quiz-header {
    margin-bottom: 20px;
}

.quiz-country-flag {
    font-size: 56px;
    display: block;
    margin-bottom: 12px;
    line-height: 1;
}

.quiz-country-flag .emoji {
    height: 56px;
    width: 56px;
}

.quiz-question {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.6;
}

.quiz-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.quiz-choice-btn {
    background: var(--bg);
    border: 3px solid #E0E8F0;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    line-height: 1.5;
}

.quiz-choice-btn:active {
    transform: scale(0.97);
}

.quiz-choice-btn.correct {
    background: #E8F8E8;
    border-color: var(--correct-color);
    animation: correctPulse 0.5s ease;
}

.quiz-choice-btn.wrong {
    background: #FFE8E8;
    border-color: var(--wrong-color);
    animation: shake 0.4s ease;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

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

.quiz-result {
    margin-top: 16px;
    text-align: center;
}

.quiz-result.hidden {
    display: none;
}

.result-text {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.btn-retry-quiz {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

/* 報酬モーダル */
.reward-content {
    text-align: center;
    overflow: visible;
}

.reward-header {
    margin-bottom: 16px;
}

.reward-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 8px;
    animation: bounceIn 0.5s ease;
}

.reward-country-flag {
    font-size: 48px;
    display: block;
    margin-bottom: 4px;
}

.reward-country-flag .emoji {
    height: 48px;
    width: 48px;
}

.reward-country-name {
    font-size: 1.3rem;
    font-weight: 900;
    color: var(--text);
}

.reward-facts {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    text-align: left;
}

.reward-fact {
    background: var(--bg);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    border-left: 3px solid var(--primary);
}

.reward-fact:nth-child(2) { border-left-color: var(--secondary); }
.reward-fact:nth-child(3) { border-left-color: var(--accent); }

.reward-sticker-area {
    background: linear-gradient(135deg, #FFF8E0, #FFF0F5);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    border: 2px dashed var(--accent-yellow);
}

.sticker-get-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 8px;
}

.sticker-reveal {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 8px;
    animation: stickerPop 0.6s ease;
}

.sticker-reveal .emoji {
    height: 64px;
    width: 64px;
}

@keyframes stickerPop {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    60% { transform: scale(1.3) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.sticker-name {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--text);
}

.sticker-rarity {
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 4px;
    padding: 4px 12px;
    border-radius: 10px;
    display: inline-block;
}

.sticker-rarity.bonbon {
    background: #E8F8FF;
    color: var(--primary-dark);
}

.sticker-rarity.funny {
    background: #F0E8FF;
    color: #7B5EA7;
}

.sticker-rarity.rare {
    background: linear-gradient(135deg, #FFF5D0, #FFE8F0);
    color: #D4A017;
    animation: rareGlow 1.5s ease infinite alternate;
}

@keyframes rareGlow {
    from { box-shadow: 0 0 4px rgba(212, 160, 23, 0.3); }
    to { box-shadow: 0 0 12px rgba(212, 160, 23, 0.6); }
}

.btn-reward-close {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-reward-close:active {
    transform: scale(0.95);
}

/* シールアルバム */
#album-screen {
    background: var(--bg);
}

.album-tabs {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    background: white;
    overflow-x: auto;
}

.album-tab {
    flex-shrink: 0;
    background: var(--bg);
    border: 2px solid transparent;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.album-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-dark);
}

.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.album-cell {
    aspect-ratio: 1;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: relative;
    transition: transform 0.2s;
}

.album-cell:active {
    transform: scale(0.95);
}

.album-cell .sticker-emoji {
    font-size: 36px;
    line-height: 1;
}

.album-cell .sticker-emoji .emoji {
    height: 36px;
    width: 36px;
}

.album-cell .sticker-count {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.7rem;
    font-weight: 900;
    color: var(--primary-dark);
    background: var(--accent-yellow);
    padding: 2px 6px;
    border-radius: 8px;
}

.album-cell.empty {
    background: #F0F0F0;
    border: 2px dashed #DDD;
}

.album-cell.empty .sticker-emoji {
    font-size: 28px;
    opacity: 0.3;
    filter: grayscale(1);
}

/* プログレスバー */
.progress-container {
    position: relative;
    height: 6px;
    background: #E8F0F8;
    z-index: 1000;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 0 4px 4px 0;
    width: 0%;
    transition: width 0.5s ease;
}

/* ローディング */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(240, 248, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1001;
}

.loading-overlay.hidden {
    display: none;
}

.loading-content {
    text-align: center;
}

.loading-globe {
    font-size: 48px;
    animation: spin 3s linear infinite;
    margin-bottom: 12px;
}

.loading-content p {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-dark);
}

/* エラー */
.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1001;
    background: white;
    padding: 24px 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.error-message.hidden {
    display: none;
}

.error-message p {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.btn-retry {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

/* 紙吹雪 */
.confetti-piece {
    position: absolute;
    top: 0;
    animation: confettiFall 1.4s ease forwards;
    pointer-events: none;
    z-index: 10;
}

@keyframes confettiFall {
    0% { opacity: 1; transform: translateY(-20px) rotate(0deg) scale(0); }
    20% { opacity: 1; transform: translateY(10px) rotate(60deg) scale(1.2); }
    100% { opacity: 0; transform: translateY(120px) rotate(360deg) scale(0.5); }
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Leaflet */
.leaflet-container {
    background: #E8F4FD;
}

.country-tooltip {
    background: white;
    border: 2px solid var(--primary);
    border-radius: 8px;
    padding: 6px 12px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* 日本マーカー */
.japan-label {
    background: var(--japan-color);
    border: 2px solid #DAA520;
    border-radius: 12px;
    padding: 4px 10px;
    font-family: 'M PLUS Rounded 1c', sans-serif;
    font-weight: 900;
    font-size: 0.75rem;
    color: #5C4300;
    box-shadow: 0 2px 6px rgba(218, 165, 32, 0.4);
    white-space: nowrap;
}

/* レスポンシブ */
@media (max-width: 480px) {
    .modal-content {
        padding: 20px 16px;
    }
    .quiz-country-flag {
        font-size: 44px;
    }
    .app-header {
        padding: 10px 12px;
    }
    .header-title {
        font-size: 0.9rem;
    }
    .album-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 8px;
        padding: 12px;
    }
}

@media (min-width: 768px) {
    .modal-content {
        max-width: 440px;
        padding: 32px;
    }
    .region-buttons {
        justify-content: center;
    }
    .album-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}
