/* きずなの紋章 ― むかしの RPG ふうの まど */
@font-face {
  font-family: 'KizunaDot';
  src: url('../fonts/DotGothic16-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #05071a;
  --win: rgba(4, 6, 22, 0.93);
  --win-solid: #04061a;
  --line: #f3f0ff;
  --text: #ffffff;
  --muted: #a9a8c8;
  --accent: #ffd66b;
  --warn: #ffb347;
  --danger: #ff6464;
  --good: #7dffb0;
  --mp: #8fd0ff;
  --bond-a: #ff8ad8;
  --bond-b: #ffd66b;
  --fs: clamp(14px, 1.6vmin + 8px, 22px);
  --fs-small: calc(var(--fs) * 0.8);
  --fs-big: calc(var(--fs) * 1.3);
  --radius: 9px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  /* ウインドウ用の 十字キーが したに 出ている ときの たかさ（ふだんは 0） */
  --pad-h: 0px;
}

body.big-text { --fs: clamp(17px, 2vmin + 10px, 27px); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'KizunaDot', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', 'Yu Gothic', 'Meiryo', sans-serif;
  font-size: var(--fs);
  line-height: 1.55;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* iPhone: ピンチや ひっぱりで がめんが うごかないように（スクロールする リストだけ たてに うごかせる） */
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
.scroll, .b-cmd .menu, .b-msg, .title-screen { touch-action: pan-y; }

#field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* 2.5D（たちたい）の がめん。うえに 2D の キャンバス（くらやみ・しるし）を かさねる */
#field3d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
button:focus-visible, input:focus-visible, .item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ───── まど ───── */
.win {
  background: var(--win);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px #000, inset 0 0 0 2px #000, 0 6px 20px rgba(0, 0, 0, 0.45);
  padding: 0.55em 0.8em;
  color: var(--text);
}

.win h2, .win h3 {
  margin: 0 0 0.3em;
  font-size: var(--fs);
  font-weight: normal;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.muted { color: var(--muted); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.good { color: var(--good); }
.gold { color: var(--accent); }
.mpc { color: var(--mp); }
.small { font-size: var(--fs-small); }

/* ───── メニューの ならび ───── */
.menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.05em; }
.menu.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.2em; }
.menu .item {
  position: relative;
  padding: 0.12em 0.4em 0.12em 1.3em;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 0.8em;
  align-items: baseline;
  min-height: 1.9em;
  align-items: center;
}
.menu .item::before {
  content: '';
  position: absolute;
  left: 0.2em;
  top: 50%;
  transform: translateY(-50%);
  border: 0.32em solid transparent;
  border-left: 0.5em solid transparent;
}
.menu .item.sel { background: rgba(255, 255, 255, 0.08); }
.menu .item.sel::before { border-left-color: var(--accent); }
.menu .item.dis { color: #6d6c88; }
.menu .item .r { color: var(--muted); font-size: var(--fs-small); white-space: nowrap; }
.menu .item .r.pen { color: var(--warn); }
.menu .item .r.gold { color: var(--accent); }
.menu .item .r.good { color: var(--good); }
.menu .hdr {
  color: var(--accent);
  font-size: var(--fs-small);
  padding: 0.5em 0.4em 0.1em;
  border-bottom: 1px dashed rgba(255, 214, 107, 0.35);
  margin-bottom: 0.15em;
  pointer-events: none;
}
.menu .hdr:first-child { padding-top: 0.1em; }
.menu .item .face { height: 1.9em; width: auto; image-rendering: pixelated; margin-right: 0.4em; flex: none; object-fit: contain; }
.menu .item .l.wf { display: flex; align-items: center; min-width: 0; flex-wrap: wrap; }
.menu .tag { font-size: 0.7em; padding: 0 0.35em; border: 1px solid currentColor; border-radius: 4px; margin-left: 0.3em; vertical-align: 0.1em; }

.scroll { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: #3b3a66; border-radius: 4px; }

/* ───── UI の そう ───── */
#ui { position: absolute; inset: 0; pointer-events: none; z-index: 60; }
#ui > * { pointer-events: auto; }

.panel {
  position: absolute;
  max-height: calc(100% - 24px - var(--safe-b) - var(--safe-t));
  display: flex;
  flex-direction: column;
}

.center-panel {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 720px);
}

.modal-back { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.35); }

/* ───── メッセージ ───── */
.dialog {
  position: absolute;
  left: 50%;
  bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%);
  width: min(94vw, 880px);
  min-height: 5.6em;
  padding: 0.7em 1em 0.9em;
  font-size: calc(var(--fs) * 1.05);
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-all;
}
.dialog .speaker {
  position: absolute;
  top: -1.35em;
  left: 0.9em;
  background: var(--win-solid);
  border: 3px solid var(--line);
  border-radius: 7px;
  padding: 0 0.6em;
  font-size: var(--fs-small);
  color: var(--accent);
}
.dialog .more {
  position: absolute;
  right: 0.8em;
  bottom: 0.2em;
  animation: blink 0.8s steps(2) infinite;
  color: var(--accent);
}
.dialog.spectator .more { color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }

.choice {
  position: absolute;
  right: max(3vw, calc(50% - 440px));
  bottom: calc(8.2em + var(--safe-b));
  min-width: 9em;
}
.choice .q { font-size: var(--fs-small); color: var(--muted); margin-bottom: 0.2em; }

/* ───── HUD ───── */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

.hud-party {
  position: absolute;
  left: calc(8px + var(--safe-l));
  top: calc(8px + var(--safe-t));
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 62vw;
  pointer-events: none;
}
.hud-mem {
  padding: 0.15em 0.5em 0.25em;
  font-size: var(--fs-small);
  min-width: 6.5em;
  line-height: 1.3;
}
.hud-mem .nm { display: flex; justify-content: space-between; gap: 0.4em; }
.hud-mem .lv { color: var(--muted); }
.bar { height: 0.36em; background: #22203a; border-radius: 3px; overflow: hidden; margin-top: 0.15em; }
.bar > i { display: block; height: 100%; background: var(--good); transition: width 0.25s; }
.bar.mp > i { background: var(--mp); }
.bar.low > i { background: var(--warn); }
.hud-mem.dead .nm { color: var(--danger); }
.hud-mem.away { opacity: 0.55; }

.hud-area {
  position: absolute;
  left: 50%;
  top: calc(10px + var(--safe-t));
  transform: translateX(-50%);
  font-size: var(--fs);
  padding: 0.15em 1em;
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
  white-space: nowrap;
}
.hud-area.show { opacity: 1; }

.hud-obj {
  position: absolute;
  left: calc(8px + var(--safe-l));
  bottom: calc(10px + var(--safe-b));
  max-width: min(54vw, 440px);
  font-size: var(--fs-small);
  padding: 0.3em 0.7em;
  line-height: 1.4;
  cursor: pointer;
}
.hud-obj b { color: var(--accent); font-weight: normal; }

.hud-map {
  position: absolute;
  right: calc(8px + var(--safe-r));
  top: calc(8px + var(--safe-t));
  padding: 3px;
  line-height: 0;
  cursor: pointer;
}
.hud-map canvas { width: clamp(90px, 18vmin, 170px); height: clamp(90px, 18vmin, 170px); image-rendering: pixelated; border-radius: 5px; }

.hud-btns {
  position: absolute;
  right: calc(8px + var(--safe-r));
  top: calc(clamp(90px, 18vmin, 170px) + 22px + var(--safe-t));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud-btn {
  padding: 0.2em 0.7em;
  font-size: var(--fs-small);
  min-width: 4.6em;
  text-align: center;
}

.hud-chat {
  position: absolute;
  left: calc(8px + var(--safe-l));
  bottom: calc(3.8em + var(--safe-b));
  max-width: min(60vw, 460px);
  font-size: var(--fs-small);
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: none;
}
.hud-chat div {
  background: rgba(0, 0, 0, 0.55);
  padding: 0.05em 0.5em;
  border-radius: 5px;
  animation: fadeout 12s forwards;
}
.hud-chat b { color: var(--accent); font-weight: normal; }
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* プレイヤーの なまえ・ふきだし */
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.plabel {
  position: absolute;
  transform: translate(-50%, -100%);
  font-size: calc(var(--fs) * 0.7);
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  white-space: nowrap;
}
.plabel.party { color: var(--accent); }
.bubble {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #fff;
  color: #111;
  border-radius: 10px;
  padding: 0.1em 0.6em;
  font-size: calc(var(--fs) * 0.8);
  white-space: nowrap;
  animation: pop 0.25s ease-out;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}
@keyframes pop { from { transform: translate(-50%, -80%) scale(0.6); opacity: 0; } }

/* ───── タッチ そうさ ───── */
#touch { position: absolute; inset: 0; pointer-events: none; }
#stick {
  position: absolute;
  width: 128px;
  height: 128px;
  left: calc(26px + var(--safe-l));
  bottom: calc(26px + var(--safe-b));
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  border: 2px solid rgba(255, 255, 255, 0.25);
  opacity: 0.8;
  transition: opacity 0.15s;
}
#stick.on { opacity: 1; border-color: rgba(255, 255, 255, 0.55); }
/* さわった ところに でる スティック（はなすと ひだりしたに もどる） */
#stick.float { transition: none; background: rgba(255, 255, 255, 0.12); }
#stick:not(.on) { opacity: 0.35; }
#stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.6);
}
.tbtn {
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.75);
  background: rgba(10, 12, 40, 0.55);
  color: #fff;
  font-size: 24px;
  pointer-events: auto;
  touch-action: none;
}
.tbtn.on { background: rgba(255, 214, 107, 0.5); }
#btn-a { right: calc(22px + var(--safe-r)); bottom: calc(70px + var(--safe-b)); }
#btn-b { right: calc(100px + var(--safe-r)); bottom: calc(26px + var(--safe-b)); }
#btn-run {
  right: calc(30px + var(--safe-r)); bottom: calc(152px + var(--safe-b));
  width: 58px; height: 58px; font-size: 13px; line-height: 1.1;
  border-color: rgba(143, 208, 255, 0.8);
}
#btn-run.on { background: rgba(143, 208, 255, 0.55); border-color: #ffffff; box-shadow: 0 0 12px rgba(143, 208, 255, 0.9); }
#btn-run span { display: block; }
body.touch .hud-obj { bottom: calc(170px + var(--safe-b)); }

/* ───── ウインドウ用の 十字キー（スマホ。input.js の bindPad） ───── */
#pad { position: absolute; inset: 0; pointer-events: none; z-index: 65; }
#pad button { pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#pad-cross {
  position: absolute;
  left: calc(10px + var(--safe-l));
  bottom: calc(10px + var(--safe-b));
  display: grid;
  grid-template-columns: repeat(3, var(--pk));
  grid-template-rows: repeat(3, var(--pk));
  grid-template-areas: ". up ." "left . right" ". down .";
  --pk: 46px;
}
#pad .pk {
  width: var(--pk);
  height: var(--pk);
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 9px;
  background: rgba(10, 12, 40, 0.72);
  color: #fff;
  font-size: 17px;
  line-height: 1;
}
#pad .pk.up { grid-area: up; }
#pad .pk.down { grid-area: down; }
#pad .pk.left { grid-area: left; }
#pad .pk.right { grid-area: right; }
#pad .pk.on, #pad .tbtn.on { background: rgba(255, 214, 107, 0.55); }
#pad-ab { position: absolute; right: calc(10px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); width: 138px; height: 138px; }
#pad-ab .tbtn { width: 64px; height: 64px; font-size: 22px; }
#pad-ab .pa { right: 0; top: 8px; }
#pad-ab .pb { left: 0; bottom: 4px; }
/* パッドが 出ている あいだは、ウインドウを パッドの ない ところへ よせる（たて: うえ・よこ: まんなか） */
body.pad-on { --pad-h: calc(160px + var(--safe-b)); }
body.pad-on #ui { bottom: var(--pad-h); }
body.pad-on #ui .panel, body.pad-on #ui .dialog, body.pad-on #ui .choice { max-width: calc(100% - 12px) !important; }
@media (orientation: landscape) {
  body.pad-on { --pad-h: 0px; }
  body.pad-on #ui { bottom: 0; left: calc(140px + var(--safe-l)); right: calc(84px + var(--safe-r)); }
  #pad-cross { --pk: 42px; }
  #pad-ab { width: 66px; height: 136px; }
  #pad-ab .tbtn { width: 60px; height: 60px; }
  #pad-ab .pa { right: 0; top: 0; }
  #pad-ab .pb { left: auto; right: 0; bottom: 0; }
}
body.talking .hud-obj, body.talking .hud-chat { visibility: hidden; }
body.touch .hud-chat { bottom: calc(230px + var(--safe-b)); }

/* ───── トースト・まく ───── */
#toast {
  position: absolute;
  left: 50%;
  top: calc(18% + var(--safe-t));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  pointer-events: none;
  z-index: 70;
}
#toast .t {
  white-space: pre-line;
  text-align: center;
  animation: toast 3.2s forwards;
}
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 10%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

#curtain {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.45s;
  z-index: 50;
}
#curtain.on { opacity: 1; }
#curtain.flash { background: #fff; transition: opacity 0.12s; }

#fx { position: absolute; inset: 0; pointer-events: none; z-index: 55; }
.chapter {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  gap: 0.4em;
  animation: chapter 4.2s forwards;
  text-align: center;
  padding: 1em;
}
.chapter .c1 { font-size: var(--fs); color: var(--muted); letter-spacing: 0.4em; }
.chapter .c2 { font-size: calc(var(--fs) * 2); color: var(--accent); letter-spacing: 0.15em; text-shadow: 0 0 18px rgba(255, 214, 107, 0.5); }
@keyframes chapter { 0% { opacity: 0; } 15%, 85% { opacity: 1; } 100% { opacity: 0; } }

/* ───── タイトル ───── */
.title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2em;
  padding: 1em;
  text-align: center;
}
.logo { display: flex; flex-direction: column; align-items: center; gap: 0.2em; }
.logo .sub { color: var(--muted); letter-spacing: 0.3em; font-size: var(--fs-small); }
.logo .main {
  font-size: clamp(34px, 9vmin, 84px);
  letter-spacing: 0.12em;
  color: #fff6d8;
  text-shadow: 0 0 2px #000, 3px 3px 0 #3c2a8c, 0 0 28px rgba(255, 214, 107, 0.55);
  line-height: 1.1;
}
.logo .crest { width: clamp(56px, 12vmin, 110px); height: auto; image-rendering: pixelated; }
.title-screen .win { min-width: min(88vw, 420px); }
.bigbtn {
  display: block;
  width: 100%;
  padding: 0.5em 1em;
  background: var(--win);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px #000;
  color: #fff;
  text-align: center;
}
.bigbtn:hover, .bigbtn.sel { border-color: var(--accent); color: var(--accent); }
.bigbtn:disabled { opacity: 0.5; cursor: default; }
.bigbtn.home-btn { margin-top: 0.5em; font-size: 0.92em; border-color: #6fb3ff; }
.bigbtn.home-btn.down { border-color: var(--line); opacity: 0.75; }
/* 家族サーバーに つながらない ときの あんない */
.server-down {
  position: absolute;
  left: 50%;
  bottom: calc(12px + var(--safe-b));
  transform: translateX(-50%);
  width: min(94vw, 520px);
  z-index: 80;
  gap: 0.45em;
  white-space: pre-line;
}
.server-down a.btn { text-decoration: none; }

/* 家族サーバーと データを 合わせている あいだの まく */
.sync-cover {
  position: absolute;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 7, 26, 0.94);
  white-space: pre-line;
}
.row { display: flex; gap: 0.6em; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 0.5em; }
.textin {
  width: 100%;
  background: #000;
  border: 2px solid var(--muted);
  border-radius: 6px;
  padding: 0.3em 0.6em;
  color: #fff;
  -webkit-user-select: text;
  user-select: text;
  /* iPhone: 長おしで「コピー」「ペースト」を出す（ページ全体では 出さない せってい） */
  -webkit-touch-callout: default;
}
.textin:focus { border-color: var(--accent); outline: none; }
.codearea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.72em; line-height: 1.3; word-break: break-all; resize: vertical; min-height: 6em; max-height: 30vh; }
.transfer-panel .detail, .transfer-panel .small { white-space: pre-line; }
/* iPhone は 16px より ちいさい にゅうりょくらんで かってに かくだい するので */
body.touch .textin { font-size: max(16px, 1em); }
.btn {
  background: #13153a;
  border: 2px solid var(--line);
  border-radius: 7px;
  padding: 0.25em 0.9em;
  color: #fff;
  min-height: 2.1em;
}
.btn.primary { border-color: var(--accent); color: var(--accent); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: 0.45; }
.btn.sel { background: #2a2d6a; }

.chars { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 15em), 1fr)); gap: 0.6em; }
.charcard { display: flex; gap: 0.7em; align-items: center; padding: 0.5em 0.7em; text-align: left; cursor: pointer; }
.charcard canvas { width: 48px; height: 63px; image-rendering: pixelated; flex: none; }
.charcard.sel { border-color: var(--accent); }
.charcard .meta { font-size: var(--fs-small); color: var(--muted); line-height: 1.35; }
.charcard .on { color: var(--good); }

.create { display: grid; grid-template-columns: auto 1fr; gap: 1em; align-items: start; }
.create .preview { display: flex; flex-direction: column; align-items: center; gap: 0.4em; }
.create .preview canvas { width: 96px; height: 126px; image-rendering: pixelated; }
.opt { display: flex; flex-wrap: wrap; gap: 0.35em; }
.opt button { min-width: 2.4em; }
.swatch { width: 2em; height: 2em; border-radius: 50%; border: 3px solid #333; padding: 0; }
.swatch.sel { border-color: #fff; box-shadow: 0 0 0 2px var(--accent); }
.jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); gap: 0.4em; }
.jobbtn { text-align: left; padding: 0.3em 0.6em; }
.jobbtn .jn { display: block; }
.jobbtn .jd { display: block; font-size: 0.7em; color: var(--muted); line-height: 1.3; }
.jobdesc { font-size: var(--fs-small); color: var(--muted); min-height: 3em; }

@media (max-width: 640px) {
  .create { grid-template-columns: 1fr; }
  .create .preview { flex-direction: row; justify-content: center; }
}

/* ───── とじる・もどる（タッチでも わかるように） ───── */
.closebtn {
  position: absolute;
  right: 0.45em;
  top: 50%;
  transform: translateY(-50%);
  min-height: 40px;
  min-width: 44px;
  padding: 0.05em 0.8em;
  border-color: var(--accent);
  color: var(--accent);
  font-size: var(--fs-small);
  white-space: nowrap;
}
.closebtn:active { background: #2a2d6a; }
.menu .backchip {
  order: -1;
  grid-column: 1 / -1;
  align-self: flex-start;
  justify-self: start;
  position: sticky;
  top: 0;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0.05em 0.9em;
  margin-bottom: 0.3em;
  border: 2px solid var(--muted);
  border-radius: 999px;
  background: var(--win-solid);
  color: var(--muted);
  font-size: var(--fs-small);
  cursor: pointer;
}
.menu .backchip:hover, .menu .backchip:active { border-color: var(--accent); color: var(--accent); }
.fm-head, .svc-head {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2em 1em;
  margin-bottom: 6px;
  padding-right: 7.4em;
  min-height: 3.1em;
}
.fm-stat, .svc-right { margin-left: auto; }
/* うえに そろえる: みぎの なかみの たかさが かわっても、ひだりの リスト（ゆびの した）が うごかない */
.fmenu-panel { left: 50%; top: calc(var(--safe-t) + max(8px, 4vh)); transform: translateX(-50%); width: min(96vw, 900px); }
.svc-panel { width: min(96vw, 860px); top: calc(var(--safe-t) + max(8px, 4vh)); transform: translateX(-50%); }
.wm-head { position: relative; width: 100%; min-height: 2.8em; display: flex; align-items: center; padding-right: 7.4em; }
.map-legend { display: flex; flex-wrap: wrap; gap: 0.2em 0.9em; margin: 0.35em 0 0.2em; }
.map-legend .lg { display: inline-flex; align-items: center; gap: 0.3em; white-space: nowrap; }
.map-legend img { width: 1.4em; height: 1.4em; image-rendering: pixelated; }
.stamp-panel { right: calc(12px + var(--safe-r)); top: 38%; width: min(80vw, 320px); }

/* ───── メニュー ───── */
.fmenu { display: grid; grid-template-columns: minmax(8em, auto) 1fr; gap: 10px; }
.fmenu .side { min-width: 8.5em; }
.fmenu .main { min-height: 12em; max-height: min(calc(74vh - var(--pad-h)), 640px); }
.fmenu-panel .fmenu .main { height: min(calc(74vh - var(--pad-h)), 640px); }
.fmenu-panel .fmenu .side { max-height: min(calc(74vh - var(--pad-h)), 640px); overflow-y: auto; }
.gold-box { font-size: var(--fs-small); margin-top: 0.4em; }
.twocol { display: grid; grid-template-columns: 1fr 1fr; gap: 0.3em 1.4em; }
.kv { display: flex; justify-content: space-between; gap: 1em; }
.kv .k { color: var(--muted); }
.detail { font-size: var(--fs-small); color: var(--muted); line-height: 1.45; margin-top: 0.4em; white-space: pre-line; }
.tabs { display: flex; gap: 0.3em; flex-wrap: wrap; margin-bottom: 0.4em; }
.tabs .btn { font-size: var(--fs-small); }
.who-list { display: flex; gap: 0.35em; flex-wrap: wrap; margin: 0.3em 0; }
.combo-row { padding: 0.3em 0; border-bottom: 1px dashed #333; }
.combo-row .nm { color: var(--accent); }
.combo-row.locked .nm { color: #6d6c88; }
.statbars { display: grid; grid-template-columns: auto 1fr auto; gap: 0.1em 0.6em; align-items: center; font-size: var(--fs-small); }
.statbars .b { height: 0.5em; background: #22203a; border-radius: 3px; overflow: hidden; }
.statbars .b i { display: block; height: 100%; background: var(--accent); }
.up { color: var(--good); }
.down { color: var(--danger); }

img.face { image-rendering: pixelated; }
.party-row .face { height: 1.8em; width: auto; vertical-align: middle; margin-right: 0.35em; }
.party-row > span:first-child { display: flex; align-items: center; }

/* 神殿（転職） */
.job-panel .job-list { max-height: min(calc(72vh - var(--pad-h)), 620px); }
.job-panel .main { height: min(calc(72vh - var(--pad-h)), 620px); }

/* 酒場 */
.tavern-panel .fmenu { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
.tavern-panel .tavern-list { max-height: min(calc(72vh - var(--pad-h)), 620px); }
.zukan-box { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.zukan-detail { flex: none; min-height: 7.6em; margin: 0.3em 0 0.4em; padding-bottom: 0.3em; border-bottom: 1px dashed rgba(255, 214, 107, 0.35); white-space: pre-line; }
.zukan-list { flex: 1; min-height: 0; }
.zukan-mon { float: right; height: 5em; width: auto; image-rendering: pixelated; margin: 0 0 0.3em 0.5em; }
.plus { color: var(--accent); font-size: 0.85em; margin-left: 0.15em; }
.tv-face { float: right; height: 3.6em; width: auto; image-rendering: pixelated; margin: 0 0 0.3em 0.5em; }
.choose-pop .menu { max-height: calc(60vh - var(--pad-h)); overflow-y: auto; }

@media (max-width: 700px) {
  .fmenu { grid-template-columns: 1fr; }
  .fmenu .side .menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fmenu .main { max-height: calc(52vh - var(--pad-h)); }
  .fmenu-panel .fmenu .main { height: calc(52vh - var(--pad-h)); }
  .job-panel .side .menu { display: flex; flex-direction: column; }
  .job-panel .job-list { max-height: calc(34vh - var(--pad-h)); }
  .job-panel .main { min-height: 0; height: calc(36vh - var(--pad-h)); max-height: calc(36vh - var(--pad-h)); }
  .tavern-panel .fmenu { grid-template-columns: 1fr; }
  .tavern-panel .side .menu { display: flex; flex-direction: column; }
  .tavern-panel .tavern-list { max-height: calc(44vh - var(--pad-h)); }
  .tavern-panel .main { min-height: 0; max-height: calc(24vh - var(--pad-h)); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .tavern-panel .fmenu { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .tavern-panel .side .menu { display: flex; flex-direction: column; }
  .tavern-panel .tavern-list, .tavern-panel .main { max-height: calc(62vh - var(--pad-h)); }
  .job-panel .fmenu { grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); }
  /* よこむきの スマホ: メニューの こうもくは 2れつ（した に はみださない） */
  .fmenu-panel .fmenu { grid-template-columns: minmax(10.5em, auto) 1fr; }
  .fmenu-panel .fmenu .side .menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 0.2em; }
  .job-panel .side .menu { display: flex; flex-direction: column; }
  .job-panel .job-list, .job-panel .main { max-height: calc(64vh - var(--pad-h)); height: calc(64vh - var(--pad-h)); }
}

/* ───── お店・教会（ドラクエ風の カウンター） ───── */
.counter-panel {
  left: 50%;
  top: calc(var(--safe-t) + max(6px, 2vh));
  transform: translateX(-50%);
  width: min(96vw, 940px);
  height: min(calc(100% - 12px - 2vh - var(--safe-t) - var(--safe-b)), 680px);
  max-height: none;
  gap: 6px;
}
.counter-panel .svc-head { margin-bottom: 0; min-height: 2.8em; flex: none; }
.counter-panel .win { background: var(--win-solid); }
.ct-title { display: inline-flex; align-items: center; gap: 0.4em; }
.ct-icon { width: 1.7em; height: 1.7em; image-rendering: pixelated; flex: none; }
.ct-gold { margin-left: auto; color: var(--accent); font-size: var(--fs-small); white-space: nowrap; }
.ct-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 6px; }
.ct-list, .ct-info { min-height: 0; }
.ct-list.active, .ct-info.active { border-color: var(--accent); }
.ct-msg {
  position: relative;
  flex: none;
  margin-top: 1em;
  min-height: 5em;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 0.8em;
  align-items: flex-start;
  padding: 0.75em 1em 0.8em;
  cursor: pointer;
}
.ct-speaker {
  position: absolute;
  top: -1.35em;
  left: 0.9em;
  background: var(--win-solid);
  border: 3px solid var(--line);
  border-radius: 7px;
  padding: 0 0.6em;
  font-size: var(--fs-small);
  color: var(--accent);
}
.ct-text { flex: 1 1 12em; min-width: 0; white-space: pre-wrap; word-break: break-all; line-height: 1.6; font-size: calc(var(--fs) * 1.02); }
.ct-choice { flex: none; margin-left: auto; }
.ct-choice .menu { min-width: 6.5em; }
.ct-choice .menu .item { min-height: 2.3em; }
.ct-more { position: absolute; right: 0.8em; bottom: 0.15em; animation: blink 0.8s steps(2) infinite; color: var(--accent); }
.ct-qty { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3em; }
.ct-qty-val { font-size: 1.15em; white-space: nowrap; }
.ct-qty .row { display: flex; gap: 0.3em; flex-wrap: wrap; justify-content: flex-end; }
.ct-item .hd { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.8em; }
.ct-item .hd .st { font-size: var(--fs-small); color: var(--good); }
.ct-item .detail { margin-top: 0.15em; }
.cmp-head { color: var(--accent); margin: 0.45em 0 0.15em; padding-bottom: 0.1em; border-bottom: 1px dashed rgba(255, 214, 107, 0.35); font-size: var(--fs-small); }
.cmp-row { display: flex; align-items: center; gap: 0.45em; padding: 0.15em 0; }
.cmp-row .face { height: 1.9em; width: auto; image-rendering: pixelated; flex: none; }
.cmp-row.dis { color: #6d6c88; }
.cmp-top { display: flex; align-items: baseline; gap: 0.1em 0.6em; flex-wrap: wrap; min-width: 0; flex: 1; }
.cmp-top .nm { min-width: 4.2em; }
.cmp-top .ar { font-weight: bold; }
.cmp-top .cmp-sub { color: var(--muted); font-size: var(--fs-small); }
.tag.e { color: var(--accent); }
.menu .tag.up { color: var(--good); }
.menu .item .cnt { color: var(--muted); font-size: 0.8em; margin-left: 0.35em; }
.menu .item .r.dis { color: #6d6c88; }
.menu .item .r.up { color: var(--good); }
.menu .item .r.down { color: var(--danger); }
@media (max-width: 700px) {
  .ct-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 0.85fr) minmax(0, 1.15fr); }
  .ct-msg { min-height: 4.4em; }
  .ct-choice.wide { flex-basis: 100%; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .counter-panel { top: calc(var(--safe-t) + 4px); height: calc(100% - 8px - var(--safe-t) - var(--safe-b)); }
  .counter-panel .svc-head { min-height: 2.4em; padding-top: 0.2em; padding-bottom: 0.2em; }
  .ct-msg { min-height: 3.2em; padding-top: 0.55em; padding-bottom: 0.45em; margin-top: 0.9em; }
  .ct-text { line-height: 1.4; }
}

/* ───── たたかい ───── */
#battle {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  padding: calc(6px + var(--safe-t)) calc(6px + var(--safe-r)) calc(6px + var(--safe-b)) calc(6px + var(--safe-l));
  gap: 6px;
  z-index: 20;
}
.b-top { display: flex; gap: 6px; align-items: stretch; }
.b-status { flex: 1; display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; }
.b-mem { padding: 0.25em 0.55em 0.35em; font-size: var(--fs-small); line-height: 1.35; position: relative; transition: transform 0.1s; }
.b-mem .nm { display: flex; justify-content: space-between; gap: 0.3em; white-space: nowrap; overflow: hidden; }
.b-mem .nm span:first-child { overflow: hidden; text-overflow: ellipsis; }
.b-mem .job { color: var(--muted); font-size: 0.85em; }
.b-mem .hpmp { display: flex; justify-content: space-between; gap: 0.4em; font-variant-numeric: tabular-nums; }
.b-mem.low .hpmp .h { color: var(--warn); }
.b-mem.dead { border-color: var(--danger); }
.b-mem.dead .nm { color: var(--danger); }
.b-mem.me { border-color: var(--accent); }
.b-mem.ready { box-shadow: 0 0 0 2px #000, 0 0 12px rgba(255, 214, 107, 0.8); }
.b-mem.cur { border-color: #ffffff; background: rgba(60, 50, 10, 0.92); }
.b-mem.cur .nm::after { content: ' ◀'; color: var(--accent); }
.b-mem.hit { animation: hit 0.3s; }
.b-mem .sts { font-size: 0.8em; color: var(--warn); min-height: 1em; }
@keyframes hit { 0%, 100% { transform: none; } 25% { transform: translateX(-4px); background: #5a0f0f; } 75% { transform: translateX(4px); } }
.atb { height: 0.42em; background: #1c1b36; border-radius: 3px; overflow: hidden; margin-top: 0.2em; }
.atb i { display: block; height: 100%; background: linear-gradient(90deg, #6fb7ff, #b9e3ff); }
.atb.full i { background: linear-gradient(90deg, #ffd66b, #fff2b8); }

.b-bond { width: 6.5em; padding: 0.25em 0.5em; font-size: var(--fs-small); display: flex; flex-direction: column; justify-content: center; gap: 0.2em; }
.b-bond .bb { height: 0.6em; background: #2a1830; border-radius: 4px; overflow: hidden; }
.b-bond .bb i { display: block; height: 100%; background: linear-gradient(90deg, var(--bond-a), var(--bond-b)); transition: width 0.3s; }
.b-bond.full { border-color: var(--bond-b); animation: glow 1s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 0 2px #000, 0 0 16px var(--bond-a); } }

.b-stage { flex: 1; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; }
.b-stage canvas { max-width: 100%; max-height: 100%; image-rendering: pixelated; }
.b-float { position: absolute; inset: 0; pointer-events: none; }
.dmg {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: calc(var(--fs) * 1.25);
  color: #fff;
  text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
  animation: dmg 1.1s forwards;
  white-space: nowrap;
}
.dmg.heal { color: var(--good); }
.dmg.crit { color: var(--accent); font-size: calc(var(--fs) * 1.6); }
.dmg.miss { color: var(--muted); }
.dmg.combo { color: var(--bond-a); font-size: calc(var(--fs) * 1.1); }
@keyframes dmg { 0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); } 12% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 70% { opacity: 1; transform: translate(-50%, -85%); } 100% { opacity: 0; transform: translate(-50%, -110%); } }
.b-banner {
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  font-size: var(--fs-big);
  color: var(--accent);
  text-shadow: 2px 2px 0 #000;
  white-space: nowrap;
  animation: banner 1.6s forwards;
  pointer-events: none;
}
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); } 15%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }

/* コマンドは 大きく（2れつの 大きな ボタン）、メッセージは コンパクトに */
.b-bottom { display: flex; gap: 6px; min-height: 10em; }
.b-cmd { flex: 2 1 0; min-width: 0; display: flex; flex-direction: column; }
.b-cmd .menu { overflow-y: auto; max-height: 12.5em; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 0.5em; align-content: start; }
.b-cmd .menu .item { min-height: 2.45em; font-size: 1.15em; }
.b-cmd .who { font-size: var(--fs); color: var(--accent); margin-bottom: 0.15em; }
.b-cmd .wait { color: var(--muted); font-size: var(--fs); }
.b-msg { flex: 1 1 0; min-width: 0; font-size: var(--fs-small); line-height: 1.5; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; }
.b-msg .ln { white-space: pre-wrap; }
.b-msg .ln.old { color: var(--muted); }
.b-tools { position: absolute; right: calc(8px + var(--safe-r)); top: 50%; display: flex; flex-direction: column; gap: 6px; z-index: 2; }
.b-tools .btn { font-size: var(--fs-small); background: rgba(10, 12, 40, 0.8); }
.b-tools .btn.on { border-color: var(--accent); color: var(--accent); }
.bondjoin {
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
  font-size: var(--fs-big);
  padding: 0.6em 1.4em;
  border: 4px solid var(--bond-b);
  background: rgba(60, 10, 60, 0.9);
  color: #fff;
  border-radius: 14px;
  z-index: 5;
  animation: glow 0.5s infinite alternate;
}
.b-result { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 640px); max-height: 80%; z-index: 6; }

/* たてむき（スマホを たてに もつ）: え は よこいっぱい、メッセージは まんなか、コマンドは したで おおきく */
@media (max-aspect-ratio: 1/1) {
  .b-top { flex-direction: column; }
  .b-status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .b-bond { width: 100%; flex-direction: row; align-items: center; }
  .b-bond .bb { flex: 1; }
  .b-stage { flex: 0 0 auto; height: calc((100vw - 12px - var(--safe-l) - var(--safe-r)) * 0.5625); max-height: 42vh; }
  .b-bottom { flex: 1; flex-direction: column-reverse; min-height: 0; }
  .b-cmd { width: 100%; flex: 1 1 auto; min-height: 0; }
  .b-cmd .menu { max-height: none; flex: 1; min-height: 0; }
  .b-cmd .menu .item { min-height: 2.8em; font-size: 1.22em; }
  /* メッセージは 3行ぶん だけ */
  .b-msg { flex: none; height: 5.6em; min-height: 0; }
  .b-tools { top: 6px; transform: none; }
}

/* ───── ぜんたいマップ ───── */
.worldmap { display: flex; flex-direction: column; align-items: center; gap: 0.4em; }
.worldmap canvas { max-width: 86vw; max-height: calc(72vh - var(--pad-h)); image-rendering: pixelated; border-radius: 6px; }

/* ───── ちいさい がめん ───── */
@media (max-height: 460px) {
  :root { --fs: clamp(12px, 2vmin + 6px, 17px); }
  .b-bottom { min-height: 6.8em; }
  .b-cmd .menu { max-height: 7.2em; }
  .b-cmd .menu .item { min-height: 2.1em; }
}

/* よこむきの スマホ（たかさが みじかい）: たたかいは ひだりに おおきく え、みぎに つよさと コマンド */
@media (orientation: landscape) and (max-height: 500px) {
  #battle {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(36vw, 320px);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas: "stage status" "stage bond" "stage cmd" "msg cmd";
  }
  .b-top, .b-bottom { display: contents; }
  .b-status { grid-area: status; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
  .b-mem { padding: 0.1em 0.45em 0.2em; line-height: 1.25; }
  .b-mem .sts:empty { display: none; }
  .b-bond { grid-area: bond; width: auto; flex-direction: row; align-items: center; padding: 0.1em 0.5em; }
  .b-bond .bb { flex: 1; }
  .b-stage { grid-area: stage; }
  .b-cmd { grid-area: cmd; width: auto; min-height: 0; overflow: hidden; }
  .b-cmd .menu { max-height: none; flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; align-content: start; }
  .b-cmd .menu .item { min-height: 2.5em; font-size: 1.1em; }
  .b-msg { grid-area: msg; min-height: 3.4em; max-height: 4.9em; }
}

/* よこむきの スマホ: もくひょう・チャットは した まんなか（スティックと ボタンの あいだ）に。キャラに かさならない */
@media (orientation: landscape) and (max-height: 520px) {
  body.touch .hud-obj {
    left: 50%;
    bottom: calc(8px + var(--safe-b));
    transform: translateX(-50%);
    max-width: min(50vw, 460px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  body.touch .hud-chat { left: 50%; transform: translateX(-50%); bottom: calc(3.4em + var(--safe-b)); max-width: min(50vw, 460px); }
  /* はしるボタンは B の うえ（メニューの ボタンと かさならない） */
  #btn-run { right: calc(104px + var(--safe-r)); bottom: calc(102px + var(--safe-b)); }
  /* メニュー・チャット・スタンプは ちずの ひだりに よこならび（A・B・走るの ボタンと かさならない） */
  .hud-btns { flex-direction: row; top: calc(8px + var(--safe-t)); right: calc(clamp(90px, 18vmin, 170px) + 28px + var(--safe-r)); }
  .hud-party { max-width: calc(100vw - clamp(90px, 18vmin, 170px) - 20em - 48px - var(--safe-l) - var(--safe-r)); }
  .hud-area { top: calc(3.4em + var(--safe-t)); }
  .hud-mem { min-width: 5.6em; }
}

/* はなしている あいだは スティックと ボタンを しまう（がめんの どこを タップしても すすむ） */
body.talking #touch { display: none; }
.talk-catcher { position: absolute; inset: 0; background: transparent; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* なかまに なりたそうな モンスター */
.mon-pop {
  position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%);
  padding: 0.8em 1.4em; z-index: 3; display: flex; align-items: center; justify-content: center;
  animation: monpop 0.5s ease-out, monbob 1.4s ease-in-out 0.5s infinite;
}
.mon-pop canvas { image-rendering: pixelated; display: block; }
@keyframes monpop { from { transform: translate(-50%, -30%) scale(0.6); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
@keyframes monbob { 0%, 100% { transform: translate(-50%, -50%); } 50% { transform: translate(-50%, -54%); } }
body.talking .mon-pop { top: 26%; }

/* 紋章が ひかる */
.crest-fx {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  pointer-events: none; z-index: 30;
}
.crest-fx canvas {
  width: min(46vmin, 260px); height: min(46vmin, 260px); image-rendering: pixelated; display: block;
  animation: crest 1.8s ease-out forwards;
  filter: drop-shadow(0 0 18px rgba(255, 214, 107, 0.95)) drop-shadow(0 0 40px rgba(255, 240, 200, 0.7));
}
@keyframes crest {
  0% { transform: scale(0.2) rotate(-30deg); opacity: 0; }
  30% { transform: scale(1.05) rotate(0deg); opacity: 1; }
  70% { transform: scale(1) rotate(0deg); opacity: 1; }
  100% { transform: scale(1.5) rotate(10deg); opacity: 0; }
}

/* ───── みかたの まどの えんしゅつ（たたかい） ───── */
.afx { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; overflow: hidden; z-index: 2; }
.afx-claw::before, .afx-claw::after {
  content: ''; position: absolute; left: calc(50% - 2.4em); width: 4.8em; top: -10%; bottom: -10%;
  background: repeating-linear-gradient(115deg, transparent 0 10px, rgba(255, 90, 90, 0.95) 10px 13px, #ffffff 13px 14px, transparent 14px 26px);
  transform-origin: left top; animation: afx-claw 0.45s ease-out forwards;
}
.afx-claw::after { background: rgba(255, 60, 60, 0.35); left: 0; right: 0; width: auto; animation: afx-fade 0.45s ease-out forwards; }
@keyframes afx-claw { 0% { clip-path: inset(0 100% 100% 0); opacity: 1; } 45% { clip-path: inset(0 0 0 0); opacity: 1; } 100% { clip-path: inset(0 0 0 0); opacity: 0; } }
@keyframes afx-fade { 0% { opacity: 1; } 100% { opacity: 0; } }
.afx-fire { background: radial-gradient(ellipse at 50% 120%, rgba(255, 230, 120, 0.95), rgba(255, 120, 40, 0.8) 40%, rgba(200, 40, 20, 0) 75%); animation: afx-rise 0.8s ease-out forwards; }
.afx-ice { background: linear-gradient(160deg, rgba(230, 251, 255, 0.9), rgba(120, 200, 255, 0.55) 45%, rgba(90, 184, 232, 0.2)); animation: afx-fade 0.8s ease-out forwards; }
.afx-ice::before { content: '✦ ✧ ✦'; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #ffffff; font-size: 1.2em; text-shadow: 0 0 6px #9ae6ff; }
.afx-wind { background: repeating-linear-gradient(170deg, transparent 0 8px, rgba(216, 255, 224, 0.75) 8px 10px, transparent 10px 18px); animation: afx-wind 0.6s ease-out forwards; }
@keyframes afx-wind { 0% { transform: translateX(-40%); opacity: 1; } 100% { transform: translateX(40%); opacity: 0; } }
.afx-dark { background: radial-gradient(circle at 50% 50%, rgba(200, 168, 240, 0.7), rgba(90, 42, 138, 0.65) 55%, rgba(20, 0, 40, 0.3)); animation: afx-fade 0.8s ease-out forwards; }
.afx-bolt { background: linear-gradient(100deg, transparent 38%, rgba(255, 251, 224, 0.95) 45%, rgba(154, 216, 255, 0.9) 50%, transparent 57%), rgba(255, 246, 176, 0.25); animation: afx-flicker 0.5s steps(2) forwards; }
@keyframes afx-flicker { 0% { opacity: 1; } 50% { opacity: 0.3; } 70% { opacity: 1; } 100% { opacity: 0; } }
.afx-quake { background: linear-gradient(0deg, rgba(160, 128, 96, 0.85), rgba(160, 128, 96, 0) 60%); animation: afx-fade 0.7s ease-out forwards; }
.afx-heal { background: radial-gradient(ellipse at 50% 100%, rgba(125, 255, 176, 0.6), rgba(125, 255, 176, 0) 70%); animation: afx-fade 0.9s ease-out forwards; }
.afx-heal::before, .afx-heal::after {
  content: '＋'; position: absolute; left: 22%; bottom: 0; color: #d8ffe8; font-size: 1.1em; text-shadow: 0 0 6px #7dffb0;
  animation: afx-up 0.9s ease-out forwards;
}
.afx-heal::after { left: 66%; animation-delay: 0.15s; }
.afx-revive { background: linear-gradient(90deg, rgba(255, 246, 176, 0) 20%, rgba(255, 246, 176, 0.9) 50%, rgba(255, 246, 176, 0) 80%); animation: afx-rise 0.9s ease-out forwards; }
.afx-poison { background: radial-gradient(circle at 30% 70%, rgba(176, 106, 224, 0.8) 0 6%, transparent 7%), radial-gradient(circle at 60% 50%, rgba(176, 106, 224, 0.8) 0 5%, transparent 6%), radial-gradient(circle at 80% 80%, rgba(216, 168, 255, 0.8) 0 4%, transparent 5%), rgba(122, 58, 168, 0.3); animation: afx-rise 0.9s ease-out forwards; }
.afx-up, .afx-down, .afx-sleep {
  display: flex; align-items: center; justify-content: center; font-size: 1.05em; letter-spacing: 0.1em;
  text-shadow: 2px 2px 0 #000;
}
.afx-up { color: #ffd66b; background: rgba(255, 214, 107, 0.18); animation: afx-up 0.9s ease-out forwards; }
.afx-down { color: #c8a8f0; background: rgba(138, 90, 200, 0.2); animation: afx-down 0.9s ease-out forwards; }
.afx-sleep { color: #ffffff; background: rgba(247, 200, 232, 0.25); animation: afx-up 1s ease-out forwards; }
.afx-shield { border: 3px solid rgba(143, 208, 255, 0.95); box-shadow: inset 0 0 14px rgba(143, 208, 255, 0.8); animation: afx-fade 0.9s ease-out forwards; }
.afx-charge { box-shadow: inset 0 0 18px rgba(255, 90, 60, 0.95); animation: afx-pulse 0.9s ease-out forwards; }
@keyframes afx-rise { 0% { transform: translateY(40%); opacity: 1; } 100% { transform: translateY(-30%); opacity: 0; } }
@keyframes afx-up { 0% { transform: translateY(35%); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(-45%); opacity: 0; } }
@keyframes afx-down { 0% { transform: translateY(-35%); opacity: 0; } 25% { opacity: 1; } 100% { transform: translateY(45%); opacity: 0; } }
@keyframes afx-pulse { 0%, 100% { opacity: 0; } 30%, 60% { opacity: 1; } }
