/* ACADEMIA UI — ダークネイビー・黒・白・落ち着いた金を基調。発光は要所のみ */
:root {
  --bg: #0a0e16; --bg2: #0f1520; --panel: #131a27; --panel2: #182131; --line: #243046; --line2: #30405c;
  --text: #e9edf4; --mute: #8d99ab; --dim: #5f6b7d; --gold: #c9a961; --gold2: #e6cd8f; --ok: #6fd39a; --ng: #e27a7a;
  --r: 8px; --fh: "Zen Kaku Gothic New", "Hiragino Sans", sans-serif; --fn: "Barlow Condensed", "Zen Kaku Gothic New", sans-serif; --serif: var(--fh);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif; font-weight: 500; font-size: 14px; letter-spacing: .02em; overflow: hidden; }
button { font: inherit; }
canvas#cv { position: fixed; inset: 0; display: none; cursor: none; }
body.in-battle canvas#cv { display: block; }
body.in-battle #shell, body.in-battle #title { display: none !important; }
.hidden { display: none !important; }
a { color: var(--gold2); }

/* ---------- タイトル（白紙から再設計：大きな題字・最小限のメニュー・短いアニメーション） ---------- */
#title { position: fixed; inset: 0; overflow: hidden; background: #05070c; }
#title .bg { position: absolute; inset: -2%; background: #05070c center/cover no-repeat; animation: kb 18s ease-out both; }
#title::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(4,6,11,.94) 0%, rgba(4,6,11,.7) 38%, rgba(4,6,11,.05) 75%), linear-gradient(0deg, rgba(4,6,11,.8), transparent 40%); }
#title .inner { position: absolute; left: 7vw; bottom: 11vh; z-index: 1; }
#title .kicker { font-family: var(--fn); font-weight: 600; letter-spacing: .5em; color: var(--gold); font-size: 14px; animation: rise .6s .05s both; }
#title .logo { font-family: var(--fn); font-style: italic; font-weight: 900; font-size: clamp(84px, 12vw, 200px); line-height: .86; letter-spacing: .01em; color: #f4f1ea; margin: 6px 0 4px -6px; animation: rise .6s .12s both; }
#title .logo::after { content: ""; display: block; height: 4px; width: 0; background: var(--gold); margin-top: 14px; animation: bar .7s .45s cubic-bezier(.2,.8,.2,1) forwards; }
#title .tagline { font-weight: 700; font-size: clamp(18px, 1.8vw, 26px); letter-spacing: .12em; margin: 16px 0 40px; animation: rise .6s .25s both; }
.tmenu { display: flex; flex-direction: column; gap: 2px; width: 340px; }
.tmenu button { display: flex; align-items: baseline; gap: 14px; text-align: left; background: none; color: var(--text); border: 0; padding: 10px 0 10px 18px; cursor: pointer; position: relative; animation: rise .5s both; }
.tmenu button:nth-child(1) { animation-delay: .35s } .tmenu button:nth-child(2) { animation-delay: .4s } .tmenu button:nth-child(3) { animation-delay: .45s } .tmenu button:nth-child(4) { animation-delay: .5s }
.tmenu button::before { content: ""; position: absolute; left: 0; top: 50%; width: 3px; height: 0; background: var(--gold); transform: translateY(-50%); transition: height .15s; }
.tmenu button:hover::before, .tmenu button:focus::before { height: 70%; }
.tmenu button b { font-family: var(--fn); font-style: italic; font-weight: 800; font-size: 30px; letter-spacing: .04em; transition: transform .15s, color .15s; }
.tmenu button:hover b, .tmenu button:focus b { transform: translateX(6px); color: var(--gold2); }
.tmenu button span { color: var(--mute); font-size: 13px; }
.tmenu button:disabled { opacity: .35; cursor: default; }
#title .ver { position: absolute; right: 24px; bottom: 18px; color: var(--dim); font-size: 12px; z-index: 1; font-family: var(--fn); letter-spacing: .1em; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes bar { to { width: 160px; } }
@keyframes kb { from { transform: scale(1.08); } to { transform: scale(1); } }

/* ---------- シェル ---------- */
#shell { position: fixed; inset: 0; display: grid; grid-template-columns: 188px 1fr; grid-template-rows: 56px 1fr; }
#topbar { grid-column: 1 / 3; display: flex; align-items: center; gap: 18px; padding: 0 18px; background: var(--bg2); border-bottom: 1px solid var(--line); }
#topbar .brand { font-family: var(--fn); font-style: italic; font-weight: 800; letter-spacing: .08em; font-size: 24px; color: #f3ead6; width: 160px; cursor: pointer; }
#topbar .who { color: var(--mute); }
#topbar .who b { color: var(--text); }
#topbar .sp { flex: 1; }
.cur { font-family: var(--fn); font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); font-variant-numeric: tabular-nums; }
.cur i { font-style: normal; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #111; }
.cur .c { background: var(--gold); } .cur .rp { background: #7fb7ff; } .cur .tk { background: #c8a8ff; }
#nav { background: var(--bg2); border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; }
#nav button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; color: var(--mute); padding: 9px 10px; border-radius: 6px; cursor: pointer; text-align: left; position: relative; }
#nav button:hover { background: var(--panel); color: var(--text); }
#nav button.on { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--gold); }
#nav .ic { width: 18px; text-align: center; font-family: var(--fh); color: var(--gold); }
#nav .badge { position: absolute; right: 8px; background: var(--gold); color: #111; font-size: 10px; font-weight: 700; border-radius: 9px; padding: 0 6px; }
#nav hr { border: 0; border-top: 1px solid var(--line); margin: 8px 4px; }
#main { overflow-y: auto; padding: 22px 26px 40px; }
.page-h { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; }
.page-h h1 { font-family: var(--fh); font-weight: 900; font-size: 26px; margin: 0; letter-spacing: .06em; }
.page-h p { margin: 0; color: var(--mute); }

/* ---------- 部品 ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.panel h3 { margin: 0 0 10px; font-size: 14px; color: var(--gold2); font-weight: 600; letter-spacing: .05em; }
.btn { background: #1d2738; color: var(--text); border: 1px solid var(--line2); padding: 9px 16px; border-radius: 6px; cursor: pointer; }
.btn:hover { border-color: var(--gold); }
.btn.pri { background: linear-gradient(#c9a961, #a88a46); color: #15110a; border-color: #d8bd7a; font-weight: 700; }
.btn.pri:hover { filter: brightness(1.08); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: default; filter: none; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.split.l { grid-template-columns: 420px minmax(0, 1fr); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs button { background: none; border: 1px solid var(--line); color: var(--mute); padding: 6px 12px; border-radius: 16px; cursor: pointer; font-size: 13px; }
.tabs button.on { border-color: var(--gold); color: var(--text); background: rgba(201,169,97,.1); }
.muted { color: var(--mute); } .dim { color: var(--dim); } .gold { color: var(--gold2); } .ok { color: var(--ok); } .ng { color: var(--ng); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; border: 1px solid var(--c, var(--line2)); color: var(--c, var(--mute)); margin: 1px 2px 1px 0; white-space: nowrap; }
.rar { color: var(--gold2); letter-spacing: -1px; font-size: 11px; }
input[type=text], input[type=search], select { background: var(--bg2); color: var(--text); border: 1px solid var(--line2); border-radius: 6px; padding: 7px 10px; font: inherit; }
input[type=range] { accent-color: var(--gold); }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--mute); } .kv dd { margin: 0; }
.statbar { display: grid; grid-template-columns: 70px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; margin: 4px 0; }
.statbar .b { height: 6px; background: #0b0f17; border-radius: 3px; overflow: hidden; } .statbar .b i { display: block; height: 100%; background: var(--c, var(--gold)); }
.empty { color: var(--dim); padding: 20px; text-align: center; }
.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--gold); padding: 10px 18px; border-radius: 6px; z-index: 50; box-shadow: 0 8px 30px #0008; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 40; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: 22px; width: min(460px, 92vw); }
.modal h3 { margin: 0 0 10px; font-family: var(--fh); font-weight: 500; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 12px 0; }

/* カード */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--w, 168px), 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; cursor: pointer; position: relative; }
.card:hover { border-color: var(--line2); }
.card.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.card.lock { opacity: .55; }
.card .th { aspect-ratio: 16/9; background: #0b0f17 center/cover no-repeat; }
.card .th.port { aspect-ratio: 4/5; }
.card .bd { padding: 8px 10px; }
.card .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { font-size: 11px; color: var(--mute); margin-top: 2px; }
.card .acc { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, transparent); }
.card .own { position: absolute; right: 6px; top: 6px; font-size: 10px; background: #0b0f17cc; border: 1px solid var(--line2); padding: 1px 6px; border-radius: 8px; color: var(--mute); }
.card .own.y { color: var(--ok); border-color: #2c5a40; }

/* ホーム */
.home { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); gap: 18px; }
.hero { position: relative; min-height: 380px; border-radius: 10px; overflow: hidden; background: #0b0f17 center/cover no-repeat; border: 1px solid var(--line); }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(8,11,18,.9), rgba(8,11,18,.2)); }
.hero .in { position: relative; z-index: 1; padding: 26px; max-width: 460px; }
.hero .in h2 { font-family: var(--fh); font-weight: 500; font-size: 30px; margin: 4px 0 8px; }
.hero .port { position: absolute; right: 10px; bottom: 0; height: 100%; z-index: 1; }
.hero .port img, .hero .port svg { height: 100%; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; cursor: pointer; position: relative; }
.tile:hover { border-color: var(--gold); }
.tile b { display: block; font-size: 15px; margin-bottom: 4px; } .tile span { font-size: 12px; color: var(--mute); }
.tile .ic { float: right; font-family: var(--fh); color: var(--gold); font-size: 20px; }
.mission { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prog { height: 5px; background: #0b0f17; border-radius: 3px; overflow: hidden; grid-column: 1 / 2; } .prog i { display: block; height: 100%; background: var(--gold); }

/* キャラクター */
.charstage { position: relative; background: radial-gradient(ellipse at 50% 70%, #1b2335, #0b0f17 70%); border: 1px solid var(--line); border-radius: 10px; height: 560px; overflow: hidden; display: grid; place-items: end center; }
.charstage img, .charstage svg { height: 96%; max-width: 100%; object-fit: contain; }
.charstage .nm { position: absolute; left: 20px; top: 16px; }
.charstage .nm h2 { font-family: var(--fh); font-weight: 500; font-size: 32px; margin: 0; }
.charstage .nm .kana { color: var(--mute); letter-spacing: .2em; font-size: 12px; }
.charstage .sw { position: absolute; right: 12px; top: 12px; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; margin-top: 14px; }
.roster .rc { aspect-ratio: 4/5; border: 1px solid var(--line); border-radius: 6px; background: #0b0f17 center/cover; cursor: pointer; position: relative; overflow: hidden; }
.roster .rc.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.roster .rc.lock { filter: grayscale(.9) brightness(.5); }
.roster .rc span { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, #000c); font-size: 10px; padding: 8px 4px 3px; text-align: center; white-space: nowrap; overflow: hidden; }
.roster .rc i { position: absolute; left: 0; top: 0; right: 0; height: 3px; background: var(--c); }

/* ステージ */
.stageprev { position: relative; aspect-ratio: 16/9; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #0b0f17 center/cover no-repeat; }
.stageprev .ov { position: absolute; inset: 0; pointer-events: none; }
.ov.dusk { background: linear-gradient(180deg, rgba(255,120,40,.25), rgba(120,40,80,.25)); mix-blend-mode: multiply; }
.ov.night { background: rgba(6,10,30,.6); }
.ov.rain { background: repeating-linear-gradient(105deg, transparent 0 9px, rgba(180,200,255,.18) 9px 10px); }
.ov.snow { background-image: radial-gradient(#fff9 1.2px, transparent 1.6px); background-size: 22px 22px; }
.ov.fog { background: linear-gradient(0deg, rgba(210,215,225,.45), rgba(210,215,225,.15)); }
.ov.storm { background: linear-gradient(180deg, rgba(20,20,40,.5), transparent), repeating-linear-gradient(105deg, transparent 0 7px, rgba(180,200,255,.2) 7px 8px); }
.ov.heat { background: rgba(255,110,40,.15); }
.ov.wind { background: repeating-linear-gradient(0deg, transparent 0 30px, rgba(255,255,255,.06) 30px 31px); }
.stageprev .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 18px; background: linear-gradient(transparent, #000d); }
.stageprev .cap h2 { margin: 0; font-family: var(--fh); font-weight: 500; }
.opt { display: flex; gap: 4px; flex-wrap: wrap; }
.opt button { background: var(--bg2); border: 1px solid var(--line2); color: var(--mute); padding: 5px 12px; border-radius: 5px; cursor: pointer; }
.opt button.on { border-color: var(--gold); color: var(--text); }
.opt button:disabled { opacity: .3; }

/* 技リスト */
.techrow { display: grid; grid-template-columns: 44px minmax(0, 1fr) 70px 64px 48px; gap: 8px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.techrow:hover { background: var(--panel2); }
.techrow.sel { background: #1e2840; }
.techrow.lock { color: var(--dim); }
.techrow .gl { font-family: var(--fh); font-weight: 700; text-align: center; color: var(--c); font-size: 13px; border: 1px solid var(--c); border-radius: 4px; padding: 3px 0; overflow: hidden; white-space: nowrap; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot { border: 1px dashed var(--line2); border-radius: 6px; padding: 8px; min-height: 64px; font-size: 12px; cursor: pointer; position: relative; }
.slot.f { border-style: solid; border-color: var(--c); }
.slot .k { position: absolute; right: 6px; top: 4px; color: var(--mute); font-size: 11px; }
.slot.fixed { cursor: default; background: #141b29; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-bottom: 10px; }
.cmp { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 4px 10px; font-size: 12px; }
.cmp div:nth-child(3n+1) { color: var(--mute); }

/* 研究ツリー */
.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.node { border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; cursor: pointer; background: var(--panel); font-size: 13px; }
.node.done { border-color: #2c5a40; } .node.done b { color: var(--ok); }
.node.can { border-color: var(--gold); } .node.lock { opacity: .5; }
.node.sel { box-shadow: 0 0 0 2px var(--gold) inset; }
.tree { display: grid; grid-template-columns: 150px 24px repeat(3, 120px) 24px 120px; align-items: center; gap: 6px 0; font-size: 12px; overflow-x: auto; }
.tree .tn { border: 1px solid var(--line2); border-radius: 5px; padding: 6px 8px; cursor: pointer; background: var(--bg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 6px; }
.tree .tn.have { border-color: #2c5a40; color: var(--ok); }
.tree .tn.can { border-color: var(--gold); color: var(--gold2); }
.tree .tn.no { color: var(--dim); }
.tree .ln { height: 1px; background: var(--line2); }

/* 図鑑 */
.subjrow { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.subjrow:hover { background: var(--panel2); } .subjrow.sel { background: #1e2840; }
.subjrow .bar { width: 4px; height: 26px; background: var(--c); border-radius: 2px; }
.fav { cursor: pointer; color: var(--dim); font-size: 16px; } .fav.on { color: var(--gold); }

/* ショップ */
.shopgrid { --w: 150px; }
.price { color: var(--gold2); font-family: var(--fn); font-weight: 700; font-size: 1.1em; }
.preview { background: radial-gradient(ellipse at 50% 70%, #1b2335, #0b0f17 70%); border-radius: 8px; height: 300px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); }
.preview img, .preview svg { max-height: 100%; max-width: 100%; }
.swatch { width: 100%; height: 100%; display: grid; place-items: center; font-family: var(--fh); font-size: 26px; }

/* 実績・プロフィール */
.ach { display: grid; grid-template-columns: 1fr 160px 90px; gap: 12px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.ach.done b { color: var(--gold2); }
.profilecard { position: relative; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); min-height: 220px; padding: 24px; background-size: cover; }

/* 戦闘オーバーレイ */
.overlay { position: fixed; display: none; background: rgba(15,21,32,.95); border: 1px solid var(--line2); border-radius: 8px; padding: 18px 22px; z-index: 30; }
.overlay.on { display: block; }
#intro, #pause { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 92vw); max-height: 86vh; overflow: auto; }
#pause p { font-size: 13px; line-height: 1.6; margin: 4px 0; }
#quiz { left: 50%; bottom: 150px; transform: translateX(-50%); width: min(640px, 94vw); text-align: center; border-color: #c9a96188; }
#quiz .qs { font-size: 13px; font-weight: 700; } #quiz .qq { font-size: 20px; margin: 8px 0 12px; }
#quiz .qa { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
#quiz .qt { height: 3px; background: var(--gold); margin-top: 12px; width: 100%; }
kbd { background: #000; border: 1px solid #555; border-radius: 3px; padding: 0 5px; font-size: 12px; }
#tutorial { left: 20px; top: 84px; width: 250px; font-size: 12px; pointer-events: none; opacity: .88; background: rgba(10,14,22,.7); border-color: transparent; }
#tutorial ul { padding-left: 4px; list-style: none; margin: 6px 0; line-height: 1.9; } #tutorial li.ok { color: var(--ok); }
#err { left: 12px; bottom: 4px; padding: 4px 10px; font-size: 12px; color: var(--ng); pointer-events: none; }
.result { max-width: 980px; margin: 0 auto; }
.result h2.win { font-family: var(--fn); font-style: italic; font-size: 72px; color: var(--gold2); margin: 0; font-weight: 900; letter-spacing: .04em; }
.result h2.lose { font-family: var(--fn); font-style: italic; font-size: 72px; color: var(--ng); margin: 0; font-weight: 900; letter-spacing: .04em; }
.rgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 16px 0; }
.rgrid div { background: var(--bg2); border: 1px solid var(--line); padding: 10px; border-radius: 6px; text-align: center; }
.rgrid b { display: block; font-size: 11px; color: var(--mute); font-weight: 500; } .rgrid span { font-family: var(--fn); font-style: italic; font-size: 34px; font-weight: 800; }
.fact { color: #9fd0ef; } .game { color: #cdb8f0; }
@media (max-width: 1100px) { .split, .split.l, .home { grid-template-columns: 1fr; } }

/* ---------- スマートフォン：タッチ操作 ---------- */
canvas#cv { touch-action: none; }
#touch { display: none; position: fixed; inset: 0; z-index: 20; pointer-events: none; user-select: none; -webkit-user-select: none; }
body.in-battle.touch #touch { display: block; }
#tjoy { position: absolute; left: 0; top: 70px; bottom: 0; width: 45%; pointer-events: auto; touch-action: none; }
#tbase { position: absolute; left: 30px; bottom: 40px; top: auto; width: 140px; height: 140px; border-radius: 50%; border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.05); opacity: .5; }
#tbase.on { opacity: 1; bottom: auto; }
#tknob { position: absolute; left: 45px; top: 45px; width: 50px; height: 50px; border-radius: 50%; background: rgba(240,213,138,.55); border: 2px solid #f0d58a; }
.tb { pointer-events: auto; touch-action: none; position: relative; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); background: rgba(10,14,22,.7); color: #fff; font: 700 14px var(--fh); overflow: hidden; }
.tb.pr { background: rgba(201,169,97,.45); transform: scale(.94); }
#tbtns { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 220px; height: 200px; }
#tAtk { position: absolute; right: 0; bottom: 0; width: 96px; height: 96px; font-size: 18px; border-color: #f0d58a; }
#tUp { position: absolute; right: 104px; bottom: 6px; width: 66px; height: 66px; }
#tDodge { position: absolute; right: 22px; bottom: 106px; width: 62px; height: 62px; border-color: #9fd0ff; }
#tUlt { position: absolute; right: 108px; bottom: 90px; width: 58px; height: 58px; font-size: 12px; }
#tUlt.ready { border-color: #f0d58a; box-shadow: 0 0 12px #f0d58a88; }
#tPause { position: absolute; left: max(16px, env(safe-area-inset-left)); top: 62px; width: 40px; height: 40px; font-size: 14px; }
#tskills { position: absolute; right: 250px; bottom: max(16px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.tb.sk { width: 54px; height: 54px; border-radius: 12px; border-color: var(--c); font-size: 15px; }
.tb.sk.off { opacity: .45; }
.tb.sk i { position: absolute; left: 0; right: 0; top: 0; background: rgba(0,0,0,.6); }
.tb.sk span { position: relative; z-index: 1; }
#tRotate { display: none; position: absolute; top: 100px; left: 50%; transform: translateX(-50%); background: rgba(10,14,22,.85); padding: 6px 12px; border-radius: 6px; font-size: 12px; color: var(--gold2); }
@media (orientation: portrait) {
  #tRotate { display: block; }
  #tskills { right: auto; left: 50%; transform: translateX(-50%); bottom: 230px; flex-wrap: wrap; justify-content: center; width: 92vw; }
  #tjoy { width: 50%; }
}
body.touch #tutorial { display: none !important; }
body.touch #quiz { bottom: auto; top: 50%; transform: translate(-50%, -50%); width: min(560px, 94vw); }
body.touch #quiz .qa { flex-direction: column; }
body.touch #quiz .qa .btn { padding: 14px; font-size: 16px; width: 100%; }

/* ---------- スマートフォン：メニュー画面 ---------- */
@media (max-width: 820px) {
  html, body { overflow: auto; }
  #shell { grid-template-columns: 1fr; grid-template-rows: 50px 1fr 58px; }
  #topbar { grid-column: 1; gap: 8px; padding: 0 10px; }
  #topbar .brand { width: auto; font-size: 20px; }
  #topbar .who { display: none; }
  .cur { padding: 3px 8px; font-size: 13px; }
  #nav { grid-row: 3; display: flex; overflow-x: auto; padding: 4px; border-right: 0; border-top: 1px solid var(--line); gap: 2px; }
  #nav button { flex: 0 0 auto; flex-direction: column; gap: 0; width: auto; min-width: 64px; padding: 6px 6px; font-size: 10px; text-align: center; }
  #nav button .ic { font-size: 16px; }
  #nav button.on { box-shadow: inset 0 2px 0 var(--gold); }
  #nav hr { display: none; }
  #nav .badge { right: 2px; top: 2px; }
  #main { padding: 14px 12px 30px; }
  .split, .split.l, .home, .grid2 { grid-template-columns: 1fr !important; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .charstage { height: 360px; }
  .hero { min-height: 300px; } .hero .port { opacity: .35; }
  .slots { grid-template-columns: repeat(3, 1fr) !important; }
  .filters { grid-template-columns: 1fr 1fr; }
  .techrow { grid-template-columns: 40px minmax(0, 1fr) 60px; } .techrow > :nth-child(4), .techrow > :nth-child(5) { display: none; }
  .tree { grid-template-columns: 120px 12px repeat(3, 110px) 12px 110px; }
  .rgrid { grid-template-columns: 1fr 1fr; }
  .ach { grid-template-columns: 1fr; }
  .page-h { flex-direction: column; gap: 4px; }
  #title .inner { left: 6vw; right: 6vw; bottom: 8vh; }
  .tmenu { width: 100%; }
  .tmenu button b { font-size: 26px; }
  #intro, #pause { width: 94vw; }
}
@media (max-height: 520px) {
  #title .inner { bottom: 5vh; }
  #title .logo { font-size: clamp(56px, 9vw, 90px); }
  #title .logo::after { margin-top: 8px; }
  #title .tagline { margin: 8px 0 14px; font-size: 16px; }
  .tmenu { display: grid; grid-template-columns: 1fr 1fr; width: min(460px, 88vw); gap: 0 16px; }
  .tmenu button { padding: 6px 0 6px 14px; }
  .tmenu button b { font-size: 22px; }
  .tmenu button span { display: none; }
  #title .ver { display: none; }
  #intro, #pause { max-height: 92vh; padding: 12px 16px; }
  body.touch #quiz { padding: 10px 14px; }
  body.touch #quiz .qq { font-size: 16px; margin: 4px 0 8px; }
  body.touch #quiz .qa .btn { padding: 9px; font-size: 14px; }
}
.slot select { width: 100%; max-width: 100%; margin-top: 4px; font-size: 11px; padding: 4px; }
.slot { min-width: 0; overflow: hidden; }
@media (max-width: 820px) { .slots .slot.fixed { grid-column: 1 / -1; } }
