:root {
  --paper: #ead8ae; --paper2: #dcc28c; --paper3: #f3e6c6; --ink: #2a1c12; --sepia: #6e4a2a; --red: #b23a26; --red2: #d0573a; --indigo: #2f4a6e; --ochre: #c88a2a; --gold: #d9a93b;
  --k: 1; --pw: 200px;
  --fh: "Zen Antique", "Shippori Mincho B1", serif; --fb: "Shippori Mincho B1", "Hiragino Mincho ProN", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d130c; color: var(--ink); font-family: var(--fb); font-weight: 700; user-select: none; -webkit-user-select: none; touch-action: none; }
body {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(120, 72, 32, .35), rgba(0, 0, 0, 0) 70%),
    repeating-linear-gradient(92deg, rgba(0, 0, 0, .12) 0 2px, rgba(0, 0, 0, 0) 2px 9px, rgba(255, 210, 150, .03) 9px 11px, rgba(0, 0, 0, 0) 11px 23px),
    linear-gradient(180deg, #3a2516, #23160d);
}
.hide { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

#app { position: absolute; left: 0; top: 0; }
#mapwrap { position: absolute; left: 0; top: 0; width: 1080px; height: 720px; transform-origin: 0 0; box-shadow: 0 10px 40px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .6); overflow: hidden; }
#cv { position: absolute; left: 0; top: 0; width: 1080px; height: 720px; display: block; cursor: default; }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(178, 58, 38, 0) 40%, rgba(178, 58, 38, .55)); transition: opacity .5s; }
#flash.on { opacity: 1; transition: none; }

/* ---------- 右の手帳 ---------- */
#side { position: absolute; top: 0; width: var(--pw); height: 100%; padding: calc(8px * var(--k)); }
#side .sheet {
  height: 100%; display: flex; flex-direction: column; gap: calc(6px * var(--k)); padding: calc(10px * var(--k)) calc(9px * var(--k));
  background: linear-gradient(180deg, rgba(255, 250, 230, .3), rgba(0, 0, 0, 0) 30%), var(--paper);
  border-radius: 3px; box-shadow: inset 0 0 0 calc(2px * var(--k)) var(--ink), inset 0 0 0 calc(5px * var(--k)) var(--paper), inset 0 0 0 calc(6px * var(--k)) rgba(42, 28, 18, .6), inset 0 0 40px rgba(110, 70, 25, .45), 0 8px 26px rgba(0, 0, 0, .5);
  overflow: hidden;
}
#mname { font-family: var(--fh); font-size: calc(17px * var(--k)); text-align: center; letter-spacing: .12em; padding-bottom: calc(4px * var(--k)); border-bottom: 1px solid rgba(42, 28, 18, .35); white-space: nowrap; }
.stats { display: flex; flex-direction: column; gap: calc(2px * var(--k)); }
.st { display: flex; align-items: center; gap: calc(6px * var(--k)); font-size: calc(19px * var(--k)); font-family: var(--fh); }
.st svg { width: calc(24px * var(--k)); height: calc(24px * var(--k)); fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; flex: none; }
.st svg .thin { stroke-width: 1.3; }
.st b { font-weight: 400; }
.st.bump b { animation: bump .35s; }
.st.hurt b { color: var(--red); animation: bump .4s; }
@keyframes bump { 40% { transform: scale(1.25); } }

#cards { display: grid; grid-template-columns: 1fr 1fr; gap: calc(5px * var(--k)); margin-top: calc(4px * var(--k)); }
.card { position: relative; display: flex; flex-direction: column; align-items: center; padding: calc(3px * var(--k)) 0 calc(4px * var(--k)); background: var(--paper3); border: calc(1.6px * var(--k)) solid var(--ink); border-radius: 2px; transition: transform .1s; min-height: calc(74px * var(--k)); }
.card:nth-child(5) { grid-column: span 2; flex-direction: row; justify-content: center; gap: calc(8px * var(--k)); min-height: 0; }
.card canvas { width: calc(46px * var(--k)); height: calc(46px * var(--k)); }
.card .nm { font-size: calc(12px * var(--k)); line-height: 1.1; }
.card .pr { font-family: var(--fh); font-size: calc(14px * var(--k)); color: var(--sepia); display: flex; align-items: center; gap: 2px; }
.card .pr::before { content: ""; width: calc(9px * var(--k)); height: calc(9px * var(--k)); border-radius: 50%; border: 1.5px solid var(--ochre); background: var(--gold); }
.card .hk { position: absolute; left: calc(4px * var(--k)); top: calc(2px * var(--k)); font-size: calc(10px * var(--k)); opacity: .45; font-family: var(--fh); }
.card.no { opacity: .45; }
.card.no .pr { color: var(--red); }
.card.sel { background: #f7e9c0; box-shadow: 0 0 0 calc(2px * var(--k)) var(--red), 0 2px 0 var(--ink); transform: translateY(-1px); }
.card:active { transform: translateY(1px); }
.lab { font-family: var(--fh); font-size: calc(12px * var(--k)); letter-spacing: .2em; color: var(--sepia); margin-top: calc(2px * var(--k)); display: flex; align-items: center; gap: 6px; }
.lab::before, .lab::after { content: ""; flex: 1; height: 1px; background: rgba(42, 28, 18, .35); }
#abils { display: grid; grid-template-columns: 1fr 1fr; gap: calc(5px * var(--k)); }
.ab { position: relative; height: calc(48px * var(--k)); border: calc(1.6px * var(--k)) solid var(--ink); background: var(--paper3); border-radius: 2px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: calc(12px * var(--k)); line-height: 1.15; padding: 0; }
.ab svg { width: calc(22px * var(--k)); height: calc(22px * var(--k)); fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ab .cdv { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(42, 28, 18, .32); pointer-events: none; }
.ab .cdt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--fh); font-size: calc(18px * var(--k)); color: var(--paper3); text-shadow: 0 0 3px var(--ink), 0 0 6px var(--ink); }
.ab.sel { box-shadow: 0 0 0 calc(2px * var(--k)) var(--red); background: #f7e9c0; }
.ab.ready { animation: readyPulse 1.6s infinite; }
@keyframes readyPulse { 50% { background: #f6e2a8; } }
.grow { flex: 1; }
.row { display: flex; gap: calc(5px * var(--k)); }
.row .btn { flex: 1; }

.btn { border: calc(1.8px * var(--k)) solid var(--ink); background: var(--paper3); padding: calc(7px * var(--k)) calc(10px * var(--k)); font-size: calc(14px * var(--k)); border-radius: 2px; box-shadow: 0 calc(2px * var(--k)) 0 var(--ink); position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn:active { transform: translateY(calc(2px * var(--k))); box-shadow: none; }
.btn svg { width: calc(18px * var(--k)); height: calc(18px * var(--k)); fill: var(--ink); }
.btn.big { background: var(--red); color: #f6ead0; font-family: var(--fh); font-size: calc(18px * var(--k)); letter-spacing: .08em; padding: calc(9px * var(--k)) calc(12px * var(--k)); flex-direction: column; gap: 0; text-shadow: 0 1px 0 rgba(0, 0, 0, .35); }
.btn.big .s { font-family: var(--fb); font-size: calc(11px * var(--k)); letter-spacing: 0; opacity: .9; }
.btn.big.wait { background: var(--sepia); }
.btn.big:disabled, .btn.big.off { background: #9c8a68; color: #e6d8b6; }
.btn.sm { padding: calc(5px * var(--k)) calc(8px * var(--k)); font-size: calc(13px * var(--k)); }
.btn.on { background: var(--ink); color: var(--paper3); }
.btn.on svg { fill: var(--paper3); }
#go.pulse { animation: goPulse 1.4s infinite; }
@keyframes goPulse { 50% { box-shadow: 0 2px 0 var(--ink), 0 0 0 5px rgba(178, 58, 38, .35); } }

/* ---------- 地図の上の表示 ---------- */
#banner { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); text-align: center; pointer-events: none; font-family: var(--fh); color: var(--ink); white-space: nowrap; }
#banner .b1 { font-size: 46px; letter-spacing: .25em; text-shadow: 0 0 10px var(--paper), 0 0 18px var(--paper), 0 0 24px var(--paper); }
#banner .b2 { font-size: 18px; color: var(--sepia); text-shadow: 0 0 8px var(--paper), 0 0 14px var(--paper); margin-top: 2px; }
#banner.boss .b1 { color: var(--red); font-size: 54px; }
#banner.show { animation: banIn 2.6s forwards; }
@keyframes banIn { 0% { opacity: 0; transform: translate(-50%, 10px) scale(1.15); filter: blur(4px); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1); filter: blur(0); } 78% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -8px); } }
#banner .rule { width: 260px; height: 10px; margin: 2px auto 0; background: radial-gradient(circle, var(--red) 3px, transparent 3.5px) center/14px 10px no-repeat, linear-gradient(var(--ink), var(--ink)) center/100% 1.5px no-repeat; }

#bossbar { position: absolute; left: 50%; top: 18px; width: 460px; transform: translateX(-50%); text-align: center; pointer-events: none; }
#bossbar .bn { font-family: var(--fh); font-size: 20px; letter-spacing: .2em; color: var(--red); text-shadow: 0 0 6px var(--paper), 0 0 12px var(--paper); }
#bossbar .bt { height: 12px; border: 2px solid var(--ink); background: rgba(243, 230, 198, .85); margin-top: 3px; position: relative; }
#bossbar .bt i { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(115deg, var(--red) 0 6px, var(--red2) 6px 9px); transition: width .15s; }

#foe { position: absolute; left: 14px; top: 14px; width: 300px; display: flex; gap: 10px; padding: 10px 12px; background: var(--paper3); border: 2px solid var(--ink); box-shadow: 0 4px 0 rgba(42, 28, 18, .5), inset 0 0 0 3px var(--paper3), inset 0 0 0 4px rgba(42, 28, 18, .4); pointer-events: none; }
#foe.show { animation: foeIn 6.5s forwards; }
@keyframes foeIn { 0% { opacity: 0; transform: translateX(-30px); } 6% { opacity: 1; transform: none; } 90% { opacity: 1; } 100% { opacity: 0; } }
#foe canvas { width: 72px; height: 72px; flex: none; background: radial-gradient(circle, rgba(178, 58, 38, .12), transparent 70%); }
#foe .ft { font-size: 11px; color: var(--red); letter-spacing: .2em; font-family: var(--fh); }
#foe .fn { font-family: var(--fh); font-size: 20px; }
#foe .fd { font-size: 13px; line-height: 1.35; color: var(--sepia); }

/* ---------- 塔の情報 ---------- */
#info { position: fixed; z-index: 20; width: 248px; padding: 10px 11px 11px; background: var(--paper3); border: 2px solid var(--ink); box-shadow: 0 5px 0 rgba(42, 28, 18, .55), inset 0 0 0 3px var(--paper3), inset 0 0 0 4px rgba(42, 28, 18, .35); font-size: 13px; }
#info h3 { margin: 0; font-family: var(--fh); font-weight: 400; font-size: 19px; display: flex; align-items: baseline; gap: 6px; }
#info h3 small { font-size: 12px; color: var(--paper3); background: var(--ink); padding: 0 5px; font-family: var(--fb); }
#info .x { position: absolute; right: 4px; top: 2px; border: 0; background: none; font-size: 20px; padding: 2px 6px; font-family: var(--fh); }
#info .sl { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; margin: 6px 0; color: var(--sepia); }
#info .sl b { color: var(--ink); }
#info .sl .up { color: #3f7a32; }
#info .modes { display: flex; gap: 3px; margin: 4px 0 8px; }
#info .modes button { flex: 1; padding: 4px 0; font-size: 12px; border: 1.5px solid var(--ink); background: var(--paper); border-radius: 2px; }
#info .modes button.on { background: var(--ink); color: var(--paper3); }
#info .ups { display: flex; flex-direction: column; gap: 5px; }
#info .upb { display: flex; align-items: center; gap: 8px; text-align: left; border: 1.8px solid var(--ink); background: var(--paper); padding: 5px 7px; border-radius: 2px; box-shadow: 0 2px 0 var(--ink); }
#info .upb:active { transform: translateY(2px); box-shadow: none; }
#info .upb canvas { width: 40px; height: 40px; flex: none; }
#info .upb .u1 { font-family: var(--fh); font-size: 15px; }
#info .upb .u2 { font-size: 11.5px; color: var(--sepia); line-height: 1.3; }
#info .upb .u3 { margin-left: auto; font-family: var(--fh); font-size: 16px; color: var(--sepia); white-space: nowrap; }
#info .upb.no { opacity: .5; }
#info .upb.no .u3 { color: var(--red); }
#info .sell { margin-top: 7px; width: 100%; border: 1.5px solid var(--ink); background: none; padding: 5px; font-size: 13px; border-radius: 2px; color: var(--sepia); }
#info .max { text-align: center; color: var(--sepia); padding: 4px; font-family: var(--fh); letter-spacing: .2em; }
#info .kd { font-size: 11px; color: var(--sepia); text-align: right; }

#tip { position: fixed; z-index: 25; max-width: 300px; padding: 10px 14px; background: var(--ink); color: var(--paper3); font-size: 14px; line-height: 1.5; border-radius: 3px; box-shadow: 0 6px 20px rgba(0, 0, 0, .4); pointer-events: none; animation: tipIn .3s; }
#tip::after { content: ""; position: absolute; width: 12px; height: 12px; background: var(--ink); transform: rotate(45deg); }
#tip.r::after { right: -6px; top: calc(50% - 6px); }
#tip.d::after { bottom: -6px; left: calc(50% - 6px); }
#tip.u::after { top: -6px; left: calc(50% - 6px); }
@keyframes tipIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 画面 ---------- */
.scr { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; }
#title { background: rgba(30, 18, 10, .25); }
.tcard { text-align: center; padding: clamp(20px, 4vh, 44px) clamp(28px, 6vw, 80px); background: radial-gradient(ellipse at center, rgba(243, 230, 198, .96), rgba(234, 216, 174, .94)); border: 2px solid var(--ink); box-shadow: inset 0 0 0 5px rgba(243, 230, 198, .9), inset 0 0 0 6.5px var(--ink), inset 0 0 60px rgba(120, 75, 30, .35), 0 20px 60px rgba(0, 0, 0, .55); animation: tIn .9s; max-width: 92vw; }
@keyframes tIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.tsub { font-family: var(--fh); letter-spacing: .6em; color: var(--red); font-size: clamp(13px, 2vh, 18px); margin-bottom: 4px; padding-left: .6em; }
.tcard h1 { margin: 0; font-family: var(--fh); font-weight: 400; font-size: clamp(54px, 13vh, 120px); letter-spacing: .14em; line-height: 1.05; padding-left: .14em; text-shadow: 3px 3px 0 rgba(178, 58, 38, .25); }
.tline { height: 14px; margin: 6px auto 10px; width: 80%; background: radial-gradient(circle, var(--red) 4px, transparent 4.5px) center/18px 14px no-repeat, linear-gradient(var(--ink), var(--ink)) center/100% 1.5px no-repeat; }
.tdesc { margin: 0 0 clamp(14px, 3vh, 26px); color: var(--sepia); font-size: clamp(13px, 2.2vh, 17px); }
.tcard .btn.big { font-size: clamp(20px, 3.6vh, 28px); padding: 10px 48px; }
.trow { margin-top: 14px; }
.scr .btn { --k: 1.05; }

#mapsel { background: #2a1c12; }
#wm { position: absolute; left: 0; top: 0; }
#nodes { position: absolute; inset: 0; }
.node { position: absolute; transform: translate(-50%, -50%); width: 86px; height: 86px; border-radius: 50%; border: 0; background: none; padding: 0; }
.node .ring { position: absolute; inset: 14px; border-radius: 50%; border: 2.5px solid var(--ink); background: rgba(243, 230, 198, .7); box-shadow: 0 0 0 4px rgba(243, 230, 198, .6); transition: transform .15s; }
.node.sel .ring { border-color: var(--red); box-shadow: 0 0 0 4px rgba(178, 58, 38, .3), 0 0 0 9px rgba(178, 58, 38, .12); transform: scale(1.12); }
.node.lock .ring { background: rgba(120, 100, 70, .5); border-style: dashed; }
.node .nn { position: absolute; left: 50%; top: 82px; transform: translateX(-50%); white-space: nowrap; font-family: var(--fh); font-size: 17px; text-shadow: 0 0 6px var(--paper), 0 0 10px var(--paper), 0 0 14px var(--paper); }
.node .num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--fh); font-size: 26px; }
.node .ns { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); display: flex; gap: 2px; }
.seal { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #d65a3e, var(--red) 55%, #7d2416); box-shadow: 0 1px 0 rgba(0, 0, 0, .4); position: relative; }
.seal.off { background: rgba(42, 28, 18, .15); box-shadow: inset 0 0 0 1.5px rgba(42, 28, 18, .35); }
.seal.h::after { content: "難"; position: absolute; inset: 0; color: #f3e6c6; font-size: 10px; display: flex; align-items: center; justify-content: center; font-family: var(--fh); }
#mcard { position: absolute; right: clamp(12px, 3vw, 40px); top: 50%; transform: translateY(-50%); width: min(330px, 40vw); padding: 18px 20px 20px; background: var(--paper3); border: 2px solid var(--ink); box-shadow: inset 0 0 0 4px var(--paper3), inset 0 0 0 5.5px rgba(42, 28, 18, .5), 0 14px 40px rgba(0, 0, 0, .45); max-height: 94vh; overflow: auto; }
#mcard .msub { font-family: var(--fh); color: var(--red); letter-spacing: .3em; font-size: 13px; }
#mcard h2 { margin: 2px 0 6px; font-family: var(--fh); font-weight: 400; font-size: 30px; letter-spacing: .06em; }
#mcard .mstory { margin: 0 0 10px; font-size: 14px; line-height: 1.6; color: var(--sepia); }
#mcard .mmeta { font-size: 13px; color: var(--sepia); margin-bottom: 10px; }
#mcard .diff { display: flex; gap: 6px; margin-bottom: 10px; }
#mcard .diff .btn { flex: 1; }
#mcard .mstars { display: flex; gap: 14px; font-size: 12px; color: var(--sepia); margin-bottom: 12px; }
#mcard .mstars div { display: flex; align-items: center; gap: 3px; }
#mcard .btn.big { width: 100%; font-size: 22px; }
#mapsel .back { position: absolute; left: 14px; top: 14px; }

#result, #pausem { background: rgba(30, 18, 10, .55); }
.rcard { min-width: min(440px, 92vw); text-align: center; padding: 22px 30px 26px; background: radial-gradient(ellipse at center, #f3e6c6, #e6d2a4); border: 2px solid var(--ink); box-shadow: inset 0 0 0 5px #f3e6c6, inset 0 0 0 6.5px var(--ink), inset 0 0 50px rgba(120, 75, 30, .3), 0 20px 60px rgba(0, 0, 0, .55); animation: tIn .5s; max-height: 96vh; overflow: auto; }
.rcard.small { min-width: min(320px, 92vw); }
.rcard h2 { margin: 0 0 6px; font-family: var(--fh); font-weight: 400; font-size: clamp(36px, 8vh, 56px); letter-spacing: .2em; padding-left: .2em; }
.rcard .rsub { font-family: var(--fh); color: var(--red); letter-spacing: .4em; font-size: 14px; }
.seals { display: flex; justify-content: center; gap: 18px; margin: 8px 0 12px; }
.seals i { width: 64px; height: 64px; border-radius: 50%; display: block; background: rgba(42, 28, 18, .1); box-shadow: inset 0 0 0 2px rgba(42, 28, 18, .3); position: relative; }
.seals i.on { background: radial-gradient(circle at 35% 30%, #e06a4a, var(--red) 50%, #7a2214); box-shadow: 0 3px 0 rgba(0, 0, 0, .35), inset 0 0 0 5px rgba(0, 0, 0, .12), inset 0 0 0 8px rgba(255, 210, 170, .18); animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.seals i.on::after { content: "守"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--fh); color: rgba(250, 230, 200, .85); font-size: 30px; }
@keyframes stamp { 0% { transform: scale(2.4) rotate(-25deg); opacity: 0; } 60% { opacity: 1; } }
.rstat { color: var(--sepia); font-size: 15px; line-height: 1.7; margin-bottom: 14px; }
.rstat b { color: var(--ink); font-family: var(--fh); font-weight: 400; font-size: 18px; }
.rbtns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.rbtns.col { flex-direction: column; align-items: stretch; }
.row2 { display: flex; gap: 8px; }
.row2 .btn { flex: 1; }

#rotate { position: fixed; inset: 0; z-index: 60; background: rgba(30, 18, 10, .92); color: var(--paper); display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; font-size: 18px; text-align: center; padding: 20px; }
#loading { position: fixed; inset: 0; z-index: 70; background: #2a1c12; color: var(--paper); display: flex; align-items: center; justify-content: center; font-family: var(--fh); font-size: 20px; letter-spacing: .2em; transition: opacity .5s; }
#loading.out { opacity: 0; pointer-events: none; }
