:root {
  --bg: #14121a; --shell: #3b3550; --shell2: #2c2740; --line: #5a5478;
  --text: #f0ecff; --muted: #bdb6d8; --accent: #ffd35c; --ok: #6fe39a; --bad: #ff7b7b; --frag: #7fd4ff;
  --font: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; --pixel: "DotGothic16", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overscroll-behavior: none; }
body { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button { font-family: var(--font); font-size: 15px; color: var(--text); background: var(--shell2); border: 2px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
button:active { transform: translateY(1px); filter: brightness(1.2); }
button:disabled { opacity: .45; }
button.ok { background: #2e7d4b; border-color: var(--ok); }
button.danger { background: #6b2a2a; border-color: #b05050; }
button.mini { font-size: 14px; padding: 5px 10px; }
input[type=text] { font-family: var(--font); font-size: 16px; color: var(--text); background: #1c1828; border: 2px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; }
small { color: var(--muted); font-size: 13px; }
h4 { margin: 12px 0 6px; font-size: 15px; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.plus { color: var(--ok); } .minus { color: var(--bad); } .frag { color: var(--frag); }

#app { display: flex; flex-direction: column; height: 100%; max-width: 480px; margin: 0 auto; padding-top: env(safe-area-inset-top); }

/* ---- ゲーム機 ---- */
#console { flex: 0 0 auto; background: var(--shell); border-radius: 0 0 22px 22px; padding: 6px 12px 8px; box-shadow: inset 0 -6px 0 #262238; }
.console-top { display: flex; align-items: center; gap: 8px; font-family: var(--pixel); font-size: 12px; letter-spacing: 2px; color: #cfc8ee; padding: 0 4px 5px; }
.brand { flex: 1; font-style: italic; }
.led { width: 8px; height: 8px; border-radius: 50%; background: #ff4b4b; box-shadow: 0 0 6px #ff4b4b; }
.led.off { background: #442; box-shadow: none; }
.power { padding: 1px 7px; font-size: 12px; border-radius: 6px; }

#screen { font-family: var(--pixel); position: relative; width: 100%; aspect-ratio: 4 / 3; background: #0d1a0d; border: 6px solid #1b1826; border-radius: 8px; overflow: hidden; touch-action: none; image-rendering: pixelated; }
#bg { position: absolute; inset: 0; background-size: cover; background-position: center; transition: opacity .3s; }
#hud { position: absolute; top: 0; left: 0; right: 0; display: flex; flex-wrap: wrap; gap: 0 6px; padding: 5px 8px; font-size: 14px; background: linear-gradient(rgba(0,0,0,.65), transparent); pointer-events: none; text-shadow: 1px 1px 0 #000; }
#area-name { flex: 1; }
#gold { color: var(--accent); font-weight: bold; margin-left: 10px; }
#hud2 { width: 100%; display: flex; gap: 12px; font-size: 13px; color: #cfe8ff; margin-top: 1px; }
#hud-dps::before { content: '⚔ '; } #hud-tap::before { content: '👆 '; }
#battle { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
#enemy-wrap { display: flex; flex-direction: column; align-items: center; margin-top: 18px; }
#enemy-name { font-size: 15px; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; margin-bottom: 2px; }
#enemy { width: 38%; max-width: 160px; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 4px 2px rgba(0,0,0,.4)); transition: transform .08s; }
#enemy.hit { transform: scale(.92) translateX(3px); }
#enemy.boss { width: 46%; max-width: 200px; }
#enemy.dead { transform: scale(0) rotate(90deg); transition: transform .25s; }
#hpbar { width: 44%; height: 9px; background: #222; border: 2px solid #000; border-radius: 3px; margin-top: 4px; }
#hpfill { height: 100%; width: 100%; background: linear-gradient(#ff6b6b, #c22); transition: width .08s; }
#hptext { font-size: 13px; text-shadow: 1px 1px 0 #000; }
#progress { position: absolute; bottom: 0; left: 0; right: 0; height: 5px; background: rgba(0,0,0,.5); }
#progfill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#party { position: absolute; left: 6px; bottom: 8px; right: 6px; display: flex; gap: 2px; align-items: flex-end; pointer-events: none; }
#party img { width: 11%; max-width: 44px; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 2px 1px rgba(0,0,0,.5)); animation: bob 1s infinite alternate; pointer-events: auto; }
#party img:nth-child(2n) { animation-delay: .5s; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
#party img.attack { animation: none; transform: translateY(-8px) scale(1.15); }
#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.dmg { position: absolute; font-size: 17px; font-weight: bold; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000; animation: rise .7s forwards; pointer-events: none; }
.dmg.crit { color: var(--accent); font-size: 22px; }
.dmg.gold { color: var(--accent); font-size: 15px; }
@keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-40px); opacity: 0; } }

.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #0a1a2c; z-index: 5; }
.overlay[hidden] { display: none; }
#title { background: radial-gradient(#1a3a5c, #06101c); }
.title-logo { font-size: 34px; line-height: 1.1; color: #ffe27a; text-shadow: 3px 3px 0 #7a3a00, -1px -1px 0 #000; text-align: center; letter-spacing: 2px; }
.title-sub { margin-top: 18px; font-size: 15px; color: #fff; animation: blink 1s steps(1) infinite; }
.rumor { position: absolute; bottom: 28px; left: 10px; right: 10px; font-size: 12px; color: #9fd; text-align: center; line-height: 1.4; }
.title-copy { position: absolute; bottom: 8px; font-size: 12px; color: #8ab; }
@keyframes blink { 50% { opacity: 0; } }
#off { background: #050505; }
#notice { position: absolute; left: 8px; right: 8px; top: 30%; background: rgba(0,0,0,.9); border: 2px solid var(--accent); color: #fff; font-size: 15px; line-height: 1.5; padding: 10px 12px; text-align: center; z-index: 6; animation: pop .25s; }
#notice[hidden] { display: none; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }

/* グリッチ演出 */
#screen.glitch { animation: glitch .5s steps(2); }
@keyframes glitch {
  0% { transform: translate(2px, -1px); filter: hue-rotate(90deg) contrast(2); }
  25% { transform: translate(-3px, 2px) skewX(4deg); filter: invert(1); }
  50% { transform: translate(1px, 1px); filter: hue-rotate(-90deg); }
  75% { transform: translate(-1px, -2px) skewX(-3deg); filter: contrast(3) saturate(0); }
  100% { transform: none; filter: none; }
}
/* カラーパレット（チート） */
#screen.pal-green { filter: sepia(1) hue-rotate(60deg) saturate(2) contrast(1.1); }
#screen.pal-mono { filter: grayscale(1) contrast(1.2); }
#screen.pal-red { filter: sepia(1) hue-rotate(-30deg) saturate(3); }

.console-bottom { display: flex; align-items: center; justify-content: space-between; padding: 8px 4px 0; }
#dpad { position: relative; width: 78px; height: 78px; }
.dp { position: absolute; width: 26px; height: 26px; padding: 0; font-size: 12px; background: #1c1826; border-color: #0e0c14; border-radius: 4px; color: #777; }
.dp.up { left: 26px; top: 0; } .dp.down { left: 26px; bottom: 0; } .dp.left { left: 0; top: 26px; } .dp.right { right: 0; top: 26px; }
#mid { display: flex; gap: 8px; }
.pill { font-family: var(--pixel); font-size: 9px; letter-spacing: 1px; padding: 3px 8px; border-radius: 10px; background: #1c1826; border-color: #0e0c14; color: #999; transform: rotate(-20deg); }
#ab { display: flex; gap: 10px; align-items: flex-end; }
.ab { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 18px; font-weight: bold; border-color: #4a1830; }
.ab.a { background: #c8304e; margin-bottom: 12px; } .ab.b { background: #a8284a; }
.ab:active { filter: brightness(1.4); }

/* ---- スキル ---- */
#skills { display: flex; gap: 6px; padding: 8px 6px 0; flex: 0 0 auto; }
#skills:empty { display: none; }
.skill { flex: 1; font-size: 13px; padding: 5px 2px; line-height: 1.25; background: #2e3d5c; border-color: #5f8fe0; }
.skill small { display: block; font-size: 12px; color: #cfe0ff; }
.skill.locked { background: #221e30; border-color: #3a3450; color: #777; } .skill.locked small { color: #777; }
.skill.cd { background: #2a2838; border-color: #3a3450; color: #999; } .skill.cd small { color: #999; }
.skill.gift { background: #7d3a5e; border-color: #ff9ad0; animation: pulse 1.2s ease-in-out infinite; }
.skill.active { background: #7d5a2e; border-color: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,211,92,.0); } 50% { box-shadow: 0 0 10px 2px rgba(255,211,92,.7); } }
.reward { display: block; width: 100%; text-align: left; margin: 6px 0; padding: 10px; background: #2e5a7d; border-color: #5fa8e0; line-height: 1.4; }
.reward small { color: #cfe0ff; }
#enemy.rare-glitch { animation: rareglitch .4s steps(2) infinite; }
@keyframes rareglitch { 0% { filter: hue-rotate(0deg); transform: translateX(0); } 50% { filter: hue-rotate(180deg) contrast(1.6); transform: translateX(3px) skewX(6deg); } 100% { filter: invert(.2); transform: translateX(-2px); } }
#enemy.rare-mimic { filter: drop-shadow(0 0 8px #ffd35c); }

/* ---- ひろげる ---- */
#handle { display: block; width: calc(100% - 12px); margin: 6px 6px 0; padding: 6px; font-size: 13px; color: var(--muted); background: #221e30; border: 2px solid #3a3450; border-radius: 8px; }
#mini-hud { display: none; justify-content: space-between; gap: 6px; padding: 4px 6px 2px; font-family: var(--pixel); font-size: 14px; color: var(--text); white-space: nowrap; }
#mini-hud span { flex: 1; text-align: center; background: #221e30; border-radius: 6px; padding: 4px 2px; overflow: hidden; text-overflow: ellipsis; }
#mh-gold { color: var(--accent); }
body.expanded #screen, body.expanded .console-bottom { display: none; }
body.expanded #console { border-radius: 0 0 12px 12px; padding-bottom: 6px; box-shadow: none; }

body.expanded #mini-hud { display: flex; }
body.expanded #handle { background: #2e3d5c; border-color: #5f8fe0; color: var(--text); }

/* ---- 欄の先頭の数値 ---- */
#panel-gold { display: flex; flex-wrap: wrap; gap: 4px 6px; padding: 2px 0 8px; }
#panel-gold span.chip { background: #221e30; border: 1px solid #3a3450; border-radius: 6px; padding: 2px 8px; font-size: 13px; white-space: nowrap; color: var(--text); }
#panel-gold span.chip.g { color: var(--accent); } #panel-gold span.chip.f { color: var(--frag); }

/* ---- 裏技帳 ---- */
.chap { display: flex; align-items: center; gap: 8px; padding: 10px 6px; margin-top: 6px; background: #221e30; border: 2px solid #3a3450; border-radius: 8px; cursor: pointer; }
.chap.open { border-color: var(--accent); }
.chap.done { border-color: var(--ok); }
.chap .cname { flex: 1; font-size: 16px; }
.chap .cdesc { font-size: 12px; color: var(--muted); }
.chap .ccount { font-size: 14px; color: var(--accent); }
.star { color: var(--accent); font-size: 12px; letter-spacing: -1px; }
.row.hidden .name { color: var(--muted); }
.row button.hint { min-width: 64px; font-size: 12px; background: #2e3d5c; border-color: #5f8fe0; }
.rumorbox { background: #1c2a3a; border: 2px solid #3a6a8a; border-radius: 8px; padding: 8px 10px; font-size: 14px; color: #bfe; margin-bottom: 6px; line-height: 1.5; }

/* ---- タブ・パネル ---- */
#tabs { display: flex; gap: 2px; padding: 4px 6px 0; flex: 0 0 auto; }
#tabs button { flex: 1; font-size: 14px; padding: 9px 0; border-radius: 8px 8px 0 0; border-bottom: none; background: #221e30; color: var(--muted); white-space: nowrap; letter-spacing: -0.5px; }
#tabs button.on { background: var(--shell2); color: var(--text); border-color: var(--line); }
#tabs button .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-left: 3px; vertical-align: middle; }
#panel { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--shell2); margin: 0 6px 6px; border: 2px solid var(--line); border-radius: 0 0 10px 10px; padding: 8px; font-size: 15px; line-height: 1.45; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid #3a3450; }
.row img, .row .ico { width: 44px; height: 44px; object-fit: contain; flex: 0 0 auto; image-rendering: pixelated; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.row .info { flex: 1; min-width: 0; }
.row .name { font-size: 16px; }
.row .sub { font-size: 13px; color: var(--muted); }
.row button { flex: 0 0 auto; min-width: 88px; font-size: 14px; line-height: 1.3; padding: 6px 6px; }
.row button.buy { background: #2e5a7d; border-color: #5fa8e0; }
.row button.buy:disabled { background: #2a2838; border-color: #3a3450; }
.row.locked { opacity: .55; }
.row.found .name { color: var(--ok); }
.row.on button { background: #2e7d4b; border-color: var(--ok); }
.bugno { color: var(--muted); font-size: 13px; width: 30px; flex: 0 0 auto; }
.stat { display: flex; justify-content: space-between; padding: 5px 4px; font-size: 15px; border-bottom: 1px dotted #3a3450; }
.stat span:last-child { color: var(--accent); }
.badge { background: #4a3a66; border-radius: 4px; padding: 1px 6px; font-size: 12px; color: #ffe6a0; }
.note { font-size: 14px; color: var(--muted); padding: 6px 4px; line-height: 1.6; }
.buybar { display: flex; gap: 4px; margin-bottom: 6px; }
.buybar button { flex: 1; font-size: 14px; padding: 6px; }
.buybar button.on { background: var(--accent); color: #222; border-color: var(--accent); }

/* ---- トースト・モーダル ---- */
#toast { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translateX(-50%) translateY(-20px); background: rgba(0,0,0,.9); color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 15px; opacity: 0; transition: .2s; pointer-events: none; white-space: nowrap; max-width: 95%; overflow: hidden; text-overflow: ellipsis; z-index: 50; border: 1px solid var(--line); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
#modal.show { display: flex; }
.modal-box { background: var(--shell2); border: 2px solid var(--accent); border-radius: 12px; padding: 14px; width: 100%; max-width: 360px; max-height: 80vh; overflow-y: auto; }
.modal-box h3 { margin: 0 0 8px; font-size: 18px; color: var(--accent); }
#modal-body { font-size: 15px; line-height: 1.7; }
#modal-buttons { display: flex; gap: 6px; margin-top: 10px; justify-content: flex-end; }
.ending { text-align: center; }
.ending .big { font-size: 24px; color: var(--accent); margin: 8px 0; }
