@import url('https://fonts.googleapis.com/css2?family=Mochiy+Pop+One&family=Kosugi+Maru&display=swap');

:root {
    --primary: #ff6b35;
    --secondary: #2b6cb0;
    --accent: #ffd166;
    --dark: #2d2d34;
    --gray: #f2f4f7;
    --line: #e1e5eb;
    --asphalt: #3a3f4b;
    --radius: 20px;
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
    font-family: 'Kosugi Maru', sans-serif;
    background: linear-gradient(180deg, #dfeaff 0%, #f2f4f7 320px);
    color: var(--dark);
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .scr-title, .mc-logo, .auth-title { font-family: 'Mochiy Pop One', cursive; }
button { font-family: inherit; cursor: pointer; }
input, select {
    font-family: inherit; font-size: 1rem;
    padding: 10px 14px; border: 3px solid var(--line); border-radius: 14px;
    width: 100%; background: #fff;
}
input:focus, select:focus { border-color: var(--secondary); outline: none; }
label { display: block; margin-bottom: 14px; font-weight: bold; font-size: 0.9rem; }
label input, label select { margin-top: 6px; font-weight: normal; }

#app { max-width: 900px; margin: 0 auto; padding: 0 14px 60px; }

/* ---- ヘッダー ---- */
.mc-head { display: flex; align-items: center; gap: 12px; padding: 14px 4px; flex-wrap: wrap; }
.mc-logo { font-size: 1.3rem; color: var(--primary); text-shadow: 2px 2px 0 #fff; cursor: pointer; }
.mc-sub { font-size: 0.85rem; color: #888; flex: 1; }
.mc-coins { background: #fff; border: 3px solid var(--accent); border-radius: 50px; padding: 4px 14px; font-size: 0.95rem; box-shadow: 0 3px 0 rgba(0,0,0,0.08); }

/* ---- 共通ボタン ---- */
.btn-big {
    display: block; width: 100%; max-width: 380px; margin: 18px auto 0;
    background: var(--primary); color: #fff; border: none; border-radius: 50px;
    padding: 15px 20px; font-size: 1.1rem; font-weight: bold;
    box-shadow: 0 5px 0 #c94f24; transition: transform 0.1s;
}
.btn-big:hover { transform: translateY(2px); box-shadow: 0 3px 0 #c94f24; }
.btn-mini { background: var(--secondary); color: #fff; border: none; border-radius: 50px; padding: 10px 18px; font-size: 0.9rem; font-weight: bold; box-shadow: 0 3px 0 #1c4a7a; }
.btn-back { display: block; margin: 20px auto 0; background: none; border: none; color: #888; font-size: 0.9rem; text-decoration: underline; }
.scr-title { text-align: center; color: var(--secondary); margin: 10px 0 16px; }

.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(20px); background: #333; color: #fff; padding: 12px 22px; border-radius: 50px; font-size: 0.9rem; opacity: 0; transition: all 0.3s; z-index: 999; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-err { background: #c0392b; }

/* ---- 認証 ---- */
.auth-wrap { max-width: 460px; margin: 20px auto; background: #fff; border: 4px solid var(--primary); border-radius: var(--radius); padding: 26px; box-shadow: 0 8px 0 rgba(0,0,0,0.08); }
.auth-title { text-align: center; color: var(--primary); margin: 0; font-size: 1.9rem; }
.auth-catch { text-align: center; color: #888; font-size: 0.85rem; margin-top: 4px; }
.auth-tabs { display: flex; gap: 6px; margin: 18px 0; }
.auth-tab { flex: 1; background: var(--gray); border: 2px solid var(--line); border-radius: 50px; padding: 8px 4px; font-size: 0.85rem; font-weight: bold; color: #777; }
.auth-tab.on { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.auth-note { font-size: 0.75rem; color: #999; margin-top: 16px; }

/* ---- ホーム ---- */
.home-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; }
.home-car { flex: 0 0 240px; text-align: center; background: #fff; border: 4px solid var(--accent); border-radius: var(--radius); padding: 16px; box-shadow: 0 6px 0 rgba(0,0,0,0.08); }
.home-menu { flex: 1; min-width: 260px; display: grid; gap: 12px; }
.menu-card { text-align: left; background: #fff; border: 3px solid var(--line); border-radius: 16px; padding: 14px 18px; font-size: 1.05rem; font-weight: bold; color: var(--dark); box-shadow: 0 4px 0 rgba(0,0,0,0.06); transition: transform 0.1s; }
.menu-card:hover { transform: translateY(-2px); border-color: var(--secondary); }
.menu-card small { display: block; font-size: 0.78rem; color: #999; font-weight: normal; }
.menu-hot { border-color: var(--primary); background: #fff6f0; }

/* ---- 選択画面（難易度・オンライン） ---- */
.sel-wrap { background: #fff; border: 4px solid var(--secondary); border-radius: var(--radius); padding: 24px; }
.sel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.sel-card { background: var(--gray); border: 3px solid var(--line); border-radius: 16px; padding: 18px; font-size: 1.05rem; font-weight: bold; }
.sel-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.sel-easy { border-color: #2ecc71; } .sel-normal { border-color: #f1c40f; } .sel-hard { border-color: #e67e22; } .sel-extreme { border-color: #e74c3c; }
.on-desc { color: #666; font-size: 0.9rem; }
.on-waitlist { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0; min-height: 40px; }
.on-waitchip { background: var(--gray); border: 2px solid var(--line); border-radius: 50px; padding: 8px 16px; font-weight: bold; font-size: 0.9rem; }
.on-waitchip.is-bot { border-color: #bbb; color: #888; }
.on-waitnote { text-align: center; font-size: 0.85rem; color: #888; }

/* ---- レース画面 ---- */
.mc-race { background: var(--asphalt); border-radius: var(--radius); padding: 16px; position: relative; }
.mc-race.mc-shake-race { animation: mc-race-shake 0.4s; }
@keyframes mc-race-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translate(-6px, 2px); }
    40% { transform: translate(5px, -2px); }
    60% { transform: translate(-4px, 1px); }
    80% { transform: translate(3px, -1px); }
}

/* 正解・コンボ・ニトロの派手な演出 */
.mc-particle {
    position: absolute; pointer-events: none; font-size: 1.3rem; z-index: 20;
    transform: translate(-50%, -50%);
    animation: mc-particle-fly 0.7s ease-out forwards;
}
@keyframes mc-particle-fly {
    0% { transform: translate(-50%, -50%) scale(0.6); opacity: 1; }
    100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2); opacity: 0; }
}

.mc-bigtext {
    position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0.6);
    font-family: 'Mochiy Pop One', cursive; font-size: 1.9rem; color: #fff;
    text-shadow: 0 0 10px rgba(0,0,0,0.5), 0 0 22px currentColor;
    white-space: nowrap; z-index: 30; pointer-events: none;
    animation: mc-bigtext-pop 0.9s ease-out forwards;
}
@keyframes mc-bigtext-pop {
    0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    15% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}
.mc-combo-big { color: var(--accent); }
.mc-gold-big { color: #ffe9a8; }
.mc-nitro-big { color: #7fd8ff; }

.flash-ok { animation: mc-flash-ok 0.38s ease-out; }
@keyframes mc-flash-ok {
    0% { text-shadow: 0 0 0 rgba(110,231,168,0); }
    30% { text-shadow: 0 0 18px rgba(110,231,168,0.95); color: #6ee7a8; }
    100% { text-shadow: 0 0 0 rgba(110,231,168,0); }
}

.mc-combo-break { animation: mc-combo-break 0.4s; }
@keyframes mc-combo-break {
    0%, 100% { color: #fff; }
    40% { color: #ff8a8a; transform: scale(0.92); }
}

.mc-hop { animation: mc-hop 0.38s ease-out; }
@keyframes mc-hop {
    0%, 100% { transform: translateY(-50%); }
    35% { transform: translateY(-70%) scale(1.06); }
}
.mc-track { display: flex; flex-direction: column; gap: 6px; background: repeating-linear-gradient(180deg, #4a4f5c 0 2px, #3a3f4b 2px 40px); border-radius: 14px; padding: 8px; }
.mc-lane { display: flex; align-items: center; gap: 10px; }
.mc-lane-road { position: relative; flex: 1; height: 46px; background: #555b6b; border-radius: 8px; overflow: hidden; border-bottom: 3px dashed #ffd166aa; }
.mc-lane-car { position: absolute; top: 50%; transform: translateY(-50%); transition: left 0.25s linear; z-index: 2; }
.mc-lane-flag { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 1.3rem; z-index: 1; }
.mc-lane-label { width: 92px; flex-shrink: 0; color: #fff; font-size: 0.72rem; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-lane.is-player .mc-lane-road { outline: 2px solid var(--accent); }
.mc-lane.is-finished .mc-lane-road { outline: 2px solid #2ecc71; }
.mc-flame { animation: flame-flicker 0.15s infinite alternate; }
@keyframes flame-flicker { from { opacity: 0.85; } to { opacity: 1; transform: scale(1.05); } }

.mc-hud { display: flex; justify-content: space-between; margin-top: 12px; color: #fff; font-weight: bold; font-size: 0.95rem; flex-wrap: wrap; gap: 8px; }
.mc-combo { background: rgba(255,255,255,0.12); border-radius: 50px; padding: 4px 14px; transition: transform 0.15s; }
.mc-combo.pop { animation: combo-pop 0.25s; }
@keyframes combo-pop { 0% { transform: scale(1.4); } 100% { transform: scale(1); } }
.mc-combo-hot { color: var(--accent); }
.mc-nitro { background: rgba(255,255,255,0.12); border-radius: 50px; padding: 4px 14px; }

.mc-worddisp { text-align: center; font-size: 1.9rem; color: #fff; margin-top: 18px; font-family: 'Mochiy Pop One', cursive; min-height: 2.4em; display: flex; align-items: center; justify-content: center; }
.mc-worddisp.is-gold { color: var(--accent); text-shadow: 0 0 10px rgba(255,209,102,0.8); }
.mc-worddisp ruby { ruby-align: center; }
.mc-worddisp rt { font-family: 'Kosugi Maru', sans-serif; font-size: 0.9rem; color: #ffe9c2; }
.mc-wordromaji { text-align: center; font-size: 1.6rem; letter-spacing: 2px; margin-top: 6px; font-family: monospace, 'Kosugi Maru'; }
.mc-wordromaji span.ok { color: #6ee7a8; }
.mc-wordromaji span.bad { color: #ff6b6b; text-decoration: underline wavy; }
.mc-wordromaji span.pending { color: #9aa1b1; }
.mc-wordromaji.shake { animation: mc-shake 0.25s; }
@keyframes mc-shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.mc-typein { max-width: 380px; margin: 14px auto 0; display: block; text-align: center; font-size: 1.2rem; letter-spacing: 2px; }
.mc-nitrohint { text-align: center; color: #cfd4e0; font-size: 0.78rem; margin-top: 10px; }
.mc-nitrohint kbd { background: #555; border-radius: 4px; padding: 1px 6px; }

/* ---- 結果画面 ---- */
.res-wrap { background: #fff; border: 4px solid var(--primary); border-radius: var(--radius); padding: 24px; text-align: center; }
.res-stats { display: flex; justify-content: center; gap: 24px; font-size: 1.05rem; background: var(--gray); border-radius: 14px; padding: 12px; flex-wrap: wrap; }
.res-actions { text-align: center; margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; align-items: center; }
.res-actions .btn-big { margin: 0; width: auto; }
.quiz-empty { text-align: center; color: #888; padding: 30px 0; }

/* ---- ガチャ ---- */
.gc-wrap { background: #fff; border: 4px solid var(--accent); border-radius: var(--radius); padding: 24px; text-align: center; }
.gc-machine { font-size: 4.5rem; margin: 8px 0; display: inline-block; }
.gc-machine.spin { animation: spin-shake 0.9s; }
@keyframes spin-shake { 0%,100%{transform:rotate(0)} 20%{transform:rotate(-15deg)} 40%{transform:rotate(12deg)} 60%{transform:rotate(-9deg)} 80%{transform:rotate(6deg)} }
.gc-rates { font-size: 0.75rem; color: #999; }
.gc-card { display: inline-block; background: #fff; border: 4px solid; border-radius: 16px; padding: 16px 30px; margin-top: 10px; box-shadow: 0 5px 0 rgba(0,0,0,0.08); }
.gc-card.gc-new { animation: pop-in 0.4s; }
@keyframes pop-in { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.gc-emoji { font-size: 3rem; display: block; }
.gc-swatchbig { display: block; width: 60px; height: 60px; border-radius: 50%; margin: 0 auto; }
.gc-rar { display: inline-block; color: #fff; font-size: 0.75rem; border-radius: 50px; padding: 2px 12px; font-weight: bold; margin: 4px 0; }
.gc-card p { font-size: 0.8rem; color: #888; margin: 4px 0 0; }
.gc-invtitle { margin: 22px 0 8px; }
.gc-inv { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.gc-item { display: inline-flex; flex-direction: column; align-items: center; border: 3px solid; border-radius: 12px; padding: 6px 10px; font-size: 1.5rem; background: var(--gray); }
.gc-item small { font-size: 0.6rem; font-weight: bold; color: #888; }
.gc-swatch { display: block; width: 24px; height: 24px; border-radius: 50%; }
.gc-none { color: #999; }

/* ---- ガレージ ---- */
.dr-wrap { background: #fff; border: 4px solid var(--secondary); border-radius: var(--radius); padding: 24px; }
.dr-preview { text-align: center; background: var(--gray); border-radius: 16px; padding: 10px; }
.dr-slot { margin-top: 14px; }
.dr-slotname { font-weight: bold; font-size: 0.9rem; }
.dr-items { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.dr-item { border: 3px solid var(--line); background: #fff; border-radius: 12px; padding: 8px 12px; font-size: 1.3rem; }
.dr-item.on { outline: 3px solid var(--primary); outline-offset: 1px; }
.dr-swatch { display: block; width: 22px; height: 22px; border-radius: 50%; }

/* ---- せってい ---- */
.st-wrap { background: #fff; border: 4px solid var(--line); border-radius: var(--radius); padding: 24px; }
.st-mode { font-size: 0.85rem; color: #888; text-align: center; }
.st-block { border-top: 2px dashed var(--line); padding: 14px 0; }
.st-block h3 { font-size: 0.95rem; margin: 0 0 6px; }
.st-desc { font-size: 0.8rem; color: #888; margin: 0 0 8px; }
.st-toggle { display: flex; gap: 8px; }
.st-opt { flex: 1; background: var(--gray); border: 2px solid var(--line); border-radius: 50px; padding: 10px 6px; font-size: 0.85rem; font-weight: bold; color: #777; }
.st-opt.on { background: var(--secondary); border-color: var(--secondary); color: #fff; }
.st-block input { max-width: 300px; display: inline-block; margin-right: 8px; }

@media (max-width: 640px) {
    .mc-lane-label { width: 64px; font-size: 0.65rem; }
    .mc-worddisp { font-size: 1.4rem; }
    .mc-wordromaji { font-size: 1.2rem; }
    .st-block input, .st-block select { max-width: 100%; margin-bottom: 8px; }
}
