/* AWSクエスト：縦画面の RPG。色は :root のトークンで決める */
:root {
  --bg: #12102a;
  --bg2: #1d1a3d;
  --win: rgba(14, 12, 34, 0.94);
  --win-line: #f2efe6;
  --ink: #f4f1e8;
  --ink-dim: #b9b4d4;
  --ink-faint: #8a85a8;
  --accent: #ffcf5c;
  --good: #5fe08a;
  --bad: #ff5c7a;
  --info: #6cc6ff;
  --hp: #5fe08a;
  --hp-low: #ff5c7a;
  --exp: #6cc6ff;
  --paper: #fbf6e9;
  --paper-ink: #2a2438;
  --paper-dim: #6b6380;
  --paper-line: #e3d9c2;
  --d1: #ff7a8f;
  --d2: #6cc6ff;
  --d3: #ffb347;
  --d4: #7fe08a;
  --dk: #c9b8ff;
  --splash-bg: #ffffff;
  --q-size: 16px;
  --font-ui: "DotGothic16", "Hiragino Sans", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  --font-text: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: dark;
}

/* 起動時の制作会社ロゴ（platform.js の PF.splash が消す） */
#splash {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--splash-bg);
  transition: opacity 0.5s ease;
}
#splash img { width: min(66vh, 66vw); height: auto; animation: splash-in 0.8s ease-out both; }
#splash.out { opacity: 0; pointer-events: none; }
@keyframes splash-in { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { #splash img { animation: none; } }

html {
  box-sizing: border-box;
  height: 100%;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
}
*, *::before, *::after { box-sizing: inherit; }

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #07061a;
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

/* 縦長の画面。パソコンなど横に広い画面では中央に置く */
#stage {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100%;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- 上の帯 ---- */
#hud {
  flex: none;
  display: grid;
  grid-template-columns: auto 1fr 0.8fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px max(10px, env(safe-area-inset-left, 0px)) 7px max(10px, env(safe-area-inset-right, 0px));
  background: #0b0a1e;
  border-bottom: 2px solid #2c2852;
  font-size: 13px;
}
.hud-lv b { font-size: 20px; margin-left: 2px; color: var(--accent); font-weight: 400; }
.hud-hp-text { font-size: 11px; color: var(--ink-dim); white-space: nowrap; }
.hud-hp-text b { color: var(--ink); font-weight: 400; font-size: 13px; }
.bar { height: 7px; background: #2a2650; border-radius: 4px; overflow: hidden; margin-top: 3px; }
.bar i { display: block; height: 100%; width: 100%; background: var(--hp); border-radius: 4px; transition: width 0.4s ease, background 0.3s; }
.bar.exp i { background: var(--exp); }
.bar i.low { background: var(--hp-low); }
.hud-gold { color: var(--accent); white-space: nowrap; }
.hud-gold b { font-weight: 400; font-size: 16px; }
#hud.hit { animation: hudhit 0.4s; }
@keyframes hudhit { 0%, 100% { background: #0b0a1e; } 30% { background: #6a1426; } }

/* ---- 画面 ---- */
#view {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
.pad { padding: 14px max(14px, env(safe-area-inset-left, 0px)) 18px max(14px, env(safe-area-inset-right, 0px)); }

#scene { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.scene-slot { position: relative; flex: none; overflow: hidden; background: #000; }
.scene-slot .msg {
  position: absolute;
  left: 8px; right: 8px; top: 8px;
  padding: 8px 12px;
  background: var(--win);
  border: 2px solid var(--win-line);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  min-height: 2.2em;
  pointer-events: none;
}
.scene-slot .msg:empty { display: none; }
.scene-slot .tag {
  position: absolute; top: 8px; left: 8px;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(10, 8, 28, 0.82); border: 1px solid rgba(255,255,255,0.25);
  font-size: 12px;
}
.scene-slot .tag.right { left: auto; right: 8px; }

/* ---- 窓（RPG のウィンドウ） ---- */
.win {
  background: var(--win);
  border: 2px solid var(--win-line);
  border-radius: 10px;
  padding: 12px 14px;
}
.win + .win { margin-top: 12px; }
h2.ttl { margin: 0 0 10px; font-weight: 400; font-size: 20px; color: var(--accent); }
h3.sec { margin: 16px 0 8px; font-weight: 400; font-size: 15px; color: var(--accent); }
.dim { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }
.small { font-size: 12px; }
p.lead { margin: 0 0 10px; line-height: 1.7; font-size: 14px; color: var(--ink-dim); font-family: var(--font-text); }

/* ボタン */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid var(--win-line);
  border-radius: 10px;
  background: #24204a;
  font-size: 17px;
  text-align: center;
}
.btn:active { transform: scale(0.98); background: #34306a; }
.btn.primary { background: var(--accent); color: #2a1d05; border-color: #fff3c4; }
.btn.danger { background: #5a1a2a; border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.35); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn small { font-size: 12px; color: inherit; opacity: 0.75; }
.btn.primary small { color: #5a4210; opacity: 1; }
.gu { font-family: var(--font-text); font-size: 0.82em; font-weight: 700; margin-left: 1px; }
.lib-row small { flex: none; white-space: nowrap; }
.btns { display: grid; gap: 10px; }
.btns.two { grid-template-columns: 1fr 1fr; }
.btns.three { grid-template-columns: 1fr 1fr 1fr; }
.menu-btn { flex-direction: column; gap: 2px; min-height: 64px; font-size: 16px; }
.menu-btn small { font-size: 11px; color: var(--ink-dim); }

/* ---- タイトル ---- */
.title-screen { position: relative; justify-content: flex-end; }
.title-screen .scene-slot { position: absolute; inset: 0; height: auto !important; }
.title-box { position: relative; padding: 18px max(16px, env(safe-area-inset-left, 0px)) 22px; display: grid; gap: 12px; }
.title-logo { text-align: center; margin-bottom: 4px; }
.title-logo h1 { margin: 0; font-weight: 400; font-size: 44px; letter-spacing: 0.04em; color: var(--accent); text-shadow: 3px 3px 0 #2a1d05, 0 0 18px rgba(255, 207, 92, 0.4); }
.title-logo p { margin: 4px 0 0; font-size: 14px; color: #fff; text-shadow: 2px 2px 0 #000; }
.countdown { text-align: center; font-size: 15px; color: #fff; text-shadow: 2px 2px 0 #000; }
.countdown b { color: var(--accent); font-size: 24px; font-weight: 400; }
.t-note { font-size: 11px; line-height: 1.6; color: var(--ink-dim); font-family: var(--font-text); text-align: center; text-shadow: 1px 1px 0 #000; }

/* ---- 町・地図 ---- */
.town-info { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.area-card {
  display: grid; grid-template-columns: 6px 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: left;
  padding: 10px 12px; margin-bottom: 10px;
  border: 2px solid rgba(255,255,255,0.7); border-radius: 10px;
  background: #1c1940;
}
.area-card:active { background: #2a2660; }
.area-card .stripe { align-self: stretch; border-radius: 3px; }
.area-card .nm { font-size: 17px; }
.area-card .sb { font-size: 12px; color: var(--ink-dim); margin-top: 2px; }
.area-card .st { font-size: 12px; color: var(--ink-dim); text-align: right; white-space: nowrap; }
.area-card.locked { opacity: 0.45; }
.area-card .clear { color: var(--accent); }
.prog { height: 6px; background: #2a2650; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.prog i { display: block; height: 100%; background: var(--good); }

/* ---- 戦闘 ---- */
.battle { background: var(--bg); }
.qpanel { padding: 10px max(12px, env(safe-area-inset-left, 0px)) 14px max(12px, env(safe-area-inset-right, 0px)); }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; font-size: 12px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; border: 1px solid currentColor; font-size: 12px; line-height: 1.5; white-space: nowrap; }
.chip.solid { background: currentColor; }
.chip.solid > span { color: #1b1626; }
.chip.d1 { color: var(--d1); } .chip.d2 { color: var(--d2); } .chip.d3 { color: var(--d3); } .chip.d4 { color: var(--d4); } .chip.dk { color: var(--dk); }
.chip.diff1 { color: var(--bad); } .chip.diff2 { color: var(--ink-dim); } .chip.diff3 { color: var(--info); }
.chip.pred { color: var(--accent); }
.warn { color: var(--bad); font-size: 12px; }
.qtext {
  font-family: var(--font-text);
  font-size: var(--q-size);
  line-height: 1.75;
  color: var(--ink);
}
.qtext p { margin: 0 0 8px; }
.qhint { margin: 4px 0 10px; font-size: 13px; color: var(--accent); }
.choices { display: grid; gap: 8px; }
.choice {
  display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center;
  width: 100%; text-align: left;
  padding: 8px 10px 8px 8px;
  border: 2px solid rgba(255,255,255,0.55);
  border-radius: 10px;
  background: #1c1940;
  font-family: var(--font-text);
  font-size: var(--q-size);
  line-height: 1.6;
}
.choice .ic { position: relative; width: 40px; height: 40px; }
.choice .ic img { width: 40px; height: 40px; image-rendering: pixelated; display: block; }
.choice .ic b { position: absolute; left: -4px; top: -6px; font-family: var(--font-ui); font-weight: 400; font-size: 15px; color: #fff; text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
.choice .orb { display: grid; place-items: center; width: 36px; height: 36px; margin: 2px; border-radius: 50%; background: #5a1a2a; border: 2px solid #ff9aae; font-family: var(--font-ui); font-size: 18px; color: #fff; }
.boss-streak { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; padding: 6px 10px; border-radius: 8px; background: #3a1424; border: 1px solid var(--bad); font-size: 14px; }
.boss-streak b { color: var(--accent); font-weight: 400; font-size: 18px; }
.boss-streak .dots { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.boss-streak .dots i { width: 12px; height: 12px; border-radius: 50%; background: #2a2650; border: 1px solid #ff9aae; }
.boss-streak .dots i.on { background: var(--accent); border-color: var(--accent); }
.choice.sel { border-color: var(--accent); background: #3d3460; box-shadow: 0 0 0 2px var(--accent) inset; }
.choice.gone { opacity: 0.3; text-decoration: line-through; pointer-events: none; }
.choice.ok { border-color: var(--good); background: #173d2a; }
.choice.ng { border-color: var(--bad); background: #4a1726; }
.choice[disabled] { pointer-events: none; }
.bbar {
  flex: none;
  display: grid; grid-template-columns: 1fr 1fr 1.6fr; gap: 8px;
  padding: 8px max(10px, env(safe-area-inset-left, 0px)) 10px max(10px, env(safe-area-inset-right, 0px));
  background: #0b0a1e;
  border-top: 2px solid #2c2852;
}
.bbar .btn { min-height: 50px; font-size: 16px; }

/* ---- 重ねて出す窓 ---- */
#modals { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.modal {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  background: rgba(5, 4, 16, 0.6);
  pointer-events: auto;
  animation: fadein 0.18s ease-out;
}
.modal.center { justify-content: center; padding: 16px; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  display: flex; flex-direction: column;
  max-height: 92%;
  background: var(--bg2);
  border-top: 2px solid var(--win-line);
  border-radius: 14px 14px 0 0;
  animation: up 0.22s ease-out;
}
.modal.full .sheet { height: 100%; max-height: 100%; border-radius: 0; border-top: 0; }
.modal.center .sheet { border: 2px solid var(--win-line); border-radius: 12px; max-height: 100%; }
@keyframes up { from { transform: translateY(30px); opacity: 0.4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet, .modal { animation: none; } }
.sheet-head {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sheet-head h2 { flex: 1; margin: 0; font-weight: 400; font-size: 18px; color: var(--accent); }
.sheet-head .x { flex: none; width: 40px; height: 40px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.4); background: transparent; font-size: 18px; }
.sheet-foot { flex: none; padding: 10px 14px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(255,255,255,0.15); }
.modal.full .sheet-foot { padding-bottom: 12px; }

/* 解説（紙のような読みやすい面） */
.paper {
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--font-text);
  font-size: var(--q-size);
  line-height: 1.75;
  -webkit-user-select: text; user-select: text;
}
.paper .pad { padding: 14px 16px 20px; }
.paper h3 { font-family: var(--font-ui); font-weight: 400; font-size: 15px; margin: 18px 0 6px; color: #5a3fa0; }
.paper h3:first-child { margin-top: 0; }
.paper h4, .paper h5, .paper h6 { font-size: 15px; margin: 16px 0 6px; color: #5a3fa0; }
.paper p { margin: 0 0 8px; }
.paper ul { margin: 0 0 8px; padding-left: 1.3em; }
.paper li { margin: 3px 0; }
.paper li.sub { margin-left: 1.2em; list-style: circle; }
.paper b { color: #7a2a4a; }
.paper code { font-size: 0.92em; background: #efe6cf; padding: 0 3px; border-radius: 3px; }
.paper .callout { border-left: 4px solid #c9a446; background: #f5ecd2; padding: 8px 10px; margin: 8px 0; border-radius: 0 6px 6px 0; }
.paper .callout p:last-child { margin-bottom: 0; }
.paper .tbl { overflow-x: auto; margin: 8px 0 12px; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y; }
.paper table { border-collapse: collapse; font-size: 13px; line-height: 1.55; min-width: 100%; }
.paper th, .paper td { border: 1px solid var(--paper-line); padding: 5px 7px; vertical-align: top; text-align: left; }
.paper th { background: #efe6cf; white-space: nowrap; }
.paper .freq { display: inline-block; font-size: 11px; padding: 0 5px; border-radius: 4px; background: #e0566b; color: #fff; vertical-align: 2px; }
.paper .chk { margin-right: 4px; color: var(--paper-dim); }
.paper .muted { color: var(--paper-dim); font-size: 13px; }
.verdict { font-family: var(--font-ui); font-size: 22px; margin: 0 0 4px; }
.verdict.ok { color: #1f8a4c; }
.verdict.ng { color: #c42b4f; }
.answer-line { font-size: 15px; margin-bottom: 10px; }
.answer-line b { font-size: 17px; }
.point { background: #fff1b8; border: 2px solid #e8c547; border-radius: 8px; padding: 8px 10px; margin: 10px 0; }
.point::before { content: '覚えるポイント'; display: block; font-family: var(--font-ui); font-size: 12px; color: #8a6a12; margin-bottom: 2px; }
.pchoices { margin: 8px 0 12px; display: grid; gap: 6px; }
.pchoice { display: grid; grid-template-columns: 26px 1fr; gap: 6px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--paper-line); background: #fff; font-size: calc(var(--q-size) - 1px); }
.pchoice .k { font-family: var(--font-ui); font-size: 15px; }
.pchoice.ans { border-color: #2fa35f; background: #e6f6ec; }
.pchoice.pick { border-color: #d64566; background: #fbe6eb; }
.pchoice .why { grid-column: 2; font-size: 13px; color: #6b3a4a; margin-top: 3px; }
.pchoice.ans .why { color: #1f6a3c; }
.reward { font-family: var(--font-ui); font-size: 15px; background: #2a2650; color: #fff; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; line-height: 1.6; }
.reward b { color: var(--accent); font-weight: 400; }
.ref-btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ref-btn { font-family: var(--font-text); font-size: 13px; padding: 6px 10px; border-radius: 8px; border: 1px solid #b9a6e0; background: #f1ebff; color: #4a2f8f; }
.toggle-more { margin: 6px 0 10px; font-family: var(--font-ui); font-size: 14px; padding: 8px 12px; border-radius: 8px; border: 2px solid #b9a6e0; background: #f1ebff; color: #4a2f8f; width: 100%; }

/* ---- 一覧 ---- */
.tabs { flex: none; display: flex; gap: 4px; padding: 8px 10px 0; overflow-x: auto; border-bottom: 2px solid #2c2852; touch-action: pan-x; }
.tab { flex: none; padding: 8px 12px; border: 2px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; background: transparent; font-size: 15px; color: var(--ink-dim); }
.tab.on { background: #24204a; border-color: #2c2852; color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.fbtn { padding: 6px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.4); background: transparent; font-size: 13px; color: var(--ink-dim); }
.fbtn.on { background: var(--accent); color: #2a1d05; border-color: var(--accent); }
.qrow {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
  width: 100%; text-align: left;
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 10px;
  background: #1c1940;
}
.qrow:active { background: #2a2660; }
.qrow .top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.qrow .txt { grid-column: 1 / -1; font-family: var(--font-text); font-size: 13px; line-height: 1.55; color: var(--ink-dim); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qrow .res { font-size: 13px; white-space: nowrap; text-align: right; }
.res .o { color: var(--good); } .res .x { color: var(--bad); }
.mastered { color: var(--accent); font-size: 12px; }
.empty { text-align: center; padding: 30px 10px; color: var(--ink-dim); line-height: 1.8; font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: #1c1940; border: 1px solid rgba(255,255,255,0.25); border-radius: 10px; padding: 8px; text-align: center; }
.stat b { display: block; font-size: 22px; font-weight: 400; color: var(--accent); }
.stat span { font-size: 11px; color: var(--ink-dim); }
.dom-row { margin-bottom: 12px; }
.dom-row .hd { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.dom-row .hd span { font-size: 12px; color: var(--ink-dim); }
.stack { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #2a2650; }
.stack i { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 11px; color: var(--ink-dim); margin: 4px 0 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.day { margin-bottom: 14px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; margin-bottom: 6px; color: var(--accent); }
.day-head span { font-size: 12px; color: var(--ink-dim); }
.idlist { font-family: var(--font-text); font-size: 13px; line-height: 1.7; color: var(--ink); background: #1c1940; border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; -webkit-user-select: text; user-select: text; word-break: break-all; }
.lib-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 6px; border: 1px solid rgba(255,255,255,0.3); border-radius: 10px; background: #1c1940; font-size: 15px; }
.lib-row .f { font-size: 11px; color: #1b1626; background: var(--bad); border-radius: 4px; padding: 0 5px; }
.lib-row small { color: var(--ink-dim); font-size: 12px; }
.search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 2px solid rgba(255,255,255,0.4); background: #0b0a1e; color: var(--ink); font-size: 16px; font-family: var(--font-text); margin-bottom: 10px; -webkit-user-select: text; user-select: text; }

/* ---- お店 ---- */
.shop-row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid rgba(255,255,255,0.3); border-radius: 10px; background: #1c1940;
}
.shop-row .nm { font-size: 16px; }
.shop-row .ef { font-size: 13px; color: var(--info); margin-left: 6px; }
.shop-row .ds { grid-column: 1; font-size: 12px; color: var(--ink-dim); font-family: var(--font-text); line-height: 1.5; }
.shop-row .act { grid-row: 1 / span 2; grid-column: 2; display: grid; gap: 4px; justify-items: end; }
.shop-row .pr { color: var(--accent); font-size: 14px; }
.sbtn { min-width: 76px; padding: 8px 10px; border-radius: 8px; border: 2px solid var(--win-line); background: #2f2a66; font-size: 14px; }
.sbtn.eq { background: var(--accent); color: #2a1d05; }
.sbtn[disabled] { opacity: 0.4; pointer-events: none; }
.cmp { font-size: 12px; color: var(--good); }

/* ---- フィールド（歩く画面） ---- */
.screen.field { background: #000; }
.scene-slot.fslot { flex: 1; min-height: 0; touch-action: none; }
.fbanner {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%);
  display: grid; justify-items: center; gap: 2px;
  padding: 7px 16px; border-radius: 10px;
  background: var(--win); border: 2px solid var(--win-line);
  font-size: 16px; white-space: nowrap; pointer-events: none;
  animation: fadein 0.3s; transition: opacity 0.5s;
}
.fbanner span { font-size: 11px; color: var(--ink-dim); }
.fbanner.out { opacity: 0; }
.fmsg {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  min-height: 5.2em; padding: 12px 16px 16px;
  background: rgba(6, 5, 20, 0.95);
  border: 3px double var(--win-line); border-radius: 8px;
  font-size: 16px; line-height: 1.7;
  font-family: var(--font-ui);
}
.fmsg .more { position: absolute; right: 12px; bottom: 4px; font-size: 13px; animation: blink 0.9s steps(2) infinite; }
.fmsg .who { color: var(--accent); }
.fmsg .tipq { display: block; margin-top: 4px; font-family: var(--font-text); font-size: 14px; line-height: 1.6; color: #e8e4ff; }
@keyframes blink { 50% { opacity: 0; } }
.fctl {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left, 0px)) 12px max(16px, env(safe-area-inset-right, 0px));
  background: #0b0a1e; border-top: 2px solid #2c2852;
  touch-action: none;
}
.dpad { position: relative; width: 156px; height: 156px; flex: none; }
.dp {
  position: absolute; width: 54px; height: 54px;
  display: grid; place-items: center;
  border-radius: 12px; border: 2px solid #5a5590;
  background: #24204a; color: #e8e4ff; font-size: 20px;
  touch-action: none;
}
.dp.on, .dp:active { background: #4a4290; border-color: var(--accent); }
.dp.up { left: 51px; top: 0; }
.dp.down { left: 51px; bottom: 0; }
.dp.left { left: 0; top: 51px; }
.dp.right { right: 0; top: 51px; }
.dpad::after { content: ""; position: absolute; left: 60px; top: 60px; width: 36px; height: 36px; border-radius: 50%; background: #17143a; pointer-events: none; }
.fbtns { display: grid; justify-items: center; gap: 12px; }
.abtn {
  width: 92px; height: 92px; border-radius: 50%;
  border: 3px solid #fff3c4; background: var(--accent); color: #2a1d05;
  display: grid; place-content: center; gap: 0;
  font-size: 17px; line-height: 1.2;
  box-shadow: 0 4px 0 #8a6a12;
  touch-action: manipulation;
}
.abtn small { font-size: 12px; color: #5a4210; }
.abtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #8a6a12; }
.mbtn { min-width: 104px; padding: 9px 14px; border-radius: 22px; border: 2px solid var(--win-line); background: #2f2a66; font-size: 15px; }
.mbtn:active { background: #4a4290; }
@media (max-height: 640px) {
  .dpad { width: 132px; height: 132px; }
  .dp { width: 46px; height: 46px; font-size: 17px; }
  .dp.up, .dp.down { left: 43px; }
  .dp.left, .dp.right { top: 43px; }
  .dpad::after { left: 50px; top: 50px; width: 32px; height: 32px; }
  .abtn { width: 80px; height: 80px; font-size: 16px; }
  .fctl { padding-top: 7px; padding-bottom: 8px; }
}

/* 主人公をえらぶ */
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.hero-cell {
  display: grid; justify-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 10px;
  border: 2px solid #3a356e; background: #1d1a3d;
  font-size: 11px; line-height: 1.3; text-align: center;
}
.hero-cell canvas { width: 60px; height: 60px; display: block; }
.hero-cell.on { border-color: var(--accent); background: #3d3460; }
.hero-now { display: flex; align-items: center; gap: 10px; }
.hero-now canvas { width: 48px; height: 48px; display: block; }
.hero-now span { flex: 1; font-size: 15px; }

/* 世界地図 */
.wmap { display: grid; justify-items: center; margin-bottom: 10px; }
.wmap canvas { display: block; image-rendering: pixelated; border: 2px solid var(--win-line); border-radius: 4px; }
.wm-row { display: grid; grid-template-columns: 6px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #2c2852; line-height: 1.6; }
.wm-row i { border-radius: 3px; }
.wm-row.locked { opacity: 0.5; }

/* ---- ちょっとした表示 ---- */
#toast {
  position: absolute; left: 50%; top: 64px; z-index: 40;
  transform: translateX(-50%);
  max-width: 88%;
  padding: 10px 16px;
  background: var(--win); border: 2px solid var(--accent); border-radius: 10px;
  font-size: 15px; text-align: center;
  pointer-events: none;
  animation: fadein 0.2s;
}
#fade { position: absolute; inset: 0; z-index: 30; background: #000; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; }
#fade.on { opacity: 1; pointer-events: auto; }

/* 横向きのスマホでは「縦向きにしてね」 */
#rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  #rotate {
    display: grid; place-items: center; position: absolute; inset: 0; z-index: 60;
    background: var(--bg); text-align: center; padding: 20px; font-size: 18px; line-height: 1.8;
  }
}
