/*
  cast.html（龍紹介）専用スタイル
  - 背景は添付画像の赤
  - パネルはサブカラー
  - パネル内の文字色はJSで自動コントラスト調整（--panel-text / --panel-muted）
*/

:root {
  /* 中華高級ベース背景 */
  --page-bg: #2A0E12;

  /* 龍ごとの色（JSで上書き） */
  --d-main: #494544;
  --d-accent: #8B2332;
  --d-sub: #BAC8C6;

  /* パネル内文字色（JSで上書き） */
  --panel-text: #111;
  --panel-muted: rgba(0, 0, 0, .72);
}

/* page - 中華高級背景 */
.cast-page {
  background: linear-gradient(135deg,
      #2A0E12 0%,
      #4A1820 25%,
      #6A2430 50%,
      #4A1820 75%,
      #2A0E12 100%);
  background-attachment: fixed;
}

.dragons-page {
  background: transparent;
}

/* shell */
.dragons-shell {
  width: min(1280px, 92vw);
  margin: 0 auto;
  /* 上下パディングを画面高さに合わせて調整 (vh) */
  padding: clamp(10px, 2vh, 18px) 0 clamp(20px, 4vh, 46px);
  /* 画面内に収めるために max-height を考慮（必要に応じて） */
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* ヘッダー分を除いたエリア調整 */
  min-height: 85vh;
  /* 固定フッター(約100px)被り防止のための余白を追加 */
  padding-bottom: 160px;
}

/* top/bottom band: use same style (requested) */
.dragons-band {
  position: relative;
  overflow: hidden;
  background-image: url("../img/dragon_band.png");
  background-repeat: repeat-x;
  background-position: center;
  background-size: auto 100%;
}

.dragons-band::after {
  content: "";
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

/* 上段：下段と同じ色味（下段が正）に合わせる */
.dragons-band.top {
  /* 参照画像に合わせた高さ */
  height: 96px;
  border-radius: 8px 8px 0 0;
  background-color: var(--d-main);
}

.dragons-band.top::after {
  background: var(--d-main);
  /* 下段と同じトーン */
  opacity: .45;
}

/* 下段：メインカラーに馴染ませて横に引き延ばす */
.dragons-band.bottom {
  /* 下段も少し薄くして全体の縦サイズを圧縮 */
  height: 70px;
  border-radius: 0 0 8px 8px;
  background-color: var(--d-main);
}

.dragons-band.bottom::after {
  background: var(--d-main);
  opacity: .45;
  pointer-events: none;
}

/* 中段アクセント帯 */
.accent-bar {
  height: 8px;
  background: var(--d-accent);
}

body.cast-page .dragons-stage {
  position: relative;
  max-width: 100%;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 clamp(40px, 5vw, 80px);
  overflow: visible;
  /* Change from hidden to visible to prevent clipping */
  display: grid;
  grid-template-columns: auto clamp(100px, 8vw, 140px) 1fr;
  column-gap: 0;
  row-gap: 0;
  align-items: center;
  justify-items: center;
}

/* 1080p Full HD screen height adjustment */
@media (max-height: 1000px) {
  body.cast-page .dragons-stage {
    min-height: 80vh;
    /* Keep decent height but allow growth */
    height: auto;
  }

  .dragons-shell {
    /* Use standard flow padding, no forced bottom buffer needed as footer flows naturally now */
    padding: 10px 0 40px !important;
    min-height: auto;
    justify-content: flex-start !important;
    /* Keep top align for safety */
  }

  .panel-inner {
    padding: 15px 25px !important;
    min-height: 180px;
  }

  .dragon-name {
    font-size: clamp(40px, 5vw, 70px) !important;
    margin-bottom: 4px;
  }

  .dragons-portrait {
    height: clamp(280px, 55vh, 480px);
  }

  /* Show less gap in lists */
  .meta {
    gap: 8px;
  }

  .dragon-title {
    font-size: 32px;
  }
}

.dragons-stage {
  position: relative;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
}

.dragons-stage::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -14px;
  height: 6px;
  background: linear-gradient(to bottom,
      rgba(255, 255, 255, .75) 0 2px,
      var(--d-accent) 2px 4px,
      rgba(255, 255, 255, .75) 4px 6px);
  opacity: .85;
}

/* central panel uses sub color */
.dragons-panel {
  position: relative;
  background: var(--d-sub);
  color: var(--panel-text);
  border: 4px solid var(--d-accent);
  border-radius: 0;
  overflow: visible;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .28);
}

.dragons-panel::before,
.dragons-panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.dragons-panel::before {
  inset: 10px;
  border: 2px solid rgba(0, 0, 0, .45);
  opacity: .55;
}

.dragons-panel::after {
  inset: 14px;
  border: 1px solid rgba(255, 255, 255, .25);
  opacity: .4;
}

.panel-inner {
  position: relative;
  /* 縦に大きくなりすぎないように参照画像の比率へ寄せる */
  min-height: 220px;
  /* パディングをレスポンシブに */
  padding: clamp(15px, 2vh, 22px) clamp(20px, 2vw, 34px);
  overflow: visible;
}

/* cast.html 専用: Grid レイアウトを使用 */
body.cast-page .dragons-panel .panel-inner {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 1fr;
  align-items: center;
  justify-items: start;
  gap: 0;
  padding: clamp(20px, 3vh, 50px) clamp(40px, 5vw, 70px);
}

body.cast-page .panel-content-wrapper {
  width: 600px !important;
  max-width: 100% !important;
  grid-column: 1 !important;
  grid-row: 1 !important;
}

body.cast-page #dragonFlower {
  grid-column: 2;
  grid-row: 1;
  z-index: 1;
}

body.cast-page #dragonPortrait {
  grid-column: 2;
  grid-row: 1;
  z-index: 3;
}

/* レスポンシブ対応 */
@media (max-width: 1800px) {
  body.cast-page .dragons-panel .panel-inner {
    padding: clamp(20px, 3vh, 50px) clamp(30px, 4vw, 60px) !important;
  }

  body.cast-page .panel-content-wrapper {
    width: 550px !important;
  }
}

@media (max-width: 1400px) {
  body.cast-page .dragons-panel .panel-inner {
    padding: clamp(20px, 3vh, 50px) clamp(25px, 3.5vw, 55px) !important;
  }

  body.cast-page .panel-content-wrapper {
    width: 480px !important;
  }
}

@media (max-width: 1200px) {
  body.cast-page .dragons-stage {
    padding: 0 clamp(20px, 3vw, 40px) !important;
    grid-template-columns: auto clamp(80px, 6vw, 120px) 1fr !important;
  }

  body.cast-page .dragons-panel .panel-inner {
    padding: clamp(20px, 3vh, 50px) clamp(20px, 3vw, 50px) !important;
  }

  body.cast-page .panel-content-wrapper {
    width: 420px !important;
  }
}

@media (max-width: 1000px) {
  body.cast-page .dragons-stage {
    grid-template-columns: auto clamp(70px, 5vw, 100px) 1fr !important;
  }

  body.cast-page .dragons-panel .panel-inner {
    padding: clamp(20px, 3vh, 50px) clamp(15px, 2.5vw, 45px) !important;
  }

  body.cast-page .panel-content-wrapper {
    width: 360px !important;
  }
}

@media (max-width: 980px) {
  body.cast-page .dragons-stage {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    height: auto !important;
    overflow: visible !important;
  }

  body.cast-page .panel-content-wrapper {
    width: 100% !important;
  }

  /* Modal Fullscreen Restore for Mobile - Adjusted for margins */
  .dragon-modal {
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .modal-dialog {
    width: 96vw !important;
    max-width: none !important;
    height: 88vh !important;
    max-height: none !important;
    border-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
  }

  /* Increase member icon size on mobile */
  .modal-member-btn {
    width: 70px !important;
    height: 70px !important;
  }
}

/* flower */
.dragons-flower {
  position: absolute;
  right: 54px;
  top: 18px;
  /* 画面幅に応じて自然に縮む（参照画像のサイズ感） */
  width: clamp(240px, 34vw, 440px);
  max-width: none;
  opacity: .42;
  pointer-events: none;
  /* 線画をそのまま乗せる（濃度はopacityで調整） */
}

.dragons-flower.is-hidden {
  display: none;
}

/* left info */
.dragons-info {
  position: relative;
  z-index: 2;
  width: min(680px, 62%);
  padding-left: 6px;
}

.dragon-title {
  font-size: 42px;
  letter-spacing: .08em;
  margin: 0 0 4px;
  color: var(--panel-text);
}

.dragon-name {
  font-family: Georgia, "Times New Roman", Times, serif;
  /* フォントサイズを画面幅/高さに合わせて少し可変に */
  font-size: clamp(48px, 6vw, 86px);
  line-height: 1.05;
  margin: 0 0 10px;
  color: var(--d-accent);
  text-shadow: 3px 3px 0 rgba(0, 0, 0, .55);
}

.dragon-tag {
  font-size: 18px;
  color: var(--panel-muted);
  margin: 0 0 22px;
  width: 100%;
  text-align: center;
}

.meta {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.meta li {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  align-items: start;
}

.meta .k {
  color: var(--panel-text);
  font-weight: 800;
  letter-spacing: .04em;
}

.meta .k::before {
  content: "■";
  display: inline-block;
  margin-right: .35em;
  transform: translateY(-.04em);
}

.meta .v {
  color: var(--panel-text);
  padding-left: 1.25em;
  margin-top: 6px;
}

.meta .v strong {
  color: var(--panel-text);
}

.actions {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.view-details {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font-weight: 800;
  font-size: 34px;
  letter-spacing: .02em;
  color: var(--d-accent);
  text-decoration: underline;
  text-underline-offset: 8px;
  display: inline-block;
}

.view-details::before {
  content: "▼";
  margin-right: .15em;
}

.view-details:hover {
  opacity: .88;
}

/* right portrait (overlap OK) */
.dragons-portrait {
  position: absolute;
  right: 0;
  /* 下へ突き抜けて全体が縦に大きく見えるのを抑える */
  bottom: -30px;
  width: 42%;
  /* 高さを固定pxではなく画面高さ割合(vh)にする */
  height: clamp(300px, 50vh, 520px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  pointer-events: none;
  z-index: 2;
}

.dragons-portrait img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 24px 24px rgba(0, 0, 0, .35));
}

/* small icon at top right */
.dragon-badge {
  position: absolute;
  right: 24px;
  top: 22px;
  width: 104px;
  height: 104px;
  border: 3px solid var(--d-accent);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(0, 0, 0, .12);
  z-index: 3;
}

.dragon-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* icon grid */
.icon-tray {
  margin: 10px auto 0;
  max-width: 1280px;
  padding-left: 40px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  justify-content: flex-start;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 130px);
  gap: 18px;
  width: auto;
}

.thumb-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.thumb-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  background: linear-gradient(135deg, var(--d-accent), transparent);
  opacity: 0;
  border-radius: 8px;
  transition: opacity 0.3s ease;
  z-index: 0;
}

.thumb-btn::after {
  content: '';
  position: absolute;
  inset: -2px;
  border: 3px solid var(--d-accent);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
  box-shadow: 0 0 20px var(--d-accent);
  z-index: 0;
}

.thumb-btn:hover {
  transform: translateY(-8px) scale(1.1);
  filter: brightness(1.1);
}

.thumb-btn:hover::before {
  opacity: 0.2;
}

.thumb-btn.is-active {
  transform: scale(1.15);
}

.thumb-btn.is-active::before {
  opacity: 0.3;
}

.thumb-btn.is-active::after {
  opacity: 1;
}

.thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  position: relative;
  z-index: 1;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 3px solid rgba(255, 255, 255, .9);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.thumb-btn:hover .thumb-img {
  border-color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.thumb-btn.is-active .thumb-img {
  border-color: var(--d-accent);
  box-shadow: 0 0 0 2px #fff, 0 8px 24px rgba(0, 0, 0, 0.6);
}

/* bottom band は上部で定義（dragon_band.png をメインカラーに馴染ませる） */

/* modal - Unified Modern Design */
body.modal-open {
  overflow: hidden;
}

.dragon-modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 20px !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.dragon-modal.is-open {
  display: flex;
  animation: modalFadeIn 0.3s ease forwards;
}

.dragon-modal.is-closing {
  display: flex;
  /* Ensure it stays visible during fade out */
  animation: modalFadeOut 0.3s ease forwards;
}

.dragon-modal.is-open .modal-dialog {
  animation: modalSlideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes modalFadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes modalSlideUp {
  0% {
    transform: translateY(30px) scale(0.95);
    opacity: 0;
  }

  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: transparent;
  pointer-events: none;
}

.modal-dialog {
  width: 100% !important;
  max-width: 1000px !important;
  height: 85vh !important;
  max-height: 900px !important;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px !important;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  background: #fff;
  color: #1a1a1a;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Header - Minimal & Clean */
.modal-head {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
}

.modal-head::after {
  display: none;
}

.modal-title {
  color: #1a1a1a;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.4;
  font-family: 'Soukou Mincho', serif;
}

.modal-close {
  background: #1a1a1a;
  color: #fff;
  border: none;
  box-shadow: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.2s ease;
  font-family: 'Harenosora', serif;
}

.modal-close:active {
  transform: scale(0.95);
  background: #333;
}

.modal-close:hover {
  background: #333;
  cursor: pointer;
}

/* Body - Scrollable Content */
.modal-body {
  flex: 1;
  padding: 0;
  background: #fff;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Portrait Image Section */
.modal-hero {
  display: block;
  margin: 0;
  padding: 0;
  background: linear-gradient(105deg, var(--d-main) 0%, var(--d-main) 55%, var(--d-sub, #f8f8f8) 55.1%, var(--d-sub, #f8f8f8) 100%);
  position: relative;
  overflow: hidden;
  border-bottom: 4px solid #b8860b;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  min-height: 48vh;
}

/* Traditional Chinese Window Pattern Overlay */
.modal-hero::before {
  content: '';
  position: absolute;
  inset: 10px;
  z-index: 0;
  min-height: 100%;
  border: 1px solid rgba(218, 165, 32, 0.3);
  background-image:
    linear-gradient(30deg, #b8860b 12%, transparent 12.5%, transparent 87%, #b8860b 87.5%, #b8860b),
    linear-gradient(150deg, #b8860b 12%, transparent 12.5%, transparent 87%, #b8860b 87.5%, #b8860b),
    linear-gradient(30deg, #b8860b 12%, transparent 12.5%, transparent 87%, #b8860b 87.5%, #b8860b),
    linear-gradient(150deg, #b8860b 12%, transparent 12.5%, transparent 87%, #b8860b 87.5%, #b8860b),
    linear-gradient(60deg, rgba(184, 134, 11, 0.1) 25%, transparent 25.5%, transparent 75%, rgba(184, 134, 11, 0.1) 75%, rgba(184, 134, 11, 0.1)),
    linear-gradient(60deg, rgba(184, 134, 11, 0.1) 25%, transparent 25.5%, transparent 75%, rgba(184, 134, 11, 0.1) 75%, rgba(184, 134, 11, 0.1));
  background-size: 40px 70px;
  background-position: 0 0, 0 0, 20px 35px, 20px 35px, 0 0, 20px 35px;
  opacity: 0.05;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(218, 165, 32, 0.2);
}

/* Scrolling Background Text */
.modal-hero-bg-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  z-index: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 10rem;
  font-weight: 900;
  color: rgba(0, 0, 0, 0.08);
  white-space: nowrap;
  line-height: 1;
  pointer-events: none;
  transform: rotate(-10deg) translateY(-20%);
  transform-origin: left center;
  animation: bgTextScroll 20s linear infinite;
  font-family: 'Oswald', 'Roboto Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

@keyframes bgTextScroll {
  0% {
    transform: rotate(-10deg) translateY(-20%) translateX(0);
  }

  100% {
    transform: rotate(-10deg) translateY(-20%) translateX(-50%);
  }
}

/* Decorative Gold Corners */
.modal-hero-frame {
  position: absolute;
  inset: 14px;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(to right, #b8860b 2px, transparent 2px) 0 0,
    linear-gradient(to bottom, #b8860b 2px, transparent 2px) 0 0,
    linear-gradient(to left, #b8860b 2px, transparent 2px) 100% 0,
    linear-gradient(to bottom, #b8860b 2px, transparent 2px) 100% 0,
    linear-gradient(to right, #b8860b 2px, transparent 2px) 0 100%,
    linear-gradient(to top, #b8860b 2px, transparent 2px) 0 100%,
    linear-gradient(to left, #b8860b 2px, transparent 2px) 100% 100%,
    linear-gradient(to top, #b8860b 2px, transparent 2px) 100% 100%;
  background-repeat: no-repeat;
  background-size: 24px 24px;
  opacity: 0.8;
}

/* Vertical Catchphrase (One Liner) */
.modal-hero-catch-vertical {
  position: absolute;
  top: 12%;
  left: 24px;
  z-index: 3;
  writing-mode: vertical-rl;
  font-family: "Shippori Mincho", "Yu Mincho", "YuMincho", serif;
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.6;
  letter-spacing: 0.15em;
  color: #fff;
  background: var(--d-main, #333);
  padding: 20px 10px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.is-animating .modal-hero-catch-vertical {
  opacity: 1;
  transform: translateY(0);
}

/* Decorative Dragon Cloud */
.modal-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255, 255, 255, 0.1) 0%, transparent 60%),
    linear-gradient(to top, rgba(0, 0, 0, 0.4) 0%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

.modal-hero img {
  width: 100%;
  height: auto;
  min-height: 48vh;
  max-height: 55vh;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: opacity 0.8s ease-out, transform 0.8s cubic-bezier(0.215, 0.61, 0.355, 1);
}

.modal-hero.is-animating img {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.modal-hero-text {
  position: absolute;
  bottom: 12px;
  right: 16px;
  z-index: 10;
  text-align: right;
  background: transparent;
  padding: 0;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  width: auto;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.modal-hero-jp {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  margin-bottom: 2px;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.6s ease-out 0.2s, transform 0.6s ease-out 0.2s;
}

.modal-hero.is-animating .modal-hero-jp {
  opacity: 1;
  transform: translateX(0);
}

.modal-hero-name {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  margin: 0;
  line-height: 0.95;
  position: relative;
  display: inline-block;
  opacity: 0;
  transform: translateX(15px);
  transition: opacity 0.6s ease-out 0.3s, transform 0.6s ease-out 0.3s;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
}

.modal-hero.is-animating .modal-hero-name {
  opacity: 1;
  transform: translateX(0);
}

.modal-hero-name::after {
  content: '';
  display: block;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, transparent 0%, #fff 100%);
  margin-top: 6px;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.6s cubic-bezier(0.215, 0.61, 0.355, 1) 0.5s;
  border-radius: 2px;
}

.modal-hero.is-animating .modal-hero-name::after {
  transform: scaleX(1);
}

.modal-hero-tag {
  font-size: 0.85rem;
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  opacity: 0;
  transform: translateX(10px);
  transition: opacity 0.6s ease-out 0.6s, transform 0.6s ease-out 0.6s;
}

.modal-hero.is-animating .modal-hero-tag {
  opacity: 1;
  transform: translateX(0);
}

/* ID Card - Hide (mobile style) */
.modal-id-card {
  display: none !important;
}

/* Catchphrase */
.modal-catch {
  margin: 0 20px 16px;
  padding: 16px 18px;
  border-radius: 8px;
  border: none;
  background: #f8f8f8;
  font-style: normal;
  color: #2d2d2d;
  box-shadow: none;
  line-height: 1.7;
  letter-spacing: 0.02em;
  font-weight: 500;
  font-size: 0.9rem;
  border-left: 3px solid var(--d-accent, #C41A30);
  font-family: 'Harenosora', serif;
}

.modal-catch::before {
  display: none;
}

/* Section Title */
.modal-section-title {
  color: #1a1a1a;
  border-left: none;
  padding: 0 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 24px 0 10px;
  text-shadow: none;
  opacity: 0.6;
  position: relative;
  font-family: 'Harenosora', serif;
}

.modal-section-title::before {
  display: none;
}

/* Key-Value Info */
.modal-kv {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  padding: 0 20px;
  margin-bottom: 20px;
}

.modal-kv .kv {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 0;
  padding: 14px 0;
  box-shadow: none;
  transition: none;
}

.modal-kv .kv:last-child {
  border-bottom: none;
}

.modal-kv .kv::before {
  display: none;
}

.modal-kv .label {
  color: rgba(0, 0, 0, 0.5);
  text-shadow: none;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
  display: block;
  text-transform: uppercase;
  font-family: 'Harenosora', serif;
}

.modal-kv .value {
  color: #1a1a1a;
  line-height: 1.6;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'Harenosora', serif;
}

/* List Items */
.modal-list {
  padding: 0 20px;
  margin-bottom: 20px;
  list-style: none;
}

.modal-list li {
  background: #f8f8f8;
  border: none;
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: none;
  transition: none;
}

.modal-list li::before {
  display: none;
}

.modal-list .item-name {
  color: var(--d-accent, #C41A30);
  text-shadow: none;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
  display: block;
  font-family: 'Harenosora', serif;
}

.modal-list .item-desc {
  color: #2d2d2d;
  font-size: 0.85rem;
  line-height: 1.7;
  font-weight: 500;
  display: block;
  font-family: 'Harenosora', serif;
}

/* Story/Setting Text */
.modal-story {
  background: #f8f8f8;
  border: none;
  border-radius: 8px;
  padding: 16px 18px;
  margin: 0 20px 20px;
  color: #2d2d2d;
  line-height: 1.8;
  letter-spacing: 0.01em;
  box-shadow: none;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Harenosora', serif;
}

.modal-story::before {
  display: none;
}

/* Footer Navigation */
.modal-footer {
  margin: 0;
  padding: 12px 16px;
  /* padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); */
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.04);
  z-index: 10;
  flex-shrink: 0;
}

.modal-footer::before {
  display: none;
}

.modal-navbtn {
  flex: 1;
  background: #1a1a1a;
  border: none;
  color: #fff;
  padding: 14px 18px;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Harenosora', serif;
}

.modal-navbtn:active {
  transform: scale(0.98);
}

.modal-navbtn:hover {
  background: #333;
}

.modal-navbtn[data-action="prev"]::before {
  content: "← ";
}

.modal-navbtn[data-action="next"]::after {
  content: " →";
}

/* --- Sparkle Animation --- */
.sparkle {
  position: absolute;
  background: white;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
  animation: sparkleFloat linear infinite;
}

@keyframes sparkleFloat {
  0% {
    transform: translateY(0) scale(0);
    opacity: 0;
  }

  50% {
    opacity: 0.8;
    transform: translateY(-20px) scale(1);
  }

  100% {
    transform: translateY(-50px) scale(0);
    opacity: 0;
  }
}


/* --- Panel One-Liner (Main Page) --- */
.panel-oneliner {
  font-family: 'Shippori Mincho', 'Yu Mincho', serif;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  line-height: 1.6;
  color: var(--panel-text);
  margin: 16px 0 24px;
  padding-left: 12px;
  border-left: 3px solid var(--d-accent);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  font-weight: 500;
  min-height: 2.5em;
  /* ensure space even if empty */
}

/* --- Modal New Structure Support --- */

/* Wrapper for sections */
.modal-section-wrapper {
  padding: 0 20px 40px;
}

/* Profile Grid (Basic Info) */
.modal-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

/* Reuse existing .modal-kv style logic but adapted for grid cells */
.modal-profile-item {
  background: var(--modal-item-bg, rgba(255, 255, 255, .4));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--d-accent);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: all 0.2s ease;
}

.item-image-color {
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.item-image-color::before {
  content: "";
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url('../img/dragons_bg.webp');
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.1;
  /* Increased for visibility on dark bg */
  z-index: -1;
  pointer-events: none;
  filter: grayscale(100%);
  mix-blend-mode: overlay;
}

.modal-profile-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.modal-profile-label {
  font-size: 0.7rem;
  color: var(--d-accent-contrast, var(--d-accent));
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
  opacity: 0.85;
  font-family: 'Harenosora', serif;
}

.modal-profile-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--modal-text);
  word-break: break-word;
  line-height: 1.4;
  font-family: 'Harenosora', serif;
}

/* Font Override - YDWaosagi */
.dragon-modal,
.dragon-modal .modal-title,
.dragon-modal .modal-hero-name,
.dragon-modal .modal-hero-jp,
.dragon-modal .modal-hero-tag,
.dragon-modal .modal-section-title,
.dragon-modal .modal-story,
.dragon-modal .modal-body-subtext,
.dragon-modal .modal-profile-label,
.dragon-modal .modal-profile-value,
.dragon-modal .modal-member-btn,
.dragon-modal .modal-close {
  font-family: 'YDWaosagi', sans-serif !important;
}

/* Modal Member Section */
.modal-member-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  padding-bottom: 10px;
}

.modal-member-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid transparent;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  background: transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.modal-member-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s;
  opacity: 0.8;
  transform: scale(1.25);
}

.modal-member-btn:hover,
.modal-member-btn.is-active {
  border-color: var(--d-accent);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2), 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 1;
}

.modal-member-btn:hover img,
.modal-member-btn.is-active img {
  opacity: 1;
}



@media (max-width: 980px) {
  .dragons-band {
    height: 92px;
  }

  /* スマホ/タブレットでも縦に伸びすぎない */
  .panel-inner {
    min-height: 300px;
    padding: 20px 18px 16px;
  }

  .dragons-info {
    width: 100%;
    padding-right: 0;
  }

  .dragon-name {
    font-size: 46px;
  }

  .dragons-portrait {
    position: absolute;
    right: -10px;
    bottom: -78px;
    width: 100%;
    height: 320px;
  }

  .icon-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }




}

@media (max-width: 768px) {
  .dragon-title {
    font-size: 30px;
  }

  .dragon-name {
    font-size: 42px;
  }

  .modal-dialog {
    width: 94vw;
    height: 88vh;
    border-width: 2px;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .modal-close {
    padding: 8px 14px;
    font-size: 0.9rem;
  }

  .modal-section-title {
    font-size: 1rem;
    margin: 22px 0 12px;
  }
}

@media (max-width: 520px) {
  .dragons-band {
    height: 80px;
  }

  .dragon-title {
    font-size: 26px;
  }

  .dragon-name {
    font-size: 36px;
  }

  .meta li {
    grid-template-columns: 8.5em 1fr;
  }

  .dragon-badge {
    width: 84px;
    height: 84px;
  }

  .modal-dialog {
    /* width/height defined in cast.css query or upper rules based on viewport */
    /* Removing forced 100vh overrides to respect the new 88vh rule in cast.css/dragons.css */
    width: 96vw !important;
    height: 88vh !important;
    border-radius: 10px !important;
  }

  .modal-head {
    padding: 14px 14px;
  }

  .modal-body {
    padding: 16px 14px 18px;
  }

  .modal-close {
    padding: 7px 12px;
  }
}

/* Fix for overlapping text on mobile */
@media (max-width: 768px) {
  .modal-hero-name {
    font-size: 2rem;
  }

  .modal-hero-text {
    bottom: 20px;
    right: 16px;
  }

  /* Ensure vertical text doesn't overlap */
  .modal-hero-catch-vertical {
    top: 10%;
    left: 16px;
    font-size: 1.1rem;
    padding: 16px 8px;
  }
}

@media (max-width: 480px) {
  .modal-hero-name {
    font-size: 1.75rem;
    /* Smaller for very small screens */
  }

  .modal-hero-jp {
    font-size: 0.85rem;
  }

  .modal-hero-catch-vertical {
    top: 8%;
    left: 12px;
    font-size: 1rem;
    padding: 12px 6px;
    letter-spacing: 0.1em;
  }
}