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

:root {
    --primary: #6c4ee0;
    --secondary: #2b8a8a;
    --accent: #ffb347;
    --dark: #2a2440;
    --gray: #f4f2fb;
    --line: #e0dcf2;
    --gold: #ffb347;
    --hp: #e74c3c;
    --mp: #3498db;
    --radius: 20px;
}
* { box-sizing: border-box; }
html, body { overflow-x: hidden; }
body {
    font-family: 'Kosugi Maru', sans-serif;
    background: linear-gradient(180deg, #efe9ff 0%, #f4f2fb 320px);
    color: var(--dark);
    margin: 0;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .scr-title, .tp-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(--primary); 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; }

/* ---- ヘッダー ---- */
.tp-head { display: flex; align-items: center; gap: 12px; padding: 14px 4px; flex-wrap: wrap; }
.tp-logo { font-size: 1.25rem; color: var(--primary); text-shadow: 2px 2px 0 #fff; cursor: pointer; }
.tp-sub { font-size: 0.85rem; color: #888; flex: 1; }
.tp-gold { background: #fff; border: 3px solid var(--gold); 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 #4a34a3; transition: transform 0.1s; }
.btn-big:hover { transform: translateY(2px); box-shadow: 0 3px 0 #4a34a3; }
.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 #1c5c5c; }
.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(--primary); 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(--primary); border-color: var(--primary); color: #fff; }
.auth-note { font-size: 0.75rem; color: #999; margin-top: 16px; }

.job-lead { text-align: center; color: #666; font-size: 0.9rem; }
.job-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.job-card { background: #fff; border: 4px solid var(--line); border-radius: var(--radius); padding: 18px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.job-card:hover { border-color: var(--primary); transform: translateY(-3px); }
.job-emoji { font-size: 2.6rem; }
.job-name { font-family: 'Mochiy Pop One', cursive; font-size: 1.15rem; }
.job-desc { font-size: 0.78rem; color: #777; }
.job-stats { font-size: 0.75rem; color: #999; background: var(--gray); border-radius: 10px; padding: 4px; }

/* ---- ホーム ---- */
.home-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; justify-content: center; }
.home-portrait { flex: 0 0 220px; text-align: center; background: #fff; border: 4px solid var(--gold); border-radius: var(--radius); padding: 16px; box-shadow: 0 6px 0 rgba(0,0,0,0.08); }
.tp-portrait-big { font-size: 4.5rem; }
.tp-equiprow { font-size: 1.3rem; display: flex; justify-content: center; gap: 6px; margin: 4px 0; }
.home-nick { font-weight: bold; margin: 6px 0 0; }
.home-lv { font-size: 0.82rem; color: #777; }
.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(--primary); }
.menu-card small { display: block; font-size: 0.78rem; color: #999; font-weight: normal; }
.menu-hot { border-color: var(--primary); background: #f7f4ff; }

/* ---- 汎用ラッパー ---- */
.sel-wrap { background: #fff; border: 4px solid var(--secondary); border-radius: var(--radius); padding: 24px; }

/* ---- ステータス画面 ---- */
.st-wrap { background: #fff; border: 4px solid var(--line); border-radius: var(--radius); padding: 24px; }
.stat-head { display: flex; justify-content: space-between; font-weight: bold; }
.stat-job { color: var(--primary); }
.stat-exp { font-size: 0.85rem; color: #888; }
.stat-expbar { background: #eee; border-radius: 50px; height: 10px; margin: 6px 0 16px; overflow: hidden; }
.stat-expfill { height: 100%; background: linear-gradient(90deg, var(--secondary), var(--primary)); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-row { background: var(--gray); border-radius: 12px; padding: 10px 14px; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.stat-row b { margin-left: auto; }
.stat-plus { background: var(--primary); color: #fff; border: none; border-radius: 50%; width: 26px; height: 26px; font-weight: bold; }
.stat-points { text-align: center; color: var(--accent); font-weight: bold; margin-top: 10px; }
.stat-subtitle { margin-top: 22px; color: var(--secondary); }
.stat-skills { display: grid; gap: 8px; }
.stat-skill { background: var(--gray); border-radius: 12px; padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stat-skill b { flex: 0 0 auto; }
.stat-skill span { color: var(--mp); font-size: 0.8rem; }
.stat-skill small { flex-basis: 100%; color: #888; }
.stat-none { color: #999; font-size: 0.85rem; }
.stat-advance { margin-top: 20px; background: #fff9e9; border: 3px dashed var(--gold); border-radius: 16px; padding: 16px; text-align: center; }

/* ---- ステージ選択 ---- */
.area-title { color: var(--secondary); margin: 18px 0 8px; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stage-card { background: var(--gray); border: 3px solid var(--line); border-radius: 14px; padding: 14px 8px; text-align: center; display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; }
.stage-card:not(.is-locked):hover { border-color: var(--primary); transform: translateY(-2px); }
.stage-card.is-boss { border-color: var(--gold); background: #fff8e8; }
.stage-card.is-locked { opacity: 0.5; cursor: not-allowed; }
.stage-icon { font-size: 1.6rem; }
.stage-name { font-weight: bold; }
.stage-lv { color: #888; font-size: 0.75rem; }
.stage-clear { color: #2ecc71; font-size: 0.72rem; font-weight: bold; }
.stage-lock { font-size: 0.9rem; }
.stage-rec { text-align: center; color: #888; }
.stage-enemies-preview { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 16px 0; }
.preview-enemy { text-align: center; font-size: 2rem; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.preview-enemy small { font-size: 0.7rem; color: #666; }
.preview-elem { font-size: 0.68rem; color: #fff; border-radius: 20px; padding: 1px 8px; }
.stage-flavor { text-align: center; font-style: italic; color: #666; }
.stage-warn { text-align: center; color: #c0392b; font-size: 0.82rem; font-weight: bold; }

/* ---- バトル画面 ---- */
.tp-battle { background: linear-gradient(180deg, #241c3d, #3a2d5c); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; }
.tp-battle.tp-shake { animation: tp-shake 0.4s; }
@keyframes tp-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)} }

.tp-enemies { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 10px; }
.tp-enemy { background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.2); border-radius: 14px; padding: 10px; text-align: center; width: 120px; color: #fff; transition: opacity 0.3s; }
.tp-enemy.is-dead { opacity: 0.3; }
.tp-enemy.is-boss { width: 160px; border-color: var(--gold); }
.tp-enemy.tp-hit { animation: tp-hitflash 0.35s; }
@keyframes tp-hitflash { 0%,100%{filter:none} 50%{filter:brightness(2.2)} }
.tp-enemy-emoji { font-size: 2.4rem; display: block; }
.tp-enemy-name { font-size: 0.78rem; font-weight: bold; display: block; }
.elem-badge { display: inline-block; font-size: 0.68rem; color: #fff; border-radius: 20px; padding: 1px 8px; margin: 3px 0; }
.tp-hpbar { background: rgba(0,0,0,0.35); border-radius: 50px; height: 8px; overflow: hidden; margin-top: 3px; }
.tp-hpfill { height: 100%; background: linear-gradient(90deg, #ff6b6b, var(--hp)); transition: width 0.35s; }
.tp-hptext { font-size: 0.68rem; color: #ddd; }
.tp-statusrow { font-size: 0.9rem; min-height: 1.2em; }

.tp-log { background: rgba(0,0,0,0.28); border-radius: 12px; padding: 8px 12px; color: #fff; font-size: 0.78rem; max-height: 90px; overflow-y: auto; margin-bottom: 10px; }
.tp-log p { margin: 2px 0; }

.tp-player { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.08); border-radius: 14px; padding: 10px 14px; margin-bottom: 10px; transition: box-shadow 0.3s; }
.tp-player.flash-dmg { box-shadow: inset 0 0 0 3px #ff6b6b; }
.tp-player.flash-guard { box-shadow: inset 0 0 0 3px #4dc3ff; }
.tp-player.flash-heal { box-shadow: inset 0 0 0 3px #6ee7a8; }
.tp-player-portrait { font-size: 2.6rem; }
.tp-player-bars { flex: 1; display: grid; gap: 4px; }
.tp-barrow { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; color: #fff; }
.tp-barrow span:first-child { width: 28px; }
.tp-barrow span:last-child { width: 60px; text-align: right; }
.tp-mpbar, .tp-focusbar { flex: 1; background: rgba(0,0,0,0.35); border-radius: 50px; height: 8px; overflow: hidden; }
.tp-mpfill { height: 100%; background: var(--mp); transition: width 0.35s; }
.tp-focusfill { height: 100%; background: var(--accent); transition: width 0.35s; }
.tp-focusfill.is-ready { background: linear-gradient(90deg, #ff6b35, #ffd166); animation: focus-pulse 0.6s infinite alternate; }
@keyframes focus-pulse { from { opacity: 0.7; } to { opacity: 1; } }

.tp-actionarea { min-height: 150px; }
.tp-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tp-menubtn { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 14px; font-size: 1rem; font-weight: bold; }
.tp-menubtn:hover:not(:disabled) { border-color: var(--primary); }
.tp-menubtn:disabled { opacity: 0.4; }
.tp-flee { grid-column: span 2; background: var(--gray); }
.tp-skilllist { display: grid; gap: 8px; }
.tp-skillbtn { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 10px 14px; text-align: left; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tp-skillbtn:disabled { opacity: 0.4; }
.tp-skillbtn b { flex: 0 0 auto; }
.tp-skillbtn span { color: var(--mp); font-size: 0.8rem; }
.tp-skillbtn small { flex-basis: 100%; color: #888; }
.tp-back-btn { background: none; border: none; color: #ccc; text-decoration: underline; font-size: 0.85rem; }
.tp-pickmsg { text-align: center; color: #fff; font-size: 0.9rem; }
.tp-targets { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tp-targetbtn { background: #fff; border: 3px solid var(--line); border-radius: 14px; padding: 10px 16px; font-weight: bold; }

.tp-worddisp { text-align: center; font-size: 1.7rem; color: #fff; font-family: 'Mochiy Pop One', cursive; min-height: 2.2em; display: flex; align-items: center; justify-content: center; }
.tp-worddisp ruby { ruby-align: center; }
.tp-worddisp rt { font-family: 'Kosugi Maru', sans-serif; font-size: 0.85rem; color: #e0d6ff; }
.tp-wordromaji { text-align: center; font-size: 1.4rem; letter-spacing: 2px; font-family: monospace, 'Kosugi Maru'; }
.tp-wordromaji span.ok { color: #6ee7a8; }
.tp-wordromaji span.bad { color: #ff6b6b; text-decoration: underline wavy; }
.tp-wordromaji span.pending { color: #b0a8d0; }
.tp-timerbar { background: rgba(255,255,255,0.2); border-radius: 50px; height: 6px; margin: 10px auto; max-width: 300px; overflow: hidden; }
.tp-timerfill { height: 100%; background: var(--accent); width: 100%; }
.tp-timerfill.low { background: #ff6b6b; }
.tp-typein { max-width: 340px; margin: 8px auto 0; display: block; text-align: center; font-size: 1.15rem; letter-spacing: 2px; }

.tp-guard { text-align: center; color: #fff; }
.tp-guard p { font-weight: bold; }
.tp-guard kbd { background: #555; border-radius: 4px; padding: 1px 8px; }
.tp-guardbar { background: rgba(255,255,255,0.2); border-radius: 50px; height: 12px; max-width: 280px; margin: 10px auto; overflow: hidden; }
.tp-guardfill { height: 100%; background: #4dc3ff; }

.tp-particle { position: absolute; pointer-events: none; font-size: 1.2rem; z-index: 20; transform: translate(-50%,-50%); animation: tp-particle-fly 0.7s ease-out forwards; }
@keyframes tp-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; } }
.tp-bigtext { position: absolute; left: 50%; top: 40%; transform: translate(-50%,-50%) scale(0.6); font-family: 'Mochiy Pop One', cursive; font-size: 1.6rem; color: #fff; text-shadow: 0 0 10px rgba(0,0,0,0.6), 0 0 20px currentColor; white-space: nowrap; z-index: 30; pointer-events: none; animation: tp-bigtext-pop 0.9s ease-out forwards; }
@keyframes tp-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} }
.tp-weak-big { color: #ff6b6b; }
.tp-crit-big { color: var(--accent); }
.tp-focus-big { color: #ff6b35; }

/* ---- 結果画面 ---- */
.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-levelup { margin-top: 14px; background: #fff8e8; border: 3px dashed var(--gold); border-radius: 14px; padding: 12px; font-weight: bold; color: #b8860b; }
.res-titles { margin-top: 10px; }
.res-title { background: #eef7ff; border-radius: 12px; padding: 8px; margin-top: 6px; font-weight: bold; color: var(--secondary); }
.res-lose-msg { color: #666; }
.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(--gold); 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-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-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: 14px; }
.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; }

/* ---- 称号 ---- */
.title-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.title-card { background: var(--gray); border: 3px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.title-card.is-got { background: #fff8e8; border-color: var(--gold); }
.title-emoji { font-size: 1.8rem; display: block; }
.title-name { font-weight: bold; font-size: 0.85rem; display: block; margin-top: 4px; }
.title-desc { font-size: 0.72rem; color: #888; }

/* ---- せってい ---- */
.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(--primary); border-color: var(--primary); color: #fff; }
.st-block input { max-width: 300px; display: inline-block; margin-right: 8px; }

@media (max-width: 640px) {
    .tp-enemy { width: 96px; }
    .tp-worddisp { font-size: 1.3rem; }
    .tp-wordromaji { font-size: 1.1rem; }
    .st-block input, .st-block select { max-width: 100%; margin-bottom: 8px; }
}
