:root {
  --bg: #0b0c1e;
  --panel: rgba(14, 18, 40, .86);
  --line: rgba(243, 213, 138, .28);
  --gold: #f3d58a;
  --gold-2: #c9a24b;
  --ink: #eef0ff;
  --ink-2: #a8aed0;
  --blue: #7ad0ff;
  --red: #ff6a5a;
  --mincho: 'Yu Mincho', 'YuMincho', 'Hiragino Mincho ProN', 'Hiragino Mincho Pro', 'Noto Serif JP', serif;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: #000; color: var(--ink);
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic UI', 'Yu Gothic', 'Meiryo', sans-serif;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; overflow: hidden;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }

.scene { position: fixed; inset: 0; max-width: 560px; margin: 0 auto; overflow: hidden; background: var(--bg); touch-action: none; }
.bg { position: absolute; inset: 0; }
.bg svg { width: 100%; height: 100%; display: block; }
.en { font-size: 11px; letter-spacing: .22em; color: var(--gold-2); margin: 0; font-weight: 700; }
.en.small { font-size: 9px; }
.gold {
  font-family: var(--mincho); font-weight: 800; margin: 0; letter-spacing: .12em;
  background: linear-gradient(180deg, #fff6d0 0%, #f3d58a 45%, #b8862a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .7));
}
.goldtext { color: var(--gold); }
.small { font-size: 11px; }

/* 題名 */
.title .title-hero { position: absolute; right: -6%; bottom: 0; width: 62%; max-width: 330px; opacity: .95; filter: drop-shadow(0 0 20px rgba(0, 0, 0, .6)); }
.title .title-hero svg { width: 100%; display: block; }
.title-box { position: absolute; left: 0; right: 0; top: 18%; text-align: center; padding: 0 16px; }
.title h1 { font-size: clamp(36px, 10.5vw, 60px); margin: 10px 0 6px; letter-spacing: .06em; white-space: nowrap; }
.title .sub { font-family: var(--mincho); color: #e8e4f8; letter-spacing: .2em; margin: 0; text-shadow: 0 2px 8px #000; }
.rule { display: block; width: 180px; height: 1px; margin: 18px auto; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
.btn.gold-btn {
  min-width: 230px; min-height: 52px; border-radius: 6px; border: 1px solid var(--gold-2);
  background: linear-gradient(180deg, rgba(40, 36, 60, .9), rgba(16, 14, 30, .95)); color: var(--gold);
  font-family: var(--mincho); font-weight: 700; font-size: 18px; letter-spacing: .15em; box-shadow: 0 0 20px rgba(243, 213, 138, .2);
}
.tap { font-size: 9px; letter-spacing: .25em; color: var(--ink-2); margin-top: 14px; }
.ver { position: absolute; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 10px); font-size: 9px; letter-spacing: .15em; color: var(--ink-2); margin: 0; }

/* 町 */
.town .bg { bottom: auto; height: 66%; }
.town::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5, 6, 20, 0) 35%, rgba(5, 6, 20, .85) 60%, rgba(5, 6, 20, 1) 68%); pointer-events: none; }
.town-head { position: absolute; left: 16px; right: 16px; top: max(14px, env(safe-area-inset-top)); z-index: 2; }
.town-head h2 { font-size: 30px; margin-top: 2px; }
.icon-btn { position: absolute; right: 0; top: 4px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(10, 12, 30, .6); font-size: 20px; color: var(--gold); }
.town-body { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 0 14px calc(env(safe-area-inset-bottom) + 14px); }
.hero-card { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.hero-face { width: 66px; height: 66px; border-radius: 10px; overflow: hidden; border: 1px solid var(--gold-2); background: linear-gradient(160deg, #2a3570, #141a40); flex: none; }
.hero-face svg { width: 150%; margin: -6% 0 0 -25%; display: block; }
.hero-name { margin: 2px 0; font-size: 15px; }
.hero-name b { font-family: var(--mincho); font-size: 18px; }
.hero-line { margin: 0; font-size: 12px; color: var(--ink-2); }
.enter {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; border-radius: 10px;
  border: 1px solid rgba(122, 208, 255, .45); background: linear-gradient(120deg, rgba(20, 40, 70, .9), rgba(12, 18, 40, .9));
  box-shadow: 0 0 24px rgba(90, 190, 255, .18);
}
.enter .mark { font-size: 26px; color: var(--blue); }
.enter b { display: block; font-family: var(--mincho); font-size: 18px; letter-spacing: .1em; }
.enter small { display: block; font-size: 11px; color: var(--ink-2); }
.enter .arrow { margin-left: auto; font-size: 26px; color: var(--gold); }
.menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.menu-grid button { border: 1px solid var(--line); border-radius: 8px; background: rgba(14, 16, 36, .85); padding: 10px 4px; line-height: 1.35; }
.menu-grid span { display: block; color: var(--gold); font-size: 16px; }
.menu-grid b { display: block; font-size: 13px; }
.menu-grid small { display: block; font-size: 10px; color: var(--ink-2); }
.town-stats { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-2); }
.town-stats b { color: var(--ink); }

/* 迷宮 */
#view { position: absolute; left: 0; top: 0; }
.hud-top { position: absolute; left: 8px; right: 8px; top: max(8px, env(safe-area-inset-top)); display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.hud-hero { display: flex; gap: 8px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px 5px 5px; min-width: 0; flex: 1; max-width: 250px; }
.hud-face { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; background: #1c2350; flex: none; }
.hud-face svg { width: 160%; margin: -8% 0 0 -30%; display: block; }
.hud-stat { flex: 1; min-width: 0; }
.hud-stat p { margin: 0 0 3px; font-size: 13px; }
.hud-stat b { font-family: var(--mincho); }
.hud-stat span { color: var(--gold); font-size: 12px; }
.hpbar { position: relative; height: 14px; border-radius: 7px; background: #2a1e2e; overflow: hidden; }
.hpbar i { position: absolute; inset: 0 auto 0 0; width: 100%; background: linear-gradient(90deg, #4fd87a, #b8f07a); transition: width .2s; }
.hpbar i.low { background: linear-gradient(90deg, #ff5a4a, #ffa04a); }
.hpbar span { position: relative; display: block; text-align: center; font-size: 10px; line-height: 14px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.hud-floor { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; display: grid; grid-template-columns: auto auto; column-gap: 8px; align-items: center; }
.hud-floor small { grid-column: 1; font-size: 8px; letter-spacing: .15em; color: var(--ink-2); }
.hud-floor b { grid-column: 1; grid-row: 2; font-family: var(--mincho); font-size: 26px; line-height: 1; color: var(--gold); }
.hud-floor span { grid-column: 2; grid-row: 1 / 3; font-size: 11px; line-height: 1.5; }
.hud-floor i { font-style: normal; font-weight: 700; }
.hud-sub { position: absolute; left: 12px; top: calc(max(8px, env(safe-area-inset-top)) + 62px); pointer-events: none; text-shadow: 0 1px 3px #000; }
.hud-sub p { margin: 0; font-size: 12px; }
.hud-sub .small { color: var(--ink-2); font-size: 10px; }
.hud-sub .status { color: #c89aff; font-size: 11px; }
.map-tools { position: absolute; right: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 60px); display: flex; gap: 6px; }
.chip { font-size: 11px; padding: 6px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.minimap { position: absolute; right: 8px; top: calc(max(8px, env(safe-area-inset-top)) + 96px); width: 132px; height: 99px; border-radius: 8px; border: 1px solid var(--line); pointer-events: none; }
.minimap.overlay { left: 0; right: 0; top: 18%; width: 100%; height: 56%; border: none; opacity: .85; }
.log {
  position: absolute; left: 10px; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 196px); margin: 0; font-size: 12px; line-height: 1.5;
  background: rgba(8, 10, 24, .72); border: 1px solid rgba(255, 255, 255, .08); border-radius: 8px; padding: 6px 10px; pointer-events: none; min-height: 40px;
}
.log span { display: block; }
.log span.old { color: var(--ink-2); }

/* スティック（左下）とボタン（右下）。iPhone の画面の下のふちから十分はなす */
.stick-area { position: absolute; left: 12px; bottom: calc(env(safe-area-inset-bottom) + 26px); width: 150px; height: 160px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; touch-action: none; }
.stick-area small { font-size: 9px; color: var(--ink-2); letter-spacing: .1em; margin-top: 6px; }
.stick {
  position: relative; width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle, rgba(243, 213, 138, .08), rgba(14, 18, 40, .7) 60%, rgba(243, 213, 138, .12));
  border: 2px solid rgba(243, 213, 138, .45); box-shadow: inset 0 0 18px rgba(0, 0, 0, .6);
}
.stick i {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6d0, #c9a24b 50%, #6a4a14 100%); box-shadow: 0 0 14px rgba(243, 213, 138, .5);
}
.stick.face { border-color: #7ad0ff; }
.actions { position: absolute; right: 10px; bottom: calc(env(safe-area-inset-bottom) + 26px); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.actions .row { display: flex; gap: 6px; }
.act { min-width: 54px; height: 38px; padding: 0 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); font-size: 12px; font-weight: 700; }
.act.on { border-color: var(--blue); color: var(--blue); box-shadow: 0 0 10px rgba(122, 208, 255, .4); }
.attack {
  width: 78px; height: 78px; border-radius: 50%; margin-right: 34px; border: 2px solid var(--gold-2);
  background: radial-gradient(circle at 40% 35%, #4a4060, #1a1630); font-family: var(--mincho); font-size: 18px; font-weight: 800; color: var(--gold);
  box-shadow: 0 0 18px rgba(243, 213, 138, .25); line-height: 1.1;
}
.attack small { display: block; font-size: 9px; color: var(--ink-2); font-family: inherit; }

/* 小さな画面 */
.modal { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; background: rgba(2, 3, 12, .6); }
.panel {
  width: min(100%, 560px); max-height: 86vh; display: flex; flex-direction: column; border-radius: 16px 16px 0 0;
  background: linear-gradient(180deg, #161a38, #0c0e22); border: 1px solid var(--line); border-bottom: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.panel header { position: relative; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.panel h3 { margin: 2px 0 0; font-family: var(--mincho); font-size: 20px; color: var(--gold); }
.x { position: absolute; right: 10px; top: 10px; width: 40px; height: 40px; font-size: 24px; color: var(--ink-2); }
.m-body { overflow-y: auto; padding: 12px 14px 18px; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.m-body p { margin: 0 0 8px; font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.m-body h4 { margin: 12px 0 4px; font-size: 14px; color: var(--gold); font-family: var(--mincho); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.list li img { width: 40px; height: 40px; }
.list li b { font-size: 14px; display: block; }
.list li small { font-size: 11px; color: var(--ink-2); display: block; line-height: 1.5; }
.list li.sel { background: rgba(243, 213, 138, .08); border-radius: 8px; }
.list li.unknown { opacity: .45; }
.mini-btn { min-width: 64px; height: 36px; border-radius: 8px; border: 1px solid var(--gold-2); color: var(--gold); font-size: 12px; font-weight: 700; padding: 0 8px; }
.mini-btn:disabled { opacity: .35; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.wide-btn { flex: 1; min-height: 46px; border-radius: 10px; border: 1px solid var(--gold-2); color: var(--gold); font-weight: 700; background: rgba(243, 213, 138, .06); }
.wide-btn.blue { border-color: var(--blue); color: var(--blue); }
.choice { display: block; width: 100%; text-align: left; padding: 12px 14px; margin-bottom: 8px; border-radius: 10px; border: 1px solid rgba(122, 208, 255, .45); background: rgba(20, 40, 70, .6); }
.choice b { display: block; font-family: var(--mincho); font-size: 16px; color: var(--gold); }
.choice small { font-size: 12px; color: var(--ink-2); }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; height: 36px; border-radius: 8px; border: 1px solid var(--line); font-size: 13px; }
.tabs button.on { border-color: var(--gold); color: var(--gold); background: rgba(243, 213, 138, .08); }
.result-face { width: 120px; margin: 0 auto 8px; }
.result-face svg { width: 100%; display: block; }
.center { text-align: center; }
.big-gold { font-family: var(--mincho); font-size: 26px; color: var(--gold); margin: 4px 0; }
.toast { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); z-index: 30; background: rgba(10, 12, 30, .92); border: 1px solid var(--line); color: var(--gold); padding: 10px 18px; border-radius: 99px; font-size: 14px; }

@media (hover: hover) and (pointer: fine) {
  .stick-area { transform: scale(.85); transform-origin: left bottom; }
}
