:root {
  --ink: #27425E; --paper: #FFF5DC; --sand: #F2E6C9; --sky: #89C8DC; --blue: #417EB4; --coral: #D87458; --amber: #E6A757; --leaf: #78A98A; --night: #404766;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  --round: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", var(--font);
  --shadow: 0 3px 0 rgba(39, 66, 94, 0.35);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; color: var(--ink); font-family: var(--font); font-size: 15px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
body { display: flex; justify-content: center; align-items: center; background: radial-gradient(ellipse at 15% 10%, #d4ebf2, transparent 45%), linear-gradient(135deg, #eef0e3, #f5e8d2); }
button { font-family: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.hidden { display: none !important; }
#app { position: relative; overflow: hidden; background: var(--sand); box-shadow: 0 16px 40px rgba(38, 60, 84, 0.25); }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.scr { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: calc(14px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; touch-action: pan-y; }
.paperBg { background: var(--sand) repeating-linear-gradient(0deg, transparent 0 5px, rgba(255, 247, 218, 0.4) 5px 6px); }
.grow { flex: 1; min-height: 8px; }
.row { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.note { font-size: 12px; color: #5a6a78; line-height: 1.6; text-align: center; margin: 6px 0; }
.lead { text-align: center; line-height: 1.6; margin: 4px 0 12px; }
.lead small { display: block; font-size: 12px; color: #5a6a78; }
.scrTitle { margin: 6px 0 2px; font-size: 22px; font-family: var(--round); }

/* ボタン（ButtonPrimary / ButtonSecondary） */
.btnP { min-height: 50px; padding: 0 22px; border-radius: 16px; border: 2px solid var(--ink); color: var(--paper); font-weight: 800; font-size: 17px; box-shadow: var(--shadow); transition: transform .12s; }
.btnP.blue { background: var(--blue); } .btnP.coral { background: var(--coral); } .btnP.leaf { background: var(--leaf); }
.btnP:active, .btnS:active, .navBtn:active, .mainBtn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(39, 66, 94, 0.35); }
.btnS { min-height: 44px; padding: 0 16px; border-radius: 14px; border: 2px solid var(--ink); background: var(--paper); font-weight: 700; font-size: 14px; box-shadow: var(--shadow); }
.btnS.small { min-height: 32px; font-size: 12px; padding: 0 10px; }
.btnS:active { background: #e0eef2; }
.wideBtn { width: 100%; max-width: 360px; margin-top: 10px; }
.panel { background: var(--paper); border: 2px solid var(--ink); border-radius: 18px; padding: 16px; width: min(92%, 380px); box-shadow: 0 6px 0 rgba(39, 66, 94, 0.25), inset 0 0 0 3px rgba(242, 230, 201, 0.8); max-height: 90%; overflow-y: auto; touch-action: pan-y; }
.panel.center { text-align: center; }
.overlay { position: absolute; inset: 0; background: rgba(39, 66, 94, 0.35); display: flex; align-items: center; justify-content: center; z-index: 30; }
.newTag { display: inline-block; background: var(--coral); color: var(--paper); border: 2px solid var(--ink); padding: 4px 14px; border-radius: 12px; font-weight: 900; transform: rotate(-3deg); margin-bottom: 6px; }

/* タイトル */
#title { padding-top: calc(20px + env(safe-area-inset-top)); }
.logoWrap { text-align: center; margin-top: 2vh; }
.logo { font-family: var(--round); font-weight: 900; font-size: clamp(50px, 15vw, 66px); line-height: 1; letter-spacing: -.02em; }
.logo span { display: inline-block; -webkit-text-stroke: 3px #3b2e2a; paint-order: stroke fill; text-shadow: 0 4px 0 #3b2e2a; }
.logo .c1 { color: #D87458; transform: rotate(-6deg); } .logo .c2 { color: #E6A757; transform: rotate(3deg); } .logo .c3 { color: #78A98A; transform: rotate(-3deg); } .logo .c4 { color: #417EB4; transform: rotate(4deg); } .logo .c5 { color: #5a9ad0; transform: rotate(-4deg); }
.latin { font-weight: 900; letter-spacing: .35em; color: var(--ink); font-size: 13px; margin-top: 8px; }
.ribbon { display: inline-block; margin-top: 8px; background: var(--paper); border: 2px solid #8a6a4a; border-radius: 10px; padding: 5px 14px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }
.titleSave { font-size: 12px; background: rgba(255, 245, 220, 0.9); border: 1.5px solid var(--ink); border-radius: 10px; padding: 4px 10px; margin-bottom: 8px; }
.titleSave:empty { display: none; }
.mainBtns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.mainBtn { min-height: 86px; border-radius: 20px; border: 3px solid #3b2e2a; color: var(--paper); display: flex; flex-direction: column; justify-content: center; align-items: center; box-shadow: 0 5px 0 rgba(59, 46, 42, 0.45); }
.mainBtn b { font-size: 24px; font-family: var(--round); letter-spacing: .05em; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.mainBtn small { font-size: 11px; margin-top: 2px; }
.mainBtn.adv { background: linear-gradient(#e0805e, #c8603a); } .mainBtn.vs { background: linear-gradient(#5a92c8, #3a6ea4); }
.subBtns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin-top: 10px; }
.subBtn { min-height: 48px; border-radius: 14px; border: 2px solid #8a6a4a; background: var(--paper); font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }

/* 主人公・相棒選択 */
.heroPick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.hcard { border: 2px solid #b8a888; background: var(--paper); border-radius: 14px; padding: 4px; min-height: 120px; }
.hcard canvas { width: 100%; height: auto; display: block; }
.hcard.sel, .pcard.sel { border: 3px solid var(--blue); box-shadow: 0 0 0 3px rgba(65, 126, 180, 0.25); }
.field { width: 100%; display: flex; flex-direction: column; gap: 6px; font-weight: 700; margin-top: 12px; font-size: 14px; }
.field input { font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--ink); background: #fffdf4; user-select: text; -webkit-user-select: text; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 12px; border-radius: 12px; border: 2px solid #b8a888; background: var(--paper); font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.chip.sel { border-color: var(--blue); background: #e0eef2; }
.chip i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-block; }
.pCards { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.pcard { display: grid; grid-template-columns: 96px 1fr; gap: 10px; text-align: left; border: 2px solid #b8a888; background: var(--paper); border-radius: 16px; padding: 8px; box-shadow: var(--shadow); }
.pcard img { width: 96px; height: 96px; object-fit: cover; object-position: center 12%; border-radius: 12px; border: 2px solid var(--ink); }
.pcard b { font-size: 19px; font-family: var(--round); }
.pcard .role { display: inline-block; font-size: 11px; color: var(--paper); background: var(--blue); border-radius: 8px; padding: 1px 8px; margin-left: 6px; vertical-align: 3px; }
.pcard .q { font-size: 13px; font-weight: 700; margin: 4px 0 2px; }
.pcard .d { font-size: 12px; color: #5a6a78; line-height: 1.5; }

/* フィールドHUD */
#exHud { position: absolute; inset: 0; pointer-events: none; }
#exHud button, #exHud canvas { pointer-events: auto; }
.exTop { position: absolute; top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: flex-start; }
.placeBox { flex: 1; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 6px 10px; box-shadow: var(--shadow); }
.placeBox b { display: block; font-size: 15px; } .placeBox span { display: block; font-size: 12px; color: #5a6a78; margin-top: 2px; }
#miniMap { width: 74px; height: 74px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); }
.exInfo { position: absolute; top: calc(92px + env(safe-area-inset-top)); left: 10px; font-size: 12px; background: rgba(255, 245, 220, 0.9); border: 1.5px solid var(--ink); border-radius: 10px; padding: 3px 8px; }
.exBar { position: absolute; left: 8px; right: 8px; bottom: calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1.25fr 1fr 1fr; gap: 6px; }
.navBtn { min-height: 58px; border-radius: 14px; border: 2px solid var(--ink); background: var(--paper); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.navBtn i { font-style: normal; font-size: 18px; }
.navBtn.act { background: var(--coral); color: var(--paper); font-size: 15px; }
.navBtn.hot { animation: hot 1s infinite; }
@keyframes hot { 50% { box-shadow: 0 0 0 5px rgba(216, 116, 88, 0.35), var(--shadow); } }
.exHint { position: absolute; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(39, 66, 94, 0.82); color: var(--paper); padding: 6px 14px; border-radius: 12px; font-size: 13px; transition: opacity 1s; white-space: nowrap; }
.exHint.gone { opacity: 0; }
#joy { position: absolute; width: 108px; height: 108px; margin: -54px 0 0 -54px; border-radius: 50%; background: rgba(255, 245, 220, 0.35); border: 2px solid rgba(39, 66, 94, 0.5); display: none; pointer-events: none; z-index: 5; }
#joy.on { display: block; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; border-radius: 50%; background: rgba(39, 66, 94, 0.55); transform: translate(-50%, -50%); }

/* ダイアログ */
.dlgBox { background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; padding: 10px 14px; font-weight: 700; line-height: 1.5; box-shadow: var(--shadow); position: relative; }
.nameTab { max-width: calc(100% - 40px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: absolute; top: -14px; left: 12px; background: var(--ink); color: var(--paper); border-radius: 8px; padding: 2px 10px; font-size: 13px; }
#dialog { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px calc(16px + env(safe-area-inset-bottom)); z-index: 25; display: flex; flex-direction: column; align-items: flex-start; }
#dlgFace { width: 96px; height: 96px; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; margin-bottom: -6px; margin-left: 6px; z-index: 1; position: relative; }
.dlgBox.big { width: 100%; min-height: 96px; padding-top: 18px; font-size: 16px; }
.dlgBox.big p { margin: 0 0 18px; }
#dlgSkip { position: absolute; right: 8px; bottom: 6px; }

/* バトル */
#battle { position: absolute; inset: 0; pointer-events: none; }
#bPanel { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 10px calc(10px + env(safe-area-inset-bottom)); pointer-events: auto; }
#bLog { min-height: 46px; font-size: 15px; }
#bParty { display: flex; gap: 6px; margin: 8px 0; }
.pchip { flex: 1; display: flex; gap: 4px; background: var(--paper); border: 2px solid var(--ink); border-radius: 12px; padding: 4px; box-shadow: var(--shadow); position: relative; min-width: 0; }
.pchip canvas { width: 40px; height: 40px; flex: none; border-radius: 50%; background: #e8dcc0; border: 1.5px solid var(--ink); }
.pchip .pinfo { min-width: 0; flex: 1; font-size: 11px; }
.pchip b { font-size: 12px; display: block; white-space: nowrap; overflow: hidden; }
.pchip.cur { border-color: var(--coral); box-shadow: 0 0 0 2px var(--coral); }
.pchip.ko { opacity: .5; }
.pchip em { position: absolute; top: -9px; right: 4px; background: var(--sky); border: 1.5px solid var(--ink); border-radius: 6px; font-size: 9px; font-style: normal; padding: 0 4px; }
.bar { height: 6px; border-radius: 3px; background: #e0d4b8; overflow: hidden; margin: 2px 0; border: 1px solid rgba(39, 66, 94, 0.4); }
.bar i { display: block; height: 100%; transition: width .3s; }
.bar.hp i { background: #3f8a5a; } .bar.mp i { background: var(--sky); } .bar.ex i { background: var(--amber); }
.cmds.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cmds.list { display: flex; flex-direction: column; gap: 6px; max-height: 34vh; overflow-y: auto; touch-action: pan-y; }
.bbtn { min-height: 52px; border-radius: 14px; border: 2px solid var(--ink); background: var(--paper); font-size: 17px; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.cmds.list .bbtn { min-height: 46px; font-size: 15px; align-items: flex-start; padding: 0 14px; }
.bbtn small { font-size: 11px; font-weight: 500; color: #5a6a78; }
.bbtn .mp { font-size: 12px; color: var(--blue); margin-left: 6px; } .bbtn .hint { display: block; font-size: 10px; font-weight: 500; opacity: .8; }
.bbtn.atk { background: var(--coral); color: var(--paper); } .bbtn.skill { background: var(--blue); color: var(--paper); } .bbtn.item { background: var(--leaf); color: var(--paper); } .bbtn.run { background: var(--paper); }
.bbtn.def { grid-column: span 2; min-height: 42px; font-size: 15px; background: #e0eef2; }
.bbtn.wide { grid-column: span 2; }
.bbtn.back { min-height: 40px; font-size: 13px; background: transparent; box-shadow: none; }
.skiphint { text-align: center; font-size: 12px; color: #5a6a78; padding: 8px; }
.tip { font-size: 13px; background: #fff0d0; border: 1.5px solid var(--amber); border-radius: 10px; padding: 8px 10px; }

/* 対戦 */
#vsPick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.pick { border-radius: 14px; border: 2px solid #b8a888; background: var(--paper); padding: 6px 4px 8px; display: flex; flex-direction: column; align-items: center; position: relative; box-shadow: var(--shadow); }
.pick.on { border: 3px solid var(--blue); background: #e0eef2; }
.pick canvas { width: 64px; height: 64px; }
.pick b { font-size: 15px; } .pick span { font-size: 11px; color: #5a6a78; } .pick small { font-size: 10px; color: var(--coral); font-weight: 700; }
.pick i { position: absolute; top: 4px; left: 6px; background: var(--blue); color: var(--paper); border-radius: 50%; width: 20px; height: 20px; font-style: normal; font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.pick.locked { opacity: .55; } .pick .lock { width: 64px; height: 64px; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 900; }
#vsHud { position: absolute; inset: 0; pointer-events: none; }
#vsHud button { pointer-events: auto; }
.vsTop { position: absolute; top: calc(6px + env(safe-area-inset-top)); left: 8px; right: 8px; display: flex; align-items: center; gap: 6px; background: var(--paper); border: 2px solid var(--ink); border-radius: 16px; padding: 4px 10px; box-shadow: var(--shadow); }
.sc { flex: 1; display: flex; align-items: center; gap: 6px; }
.sc b { font-size: 24px; font-weight: 900; width: 32px; text-align: center; }
.sc.a b { color: var(--blue); } .sc.b b { color: var(--coral); }
.sc i { flex: 1; height: 10px; border-radius: 5px; background: #e0d4b8; overflow: hidden; display: flex; border: 1px solid rgba(39, 66, 94, 0.4); }
.sc.b i { justify-content: flex-end; }
.sc u { display: block; height: 100%; } .sc.a u { background: var(--blue); } .sc.b u { background: var(--coral); }
.tm { display: flex; flex-direction: column; align-items: center; min-width: 78px; }
.tm b { font-size: 20px; font-weight: 900; }
.zstate { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
.zstate.a { background: var(--blue); color: var(--paper); } .zstate.b { background: var(--coral); color: var(--paper); } .zstate.c { background: var(--amber); }
.btnS.q { position: absolute; top: calc(60px + env(safe-area-inset-top)); left: 8px; min-height: 36px; }
#vsAnn { position: absolute; top: 24%; left: 0; right: 0; text-align: center; opacity: 0; pointer-events: none; }
#vsAnn.on { animation: ann 1.8s forwards; }
#vsAnn b { display: block; font-size: 30px; font-weight: 900; font-family: var(--round); color: var(--paper); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; }
#vsAnn span { display: inline-block; font-size: 13px; background: var(--paper); border: 2px solid var(--ink); padding: 4px 10px; border-radius: 10px; margin-top: 4px; }
@keyframes ann { 0% { opacity: 0; transform: scale(1.3); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }
#vsSwap { position: absolute; left: 10px; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.sw { width: 58px; height: 70px; border-radius: 14px; border: 2px solid var(--ink); background: var(--paper); position: relative; padding: 0; overflow: hidden; touch-action: none; box-shadow: var(--shadow); }
.sw canvas { width: 52px; height: 52px; display: block; margin: 0 auto; }
.sw .hp { position: absolute; left: 4px; right: 4px; bottom: 5px; height: 6px; border-radius: 3px; background: #e0d4b8; overflow: hidden; }
.sw .hp u { display: block; height: 100%; background: #3f8a5a; }
.sw em { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-style: normal; font-weight: 900; font-size: 22px; color: var(--paper); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; }
.sw.act { border: 3px solid var(--coral); }
.sw.ko { filter: grayscale(1); opacity: .6; }
.round { border-radius: 50%; border: 3px solid var(--ink); font-weight: 900; display: flex; flex-direction: column; align-items: center; justify-content: center; touch-action: none; box-shadow: var(--shadow); }
.round.atk { position: absolute; right: 14px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 100px; height: 100px; background: var(--coral); color: var(--paper); font-size: 17px; }
.round.sp { --cd: 0; position: absolute; right: 120px; bottom: calc(94px + env(safe-area-inset-bottom)); width: 72px; height: 72px; background: var(--blue); color: var(--paper); overflow: hidden; }
.round.sp::after { content: ""; position: absolute; inset: 0; background: conic-gradient(rgba(39, 66, 94, 0.7) calc(var(--cd) * 360deg), transparent 0); pointer-events: none; }
.round.sp.ready { box-shadow: 0 0 0 4px rgba(230, 167, 87, 0.7), var(--shadow); }
.round.sp b { font-size: 15px; } .round.sp span { font-size: 9px; }
#vrTitle { font-size: 38px; font-weight: 900; font-family: var(--round); }
#vrTitle.win { color: var(--coral); } #vrTitle.lose { color: var(--night); }
#vrScore { font-size: 28px; font-weight: 900; } #vrScore .a { color: var(--blue); } #vrScore .b { color: var(--coral); }
#vrChar { width: 140px; height: 120px; }

/* メニュー */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; top: calc(36px + env(safe-area-inset-top)); background: var(--sand); border-top: 2px solid var(--ink); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.tabs { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 8px 8px 0; }
.tabs button { min-height: 52px; border: 2px solid var(--ink); border-bottom: none; border-radius: 12px 12px 0 0; background: #e8dcc0; font-size: 11px; font-weight: 700; line-height: 1.3; }
.tabs button.on { background: var(--paper); }
.sheetBody { flex: 1; overflow-y: auto; background: var(--paper); border-top: 2px solid var(--ink); padding: 12px; touch-action: pan-y; }
.sheetFoot { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1.5px solid #d8c8a8; font-weight: 700; font-size: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ccard { border: 2px solid var(--ink); border-radius: 14px; background: #fffdf4; padding: 4px 4px 6px; text-align: center; position: relative; box-shadow: var(--shadow); }
.ccard canvas { width: 72px; height: 72px; }
.ccard b { display: block; font-size: 14px; } .ccard span { font-size: 11px; color: #5a6a78; }
.ccard .badge { position: absolute; top: 4px; left: 4px; font-size: 10px; background: var(--coral); color: var(--paper); border-radius: 6px; padding: 0 5px; }
.ccard .badge.p { background: var(--blue); left: auto; right: 4px; }
.ccard.locked { opacity: .5; }
.ccard.grow::after { content: "✦"; position: absolute; top: 2px; right: 6px; color: var(--amber); font-size: 16px; }
.secTitle { font-weight: 900; margin: 14px 0 6px; font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.list { display: flex; flex-direction: column; gap: 6px; }
.li { display: flex; align-items: center; gap: 10px; border: 2px solid #c8b898; background: #fffdf4; border-radius: 12px; padding: 8px 10px; min-height: 52px; }
.li .grow { flex: 1; } .li b { font-size: 14px; } .li small { display: block; font-size: 11px; color: #5a6a78; }
.detail { display: grid; grid-template-columns: 120px 1fr; gap: 10px; }
.detail canvas { width: 120px; height: 120px; background: radial-gradient(circle, #fff 30%, #e8dcc0); border: 2px solid var(--ink); border-radius: 16px; }
.stats { font-size: 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.stats b { float: right; }
.forms { display: flex; gap: 8px; margin-top: 6px; }
.forms button { flex: 1; border: 2px solid #c8b898; border-radius: 12px; background: #fffdf4; padding: 2px; font-size: 11px; font-weight: 700; }
.forms button.on { border-color: var(--blue); background: #e0eef2; }
.forms button canvas { width: 56px; height: 56px; display: block; margin: 0 auto; }
.forms button.lock { opacity: .4; }
.skillList { font-size: 13px; line-height: 1.6; }
.skillList div { border-bottom: 1px dashed #d8c8a8; padding: 4px 0; } .skillList small { color: #5a6a78; }
.aff { color: var(--coral); font-size: 13px; }
.worldMap { position: relative; width: 100%; aspect-ratio: 1 / 1; border: 2px solid var(--ink); border-radius: 16px; overflow: hidden; }
.worldMap canvas { width: 100%; height: 100%; }
.wpin { position: absolute; transform: translate(-50%, -100%); min-height: 36px; padding: 0 10px; border-radius: 12px; border: 2px solid var(--ink); background: var(--paper); font-size: 12px; font-weight: 800; box-shadow: var(--shadow); }
.wpin.here { background: var(--coral); color: var(--paper); }
.wpin.lock { opacity: .55; background: #e8dcc0; }
.gachaBox { text-align: center; }
.gachaBox canvas { width: 220px; height: 200px; }
.setRow { display: flex; align-items: center; gap: 10px; min-height: 52px; border-bottom: 1px dashed #d8c8a8; font-weight: 700; }
.setRow .grow { flex: 1; }
.setRow input[type=range] { width: 130px; }
.toggle { min-width: 72px; min-height: 40px; border-radius: 12px; border: 2px solid var(--ink); background: #e8dcc0; font-weight: 800; }
.toggle.on { background: var(--leaf); color: var(--paper); }

/* 会話 */
.cpList { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.cpBtn { border: 2px solid var(--ink); background: #fffdf4; border-radius: 14px; padding: 4px; font-weight: 800; box-shadow: var(--shadow); }
.cpBtn canvas { width: 60px; height: 60px; display: block; margin: 0 auto; }
#chat { position: absolute; left: 0; right: 0; bottom: 0; height: 74%; background: var(--paper); border-top: 2px solid var(--ink); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; z-index: 26; box-shadow: 0 -8px 30px rgba(39, 66, 94, 0.3); padding-bottom: env(safe-area-inset-bottom); }
.chHead { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 2px dashed #d8c8a8; }
#chFace { width: 72px; height: 72px; background: radial-gradient(circle, #fff 30%, #e8dcc0); border: 2px solid var(--ink); border-radius: 50%; }
.chInfo { flex: 1; } .chInfo b { font-size: 18px; } #chStory { font-size: 13px; color: var(--ink); }
#chLog { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; touch-action: pan-y; }
.msg { max-width: 84%; padding: 9px 13px; border-radius: 14px; font-size: 15px; line-height: 1.5; font-weight: 700; border: 2px solid var(--ink); animation: pop .18s; }
.msg.them { background: #fffdf4; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.me { background: #e0eef2; align-self: flex-end; border-bottom-right-radius: 4px; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
#chChips { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; touch-action: pan-x; }
#chChips button { flex: none; border: 2px solid #b8a888; background: #fffdf4; border-radius: 12px; padding: 7px 12px; font-size: 13px; font-weight: 700; min-height: 40px; }
#chForm { display: flex; gap: 6px; padding: 6px 10px 8px; }
#chIn { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--ink); background: #fffdf4; user-select: text; -webkit-user-select: text; }
#chMic { min-width: 48px; border-radius: 12px; border: 2px solid var(--ink); background: #e8dcc0; font-size: 18px; }
#chMic.rec { background: var(--coral); animation: pulse 1s infinite; }
#chSend { min-height: 46px; padding: 0 14px; }
#chMicNote { font-size: 11px; color: #5a6a78; padding: 0 12px 6px; }
@keyframes pulse { 50% { transform: scale(1.08); } }

/* 加入・進化 */
#joinCv { width: 220px; height: 200px; } #joinTitle, #evoTitle { display: block; font-size: 20px; font-family: var(--round); }
#evoCv { width: 260px; height: 186px; }
#popup { position: absolute; top: 18%; left: 50%; transform: translate(-50%, -10px); background: var(--paper); border: 2px solid var(--ink); border-radius: 16px; padding: 10px 18px; text-align: center; opacity: 0; pointer-events: none; transition: all .2s; z-index: 40; width: 84%; box-shadow: var(--shadow); }
#popup.on { opacity: 1; transform: translate(-50%, 0); }
#popup b { display: block; font-size: 16px; } #popup span { font-size: 13px; color: #5a6a78; }
body.reduce *, body.reduce *::before, body.reduce *::after { animation: none !important; transition: none !important; }

/* オープニング／エンディングロール */
.credits { position: absolute; inset: 0; z-index: 60; overflow: hidden; background: linear-gradient(#0f1a2b, #1d2f4d 60%, #2b3f63); color: #fff8e6; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.credits.ending { background: linear-gradient(#27304f, #6a5a86 55%, #e9a97a); }
.creditsRoll { position: absolute; left: 0; right: 0; top: 0; padding: 0 28px; text-align: center; will-change: transform; }
.creditsRoll p { margin: 0 0 .5em; font-size: 16px; line-height: 1.8; }
.creditsRoll p.small { font-size: 12px; opacity: .75; }
.creditsRoll p.sp { margin: 0; line-height: 1.1; }
.creditsRoll h2 { margin: 1.2em 0 .6em; font-size: 24px; letter-spacing: .12em; color: #ffd98a; text-shadow: 0 2px 0 rgba(0,0,0,.35); }
.creditsSkip { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 2; }
.creditsHint { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); text-align: center; font-size: 12px; opacity: .8; transition: opacity .2s; pointer-events: none; }
.dexChips { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.dexChips button.on { background: var(--ink); color: #fffdf4; }
.ccard small.where { display: block; font-size: 10px; color: #7a6a58; margin-top: 2px; line-height: 1.25; }
.pfBar { margin: 4px 0 8px; display: flex; flex-direction: column; gap: 4px; }
.pfRow { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pfRow > span { font-size: 11px; color: #5a6a78; min-width: 44px; }
.pfRow input[type=search] { flex: 1; min-width: 120px; border: 2px solid var(--ink); border-radius: 10px; padding: 6px 8px; font-size: 14px; background: #fffdf4; }
.pfRow button.on { background: var(--ink); color: #fffdf4; }
.pfChips { display: flex; flex-direction: column; gap: 4px; }
.pfSum { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 2px 0; }
.pfTag { border: 2px solid var(--ink); background: #ffe9a8; border-radius: 12px; padding: 2px 8px; font-size: 12px; font-weight: 700; cursor: pointer; }
.pfRow button.on::before { content: '✔ '; }
.costDot { display: inline-block; width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 50%; margin-right: 8px; flex: none; }
.newTag { background: #c8463a; color: #fff; font-size: 10px; padding: 0 5px; border-radius: 6px; vertical-align: middle; }
.chips { flex-wrap: wrap; }
/* 性格タイプ（キャラ情報） */
.mbtiBox{margin:6px 0 8px;padding:7px 10px;border-radius:10px;background:rgba(122,90,216,.09);border:1px solid rgba(122,90,216,.28);font-size:13px;line-height:1.5}
.mbtiBox .mbtiTag{display:inline-block;margin-right:6px;padding:1px 7px;border-radius:6px;background:#7a5ad8;color:#fff;font-weight:700;letter-spacing:.06em;font-size:12px}
.mbtiBox small{margin-left:6px;opacity:.65}
.mbtiBox p{margin:3px 0 0}

/* 図鑑の閲覧カードとキャラクター紹介 */
.dexCard { font-family:inherit; color:var(--ink); cursor:pointer; min-width:0; }
.dexCard:focus-visible { outline:3px solid var(--blue); outline-offset:2px; }
.dexProfile { align-items:center; }
.dexProfile p { font-size:12px; line-height:1.6; margin:6px 0; overflow-wrap:anywhere; }
.dexText,.dexQuote { font-size:13px; line-height:1.8; overflow-wrap:anywhere; }
.dexQuote { padding:10px; background:#fff4d8; border-left:4px solid var(--amber); }
#dxForms small { display:block; font-size:11px; }
