:root {
    --primary: #4255ff; --primary-light: #eef1ff; --bg-body: #f7f9fc;
    --bg-card: #ffffff; --text-main: #1f2937; --text-sub: #6b7280;
    --border: #e5e7eb; --success: #10b981; --danger: #ef4444;
    --pill-radius: 50px; --card-radius: 24px;
}
body { font-family: 'Inter', sans-serif; background: var(--bg-body); margin: 0; display: flex; justify-content: center; }
.container { width: 100%; max-width: 900px; padding: 20px; min-height: 100vh; position: relative; }
.screen { display: none !important; }
.screen.active { display: block !important; }
header { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 20px; }
.logo { font-weight: 900; color: var(--primary); font-size: 1.2rem; }
.card { background: var(--bg-card); border-radius: var(--card-radius); padding: 32px 24px; border: 2px solid var(--border); margin-bottom: 20px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-box { background: var(--primary-light); border-radius: 20px; padding: 20px; text-align: center; }
.stat-box small { font-size: 0.75rem; color: var(--text-sub); font-weight: 800; display: block; }
.stat-box span { font-size: 1.8rem; font-weight: 900; color: var(--primary); }
.leaderboard-card { background: var(--primary-light); border-radius: 16px; padding: 20px; margin-top: 20px; margin-bottom: 24px; }

/* ランキング行の基本 */
.rank-item { display: flex; justify-content: space-between; padding: 8px 10px; background: white; margin-bottom: 4px; border-radius: 8px; font-weight: 700; font-size: 0.9rem; color: var(--text-main); }
.rank-item .pts { color: var(--primary); font-weight: 900; }

/* 自分の行（公開時） */
.rank-item.is-me { background: var(--primary); color: white; }
.rank-item.is-me .pts { color: white; }

/* 非公開（ゴースト）時：自分であっても背景を白っぽくし、文字をグレーにする */
.rank-item.is-ghost { 
    background: rgba(255, 255, 255, 0.6) !important; 
    border: 2px dashed var(--text-sub) !important; 
    color: var(--text-sub) !important; 
    opacity: 1; 
}
.rank-item.is-ghost .pts { color: var(--text-sub) !important; }

.status-bar { display: flex; justify-content: space-between; font-weight: 800; color: var(--text-sub); margin-bottom: 10px; }
.progress-rail { height: 8px; background: var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 20px; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.3s; }
.flip-scene { height: 320px; perspective: 1000px; margin-bottom: 20px; }
.flip-card { width: 100%; height: 100%; position: relative; transition: 0.4s; transform-style: preserve-3d; }
.flip-card.is-flipped { transform: rotateY(180deg); }
.card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: var(--card-radius); display: flex; flex-direction: column; align-items: center; justify-content: center; background: white; border: 2px solid var(--border); padding: 20px; box-sizing: border-box; }
.card-face.back { transform: rotateY(180deg); background: var(--primary-light); border-color: var(--primary); }
.flag-img { max-height: 160px; max-width: 100%; object-fit: contain; }
.btn-pill { width: 100%; padding: 18px; border-radius: var(--pill-radius); font-weight: 800; cursor: pointer; border: none; margin-bottom: 12px; font-family: inherit; font-size: 1rem; transition: 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: white; border: 2px solid var(--border); color: var(--text-main); }
.btn-option { background: white; border: 2px solid var(--border); text-align: left; padding-left: 25px; }
.btn-option.correct { background: var(--success); color: white; border-color: var(--success); }
.btn-option.wrong { background: var(--danger); color: white; border-color: var(--danger); }
.auth-pill { display: flex; align-items: center; background: white; border: 2px solid var(--border); padding: 4px 12px; border-radius: 50px; cursor: pointer; }
.user-photo { width: 32px; height: 32px; border-radius: 50%; margin-left: 8px; }
.dropdown { position: absolute; top: 110%; right: 0; background: white; border: 2px solid var(--border); border-radius: 16px; width: 150px; display: none; z-index: 1005; box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
.dropdown.open { display: block; }
.dropdown-item { padding: 12px 16px; cursor: pointer; font-weight: 700; font-size: 0.9rem; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none !important; align-items: center; justify-content: center; z-index: 2000; }
.modal.open { display: flex !important; }
.modal-body { background: white; padding: 30px; border-radius: 24px; width: 90%; max-width: 400px; }
.quiz-overlay { position: fixed; inset: 0; background: rgba(247,249,252,0.98); display: none; flex-direction: column; align-items: center; justify-content: center; z-index: 1000; }
.quiz-overlay.active { display: flex; }
.countdown-text { font-size: 8rem; font-weight: 900; color: var(--primary); }