/* ==========================================================================
   연면유색 (连绵有色) — Official Game World Portal Stylesheet
   Theme: Midnight Obsidian / Celestial Starlight / Chromatic Waters
   ========================================================================== */

:root {
  /* Metrics & Scales */
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 36px;
  --space-xxl: 56px;
  --space-hero: 80px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --header-height: 64px;
  --max-width-content: 1320px;

  /* Font Stacks */
  --font-serif: 'KoPubWorldBatang', 'Nanum Myeongjo', 'Batang', Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* Color Palette - AAA Fantasy RPG */
  --bg-deep: #06090e;
  --bg-app: #090e15;
  --bg-surface: #0e1520;
  --bg-card: rgba(16, 24, 36, 0.78);
  --bg-card-hover: rgba(22, 33, 50, 0.92);
  --bg-glass: rgba(14, 21, 32, 0.65);
  --bg-header: rgba(8, 13, 20, 0.88);
  --bg-input: #0a0f16;

  --text-primary: #edf4fa;
  --text-secondary: #a9bece;
  --text-muted: #9bb1c3;
  --text-glow: #ffffff;

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.16);
  --border-strong: rgba(255, 255, 255, 0.28);
  --border-focus: #5cc2d0;

  /* Chromatic Signatures */
  --color-star: #e7c57b;
  --color-star-subtle: rgba(231, 197, 123, 0.14);
  --color-star-glow: rgba(231, 197, 123, 0.35);

  --color-water: #8cd7df;
  --color-water-subtle: rgba(140, 215, 223, 0.14);
  --color-water-glow: rgba(140, 215, 223, 0.35);

  --color-sword: #db9b87;
  --color-sword-subtle: rgba(219, 155, 135, 0.14);

  --color-crimson: #d9534f;
  --color-crimson-subtle: rgba(217, 83, 79, 0.18);

  --color-sage: #b6c8bc;

  /* Lighting & Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.75);
  --shadow-glow-cyan: 0 0 24px rgba(140, 215, 223, 0.25);
  --shadow-glow-gold: 0 0 24px rgba(231, 197, 123, 0.25);

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.28s var(--ease-out);
}

/* Base Reset & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  scroll-behavior: smooth;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-md);
  z-index: 1000;
  background: var(--color-star);
  color: #000;
  padding: var(--space-xs) var(--space-md);
  font-weight: 700;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: var(--space-md);
}

/* Focus States */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 3px;
}

button, a {
  color: inherit;
  font-family: inherit;
}

/* ==========================================================================
   Motion Control & Reduced Motion Overrides
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

[data-portal-motion="off"] html,
[data-portal-motion="off"] *,
[data-portal-motion="off"] *::before,
[data-portal-motion="off"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */
.portal-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-header);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 90;
  display: flex;
  align-items: center;
}

.header-container {
  width: 100%;
  max-width: var(--max-width-content);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  text-decoration: none;
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  flex-shrink: 0;
}

.portal-brand .brand-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.portal-brand .brand-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-star);
  background: var(--color-star-subtle);
  border: 1px solid rgba(231, 197, 123, 0.3);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  margin-left: 2px;
}

.portal-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.portal-nav::-webkit-scrollbar {
  display: none;
}

.nav-scroll-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.nav-item:hover {
  color: var(--text-primary);
  background-color: var(--border-subtle);
}

.nav-item[aria-current="page"] {
  color: var(--color-water);
  background-color: var(--color-water-subtle);
  border-color: rgba(140, 215, 223, 0.35);
  font-weight: 700;
}

.nav-item-action {
  color: var(--color-star);
  border-color: rgba(231, 197, 123, 0.25);
  background-color: rgba(231, 197, 123, 0.06);
}

.nav-pulse {
  width: 6px;
  height: 6px;
  background-color: var(--color-star);
  border-radius: var(--radius-full);
  display: inline-block;
  box-shadow: 0 0 6px var(--color-star);
  animation: pulseBeacon 2s infinite ease-in-out;
}

@keyframes pulseBeacon {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.3); }
}

.nav-item-reader {
  color: var(--text-muted);
  border-left: 1px solid var(--border-subtle);
  margin-left: var(--space-xs);
  padding-left: var(--space-md);
}
.nav-item-reader:hover {
  color: var(--text-primary);
}

.header-controls {
  flex-shrink: 0;
}

.btn-motion-toggle {
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-motion-toggle:hover {
  background-color: var(--border-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-motion-toggle[aria-pressed="true"] {
  background-color: var(--color-water-subtle);
  color: var(--color-water);
  border-color: var(--color-water);
}

/* ==========================================================================
   Portal Main Mount Root
   ========================================================================== */
.portal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Universal View Header */
.view-heading {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg) var(--space-md);
  text-align: left;
}

.view-heading .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--color-water);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: var(--space-xs);
}

.view-heading h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
}

.view-heading p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 720px;
}

/* ==========================================================================
   1. HOME VIEW (Epic RPG Gateway)
   ========================================================================== */
.home-hero {
  position: relative;
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: var(--space-hero) clamp(var(--space-lg), 6vw, var(--space-xxl));
  overflow: hidden;
  background-image: url('../public/key-art.webp');
  background-size: cover;
  background-position: right 30%;
  background-repeat: no-repeat;
}

.home-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  /* Dark overlay concentrated on the left text side, exposing right 60% artwork */
  background: linear-gradient(to right,
    rgba(6, 9, 14, 0.98) 0%,
    rgba(6, 9, 14, 0.92) 28%,
    rgba(6, 9, 14, 0.55) 48%,
    rgba(6, 9, 14, 0.12) 65%,
    transparent 100%
  ),
  linear-gradient(to top,
    var(--bg-deep) 0%,
    transparent 20%
  );
  pointer-events: none;
  z-index: 1;
}

/* Hero Atmosphere Motion Elements */
.hero-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.hero-orbit {
  position: absolute;
  top: 45%;
  left: 65%;
  border-radius: var(--radius-full);
  border: 1px dashed rgba(140, 215, 223, 0.18);
  transform: translate(-50%, -50%);
}

.orbit-one {
  width: 580px;
  height: 580px;
  animation: rotateOrbit 60s linear infinite;
}

.orbit-two {
  width: 820px;
  height: 820px;
  border-color: rgba(231, 197, 123, 0.12);
  border-style: solid;
  border-width: 1px;
  stroke-dasharray: 20 40;
  animation: rotateOrbitRev 90s linear infinite;
}

@keyframes rotateOrbit {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes rotateOrbitRev {
  from { transform: translate(-50%, -50%) rotate(360deg); }
  to { transform: translate(-50%, -50%) rotate(0deg); }
}

.hero-starfield {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(1.5px 1.5px at 20px 30px, #ffffff, rgba(0,0,0,0)),
                    radial-gradient(1.5px 1.5px at 150px 80px, #e7c57b, rgba(0,0,0,0)),
                    radial-gradient(1px 1px at 300px 220px, #8cd7df, rgba(0,0,0,0));
  background-repeat: repeat;
  background-size: 550px 550px;
  opacity: 0.45;
  animation: starPulse 8s ease-in-out infinite alternate;
}

@keyframes starPulse {
  0% { opacity: 0.25; transform: scale(1); }
  100% { opacity: 0.65; transform: scale(1.02); }
}

.hero-waterline {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, var(--color-star) 30%, var(--color-water) 70%, transparent 100%);
  opacity: 0.7;
}

/* Hero Copy: Completely removed card/border/blur/rounded-box */
.hero-copy {
  position: relative;
  z-index: 3;
  max-width: 660px;
  margin: 0;
  text-align: left;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.hero-copy .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  color: var(--color-star);
  font-weight: 700;
  margin-bottom: var(--space-xs);
  display: inline-block;
}

.hero-prologue {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-water);
  margin-bottom: var(--space-xs);
  letter-spacing: -0.01em;
}

.hero-copy h1 {
  font-family: var(--font-serif);
  font-size: clamp(3.2rem, 7vw, 5.8rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: #ffffff;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-start;
  gap: var(--space-sm);
  margin: var(--space-xs) 0 var(--space-md);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.85);
}

.hero-copy h1 span {
  font-size: 0.38em;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.hero-description {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-xl);
  max-width: 540px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-lg);
}

.action-primary,
.action-secondary,
.action-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 14px 32px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.action-primary {
  background: linear-gradient(135deg, var(--color-star) 0%, #cfa038 100%);
  color: #0b0f14;
  box-shadow: 0 4px 18px var(--color-star-glow);
}
.action-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
  box-shadow: 0 6px 24px rgba(231, 197, 123, 0.45);
}

.action-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.action-secondary:hover {
  background-color: var(--border-subtle);
  border-color: var(--color-water);
  color: var(--color-water);
}

.action-small {
  padding: 8px 16px;
  font-size: 0.88rem;
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border-medium);
}
.action-small:hover {
  background-color: var(--border-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.hero-credit {
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-md);
}

.hero-coordinate {
  position: absolute;
  top: var(--space-xl);
  right: var(--space-xl);
  z-index: 3;
  text-align: right;
  font-family: var(--font-mono);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
}
.hero-coordinate span {
  font-size: 1.2rem;
  color: var(--color-star);
  letter-spacing: 0.15em;
}
.hero-coordinate small {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
}

.hero-scroll {
  position: absolute;
  bottom: var(--space-lg);
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}
.hero-scroll:hover {
  color: var(--color-water);
}

/* Expedition Grid Section */
.expedition-section {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-xxl) var(--space-lg);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-md);
}

.section-heading .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--color-star);
  font-weight: 700;
  margin-bottom: 4px;
}

.section-heading h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.section-heading p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.expedition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-lg);
}

.expedition-entry {
  position: relative;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
  overflow: hidden;
}

.expedition-entry::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--border-subtle);
  transition: background-color var(--transition-fast);
}

.expedition-entry:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-strong);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.entry-arena:hover::before { background-color: var(--color-crimson); }
.entry-characters:hover::before { background-color: var(--color-star); }
.entry-world:hover::before { background-color: var(--color-water); }
.entry-archive:hover::before { background-color: var(--color-sage); }

.entry-index {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: var(--space-xs);
  display: block;
}

.entry-symbol {
  font-size: 1.8rem;
  color: var(--color-star);
  margin-bottom: var(--space-sm);
  display: block;
}

.expedition-entry h3 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.expedition-entry p {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-lg);
  flex: 1;
}

.entry-link {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-water);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Home Story Strip */
.home-story-strip {
  max-width: var(--max-width-content);
  width: 100%;
  margin: var(--space-xl) auto var(--space-xxl);
  padding: var(--space-xl) var(--space-lg);
  background: linear-gradient(135deg, rgba(22, 33, 48, 0.7) 0%, rgba(14, 20, 30, 0.9) 100%);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.home-story-strip .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-star);
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.home-story-strip h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.4;
}

.text-link {
  color: var(--color-water);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.text-link:hover {
  text-decoration: underline;
  color: #ffffff;
}

/* ==========================================================================
   2. CHARACTERS & RELATIONSHIPS VIEW
   ========================================================================== */
.character-layout {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-xxl);
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: var(--space-xl);
}

.relationship-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.panel-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-md);
}

.relation-map {
  position: relative;
  width: 100%;
  height: 420px;
  background: radial-gradient(circle at 50% 50%, rgba(20, 30, 45, 0.6) 0%, rgba(8, 12, 18, 0.95) 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.relation-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.relation-orbit {
  fill: none;
  stroke: var(--border-subtle);
  stroke-dasharray: 4 8;
}

.relation-line {
  stroke: var(--border-medium);
  stroke-width: 2;
  transition: all var(--transition-normal);
}

.relation-line.is-active {
  stroke: var(--color-water);
  stroke-width: 3.5;
  stroke-dasharray: 8 6;
  filter: drop-shadow(0 0 8px var(--color-water));
  animation: dashFlow 1.5s linear infinite;
}

@keyframes dashFlow {
  from { stroke-dashoffset: 28; }
  to { stroke-dashoffset: 0; }
}

.relation-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-star);
  opacity: 0.35;
  z-index: 1;
  pointer-events: none;
}

.relation-node {
  position: absolute;
  left: var(--node-x);
  top: var(--node-y);
  transform: translate(-50%, -50%);
  z-index: 2;
  background-color: var(--bg-surface);
  border: 2px solid var(--character-color, var(--border-medium));
  border-radius: var(--radius-lg);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  min-width: 90px;
}

.relation-node:hover {
  transform: translate(-50%, -54%);
  box-shadow: 0 0 16px var(--character-color, var(--color-water));
}

.relation-node.is-selected {
  background-color: var(--bg-card-hover);
  border-width: 3px;
  box-shadow: 0 0 24px var(--character-color, var(--color-star));
}

.node-portrait {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 4px;
  background-color: var(--bg-deep);
}

.node-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.relation-node strong {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.relation-node small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.relation-legend {
  list-style: none;
  margin-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.relation-legend li {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.legend-line {
  width: 16px;
  height: 2px;
  background-color: var(--color-water);
  display: inline-block;
}

/* Character Detail Card */
.character-detail {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.character-portrait-stage {
  position: relative;
  width: 100%;
  height: 260px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: radial-gradient(circle at 50% 50%, rgba(25, 35, 50, 0.8) 0%, #090e15 100%);
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
}

.character-portrait-stage img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.portrait-sigil {
  position: absolute;
  bottom: var(--space-sm);
  right: var(--space-sm);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--character-color, var(--color-star));
  opacity: 0.4;
  font-family: var(--font-serif);
}

.character-biography .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--character-color, var(--color-water));
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.character-biography h2 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.character-biography blockquote {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--character-color, var(--color-star));
  border-left: 2px solid var(--character-color, var(--color-star));
  padding-left: var(--space-md);
  margin-bottom: var(--space-md);
}

.character-biography p {
  color: var(--text-secondary);
  font-size: 0.98rem;
  line-height: 1.7;
  margin-bottom: var(--space-lg);
}

.skill-tags {
  display: flex;
  gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-xl);
}

.skill-tags span {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.character-biography h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 4px;
}

.relationship-details {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.relationship-details strong {
  font-size: 0.95rem;
  color: var(--color-water);
}

.relationship-details p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ==========================================================================
   3. WORLD & EXPEDITION JOURNAL VIEW
   ========================================================================== */
.world-layout {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-xxl);
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: var(--space-xl);
}

.world-map-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.world-map {
  position: relative;
  width: 100%;
  height: 480px;
  background: radial-gradient(circle at 60% 40%, #101c27 0%, #070d14 100%);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.world-map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.map-contours {
  position: absolute;
  inset: 0;
  background-image: repeating-radial-gradient(circle at 30% 30%, transparent 0, transparent 40px, rgba(255,255,255,0.02) 41px, transparent 42px);
  pointer-events: none;
}

.map-route {
  stroke: var(--color-star);
  stroke-width: 3;
  stroke-dasharray: 6 6;
  fill: none;
  animation: routeDash 2.5s linear infinite;
}

@keyframes routeDash {
  from { stroke-dashoffset: 24; }
  to { stroke-dashoffset: 0; }
}

.map-river {
  stroke: var(--color-water);
  stroke-width: 4;
  fill: none;
  opacity: 0.6;
}

.map-compass {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--color-star);
  text-align: center;
  opacity: 0.6;
  pointer-events: none;
}

.map-location {
  position: absolute;
  left: var(--map-x);
  top: var(--map-y);
  transform: translate(-50%, -50%);
  z-index: 2;
  background-color: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
  min-width: 100px;
}

.map-location:hover {
  border-color: var(--color-water);
  transform: translate(-50%, -54%);
  box-shadow: 0 0 16px var(--color-water-glow);
}

.map-location.is-selected {
  border-color: var(--color-star);
  background-color: var(--bg-card-hover);
  box-shadow: 0 0 20px var(--color-star-glow);
}

.map-marker {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-star);
}

.map-location strong {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.map-location small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.bookmark-marker {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-star);
  margin-top: 2px;
}

.map-footnote {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: var(--space-sm);
}

/* Location Detail Panel & Journal Editor */
.location-detail {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.location-detail .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--color-water);
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.location-detail h2 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.location-detail > p {
  color: var(--text-secondary);
  font-size: 0.98rem;
  line-height: 1.7;
  margin-bottom: var(--space-md);
}

.location-detail h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.location-events {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.92rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bookmark-button {
  align-self: flex-start;
  margin-bottom: var(--space-lg);
}

.bookmark-button[aria-pressed="true"] {
  border-color: var(--color-star);
  color: var(--color-star);
  background-color: var(--color-star-subtle);
}

.journal-editor {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.journal-editor label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.journal-editor p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.journal-editor textarea {
  width: 100%;
  padding: 10px 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  resize: vertical;
}

.journal-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

#note-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.save-status {
  font-size: 0.8rem;
  color: var(--color-water);
  margin-top: var(--space-xs);
}

/* ==========================================================================
   4. ARCHIVE & CHROMATIC LAB VIEW
   ========================================================================== */
.ability-tabs {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0 auto var(--space-lg);
  padding: 0 var(--space-lg);
  display: flex;
  gap: var(--space-md);
  overflow-x: auto;
}

.ability-tab {
  flex: 1;
  min-width: 200px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ability-tab:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--ability-color, var(--border-strong));
}

.ability-tab.is-selected {
  border-color: var(--ability-color, var(--color-water));
  border-width: 2px;
  background-color: var(--bg-card-hover);
  box-shadow: 0 0 20px rgba(140, 215, 223, 0.2);
}

.ability-tab span {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.ability-tab strong {
  font-size: 1.25rem;
  font-family: var(--font-serif);
  color: var(--text-primary);
  margin: 2px 0;
}

.ability-tab small {
  font-size: 0.78rem;
  color: var(--ability-color, var(--color-water));
  font-weight: 600;
}

.ability-lab {
  max-width: var(--max-width-content);
  width: calc(100% - 2 * var(--space-lg));
  margin: 0 auto var(--space-xl);
  padding: var(--space-xl);
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.ability-lab-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-md);
}

.ability-lab-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ability-color, var(--color-water));
  letter-spacing: 0.1em;
}

.ability-lab-header h2 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.ability-lab-header h2 span {
  color: var(--text-muted);
  font-size: 0.65em;
  font-weight: 500;
}

/* Ability Flow Step Animation */
.ability-flow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  padding: var(--space-md) 0;
}

.flow-track {
  position: absolute;
  top: 48px;
  left: 10%;
  right: 10%;
  height: 4px;
  background-color: var(--border-subtle);
  z-index: 1;
}

.flow-track span {
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--ability-color, var(--color-water)), #ffffff);
  border-radius: var(--radius-full);
  animation: flowLight 2.5s ease-in-out infinite;
}

@keyframes flowLight {
  0% { transform: translateX(0%); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateX(250%); opacity: 0; }
}

.ability-flow.is-replaying .flow-track span {
  animation: flowLight 1s ease-in-out;
}

.flow-step {
  position: relative;
  z-index: 2;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.flow-glyph {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background-color: var(--bg-deep);
  border: 2px solid var(--ability-color, var(--color-water));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--ability-color, var(--color-water));
  margin-bottom: var(--space-sm);
  box-shadow: 0 0 14px rgba(140, 215, 223, 0.25);
}

.flow-index {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}

.flow-step h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ability-explanation {
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.ability-seal {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 800;
  color: var(--ability-color, var(--color-water));
  line-height: 1;
}

.ability-explanation h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.ability-explanation p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.source-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

.codex-bottom {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-xxl);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   5. ARENA & TACTICAL TRAINING (Combat Stage)
   ========================================================================== */
.simulation-notice {
  max-width: var(--max-width-content);
  width: calc(100% - 2 * var(--space-lg));
  margin: 0 auto var(--space-md);
  padding: 6px var(--space-md);
  background-color: rgba(217, 83, 79, 0.12);
  border: 1px solid rgba(217, 83, 79, 0.35);
  border-radius: var(--radius-sm);
  color: #ff9d99;
  font-size: 0.82rem;
  text-align: center;
}

.arena-layout {
  max-width: var(--max-width-content);
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-lg) var(--space-xxl);
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: var(--space-xl);
}

.battle-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.battle-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-xs);
  margin-bottom: var(--space-md);
}

#battle-turn {
  color: var(--color-star);
  font-weight: 700;
}

/* Combatant Meters */
.battle-health {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-md);
}

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.meter-label strong {
  font-weight: 700;
}

.meter-label span {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

progress {
  width: 100%;
  height: 10px;
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: var(--radius-full);
  overflow: hidden;
  background-color: var(--bg-deep);
}

progress::-webkit-progress-bar {
  background-color: var(--bg-deep);
}

progress#player-hp::-webkit-progress-value {
  background: linear-gradient(90deg, #d9534f 0%, var(--color-star) 100%);
  transition: width 0.3s ease;
}

progress#enemy-hp::-webkit-progress-value {
  background: linear-gradient(90deg, #1c5866 0%, var(--color-water) 100%);
  transition: width 0.3s ease;
}

progress#player-focus::-webkit-progress-value {
  background: linear-gradient(90deg, #3297a6 0%, #8cd7df 100%);
  transition: width 0.3s ease;
}

/* Battle Stage Arena */
.battle-stage {
  position: relative;
  width: 100%;
  height: 420px;
  background-image:
    linear-gradient(180deg, rgba(8, 12, 18, 0.72) 0%, rgba(8, 12, 18, 0.88) 100%),
    url('../public/key-art.webp');
  background-size: cover;
  background-position: center 40%;
  background-repeat: no-repeat;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.9);
  margin-bottom: var(--space-md);
}

.arena-ring {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 85%;
  height: 80px;
  border-radius: 50%;
  border: 1px dashed rgba(231, 197, 123, 0.28);
  pointer-events: none;
}

.combatant {
  position: absolute;
  bottom: 24px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 180px;
  transition: transform var(--transition-fast);
  background: transparent;
  border: none;
  box-shadow: none;
}

.combatant-player {
  left: clamp(16px, 8%, 80px);
}

.combatant-enemy {
  right: clamp(16px, 8%, 80px);
}

.combatant img {
  width: 160px;
  height: 240px;
  object-fit: contain;
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.9));
  background: transparent;
}

.combatant span {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  font-weight: 700;
  margin-top: 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
}

.combatant-player span { color: var(--color-star); }
.combatant-enemy span { color: var(--color-water); }

.arena-vs {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.22);
  letter-spacing: 0.14em;
  text-shadow: 0 0 24px rgba(0, 0, 0, 0.95);
  z-index: 1;
  pointer-events: none;
}

/* Action Visual Particle Sprites in Stage */
.water-projectile,
.star-projectile,
.guard-shield {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

/* Action Trigger Animations */
[data-action="star"] .star-projectile {
  top: 50%;
  left: 25%;
  width: 32px;
  height: 32px;
  background: radial-gradient(circle, #ffffff 20%, var(--color-star) 60%, transparent 100%);
  border-radius: var(--radius-full);
  box-shadow: 0 0 24px var(--color-star);
  opacity: 1;
  animation: shootStar 0.5s ease-out forwards;
}

@keyframes shootStar {
  0% { transform: translate(0, -50%) scale(0.6); opacity: 1; }
  80% { transform: translate(240px, -50%) scale(1.6); opacity: 1; }
  100% { transform: translate(280px, -50%) scale(2); opacity: 0; }
}

[data-action="value"] .star-projectile {
  top: 45%;
  left: 20%;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, #ffffff 30%, #ffd700 70%, transparent 100%);
  border-radius: var(--radius-full);
  box-shadow: 0 0 40px #ffd700, 0 0 80px var(--color-star);
  opacity: 1;
  animation: blastValue 0.6s ease-out forwards;
}

@keyframes blastValue {
  0% { transform: translate(0, -50%) scale(0.5); opacity: 1; }
  70% { transform: translate(250px, -50%) scale(2.4); opacity: 1; }
  100% { transform: translate(280px, -50%) scale(3); opacity: 0; }
}

[data-action="guard"] .guard-shield {
  top: 35%;
  left: 12%;
  width: 140px;
  height: 220px;
  border: 3px solid var(--color-water);
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(140, 215, 223, 0.25) 0%, transparent 80%);
  box-shadow: 0 0 30px var(--color-water);
  opacity: 1;
  animation: pulseShield 0.6s ease-out forwards;
}

@keyframes pulseShield {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* Battle Outcome Overlay */
.battle-outcome {
  position: absolute;
  inset: 0;
  z-index: 10;
  background-color: rgba(6, 9, 14, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-lg);
  animation: fadeInOutcome 0.3s ease-out;
}

.battle-outcome[hidden] {
  display: none !important;
}

@keyframes fadeInOutcome {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.battle-outcome span {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--color-star);
  margin-bottom: var(--space-xs);
}

.battle-outcome strong {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  color: #ffffff;
  margin-bottom: var(--space-xs);
}

.battle-outcome p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* Enemy Intent Telegraph Box */
.enemy-telegraph {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  background-color: var(--bg-surface);
  border: 1px solid rgba(140, 215, 223, 0.35);
  border-left: 4px solid var(--color-water);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-xs);
}

.telegraph-indicator {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
  background-color: var(--color-water);
  box-shadow: 0 0 10px var(--color-water);
  margin-top: 4px;
  flex-shrink: 0;
}

.enemy-telegraph .eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

.enemy-telegraph h2 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2px 0;
}

.enemy-telegraph p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.battle-announcement {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--color-star);
  min-height: 20px;
  padding: 4px var(--space-xs);
}

/* Tactics Panel */
.tactics-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

.focus-meter {
  margin-bottom: var(--space-md);
}

.tactics-panel h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
}

.combat-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.combat-action {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.combat-action:hover:not(:disabled) {
  background-color: var(--bg-card-hover);
  border-color: var(--color-star);
  transform: translateX(4px);
  box-shadow: 0 0 16px var(--color-star-glow);
}

.combat-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(80%);
}

.combat-action-key {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-star);
  background-color: rgba(231, 197, 123, 0.12);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.combat-action strong {
  display: block;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.combat-action small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.action-cost {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-water);
  flex-shrink: 0;
}

.action-star .action-cost { color: var(--color-star); }
.action-value .action-cost { color: var(--color-crimson); }

.tactic-help {
  background-color: var(--bg-surface);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.tactic-help h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--color-star);
  margin-bottom: 4px;
}

.tactic-help p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.battle-log {
  flex: 1;
  margin-bottom: var(--space-md);
}

.battle-log h3 {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

#combat-log {
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 140px;
  overflow-y: auto;
}

#combat-log li {
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.03);
}

.arena-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-sm);
}

#personal-best {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-star);
  font-weight: 700;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.portal-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-xl) var(--space-lg);
  margin-top: auto;
}

.footer-container {
  max-width: var(--max-width-content);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.footer-brand-title {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.footer-brand-title span {
  font-size: 0.75em;
  color: var(--text-muted);
}

.footer-summary {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.footer-nav-section {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.footer-nav-section a {
  font-size: 0.88rem;
  color: var(--color-water);
  text-decoration: none;
}
.footer-nav-section a:hover {
  text-decoration: underline;
}

.footer-legal-section {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-sm);
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* ==========================================================================
   Responsive Adaptations (320px / 768px / 1200px)
   ========================================================================== */
@media (max-width: 992px) {
  .character-layout,
  .world-layout,
  .arena-layout {
    grid-template-columns: 1fr;
  }

  .ability-flow {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .flow-track {
    display: none;
  }
}

@media (max-width: 840px) {
  :root {
    --header-height: 58px;
  }

  .portal-header {
    height: auto;
    padding: 8px 0 6px;
  }

  .header-container {
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-sm);
    gap: 8px 0;
  }

  .portal-brand {
    order: 1;
  }

  .portal-brand .brand-tag {
    display: none;
  }

  .header-controls {
    order: 2;
  }

  .portal-nav {
    order: 3;
    width: 100%;
    margin-top: 2px;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .nav-scroll-wrap {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
  }

  .nav-item {
    padding: 6px 2px;
    font-size: 0.8rem;
    justify-content: center;
    text-align: center;
    border-radius: var(--radius-sm);
    white-space: nowrap;
  }

  .nav-item-action .nav-pulse {
    display: none;
  }

  .nav-item-reader {
    display: none;
  }

  .home-hero {
    min-height: 100vh;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 110px var(--space-md) var(--space-xl);
    background-position: 72% top;
  }

  .home-hero::before {
    background: linear-gradient(to bottom,
      rgba(6, 9, 14, 0.15) 0%,
      rgba(6, 9, 14, 0.55) 35%,
      rgba(6, 9, 14, 0.94) 65%,
      var(--bg-deep) 100%
    );
  }

  .hero-copy {
    max-width: 100%;
    text-align: left;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
  }

  .hero-copy h1 {
    font-size: clamp(2.4rem, 10vw, 3.4rem);
    justify-content: flex-start;
  }

  .hero-description {
    font-size: 1.05rem;
    margin-bottom: var(--space-lg);
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .battle-stage {
    height: 340px;
    padding: 0;
  }

  .combatant {
    width: 130px;
    bottom: 16px;
  }

  .combatant-player {
    left: 14px;
  }

  .combatant-enemy {
    right: 14px;
  }

  .combatant img {
    width: 110px;
    height: 180px;
  }

  .arena-vs {
    font-size: 2.2rem;
  }
}

/* 320px ultra-small devices */
@media (max-width: 360px) {
  .portal-header {
    height: auto;
    padding: 6px 0 4px;
  }

  .header-container {
    padding: 0 6px;
    gap: 6px 0;
  }

  .portal-brand {
    font-size: 1.05rem;
  }

  .btn-motion-toggle {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .portal-nav {
    margin-top: 1px;
    padding-top: 2px;
  }

  .nav-scroll-wrap {
    gap: 2px;
  }

  .nav-item {
    padding: 5px 1px;
    font-size: 0.72rem;
    letter-spacing: -0.04em;
  }

  .home-hero {
    padding: 95px 8px var(--space-lg);
  }

  .hero-copy h1 {
    font-size: 2.2rem;
  }

  .hero-coordinate {
    display: none;
  }

  .action-primary,
  .action-secondary {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  .expedition-grid {
    grid-template-columns: 1fr;
  }

  .relation-map {
    height: 340px;
  }

  .relation-node {
    min-width: 68px;
    padding: 4px 6px;
  }

  .node-portrait {
    width: 38px;
    height: 38px;
  }

  .relation-node strong {
    font-size: 0.78rem;
  }

  .relation-node small {
    display: none;
  }

  .world-map {
    height: 360px;
  }

  .map-location {
    min-width: 75px;
    padding: 4px 8px;
  }

  .map-location strong {
    font-size: 0.82rem;
  }

  .battle-health {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .battle-stage {
    height: 280px;
    padding: 0;
  }

  .combatant {
    width: 95px;
    bottom: 12px;
  }

  .combatant-player {
    left: 6px;
  }

  .combatant-enemy {
    right: 6px;
  }

  .combatant img {
    width: 85px;
    height: 140px;
  }

  .arena-vs {
    font-size: 1.6rem;
  }

  .combat-action {
    padding: 10px var(--space-xs);
  }

  .view-heading {
    padding: var(--space-lg) var(--space-xs) var(--space-xs);
  }

  .view-heading h1 {
    font-size: 1.7rem;
  }
}
