@font-face { font-family: 'Inter'; src: url('/assets/fonts/inter-latin-wght-v6.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
:root {
  --ink: #0c0912; --ink2: #16121f; --ink3: #221c2e; --paper: #f2e6cc; --paper2: #c9bb9c; --red: #d63048; --gold: #e8b04a; --jade: #3ae08a;
  --line: rgba(242, 230, 204, 0.14); --head: 'Shippori Mincho B1', 'Hiragino Mincho ProN', 'Yu Mincho', Georgia, serif;
  --tb: 1;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--paper); overflow: hidden; font: 15px/1.4 Inter, system-ui, -apple-system, Segoe UI, sans-serif; overscroll-behavior: none; }
#app { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #000; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- screens ---------- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; overflow-y: auto; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(120% 90% at 70% 10%, rgba(214, 48, 72, 0.18), transparent 60%), radial-gradient(90% 70% at 10% 100%, rgba(153, 69, 255, 0.14), transparent 60%), linear-gradient(180deg, rgba(12, 9, 18, 0.88), rgba(12, 9, 18, 0.97)); z-index: 20; }
.screen.show { display: flex; animation: scr-in 0.28s ease-out; }
.screen.dim { background: rgba(8, 6, 12, 0.72); backdrop-filter: blur(3px); align-items: center; justify-content: center; }
@keyframes scr-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#s-title { background: linear-gradient(180deg, rgba(12, 9, 18, 0.25), rgba(12, 9, 18, 0.85) 80%); justify-content: center; align-items: center; text-align: center; }
.title-wrap { max-width: 560px; width: 100%; }
.kicker { letter-spacing: 0.32em; text-transform: uppercase; font-size: 11px; color: var(--paper2); margin: 0 0 8px; }
.logo { font-family: var(--head); font-size: clamp(48px, 11vw, 96px); line-height: 0.95; margin: 0; letter-spacing: 0.04em; color: var(--paper); text-shadow: 0 4px 30px rgba(214, 48, 72, 0.45); }
.logo span { color: var(--red); display: inline-block; }
.logo.small { font-size: 34px; }
.tag { color: var(--paper2); margin: 12px 0 28px; font-size: 16px; }
.menu { display: grid; gap: 10px; max-width: 280px; margin: 0 auto; }
.foot { margin-top: 22px; font-size: 12px; color: rgba(242, 230, 204, 0.5); }
.load { margin: auto; text-align: center; } .load p { color: var(--paper2); }

.btn { border: 1px solid var(--line); background: rgba(242, 230, 204, 0.06); padding: 12px 18px; border-radius: 10px; font-weight: 600; letter-spacing: 0.02em; transition: transform 0.12s, background 0.15s, border-color 0.15s; min-height: 44px; }
.btn:hover, .btn:focus-visible { background: rgba(242, 230, 204, 0.12); border-color: rgba(242, 230, 204, 0.35); outline: none; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(180deg, #e04058, #b0263a); border-color: #ff7a8a55; color: #fff; box-shadow: 0 6px 24px rgba(214, 48, 72, 0.35); }
.btn.primary:hover { background: linear-gradient(180deg, #ea5068, #c02c42); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { border-color: #d6304866; color: #ff8a9a; margin-top: 18px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }

.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; max-width: 980px; width: 100%; margin: 0 auto 8px; }
.bar h2 { font-family: var(--head); margin: 0; font-size: 26px; letter-spacing: 0.06em; }
.bar > :first-child { justify-self: start; } .bar > :last-child { justify-self: end; }
.purse { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--gold); }
.coin-ic { width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff2b0, #e8b04a 55%, #9c6a10); display: inline-block; box-shadow: 0 0 8px #e8b04a88; }
.sub { color: var(--paper2); text-align: center; margin: 0 auto 14px; max-width: 980px; }

/* map */
.tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; max-width: 980px; margin: 4px auto 12px; }
.tabs button { border: 1px solid var(--line); background: rgba(242, 230, 204, 0.04); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 13px; min-height: 40px; }
.tabs button.on { background: var(--paper); color: var(--ink); }
.tabs button.locked { opacity: 0.4; }
.world-card { max-width: 980px; width: 100%; margin: 0 auto 14px; border-radius: 16px; padding: 18px 20px; border: 1px solid var(--line); position: relative; overflow: hidden; min-height: 110px; }
.world-card h3 { font-family: var(--head); font-size: 28px; margin: 0 0 4px; }
.world-card p { margin: 0; color: rgba(242, 230, 204, 0.82); max-width: 560px; }
.world-card .wc-meta { margin-top: 10px; font-size: 13px; color: var(--paper2); display: flex; gap: 16px; flex-wrap: wrap; }
.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-width: 980px; width: 100%; margin: 0 auto; }
.node { text-align: left; border: 1px solid var(--line); background: rgba(242, 230, 204, 0.05); border-radius: 12px; padding: 12px; min-height: 96px; display: flex; flex-direction: column; gap: 4px; transition: transform 0.12s, border-color 0.15s; }
.node:hover:not([disabled]) { transform: translateY(-2px); border-color: rgba(242, 230, 204, 0.4); }
.node .n-num { font-size: 11px; letter-spacing: 0.14em; color: var(--paper2); text-transform: uppercase; }
.node .n-name { font-weight: 700; font-size: 15px; }
.node .n-meta { margin-top: auto; display: flex; justify-content: space-between; font-size: 12px; color: var(--paper2); }
.node .st { color: #5a5060; letter-spacing: 1px; } .node .st b { color: var(--gold); font-weight: 400; }
.node.boss { background: linear-gradient(160deg, rgba(214, 48, 72, 0.25), rgba(242, 230, 204, 0.04)); border-color: #d6304866; }
.node.cleared { border-color: rgba(232, 176, 74, 0.35); }
.node[disabled] { opacity: 0.45; cursor: not-allowed; }
.node .lock { font-size: 12px; color: #ff9aa8; }

/* dojo + wardrobe */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; max-width: 980px; width: 100%; margin: 0 auto; }
.card-s { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: rgba(242, 230, 204, 0.05); display: flex; flex-direction: column; gap: 8px; }
.card-s h4 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card-s p { margin: 0; color: var(--paper2); font-size: 13px; }
.card-s .val { color: var(--paper); font-weight: 600; font-size: 13px; }
.pips { display: flex; gap: 4px; } .pips i { flex: 1; height: 6px; border-radius: 3px; background: rgba(242, 230, 204, 0.12); } .pips i.on { background: var(--gold); box-shadow: 0 0 6px #e8b04a88; }
.card-s .btn { margin-top: auto; }
.swatch { height: 90px; border-radius: 10px; position: relative; overflow: hidden; background: #1a1424; }
.swatch canvas { width: 100%; height: 100%; display: block; }
.card-s.eq { border-color: var(--gold); }

/* settings */
.settings { max-width: 560px; width: 100%; margin: 0 auto; display: grid; gap: 14px; }
.settings label { display: grid; grid-template-columns: 1fr 1.4fr; align-items: center; gap: 12px; }
.settings label.tog { grid-template-columns: auto 1fr; }
.settings input[type=range] { width: 100%; accent-color: var(--red); }
.settings input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--red); }
.keys { border-top: 1px solid var(--line); padding-top: 10px; font-size: 13px; color: var(--paper2); }
.keys h3 { color: var(--paper); font-size: 14px; margin: 0 0 6px; } .keys b { color: var(--paper); }

/* cards */
.card { background: linear-gradient(180deg, #1c1626, #120e18); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(420px, 100%); display: grid; gap: 10px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.card h2 { font-family: var(--head); margin: 0 0 4px; font-size: 30px; }
.results .stars { display: flex; justify-content: center; gap: 14px; margin: 6px 0; }
.results .star { width: 64px; text-align: center; font-size: 11px; color: var(--paper2); opacity: 0; transform: scale(0.4); transition: all 0.35s cubic-bezier(0.3, 1.6, 0.5, 1); }
.results .star.show { opacity: 1; transform: none; }
.results .star i { display: block; font-style: normal; font-size: 40px; line-height: 1; color: #3a3044; }
.results .star.got i { color: var(--gold); text-shadow: 0 0 18px #e8b04a; }
.stat { list-style: none; padding: 0; margin: 4px 0; display: grid; gap: 4px; font-size: 14px; }
.stat li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 4px 2px; }
.stat li b { color: var(--paper); } .stat li span { color: var(--paper2); }
.unlock { color: var(--jade); font-weight: 600; margin: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left)); }
.hud-left { position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: grid; gap: 4px; }
.hearts { display: flex; gap: 4px; }
.hearts i { width: 22px; height: 20px; display: block; background: #3a1820; clip-path: path('M11 19 C-4 9 2 -2 11 5 C20 -2 26 9 11 19Z'); }
.hearts i.on { background: linear-gradient(180deg, #ff6a7e, #c0263a); filter: drop-shadow(0 0 4px #ff4a5e); }
.hearts i.pop { animation: pop 0.35s; }
@keyframes pop { 50% { transform: scale(1.35); } }
.hud-row { display: flex; align-items: center; gap: 6px; font-weight: 700; text-shadow: 0 1px 3px #000; }
#h-scrolls i { width: 14px; height: 18px; display: inline-block; border-radius: 2px; background: rgba(242, 230, 204, 0.18); border-left: 3px solid #5a2a20; border-right: 3px solid #5a2a20; }
#h-scrolls i.on { background: #f1e2bd; border-color: #a83a24; box-shadow: 0 0 8px #ffd27a; }
.hud-right { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px #000; }
.icon-btn { pointer-events: auto; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(12, 9, 18, 0.55); font-size: 12px; }
#boss-bar { position: absolute; left: 50%; top: max(12px, env(safe-area-inset-top)); transform: translateX(-50%); width: min(460px, 52vw); text-align: center; }
.bb-name { font-family: var(--head); font-size: 18px; text-shadow: 0 2px 6px #000; letter-spacing: 0.06em; }
.bb-track { height: 10px; border-radius: 5px; background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(242, 230, 204, 0.3); overflow: hidden; }
.bb-track i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ff4a5e, #ffb04a); transition: width 0.2s; }
.hud-skills { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.sk { --cd: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; position: relative; background: conic-gradient(rgba(0, 0, 0, 0.65) calc(var(--cd) * 1turn), rgba(242, 230, 204, 0.16) 0); border: 1px solid var(--line); font-size: 16px; }
.sk em { position: absolute; right: -2px; bottom: -2px; font-style: normal; font-size: 11px; font-weight: 700; background: var(--ink); border-radius: 8px; padding: 0 4px; }
.sk.ready { border-color: rgba(242, 230, 204, 0.5); }
.sk.ult { background: conic-gradient(var(--red) calc(var(--fill, 0) * 1turn), rgba(0, 0, 0, 0.5) 0); font-family: var(--head); }
.sk.ult.ready { box-shadow: 0 0 14px var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 24px var(--red); } }
.touch-on .hud-skills { display: none; }

#banner { position: absolute; left: 0; right: 0; top: 30%; text-align: center; z-index: 12; pointer-events: none; animation: banner 2.6s ease-out forwards; }
#banner h2 { font-family: var(--head); font-size: clamp(30px, 6vw, 56px); margin: 0; text-shadow: 0 4px 24px #000; letter-spacing: 0.06em; }
#banner small { letter-spacing: 0.3em; text-transform: uppercase; color: var(--paper2); font-size: 12px; }
@keyframes banner { 0% { opacity: 0; transform: translateY(10px); } 12%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.3s; z-index: 15; }
#fade.on { opacity: 1; }

/* ---------- touch ---------- */
#touch { position: absolute; inset: 0; z-index: 11; pointer-events: none; }
#touch button { pointer-events: auto; position: absolute; border-radius: 50%; border: 1.5px solid rgba(242, 230, 204, 0.28); background: rgba(12, 9, 18, 0.38); color: rgba(242, 230, 204, 0.9); font-size: calc(22px * var(--tb)); display: grid; place-items: center; touch-action: none; backdrop-filter: blur(2px); }
#touch button.on { background: rgba(242, 230, 204, 0.28); }
#touch button.cd { opacity: 0.45; }
#touch button.ready-ult { border-color: var(--red); box-shadow: 0 0 18px var(--red); }
.dpad { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: calc(200px * var(--tb)); height: calc(130px * var(--tb)); }
.dpad [data-act=left] { left: 0; bottom: 18px; width: calc(84px * var(--tb)); height: calc(84px * var(--tb)); }
.dpad [data-act=right] { left: calc(96px * var(--tb)); bottom: 18px; width: calc(84px * var(--tb)); height: calc(84px * var(--tb)); }
.dpad .small { left: calc(66px * var(--tb)); bottom: calc(-6px * var(--tb)); width: calc(48px * var(--tb)); height: calc(36px * var(--tb)); border-radius: 12px !important; font-size: 14px !important; opacity: 0.7; }
.acts { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); width: calc(250px * var(--tb)); height: calc(210px * var(--tb)); }
.a-jump { right: 0; bottom: 0; width: calc(88px * var(--tb)); height: calc(88px * var(--tb)); font-size: calc(30px * var(--tb)) !important; }
.a-atk { right: calc(98px * var(--tb)); bottom: calc(6px * var(--tb)); width: calc(76px * var(--tb)); height: calc(76px * var(--tb)); }
.a-dash { right: calc(18px * var(--tb)); bottom: calc(98px * var(--tb)); width: calc(64px * var(--tb)); height: calc(64px * var(--tb)); }
.a-star { right: calc(102px * var(--tb)); bottom: calc(92px * var(--tb)); width: calc(58px * var(--tb)); height: calc(58px * var(--tb)); }
.a-log { right: calc(176px * var(--tb)); bottom: calc(74px * var(--tb)); width: calc(50px * var(--tb)); height: calc(50px * var(--tb)); font-size: 18px !important; }
.a-ult { right: calc(168px * var(--tb)); bottom: calc(140px * var(--tb)); width: calc(52px * var(--tb)); height: calc(52px * var(--tb)); font-family: var(--head); }

@media (max-width: 640px) {
  .bar h2 { font-size: 21px; }
  .nodes { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .settings label { grid-template-columns: 1fr; }
  .row { grid-template-columns: 1fr 1fr; } .row .primary { grid-column: span 2; order: -1; }
}
@media (max-height: 460px) {
  .logo { font-size: 46px; } .tag { margin: 6px 0 14px; } .menu { grid-template-columns: 1fr 1fr; max-width: 420px; }
  .card { padding: 14px; gap: 6px; } .results .star i { font-size: 30px; }
}
/* controls screen */
.ctrl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 980px; width: 100%; margin: 0 auto; }
.ctrl-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: rgba(242, 230, 204, 0.05); }
.ctrl-card h3 { margin: 0 0 10px; font-family: var(--head); font-size: 20px; }
.keylist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.keylist li { display: grid; grid-template-columns: 168px 1fr; align-items: center; column-gap: 12px; }
.keylist li small { grid-column: 2; color: var(--paper2); font-size: 12px; margin-top: -2px; }
.keylist.touch li { grid-template-columns: 48px 1fr; }
.keys2 { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.keys2 em { font-style: normal; font-size: 11px; color: var(--paper2); margin: 0 2px; }
kbd { min-width: 30px; height: 30px; padding: 0 7px; display: inline-grid; place-items: center; border-radius: 7px; font: 600 13px Inter, system-ui, sans-serif; color: var(--paper);
  background: linear-gradient(180deg, #2c2438, #1a1522); border: 1px solid rgba(242, 230, 204, 0.25); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
kbd.wide { min-width: 52px; }
.tb { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(242, 230, 204, 0.35); background: rgba(12, 9, 18, 0.5); font-size: 14px; }
.pad-note { color: var(--paper2); font-size: 12px; margin: 12px 0 0; }
.phone { border: 3px solid #3a3346; border-radius: 18px; padding: 6px; background: #08060c; margin-bottom: 12px; }
.ph-screen { position: relative; aspect-ratio: 19.5 / 9; border-radius: 12px; overflow: hidden; background: linear-gradient(180deg, #2a1640 0%, #7a3a5a 55%, #1a1022 56%, #0e0a12 100%); }
.ph-b { position: absolute; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid rgba(242, 230, 204, 0.4); background: rgba(12, 9, 18, 0.45); color: var(--paper); font-size: 12px; transform: translate(-50%, -50%); }
.ph-left { left: 9%; top: 72%; width: 15%; aspect-ratio: 1; } .ph-right { left: 26%; top: 72%; width: 15%; aspect-ratio: 1; }
.ph-down { left: 17.5%; top: 92%; width: 8%; aspect-ratio: 1.4; border-radius: 6px; font-size: 9px; }
.ph-jump { left: 91%; top: 76%; width: 15%; aspect-ratio: 1; font-size: 15px; } .ph-atk { left: 74%; top: 79%; width: 13%; aspect-ratio: 1; }
.ph-dash { left: 88%; top: 46%; width: 11%; aspect-ratio: 1; } .ph-star { left: 74%; top: 50%; width: 10%; aspect-ratio: 1; }
.ph-log { left: 61%; top: 60%; width: 9%; aspect-ratio: 1; font-size: 10px; } .ph-ult { left: 63%; top: 36%; width: 9%; aspect-ratio: 1; color: #ff8a9a; }
.ph-pause { left: 94%; top: 10%; width: 7%; aspect-ratio: 1; border-radius: 6px; font-size: 7px; }
@media (max-width: 760px) { .ctrl-grid { grid-template-columns: 1fr; } .keylist li { grid-template-columns: 150px 1fr; } }
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  body.playing #rotate { display: grid; position: absolute; inset: 0; z-index: 30; place-items: center; text-align: center; background: rgba(8, 6, 12, 0.92); }
  #rotate .rot-ic { font-size: 54px; display: inline-block; animation: rot 1.6s ease-in-out infinite; }
  #rotate p { font-weight: 600; margin: 10px 0 0; }
}
@keyframes rot { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { .screen.show, #banner { animation: none; } }
