/* ============================================================
   AI PARTY — Chronicles of NO.
   FF風 (古典 JRPG) UI/UX
   ============================================================ */

:root {
  --bg-deep: #03040c;
  --bg-0: #060a1c;
  --bg-1: #0a1530;
  --bg-2: #142049;
  --bg-3: #1d2a5c;

  --ff-frame-1: #6da7ff;
  --ff-frame-2: #244380;
  --ff-frame-3: #122351;

  --gold: #ffd980;
  --gold-1: #d4a04e;
  --gold-2: #9c6f2a;
  --gold-3: #5a3f15;

  --text: #f3eee0;
  --text-dim: #b5b09d;
  --text-faint: #6e6a5b;

  --hp: #5cf08a;
  --hp-dark: #176b32;
  --mp: #6db8ff;
  --mp-dark: #1d4d8f;
  --xp: #ffd980;
  --danger: #ff6464;
  --warn: #ffb24a;
  --critical: #ff2a4d;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
}

body {
  font-family: "Noto Serif JP", "Cinzel", "Georgia", serif;
  background:
    radial-gradient(ellipse at 30% 0%, #1a2658 0%, transparent 50%),
    radial-gradient(ellipse at 70% 100%, #2a1858 0%, transparent 55%),
    linear-gradient(180deg, #050818 0%, #02030a 100%);
  background-attachment: fixed;
  color: var(--text);
  letter-spacing: 0.02em;
  font-feature-settings: "palt" 1, "calt" 1;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

button { font-family: inherit; cursor: pointer; }
code, .mono { font-family: "JetBrains Mono", "Consolas", monospace; }

/* ============================================================
   Background layers (starfield + vignette + grain)
   ============================================================ */
.starfield {
  position: fixed;
  inset: -10vh -10vw;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 12% 18%, #fff, transparent 50%),
    radial-gradient(1px 1px at 27% 64%, #ffe1a8, transparent 50%),
    radial-gradient(1.5px 1.5px at 43% 32%, #fff, transparent 50%),
    radial-gradient(1px 1px at 56% 79%, #ffd980, transparent 50%),
    radial-gradient(1px 1px at 71% 22%, #fff, transparent 50%),
    radial-gradient(1px 1px at 82% 55%, #b8c6ff, transparent 50%),
    radial-gradient(1px 1px at 91% 88%, #fff, transparent 50%),
    radial-gradient(1px 1px at 4% 50%, #fff, transparent 50%),
    radial-gradient(2px 2px at 19% 85%, #ffe1a8, transparent 50%),
    radial-gradient(1px 1px at 36% 9%, #fff, transparent 50%),
    radial-gradient(1px 1px at 49% 47%, #b8c6ff, transparent 50%),
    radial-gradient(1.5px 1.5px at 62% 14%, #fff, transparent 50%),
    radial-gradient(1px 1px at 78% 71%, #ffd980, transparent 50%),
    radial-gradient(1px 1px at 88% 38%, #fff, transparent 50%);
  opacity: 0.55;
  animation: starshift 90s linear infinite;
}
.starfield--slow {
  animation-duration: 220s;
  opacity: 0.3;
  background-image:
    radial-gradient(2px 2px at 8% 28%, #ffd980, transparent 50%),
    radial-gradient(2px 2px at 52% 72%, #fff, transparent 50%),
    radial-gradient(2px 2px at 88% 18%, #b8c6ff, transparent 50%);
}
@keyframes starshift {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(0, -240px, 0); }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background:
    radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.55) 90%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  opacity: 0.06;
  background-image: repeating-conic-gradient(rgba(255,255,255,0.04) 0%, transparent 0.02%, transparent 0.04%);
  mix-blend-mode: overlay;
}

@media (prefers-reduced-motion: reduce) {
  .starfield, .starfield--slow { animation: none; }
}

/* ============================================================
   FF window frame (青ウィンドウ枠 + 縁取り)
   ============================================================ */
.ff-window {
  position: relative;
  background: linear-gradient(180deg, rgba(20,32,73,0.92) 0%, rgba(10,21,48,0.92) 100%);
  border: 1px solid var(--ff-frame-1);
  border-radius: 6px;
  padding: 14px 18px;
  box-shadow:
    0 0 0 1px var(--bg-deep),
    0 0 0 3px var(--ff-frame-3),
    inset 0 0 24px rgba(109, 167, 255, 0.10),
    0 12px 32px rgba(0, 0, 30, 0.5);
  z-index: 3;
}
.ff-window::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(109, 167, 255, 0.18);
  border-radius: 3px;
  pointer-events: none;
}
.ff-window--flat {
  box-shadow:
    0 0 0 1px var(--bg-deep),
    inset 0 0 16px rgba(109, 167, 255, 0.08);
}
.ff-window--flat::before { display: none; }

/* ============================================================
   Screens base
   ============================================================ */
.screen {
  display: none;
  position: relative;
  z-index: 3;
}
.screen.is-active { display: block; }

/* ============================================================
   TITLE SCREEN
   ============================================================ */
.screen--title {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 24px;
}
.screen--title.is-active { display: flex; }

.title-stack {
  text-align: center;
  z-index: 4;
  padding: 50px 24px;
  max-width: 760px;
}

.title-crest {
  display: inline-block;
  margin-bottom: 22px;
  filter: drop-shadow(0 0 32px rgba(255, 217, 128, 0.5));
  animation: crestFloat 6s ease-in-out infinite;
}
@keyframes crestFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

.title-name {
  font-family: "Cinzel", serif;
  font-size: clamp(54px, 10vw, 130px);
  font-weight: 900;
  letter-spacing: 0.18em;
  background: linear-gradient(180deg, #fff5cc 0%, #ffe78c 25%, #c89b3d 55%, #ffe78c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(255, 217, 128, 0.35);
  margin-bottom: 0;
  line-height: 1;
}
.title-sub {
  font-family: "Cinzel", serif;
  font-size: clamp(14px, 1.6vw, 22px);
  letter-spacing: 0.5em;
  color: var(--gold-1);
  margin: 6px 0 28px;
  text-indent: 0.5em;
}
.title-desc {
  font-family: "Noto Serif JP", serif;
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 44px;
  letter-spacing: 0.12em;
}

.press-start {
  font-family: "Cinzel", serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--gold);
  background: transparent;
  border: 2px solid var(--gold-1);
  padding: 14px 38px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.25s ease;
  animation: blink 1.6s steps(2, end) infinite;
  position: relative;
  text-indent: 0.3em;
}
.press-start:hover, .press-start:focus-visible {
  background: rgba(255, 217, 128, 0.12);
  box-shadow: 0 0 32px rgba(255, 217, 128, 0.5), inset 0 0 16px rgba(255, 217, 128, 0.15);
  animation: none;
  outline: none;
  color: #fff5cc;
  transform: translateY(-1px);
}
@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.45; }
}

.title-foot {
  margin-top: 50px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: #4a5070;
  letter-spacing: 0.15em;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================
   HUD (上部ステータスバー)
   ============================================================ */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.1fr 0.8fr 1.1fr 1.4fr;
  gap: 0;
  background: var(--ff-frame-3);
  border-bottom: 1px solid var(--ff-frame-1);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(4px);
}
.hud-cell {
  background: linear-gradient(180deg, rgba(20,32,73,0.95) 0%, rgba(10,21,48,0.95) 100%);
  padding: 9px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-right: 1px solid rgba(109, 167, 255, 0.15);
}
.hud-cell:last-child { border-right: none; }
.hud-label {
  font-family: "Cinzel", serif;
  font-size: 10px;
  color: var(--gold-1);
  letter-spacing: 0.3em;
  font-weight: 700;
}
.hud-value {
  font-family: "Cinzel", "JetBrains Mono", monospace;
  font-size: 15px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.hud-cell--gold .hud-value { color: var(--gold); }

/* ============================================================
   Main layout (sidebar + content)
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 14px;
  padding: 14px;
  min-height: calc(100vh - 60px);
}

/* ============================================================
   Command menu (sidebar)
   ============================================================ */
.cmd-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: fit-content;
  position: sticky;
  top: 74px;
}
.cmd-menu-title {
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.35em;
  color: var(--gold-1);
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 217, 128, 0.18);
  margin-bottom: 8px;
  text-indent: 0.35em;
}
.cmd-menu ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}
.cmd-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 10px 8px 10px 18px;
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  cursor: pointer;
  font-family: "Cinzel", serif;
  letter-spacing: 0.14em;
  font-size: 13px;
  font-weight: 500;
  position: relative;
  transition: all 0.18s ease;
  border-radius: 2px;
}
.cmd-item:hover, .cmd-item:focus-visible {
  background: linear-gradient(90deg, rgba(109, 167, 255, 0.16) 0%, rgba(109, 167, 255, 0) 100%);
  padding-left: 22px;
  color: var(--gold);
  outline: none;
}
.cmd-item.is-active {
  background: linear-gradient(90deg, rgba(255, 217, 128, 0.18) 0%, rgba(255, 217, 128, 0.02) 100%);
  color: var(--gold);
}
.cmd-item.is-active::before {
  content: "▶";
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-size: 10px;
  animation: blink 1.4s steps(2, end) infinite;
}
.cmd-glyph {
  color: var(--gold-1);
  font-size: 14px;
  text-align: center;
  grid-row: span 2;
  align-self: center;
}
.cmd-text {
  display: block;
}
.cmd-tip {
  display: block;
  font-family: "Noto Serif JP", serif;
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0;
  font-weight: 400;
  margin-top: 2px;
  grid-column: 2;
}
.cmd-menu-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(109, 167, 255, 0.18);
}
.cmd-item--exit { color: var(--text-dim); }

/* ============================================================
   Content area
   ============================================================ */
.content {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  animation: contentFade 0.4s ease;
}
@keyframes contentFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.content-title {
  font-family: "Cinzel", serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}
.content-title::before,
.content-title::after {
  content: "";
  flex: 0 0 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-1), transparent);
}
.content-sub {
  font-family: "Noto Serif JP", serif;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  line-height: 1.6;
}

.section-h {
  font-family: "Cinzel", serif;
  font-size: 14px;
  letter-spacing: 0.25em;
  color: var(--gold);
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px dashed rgba(255, 217, 128, 0.25);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   Bars (HP / MP / XP)
   ============================================================ */
.bar {
  position: relative;
  height: 10px;
  background: var(--bg-deep);
  border: 1px solid var(--ff-frame-2);
  border-radius: 2px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.bar-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.4), transparent);
}
.bar--hp .bar-fill { background: linear-gradient(180deg, #b1ffcc 0%, #2dba61 50%, #086a2a 100%); }
.bar--mp .bar-fill { background: linear-gradient(180deg, #c8e0ff 0%, #4a8be8 50%, #1a4e8f 100%); }
.bar--xp .bar-fill { background: linear-gradient(180deg, #fff1b0 0%, #d4a045 50%, #82591d 100%); }

/* ============================================================
   PARTY SCREEN
   ============================================================ */
.party-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.char-card {
  background: linear-gradient(180deg, rgba(20,32,73,0.85) 0%, rgba(10,21,48,0.92) 100%);
  border: 1px solid var(--ff-frame-1);
  border-radius: 6px;
  padding: 14px 14px 16px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  transition: all 0.22s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow:
    0 0 0 1px var(--bg-deep),
    0 0 0 3px var(--ff-frame-3),
    0 8px 24px rgba(0,0,40,0.4);
  position: relative;
  font-family: inherit;
}
.char-card::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(109, 167, 255, 0.18);
  border-radius: 3px;
  pointer-events: none;
}
.char-card:hover, .char-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--gold-1);
  box-shadow:
    0 0 0 1px var(--bg-deep),
    0 0 0 3px var(--gold-2),
    0 0 24px rgba(255, 217, 128, 0.25),
    0 12px 32px rgba(0,0,40,0.6);
  outline: none;
}
.char-card:hover .char-portrait {
  filter: brightness(1.2) drop-shadow(0 0 18px currentColor);
}

.char-portrait {
  width: 100%;
  aspect-ratio: 1.4;
  display: grid;
  place-items: center;
  font-size: 60px;
  background:
    radial-gradient(ellipse at top, rgba(255, 217, 128, 0.18), transparent 70%),
    linear-gradient(180deg, var(--bg-2), var(--bg-deep));
  border: 1px solid var(--ff-frame-2);
  border-radius: 4px;
  position: relative;
  transition: filter 0.25s;
  text-shadow: 0 0 16px currentColor;
}
.char-portrait::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.4));
  pointer-events: none;
}

.char-name {
  font-family: "Cinzel", serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.1em;
  line-height: 1.2;
}
.char-name-ja {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
  letter-spacing: 0.05em;
}
.char-job {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  font-family: "Noto Serif JP", serif;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(109, 167, 255, 0.2);
}
.char-job strong {
  color: var(--text);
  font-weight: 700;
}
.char-lvline {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: "Cinzel", "JetBrains Mono", monospace;
  color: var(--text);
  letter-spacing: 0.08em;
}
.char-lvline .lv-num { color: var(--gold); font-weight: 700; font-size: 14px; }
.char-lvline .lv-model { color: var(--mp); font-size: 10px; }
.char-meter {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.meter-row {
  display: grid;
  grid-template-columns: 26px 1fr 76px;
  gap: 7px;
  align-items: center;
  font-size: 10px;
  font-family: "JetBrains Mono", monospace;
}
.meter-label {
  color: var(--gold-1);
  letter-spacing: 0.1em;
  font-weight: 700;
}
.meter-num {
  text-align: right;
  color: var(--text);
}

/* ============================================================
   STATUS SCREEN
   ============================================================ */
.status-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
}
.status-portrait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.status-emoji {
  font-size: 130px;
  filter: drop-shadow(0 0 40px currentColor);
  line-height: 1;
}
.status-name {
  font-family: "Cinzel", serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
}
.status-name-ja {
  font-size: 12px;
  color: var(--text-dim);
}
.status-job {
  font-family: "Cinzel", serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--gold-1);
  padding: 4px 12px;
  border: 1px solid var(--gold-2);
  border-radius: 1px;
  margin-top: 4px;
}

.status-detail dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 18px;
  margin-bottom: 14px;
}
.status-detail dt {
  font-family: "Cinzel", serif;
  font-size: 11px;
  color: var(--gold-1);
  letter-spacing: 0.2em;
  align-self: center;
  font-weight: 700;
}
.status-detail dd {
  font-size: 13px;
  line-height: 1.5;
}
.status-detail .quote {
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 3px solid var(--gold-1);
  background: rgba(255, 217, 128, 0.04);
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-dim);
  font-style: italic;
  border-radius: 0 4px 4px 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat-cell {
  display: grid;
  grid-template-columns: 90px 1fr 44px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--ff-frame-2);
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(20,32,73,0.45), rgba(10,21,48,0.45));
}
.stat-name {
  font-family: "Cinzel", "Noto Serif JP", serif;
  font-size: 11px;
  color: var(--gold-1);
  letter-spacing: 0.2em;
  font-weight: 700;
}
.stat-bar {
  height: 8px;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--ff-frame-2);
  border-radius: 1px;
}
.stat-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #d4a045 0%, #ffe78c 50%, #fff5cc 100%);
  box-shadow: 0 0 8px rgba(255, 217, 128, 0.5);
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
.stat-num {
  text-align: right;
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  color: var(--gold);
  font-weight: 700;
}

.spells {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.spell-item {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--ff-frame-2);
  background: linear-gradient(180deg, rgba(20, 32, 73, 0.55) 0%, rgba(10, 21, 48, 0.55) 100%);
  border-radius: 2px;
  transition: all 0.18s;
}
.spell-item:hover {
  border-color: var(--gold-1);
  background: rgba(255, 217, 128, 0.06);
}
.spell-glyph {
  font-size: 14px;
  color: var(--gold);
  text-align: center;
}
.spell-info {
  font-size: 12px;
  line-height: 1.4;
}
.spell-name {
  color: var(--text);
  font-weight: 700;
}
.spell-desc {
  color: var(--text-dim);
  font-size: 10px;
  margin-top: 2px;
}
.spell-cost {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--mp);
  white-space: nowrap;
  font-weight: 700;
}

.eq-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.eq-cell {
  padding: 10px 12px;
  border: 1px solid var(--ff-frame-2);
  background: rgba(20, 32, 73, 0.4);
  text-align: center;
  border-radius: 2px;
}
.eq-label {
  font-family: "Cinzel", serif;
  font-size: 10px;
  color: var(--gold-1);
  letter-spacing: 0.2em;
  margin-bottom: 4px;
  font-weight: 700;
}
.eq-name {
  font-size: 12px;
  color: var(--text);
}

.party-switcher {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.char-switch {
  background: transparent;
  border: 1px solid var(--ff-frame-2);
  padding: 8px 10px;
  cursor: pointer;
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  border-radius: 2px;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}
.char-switch:hover {
  background: rgba(109, 167, 255, 0.1);
  color: var(--text);
}
.char-switch.is-current {
  background: rgba(255, 217, 128, 0.12);
  border-color: var(--gold-1);
  color: var(--gold);
}
.char-switch .char-switch-emoji {
  font-size: 18px;
}

/* ============================================================
   MAGIC (Materia) SCREEN
   ============================================================ */
.materia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.materia-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 18px 12px 14px;
  cursor: pointer;
  border: 1px solid var(--ff-frame-2);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(20,32,73,0.6), rgba(10,21,48,0.7));
  transition: all 0.22s;
  position: relative;
}
.materia-cell:hover, .materia-cell:focus-visible {
  border-color: var(--gold-1);
  transform: translateY(-3px);
  box-shadow: 0 0 24px var(--orb-color, rgba(255,217,128,0.4)), 0 8px 24px rgba(0,0,40,0.4);
  outline: none;
}
.materia-cell:hover .materia-orb {
  animation-duration: 1.8s;
}

.materia-orb {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, rgba(255,255,255,0.95) 0%, var(--orb-color, #ffd980) 38%, #0a0c20 110%);
  position: relative;
  box-shadow:
    0 0 24px var(--orb-color, #ffd980),
    inset -8px -8px 14px rgba(0, 0, 0, 0.45),
    inset 8px 8px 14px rgba(255, 255, 255, 0.2);
  animation: orbPulse 3.6s ease-in-out infinite;
}
.materia-orb::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.7) 0%, transparent 30%);
  pointer-events: none;
}
.materia-orb::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 50%, var(--orb-color, #ffd980) 100%);
  opacity: 0.15;
  filter: blur(8px);
  z-index: -1;
}
@keyframes orbPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 16px var(--orb-color, #ffd980), inset -8px -8px 14px rgba(0,0,0,0.45), inset 8px 8px 14px rgba(255,255,255,0.2);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 36px var(--orb-color, #ffd980), inset -8px -8px 14px rgba(0,0,0,0.45), inset 8px 8px 14px rgba(255,255,255,0.28);
  }
}

.materia-name {
  font-family: "Cinzel", serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--gold);
  margin-top: 2px;
}
.materia-name-ja {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: -4px;
  letter-spacing: 0.05em;
}
.materia-desc {
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-dim);
  margin-top: 4px;
}
.materia-cost {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  color: var(--gold-1);
  margin-top: 4px;
  letter-spacing: 0.1em;
}

/* ============================================================
   CLASS DIRECTORY SCREEN
   ============================================================ */
.class-section {
  margin: 0;
}
.class-section-title {
  font-family: "Cinzel", serif;
  font-size: 14px;
  color: var(--gold);
  letter-spacing: 0.25em;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 217, 128, 0.22);
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.class-section-title small {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.1em;
  font-family: "Noto Serif JP", serif;
}
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.class-cell {
  padding: 10px 12px;
  border: 1px solid var(--ff-frame-2);
  background: linear-gradient(180deg, rgba(20,32,73,0.4), rgba(10,21,48,0.4));
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  transition: all 0.18s;
  border-radius: 2px;
}
.class-cell:hover {
  background: rgba(109, 167, 255, 0.08);
  border-color: var(--gold-1);
  transform: translateX(2px);
}
.class-cell-glyph {
  font-size: 20px;
  color: var(--gold-1);
  text-align: center;
}
.class-cell-name {
  font-family: "Cinzel", serif;
  font-size: 12px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.class-cell-ja {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  letter-spacing: 0.05em;
}
.class-cell-tag {
  font-family: "Cinzel", serif;
  font-size: 9px;
  color: var(--gold-1);
  letter-spacing: 0.2em;
  border: 1px solid rgba(255, 217, 128, 0.3);
  padding: 2px 6px;
  border-radius: 1px;
  background: rgba(255, 217, 128, 0.05);
}

/* ============================================================
   WORLD MAP SCREEN
   ============================================================ */
.world-map {
  height: 520px;
  position: relative;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(109, 167, 255, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 70%, rgba(255, 217, 128, 0.08) 0%, transparent 55%),
    linear-gradient(180deg, #0c1d4a 0%, #050715 100%);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--ff-frame-2);
}
.world-map::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 39px, rgba(109, 167, 255, 0.05) 39px, rgba(109, 167, 255, 0.05) 40px),
    repeating-linear-gradient(90deg, transparent, transparent 39px, rgba(109, 167, 255, 0.05) 39px, rgba(109, 167, 255, 0.05) 40px);
  pointer-events: none;
}
.world-compass {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 56px;
  height: 56px;
  border: 1px solid var(--gold-1);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Cinzel", serif;
  font-size: 11px;
  color: var(--gold);
  background: rgba(0,0,0,0.4);
  text-align: center;
  line-height: 1.2;
}
.world-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.25s ease;
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  transform: translate(-50%, -50%);
  z-index: 2;
}
.world-node:hover, .world-node:focus-visible {
  transform: translate(-50%, calc(-50% - 4px));
  outline: none;
}
.world-node:hover .world-node-icon {
  box-shadow: 0 0 28px rgba(255, 217, 128, 0.7);
  border-color: var(--gold);
}
.world-node-icon {
  font-size: 28px;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle, var(--bg-2) 30%, var(--bg-deep) 100%);
  border: 2px solid var(--gold-1);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(255, 217, 128, 0.3), inset 0 0 12px rgba(0,0,0,0.5);
  transition: all 0.25s;
  position: relative;
}
.world-node-icon::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 1px solid rgba(255, 217, 128, 0.15);
  border-radius: 50%;
  pointer-events: none;
}
.world-node-label {
  font-family: "Cinzel", serif;
  font-size: 10px;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.75);
  padding: 3px 8px;
  white-space: nowrap;
  border: 1px solid var(--gold-2);
  border-radius: 1px;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.world-node-status {
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  color: var(--hp);
  letter-spacing: 0.1em;
}
.world-node--quiet .world-node-icon { border-color: var(--ff-frame-2); box-shadow: none; opacity: 0.6; }
.world-node--quiet .world-node-label { color: var(--text-dim); border-color: var(--ff-frame-2); }
.world-node--quiet .world-node-status { color: var(--text-faint); }

.territory-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.territory-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  align-items: center;
  border: 1px solid var(--ff-frame-2);
  background: linear-gradient(90deg, rgba(255, 217, 128, 0.03) 0%, transparent 100%);
  border-radius: 2px;
  transition: all 0.18s;
}
.territory-row:hover {
  border-color: var(--gold-1);
  background: linear-gradient(90deg, rgba(255, 217, 128, 0.08) 0%, transparent 100%);
}
.terr-icon { font-size: 24px; text-align: center; }
.terr-info { min-width: 0; }
.terr-name {
  font-family: "Cinzel", serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 0.1em;
  font-weight: 700;
}
.terr-desc {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.5;
}
.terr-status {
  font-family: "Cinzel", monospace;
  font-size: 10px;
  letter-spacing: 0.2em;
  padding: 4px 10px;
  border: 1px solid;
  border-radius: 1px;
  font-weight: 700;
}
.status-active { color: var(--hp); border-color: var(--hp-dark); background: rgba(92, 240, 138, 0.08); }
.status-operating { color: var(--mp); border-color: var(--mp-dark); background: rgba(109, 184, 255, 0.08); }
.status-planning { color: var(--warn); border-color: #7a4a14; background: rgba(255, 178, 74, 0.08); }
.status-deployed { color: var(--gold); border-color: var(--gold-2); background: rgba(255, 217, 128, 0.08); }

/* ============================================================
   CHRONICLE (Battle Log)
   ============================================================ */
.log-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.log-filter button {
  background: transparent;
  border: 1px solid var(--ff-frame-2);
  color: var(--text-dim);
  padding: 4px 12px;
  font-family: "Cinzel", serif;
  font-size: 11px;
  letter-spacing: 0.15em;
  border-radius: 1px;
  cursor: pointer;
  transition: all 0.18s;
}
.log-filter button:hover { color: var(--text); border-color: var(--gold-1); }
.log-filter button.is-active { background: rgba(255, 217, 128, 0.12); color: var(--gold); border-color: var(--gold-1); }
.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 640px;
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--ff-frame-2) transparent;
}
.log-list::-webkit-scrollbar { width: 8px; }
.log-list::-webkit-scrollbar-track { background: transparent; }
.log-list::-webkit-scrollbar-thumb { background: var(--ff-frame-2); border-radius: 4px; }

.log-entry {
  padding: 12px 14px;
  border-left: 3px solid var(--gold-1);
  background: linear-gradient(90deg, rgba(255, 217, 128, 0.05) 0%, transparent 80%);
  border-radius: 0 2px 2px 0;
  position: relative;
  transition: all 0.18s;
}
.log-entry:hover {
  background: linear-gradient(90deg, rgba(255, 217, 128, 0.1) 0%, transparent 80%);
  border-left-color: var(--gold);
}
.log-entry--codex { border-left-color: var(--mp); background: linear-gradient(90deg, rgba(109, 184, 255, 0.06) 0%, transparent 80%); }
.log-entry--codex:hover { border-left-color: var(--mp); }

.log-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.log-entry-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.15em;
  font-weight: 700;
}
.log-entry-actor {
  font-family: "Cinzel", serif;
  font-size: 12px;
  color: var(--mp);
  letter-spacing: 0.1em;
  font-weight: 700;
}
.log-entry--codex .log-entry-actor { color: #ff9ad4; }
.log-entry-verb {
  font-size: 11px;
  color: var(--text-dim);
}
.log-entry-action {
  font-family: "Cinzel", "Noto Serif JP", serif;
  color: var(--gold);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
}
.log-entry-detail {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ============================================================
   DUO SCREEN
   ============================================================ */
.duo-stack {
  display: grid;
  grid-template-columns: 1fr 90px 1fr;
  gap: 14px;
  align-items: stretch;
}
.duo-card {
  text-align: center;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.duo-portrait {
  font-size: 84px;
  filter: drop-shadow(0 0 24px currentColor);
  margin-bottom: 6px;
  line-height: 1;
}
.duo-card--cc .duo-portrait { color: var(--gold); }
.duo-card--codex .duo-portrait { color: #ff9ad4; }
.duo-name {
  font-family: "Cinzel", serif;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--gold);
}
.duo-card--codex .duo-name { color: #ff9ad4; }
.duo-tag {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.duo-link {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.duo-glyph {
  font-size: 52px;
  color: var(--gold);
  animation: shimmer 3s ease-in-out infinite;
  filter: drop-shadow(0 0 24px var(--gold));
  line-height: 1;
}
@keyframes shimmer {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 18px var(--gold)); }
  50% { transform: scale(1.1) rotate(180deg); filter: drop-shadow(0 0 32px var(--gold)); }
}
.duo-link-label {
  font-family: "Cinzel", serif;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--gold-1);
}
.duo-link-name {
  font-family: "Cinzel", serif;
  font-size: 11px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.15em;
}

.coin-row {
  padding: 8px 12px;
  border-left: 2px solid var(--gold-1);
  background: rgba(255, 217, 128, 0.04);
  font-size: 12px;
  line-height: 1.6;
  margin-bottom: 6px;
}
.coin-row strong { color: var(--gold); }

.proto-item {
  padding: 10px 14px;
  border: 1px solid var(--ff-frame-2);
  background: rgba(10, 21, 48, 0.5);
  font-size: 12px;
  margin-bottom: 6px;
  border-radius: 1px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.proto-item code {
  background: rgba(255, 217, 128, 0.12);
  padding: 3px 10px;
  border-radius: 2px;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ============================================================
   DIALOG OVERLAY
   ============================================================ */
[hidden] { display: none !important; }
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 12, 0.88);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(8px);
  animation: dlgFade 0.25s ease;
}
@keyframes dlgFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.dialog-card {
  max-width: 720px;
  width: 100%;
  max-height: 80vh;
  overflow: auto;
  position: relative;
  animation: dlgPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes dlgPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ff-frame-2);
  margin-bottom: 14px;
  font-family: "Cinzel", serif;
  font-size: 16px;
  letter-spacing: 0.2em;
  color: var(--gold);
  font-weight: 700;
}
.dialog-close {
  background: transparent;
  border: 1px solid var(--ff-frame-2);
  color: var(--text);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 1px;
  transition: all 0.18s;
}
.dialog-close:hover { border-color: var(--danger); color: var(--danger); }
.dialog-body {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
}
.dialog-body strong { color: var(--gold); }
.dialog-body code { color: var(--mp); background: rgba(109, 184, 255, 0.1); padding: 1px 6px; border-radius: 2px; }
.dialog-footer {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px dashed var(--ff-frame-2);
  font-size: 10px;
  color: var(--text-faint);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.1em;
  text-align: right;
}

/* ============================================================
   FOOTER STRIP
   ============================================================ */
.footer-strip {
  display: flex;
  justify-content: space-between;
  padding: 8px 18px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.08em;
  border-top: 1px solid var(--ff-frame-2);
  background: rgba(3, 4, 12, 0.65);
  flex-wrap: wrap;
  gap: 8px;
}
.ftrip-tag { display: inline-block; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1080px) {
  .party-grid { grid-template-columns: repeat(3, 1fr); }
  .status-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
}

@media (max-width: 840px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .cmd-menu {
    position: relative;
    top: auto;
  }
  .cmd-menu ul {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2px;
  }
  .cmd-tip { display: none; }
  .cmd-item {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 8px 4px;
    font-size: 10px;
    flex-direction: column;
  }
  .cmd-glyph { grid-row: auto; font-size: 16px; }
  .cmd-menu-footer { display: none; }
  .cmd-item.is-active::before { display: none; }
  .party-grid { grid-template-columns: repeat(2, 1fr); }
  .hud {
    grid-template-columns: repeat(3, 1fr);
  }
  .hud-cell:nth-child(n+4) {
    display: none;
  }
  .spells { grid-template-columns: 1fr; }
  .eq-grid { grid-template-columns: 1fr; }
  .class-grid { grid-template-columns: 1fr; }
  .materia-grid { grid-template-columns: repeat(2, 1fr); }
  .duo-stack { grid-template-columns: 1fr; }
  .duo-glyph { transform: rotate(90deg); }
  .world-map { height: 380px; }
  .content-title { font-size: 18px; }
  .title-name { font-size: 56px; }
}

@media (max-width: 480px) {
  .party-grid { grid-template-columns: 1fr; }
  .materia-grid { grid-template-columns: 1fr; }
  .footer-strip { flex-direction: column; align-items: flex-start; font-size: 9px; }
  .cmd-menu ul { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   Selection + Focus
   ============================================================ */
::selection {
  background: rgba(255, 217, 128, 0.35);
  color: #fff;
}
button:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ============================================================
   CRYSTAL HUD (4 elements: fire / water / earth / wind)
   ============================================================ */
.crystal-row {
  display: inline-flex;
  gap: 6px;
}
.crystal {
  font-size: 16px;
  filter: drop-shadow(0 0 6px currentColor);
  animation: crystalGlow 3.6s ease-in-out infinite;
  cursor: help;
  line-height: 1;
}
.crystal--fire  { color: #ff6464; animation-delay: 0s; }
.crystal--water { color: #6db8ff; animation-delay: 0.9s; }
.crystal--earth { color: #ffd980; animation-delay: 1.8s; }
.crystal--wind  { color: #9ed8a9; animation-delay: 2.7s; }
@keyframes crystalGlow {
  0%, 100% { filter: drop-shadow(0 0 4px currentColor); transform: scale(1); }
  50%      { filter: drop-shadow(0 0 14px currentColor); transform: scale(1.18); }
}

/* ============================================================
   SAVE POINT button (floating crystal)
   ============================================================ */
.save-point {
  position: fixed;
  right: 18px;
  bottom: 36px;
  z-index: 20;
  background: radial-gradient(circle at 35% 28%, #fff, var(--gold) 35%, var(--gold-2) 75%, #2a2540 100%);
  border: 2px solid var(--gold);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  cursor: pointer;
  color: #2a2540;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow:
    0 0 18px var(--gold),
    inset -6px -6px 10px rgba(0,0,0,0.45),
    inset 6px 6px 10px rgba(255,255,255,0.25);
  animation: savePointPulse 2.2s ease-in-out infinite;
  transition: transform 0.18s;
}
.save-point:hover {
  transform: scale(1.08);
  box-shadow: 0 0 30px var(--gold), inset -6px -6px 10px rgba(0,0,0,0.45), inset 6px 6px 10px rgba(255,255,255,0.35);
}
.save-point-crystal {
  font-size: 22px;
  font-weight: 900;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
  line-height: 1;
  margin-top: -2px;
}
.save-point-label {
  font-family: "Cinzel", serif;
  font-size: 8px;
  letter-spacing: 0.2em;
  font-weight: 700;
  line-height: 1;
}
@keyframes savePointPulse {
  0%, 100% { box-shadow: 0 0 14px var(--gold), inset -6px -6px 10px rgba(0,0,0,0.45), inset 6px 6px 10px rgba(255,255,255,0.25); }
  50%      { box-shadow: 0 0 32px var(--gold), inset -6px -6px 10px rgba(0,0,0,0.45), inset 6px 6px 10px rgba(255,255,255,0.4); }
}

/* ============================================================
   BATTLE menu accent
   ============================================================ */
.cmd-item--battle .cmd-glyph { color: var(--danger); }
.cmd-item--battle:hover { color: var(--danger); }
.cmd-item--battle:hover .cmd-glyph { color: var(--danger); filter: drop-shadow(0 0 8px var(--danger)); }

/* ============================================================
   ENCOUNTER (battle entry) transition
   ============================================================ */
.encounter-flash {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 0%, transparent 30%, #000 90%);
  animation: encounterSpin 0.9s cubic-bezier(0.5, 0.1, 0.4, 1) forwards;
}
@keyframes encounterSpin {
  0%   { opacity: 0; transform: scale(0.5) rotate(0deg); }
  25%  { opacity: 0.4; }
  50%  { opacity: 0.8; transform: scale(1.6) rotate(180deg); }
  100% { opacity: 0; transform: scale(3) rotate(360deg); }
}

/* ============================================================
   BATTLE SCREEN — エンカウント戦闘画面
   ============================================================ */
.battle-stage {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 14px;
}

.battle-banner {
  font-family: "Cinzel", serif;
  font-size: 20px;
  letter-spacing: 0.3em;
  color: var(--danger);
  text-align: center;
  padding: 14px;
  border: 2px solid var(--danger);
  background: linear-gradient(180deg, rgba(255, 42, 77, 0.18), rgba(255, 42, 77, 0.04));
  animation: bannerShake 0.6s ease-out;
  text-shadow: 0 0 16px rgba(255, 42, 77, 0.7);
  border-radius: 4px;
  position: relative;
}
.battle-banner::before, .battle-banner::after {
  content: "⚔";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--danger);
}
.battle-banner::before { left: 18px; }
.battle-banner::after { right: 18px; }
@keyframes bannerShake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

.enemy-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  padding: 26px 18px 22px;
  background:
    radial-gradient(ellipse at center, rgba(255, 42, 77, 0.1) 0%, transparent 60%),
    linear-gradient(180deg, #1a0820 0%, #0a0408 100%);
  border: 1px solid var(--ff-frame-2);
  border-radius: 4px;
  position: relative;
  min-height: 200px;
}
.enemy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  padding: 6px;
  border-radius: 4px;
  transition: all 0.2s;
  position: relative;
}
.enemy:hover, .enemy:focus-visible {
  background: rgba(255, 217, 128, 0.08);
  transform: translateY(-3px);
  outline: none;
}
.enemy.is-target { background: rgba(255, 42, 77, 0.18); box-shadow: 0 0 18px rgba(255, 42, 77, 0.45); }
.enemy.is-target::before {
  content: "▼";
  position: absolute;
  top: -16px;
  color: var(--danger);
  font-size: 14px;
  animation: blink 0.6s steps(2, end) infinite;
}
.enemy.is-dead {
  opacity: 0.18;
  filter: grayscale(1);
  pointer-events: none;
}
.enemy.is-hit { animation: enemyHit 0.4s; }
@keyframes enemyHit {
  0%, 100% { transform: translate(0, 0); filter: brightness(1); }
  20% { transform: translate(-6px, 2px); filter: brightness(2) hue-rotate(20deg); }
  40% { transform: translate(6px, -2px); filter: brightness(2); }
  60% { transform: translate(-4px, 0); }
  80% { transform: translate(4px, 0); }
}
.enemy-emoji {
  font-size: 64px;
  filter: drop-shadow(0 0 14px currentColor);
  line-height: 1;
  transition: transform 0.18s;
}
.enemy:hover .enemy-emoji { transform: scale(1.08); }
.enemy-name {
  font-family: "Cinzel", serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
  text-align: center;
  line-height: 1.3;
}
.enemy-name-ja {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
}
.enemy-lv {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 0.1em;
}
.enemy-hp-bar {
  width: 90px;
  height: 6px;
  background: var(--bg-deep);
  border: 1px solid var(--ff-frame-2);
  position: relative;
  overflow: hidden;
}
.enemy-hp-fill {
  height: 100%;
  background: linear-gradient(180deg, #ff8a8a 0%, #c83a4a 60%, #6a1a25 100%);
  transition: width 0.5s ease;
}
.enemy.is-boss .enemy-emoji {
  font-size: 84px;
  animation: bossFloat 3s ease-in-out infinite;
}
.enemy.is-boss .enemy-hp-fill {
  background: linear-gradient(180deg, #ffd980 0%, #ff7a3a 60%, #b03a16 100%);
}
@keyframes bossFloat {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 0 18px currentColor); }
  50% { transform: translateY(-6px); filter: drop-shadow(0 0 32px currentColor); }
}

/* Party row (FF6/9 風 4キャラ横並び) */
.party-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.party-slot {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--ff-frame-2);
  background: linear-gradient(180deg, rgba(20,32,73,0.8), rgba(10,21,48,0.9));
  border-radius: 2px;
  position: relative;
  transition: all 0.2s;
}
.party-slot.is-ready {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 217, 128, 0.4);
  background: linear-gradient(180deg, rgba(255, 217, 128, 0.12), rgba(10, 21, 48, 0.9));
}
.party-slot.is-acting {
  border-color: var(--hp);
  box-shadow: 0 0 18px rgba(92, 240, 138, 0.45);
}
.party-slot-emoji {
  font-size: 36px;
  text-align: center;
  filter: drop-shadow(0 0 8px currentColor);
}
.party-slot-info { min-width: 0; }
.party-slot-name {
  font-family: "Cinzel", serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.party-slot-bars {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 2px;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
}
.atb-row {
  display: grid;
  grid-template-columns: 18px 1fr 60px;
  gap: 4px;
  align-items: center;
}
.atb-label { color: var(--gold-1); font-weight: 700; }
.atb-num { text-align: right; color: var(--text); }
.atb-bar {
  height: 4px;
  background: var(--bg-deep);
  border: 1px solid var(--ff-frame-2);
  overflow: hidden;
}
.atb-fill {
  height: 100%;
  transition: width 0.1s linear;
}
.atb-fill--hp { background: linear-gradient(90deg, #2dba61, #92ffb5); }
.atb-fill--mp { background: linear-gradient(90deg, #4a8be8, #c8e0ff); }
.atb-fill--atb {
  background: linear-gradient(90deg, #d4a045, #ffe78c);
  position: relative;
}
.atb-fill--atb.is-full {
  animation: atbReady 0.8s ease-in-out infinite;
}
@keyframes atbReady {
  0%, 100% { box-shadow: 0 0 0 rgba(255, 217, 128, 0); }
  50% { box-shadow: 0 0 12px rgba(255, 217, 128, 0.9); }
}

/* Command window (FF6 風) */
.battle-cmd {
  display: grid;
  grid-template-columns: 2.4fr 1fr;
  gap: 12px;
}
.battle-cmd-window {
  padding: 12px 14px;
  min-height: 132px;
}
.battle-cmd-title {
  font-family: "Cinzel", serif;
  font-size: 11px;
  color: var(--gold-1);
  letter-spacing: 0.3em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--ff-frame-2);
}
.cmd-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
.cmd-row {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: "Cinzel", "Noto Serif JP", serif;
  font-size: 13px;
  text-align: left;
  padding: 7px 10px 7px 24px;
  cursor: pointer;
  letter-spacing: 0.08em;
  position: relative;
  border-radius: 2px;
  transition: all 0.14s;
}
.cmd-row:hover, .cmd-row:focus-visible {
  background: rgba(109, 167, 255, 0.12);
  color: var(--gold);
  outline: none;
}
.cmd-row.is-active {
  background: rgba(255, 217, 128, 0.18);
  color: var(--gold);
}
.cmd-row.is-active::before {
  content: "▶";
  position: absolute;
  left: 8px;
  color: var(--gold);
  animation: blink 1s steps(2, end) infinite;
  font-size: 11px;
}
.cmd-row:disabled {
  color: var(--text-faint);
  cursor: not-allowed;
}
.cmd-sub-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 6px;
}
.cmd-sub-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  text-align: left;
  padding: 5px 10px 5px 22px;
  cursor: pointer;
  border-radius: 2px;
  position: relative;
}
.cmd-sub-row:hover { background: rgba(109, 167, 255, 0.1); color: var(--gold); }
.cmd-sub-row .cmd-cost { font-family: "JetBrains Mono", monospace; font-size: 10px; color: var(--mp); margin-left: 8px; }
.cmd-sub-row:disabled { color: var(--text-faint); cursor: not-allowed; }
.cmd-sub-row:disabled .cmd-cost { color: var(--text-faint); }

.battle-log-pane {
  padding: 12px 14px;
  min-height: 132px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
}
.battle-log-pane-title {
  font-family: "Cinzel", serif;
  font-size: 11px;
  color: var(--gold-1);
  letter-spacing: 0.3em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--ff-frame-2);
}
.battle-log-pane-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  max-height: 110px;
}
.battle-log-line { font-size: 11px; color: var(--text); }
.battle-log-line .lhi { color: var(--gold); font-weight: 700; }
.battle-log-line .lhi-enemy { color: var(--danger); }
.battle-log-line .lhi-heal { color: var(--hp); }

/* Damage popup */
.dmg-pop {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Cinzel", "JetBrains Mono", monospace;
  font-size: 28px;
  font-weight: 900;
  color: #ffe78c;
  text-shadow:
    0 0 10px #fff,
    0 0 18px var(--danger),
    2px 2px 0 #6a1a25,
    -2px -2px 0 #6a1a25;
  pointer-events: none;
  animation: dmgFloat 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  z-index: 5;
}
@keyframes dmgFloat {
  0% { opacity: 0; transform: translate(-50%, 20px) scale(0.6); }
  10% { opacity: 1; transform: translate(-50%, -10px) scale(1.3); }
  30% { transform: translate(-50%, -30px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -70px) scale(0.85); }
}
.dmg-pop--heal { color: #b1ffcc; text-shadow: 0 0 10px #fff, 0 0 18px var(--hp), 2px 2px 0 #176b32, -2px -2px 0 #176b32; }
.dmg-pop--crit { color: #fff5cc; font-size: 36px; }
.dmg-pop--miss { color: var(--text-dim); font-size: 18px; }

/* Victory / Defeat overlay */
.battle-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 4, 12, 0.78);
  z-index: 4;
  backdrop-filter: blur(4px);
  animation: dlgFade 0.4s ease;
}
.battle-result-card {
  text-align: center;
  padding: 32px 44px;
  border: 2px solid var(--gold);
  background: linear-gradient(180deg, rgba(255, 217, 128, 0.18), rgba(20, 32, 73, 0.95));
  box-shadow: 0 0 40px rgba(255, 217, 128, 0.5);
  border-radius: 6px;
}
.battle-result-title {
  font-family: "Cinzel", serif;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--gold);
  text-shadow: 0 0 24px var(--gold);
  margin-bottom: 14px;
  animation: victoryRise 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes victoryRise {
  from { opacity: 0; transform: translateY(20px) scale(0.85); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.battle-result-line {
  font-size: 13px;
  color: var(--text);
  letter-spacing: 0.1em;
  line-height: 1.9;
}
.battle-result-line strong { color: var(--gold); font-family: "Cinzel", monospace; }

/* Encounter list (pre-battle) */
.encounter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.enc-card {
  background: linear-gradient(180deg, rgba(20,32,73,0.55), rgba(10,21,48,0.7));
  border: 1px solid var(--ff-frame-2);
  border-radius: 3px;
  padding: 12px 14px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
  transition: all 0.18s;
  text-align: left;
  font-family: inherit;
  color: inherit;
}
.enc-card:hover, .enc-card:focus-visible {
  border-color: var(--danger);
  background: linear-gradient(180deg, rgba(255, 42, 77, 0.12), rgba(10,21,48,0.7));
  transform: translateX(3px);
  outline: none;
}
.enc-card-emoji {
  font-size: 38px;
  text-align: center;
  filter: drop-shadow(0 0 8px currentColor);
}
.enc-card-name {
  font-family: "Cinzel", serif;
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.enc-card-meta {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: "JetBrains Mono", monospace;
}

/* ============================================================
   SUMMON RING (魔法石クリック時の召喚演出)
   ============================================================ */
.summon-ring {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.92) 100%);
  animation: summonBgFade 0.7s ease forwards;
}
@keyframes summonBgFade {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}
.summon-glyph {
  font-size: 120px;
  color: var(--summon-color, #ffd980);
  filter: drop-shadow(0 0 40px var(--summon-color, #ffd980));
  animation: summonZoom 0.7s ease forwards;
}
@keyframes summonZoom {
  0%   { transform: scale(0.2) rotate(0deg); opacity: 0; }
  40%  { transform: scale(1.4) rotate(180deg); opacity: 1; }
  80%  { transform: scale(2.2) rotate(330deg); opacity: 1; }
  100% { transform: scale(3) rotate(360deg); opacity: 0; }
}
.summon-circle {
  position: absolute;
  width: 240px;
  height: 240px;
  border: 2px solid var(--summon-color, #ffd980);
  border-radius: 50%;
  filter: drop-shadow(0 0 24px var(--summon-color, #ffd980));
  animation: summonCircle 0.7s ease forwards;
}
.summon-circle--inner {
  width: 140px;
  height: 140px;
  animation-direction: reverse;
}
@keyframes summonCircle {
  0%   { transform: scale(0) rotate(0deg); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: scale(1) rotate(360deg); opacity: 0; }
}

/* ============================================================
   CHOCOBO (World map mascot)
   ============================================================ */
.chocobo {
  position: absolute;
  bottom: 12%;
  left: -100px;
  font-size: 36px;
  z-index: 3;
  animation: chocoboRun 24s linear infinite;
  pointer-events: none;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}
.chocobo::after {
  content: "kweh!";
  position: absolute;
  top: -16px;
  right: -34px;
  font-family: "Cinzel", serif;
  font-size: 9px;
  color: var(--gold);
  background: rgba(0,0,0,0.6);
  padding: 2px 6px;
  border: 1px solid var(--gold-2);
  white-space: nowrap;
  letter-spacing: 0.1em;
  opacity: 0;
  animation: chocoboKweh 24s linear infinite;
}
@keyframes chocoboRun {
  0%   { left: -100px; transform: translateY(0) scaleX(1); }
  48%  { left: 110%; transform: translateY(0) scaleX(1); }
  49%  { left: 110%; transform: translateY(0) scaleX(-1); }
  97%  { left: -100px; transform: translateY(0) scaleX(-1); }
  100% { left: -100px; transform: translateY(0) scaleX(1); }
}
@keyframes chocoboKweh {
  0%, 5%, 95%, 100% { opacity: 0; }
  8%, 12% { opacity: 1; }
  15% { opacity: 0; }
}

/* ============================================================
   MOOGLE (Duo screen mog-post)
   ============================================================ */
.mog-post {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px;
  border: 1px dashed var(--gold-1);
  background: rgba(255, 217, 128, 0.05);
  border-radius: 4px;
}
.mog-icon {
  font-size: 42px;
  filter: drop-shadow(0 0 10px rgba(255, 220, 240, 0.6));
  animation: mogBounce 1.4s ease-in-out infinite;
  line-height: 1;
}
@keyframes mogBounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.mog-bubble {
  flex: 1;
  background: rgba(20, 32, 73, 0.65);
  border: 1px solid var(--ff-frame-2);
  padding: 10px 14px;
  border-radius: 4px;
  position: relative;
  font-size: 12px;
  line-height: 1.7;
}
.mog-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 14px;
  border: 8px solid transparent;
  border-right-color: var(--ff-frame-2);
}
.mog-bubble strong { color: var(--gold); }
.mog-bubble .kupo { color: #ff9ad4; font-weight: 700; }

/* ============================================================
   STATUS — masterJob / subJob / Limit
   ============================================================ */
.job-progress {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-family: "Cinzel", "JetBrains Mono", monospace;
  font-size: 11px;
}
.job-progress-bar {
  height: 6px;
  background: var(--bg-deep);
  border: 1px solid var(--ff-frame-2);
  overflow: hidden;
  position: relative;
}
.job-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-1), var(--gold));
  box-shadow: 0 0 6px var(--gold);
}
.job-progress-num { color: var(--gold); font-weight: 700; }

.limit-card {
  padding: 12px 14px;
  border: 1px solid var(--danger);
  background: linear-gradient(90deg, rgba(255, 42, 77, 0.12) 0%, transparent 80%);
  border-radius: 4px;
}
.limit-name {
  font-family: "Cinzel", serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--danger);
  text-shadow: 0 0 10px rgba(255, 42, 77, 0.6);
}
.limit-desc {
  font-size: 11px;
  color: var(--text);
  margin-top: 6px;
  line-height: 1.6;
}

/* Responsive battle */
@media (max-width: 1080px) {
  .party-row { grid-template-columns: repeat(2, 1fr); }
  .battle-cmd { grid-template-columns: 1fr; }
}
@media (max-width: 840px) {
  .enemy-row { grid-template-columns: repeat(2, 1fr); padding: 18px 10px; }
  .enemy-emoji { font-size: 48px; }
  .enemy.is-boss .enemy-emoji { font-size: 64px; }
  .party-row { grid-template-columns: 1fr; }
  .save-point { right: 10px; bottom: 10px; width: 50px; height: 50px; }
  .save-point-crystal { font-size: 18px; }
  .save-point-label { font-size: 7px; }
  .hud { grid-template-columns: repeat(3, 1fr); }
  .hud-cell:nth-child(n+4) { display: none; }
}
