/* Silent Canticle - 礼拝堂・カード・レトロ演出 */
/* フォントは同梱（外部リクエストなし）。ライセンスは assets/fonts/OFL.txt */
@font-face {
  font-family: 'DotGothic16';
  src: url('../assets/fonts/DotGothic16-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0c0a12;
  --panel: #16121f;
  --panel2: #1c1728;
  --line: #3a3150;
  --text: #cfc8dd;
  --text-dim: #857c9c;
  --accent: #6fd3ff;
  --gold: #e6c96b;
  --taint: 0;      /* 影汚染 0..1 蝋燭の明るさに反映 */
  --rikai: 0;      /* 理解 0..1 場の青光に反映 */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DotGothic16', 'MS Gothic', monospace, sans-serif;
  overflow: hidden;
}

#app { position: relative; width: 100%; height: 100vh; }

/* 走査線とビネット（PS1風） */
#app::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0,0,0,0.32) 100%);
  z-index: 90;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.hidden { display: none !important; }

/* ===== タイトル ===== */
#screen-title {
  /* 動画読み込み中のフォールバック（動画が来たら上に被さる） */
  background: url('../assets/title_bg.webp') center / cover no-repeat, #0c0a12;
}
/* タイトルのアニメーション背景と、その上の暗さ調整の帳 */
#title-bg-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none;
}
#title-bg-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 45% at 50% 30%, rgba(111,211,255,0.06), transparent 70%),
    linear-gradient(180deg, rgba(10,8,18,0.30) 0%, rgba(8,6,12,0.55) 70%, rgba(5,4,9,0.75) 100%);
}
.title-glow {
  position: absolute; top: 12%; left: 50%; transform: translateX(-50%);
  width: 340px; height: 340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(111,211,255,0.13), transparent 65%);
  animation: pulse 5s ease-in-out infinite;
}
/* タイトルの立ち絵: 右手側に佇み、出迎える。入堂（扉を開く）までは姿を見せない */
#title-seraphios {
  position: absolute; right: 5%; bottom: 0; z-index: 0;
  height: min(90vh, 920px); width: auto;
  filter: drop-shadow(0 0 26px rgba(111,211,255,0.22));
  pointer-events: none; user-select: none;
  opacity: 0;
}
#app.entered #title-seraphios {
  opacity: 1;
  animation: titlein 1.8s ease-out .25s backwards;
}
@keyframes titlein { from { opacity: 0; transform: translateY(22px); } }
/* 幅が足りない画面では文字と重なるため隠す */
@media (max-width: 980px) { #title-seraphios { display: none; } }
@keyframes pulse { 0%,100% { opacity: .6 } 50% { opacity: 1 } }
.title-emblem {
  width: 74px; height: 74px; z-index: 1; margin-bottom: 12px;
  filter: drop-shadow(0 0 14px rgba(111,211,255,0.4));
  animation: emblemglow 4s ease-in-out infinite;
}
@keyframes emblemglow { 0%,100% { opacity: .75 } 50% { opacity: 1 } }
.game-title {
  font-size: 84px; letter-spacing: 0.42em; text-indent: 0.42em; color: #e8e2f2;
  text-shadow: 0 0 28px rgba(111,211,255,0.5), 0 2px 0 #000;
  z-index: 1;
}
.game-title-en { margin-top: 10px; color: #8fb8dd; letter-spacing: 6px; font-size: 15px; z-index: 1; }
.game-subtitle { margin-top: 12px; color: var(--text-dim); letter-spacing: 4px; z-index: 1; }
.game-subtitle::before, .game-subtitle::after { content: ''; }
.title-buttons { display: flex; gap: 16px; margin-top: 44px; z-index: 1; }
.title-hint { position: absolute; bottom: 26px; color: #5d5474; font-size: 13px; letter-spacing: 2px; }
/* 左下隅の破壊的操作（忘却の儀の入口）: 赤系で危険を示す */
.btn-corner {
  position: absolute; left: 16px; bottom: 14px; z-index: 2;
  font-family: inherit; font-size: 11px; letter-spacing: 2px;
  color: #a96a6a; background: none; border: none; cursor: pointer; padding: 4px 6px;
}
.btn-corner:hover { color: #d89090; text-decoration: underline; }
.reset-body { line-height: 2; color: var(--text); }
.reset-body b { color: #d89090; }

.title-gold { margin-top: 20px; color: var(--gold); letter-spacing: 2px; font-size: 14px; z-index: 1;
  text-shadow: 0 0 10px rgba(230,201,107,0.35); }
.ending-collection { display: flex; gap: 12px; margin-top: 18px; z-index: 1; }

/* ===== 奉納所 ===== */
.kinjo-icon { width: 22px; height: 22px; vertical-align: -5px; filter: drop-shadow(0 0 6px rgba(230,201,107,0.4)); }
.shop-icon { width: 54px; height: 54px; border-radius: 5px; border: 1px solid var(--line); flex: none; }
#shop-gold { color: var(--gold); letter-spacing: 2px; margin: 6px 0 14px; text-align: center; }
.shop-row {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 14px; margin-bottom: 8px;
}
.shop-row.owned { opacity: 0.65; }
.shop-info { flex: 1; }
.shop-name { color: var(--gold); letter-spacing: 2px; margin-bottom: 3px; }
.shop-desc { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.shop-action { flex: none; min-width: 90px; text-align: center; color: var(--text-dim); font-size: 13px; }
.btn-buy { font-size: 13px; padding: 6px 12px; letter-spacing: 1px; }
.btn-buy:disabled { opacity: 0.4; cursor: default; }
.btn-buy:disabled:hover { border-color: var(--line); color: var(--text); box-shadow: none; }

/* エンディングの金条授与 */
#ending-gold { margin: 4px 0 16px; color: var(--gold); letter-spacing: 2px; font-size: 15px;
  text-shadow: 0 0 10px rgba(230,201,107,0.3); }
#ending-gold b { font-size: 18px; }
.ending-slot {
  width: 46px; height: 64px; border: 1px solid var(--line); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #4a4160; background: rgba(255,255,255,0.02);
}
.ending-slot.got { color: var(--gold); border-color: #6a5e37; box-shadow: 0 0 10px rgba(230,201,107,0.15); }
.ending-slot.got.slot-true { color: var(--accent); border-color: #3f7c8a; box-shadow: 0 0 12px rgba(111,211,255,0.3); }
/* 見たエンディングは押すと回想できる */
.ending-slot.got { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.ending-slot.got:hover { transform: translateY(-3px); box-shadow: 0 0 14px rgba(230,201,107,0.4); }
.ending-slot.got.slot-true:hover { box-shadow: 0 0 16px rgba(111,211,255,0.5); }

/* ===== 入堂オーバーレイ ===== */
/* ブラウザは操作前の音声再生を拒むため、最初の一押しをここで受けてBGMを解禁する */
#entry-overlay {
  position: absolute; inset: 0; z-index: 89; /* 走査線(90)の下 = CRT質感の内側 */
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: rgba(6,5,10,0.68);
  cursor: pointer;
  transition: opacity .9s ease-out;
}
#entry-overlay .entry-text {
  font-size: 26px; letter-spacing: 10px; text-indent: 10px; color: #d8f0ff;
  text-shadow: 0 0 18px rgba(111,211,255,0.5);
  animation: pulse 3s ease-in-out infinite;
}
#entry-overlay .entry-hint { font-size: 12px; color: var(--text-dim); letter-spacing: 2px; }
#entry-overlay.leaving { opacity: 0; pointer-events: none; }

/* ===== ボタン ===== */
.btn {
  font-family: inherit; font-size: 16px; letter-spacing: 2px;
  color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 3px;
  padding: 10px 26px; cursor: pointer;
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: #fff; box-shadow: 0 0 10px rgba(111,211,255,0.25); }
.btn-main { border-color: #4a6a80; color: #d8f0ff; }
.btn-danger:hover { border-color: #c98a8a; box-shadow: 0 0 10px rgba(220,120,120,0.3); }
.btn-tiny { font-family: inherit; font-size: 11px; padding: 2px 8px; background: none;
  border: 1px solid var(--line); color: var(--text-dim); border-radius: 3px; cursor: pointer; }
.btn-tiny:hover { color: var(--text); }

/* ===== ゲーム画面 ===== */
#screen-game {
  justify-content: stretch; align-items: stretch;
  /* 動画読み込み中のフォールバック（動画が来たら上に被さる） */
  background: url('../assets/chapel_bg.webp') center / cover no-repeat, #0c0a12;
}
/* 礼拝堂のアニメーション背景と、その上の暗さ調整の帳 */
#bg-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none;
}
#bg-shade {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(10,8,16,0.30) 0%, rgba(9,7,13,0.45) 55%, rgba(6,5,10,0.60) 100%);
}
/* 背景画像の窓に重なる霊素光: 理解が深まるほど明るく差す */
#window-glow {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 480px; height: 48%;
  pointer-events: none;
  background: radial-gradient(ellipse 45% 55% at 50% 26%,
    rgba(130,190,255, calc(0.06 + var(--rikai) * 0.24)), transparent 70%);
  transition: opacity 1.2s;
}
/* 影汚染が進むほど礼拝堂の光が失われていく */
#taint-veil {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 25%, rgba(2,1,6,0.95) 100%);
  opacity: calc(var(--taint) * 0.75);
  transition: opacity 1.5s;
}

/* 盤面は固定サイズのキャンバス。JSが窓に合わせて丸ごと拡縮する（レターボックス方式）
   → どんな窓サイズでも折り返し・見切れ・スクロールが起きない */
#game-grid {
  display: grid; width: 1040px; height: 680px; flex: none;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas: 'opp' 'board' 'player';
  gap: 4px; padding: 8px; position: relative; z-index: 1;
  transform-origin: top center;
}
#screen-game { overflow: hidden; justify-content: flex-start; align-items: center; }

/* --- 上段: セラフィオス --- */
#opponent-area { grid-area: opp; display: flex; align-items: center; justify-content: flex-start; gap: 28px; }
#sp-wrap { display: flex; flex-direction: column; align-items: center; height: 100%; }
/* 立ち絵: 盤面キャンバスいっぱいの背後レイヤーに立たせ、場（半透明）越しに全身が見える */
#seraphios {
  position: absolute; top: 14px; bottom: 6px; left: 0; right: 0;
  width: 500px; margin: 0 auto; z-index: -1;
  transition: transform .6s;
}
/* 佇まい差分（base/glow/pray/wary/dark）を重ねて置き、opacityでクロスフェード。
   優先順位: pray > bright(glow) > wary > dark。
   cold（警戒4〜6）はbaseのままフィルタで冷やし、dim（汚染4〜6）はdarkを半透過で滲ませる */
#seraphios .sp-img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  opacity: 0;
  filter: drop-shadow(0 0 14px rgba(111,211,255,0.18));
  transition: opacity .6s, filter .6s, transform .5s;
  transform-origin: 50% 85%;
}
#seraphios .sp-base { opacity: 1; }
#seraphios.pray .sp-pray { opacity: 1; }
#seraphios.bright:not(.pray) .sp-glow { opacity: 1; }
#seraphios.wary:not(.pray):not(.bright) .sp-wary { opacity: 1; }
#seraphios.dark:not(.pray):not(.bright):not(.wary) .sp-dark { opacity: 1; }
#seraphios.dim:not(.pray):not(.bright):not(.wary):not(.dark) .sp-dark { opacity: 0.55; }
#seraphios.pray .sp-base,
#seraphios.bright:not(.pray) .sp-base,
#seraphios.wary:not(.pray):not(.bright) .sp-base,
#seraphios.dark:not(.pray):not(.bright):not(.wary) .sp-base { opacity: 0; }
/* 佇まいの色味（差分絵が主役なので、フィルタは補助に留める） */
#seraphios.bright img { filter: drop-shadow(0 0 22px rgba(111,211,255,0.55)); }
#seraphios.dim img    { filter: drop-shadow(0 0 8px rgba(111,211,255,0.08)) brightness(0.9); }
#seraphios.cold img   { filter: drop-shadow(0 0 10px rgba(140,160,200,0.25)) saturate(0.72) brightness(0.95); }
#seraphios.dark img   { filter: drop-shadow(0 0 10px rgba(60,40,90,0.45)); }
#seraphios.tilt img   { transform: rotate(-2.5deg); }
#seraphios.bell-ring img { animation: bellring .7s ease-in-out; }
/* 金の光輪（奉納所の誉れ）: 頭の後ろに淡い金の光を灯す */
#seraphios.gold-halo::before {
  content: ''; position: absolute; top: 1%; left: 50%; transform: translateX(-50%);
  width: 42%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(230,201,107,0.32), transparent 65%);
  pointer-events: none;
}
#seraphios.wary { transform: translateY(-8px) scale(0.97); }
@keyframes bellring { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-2px) } 50% { transform: translateX(2px) } 75% { transform: translateX(-1px) } }

#opp-info {
  display: flex; flex-direction: column; gap: 8px; width: 320px;
  /* 暗い背景から浮かせる下敷き */
  background: rgba(18,14,28,0.55); border-radius: 6px; padding: 8px 12px;
}
#opp-name { color: var(--text-dim); letter-spacing: 3px; font-size: 14px; }
.mini-backs { display: flex; gap: 4px; min-height: 34px; }
.mini-back {
  width: 24px; height: 34px; border-radius: 2px;
  background: url('../assets/card_back.webp') center / cover no-repeat, #17122a;
  border: 1px solid #3d3460;
  position: relative;
}
#hidden-slot .mini-back { width: 34px; height: 49px; }

/* --- 中段: 儀式盤 --- */
#board-area { grid-area: board; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
#status-bar {
  display: flex; gap: 18px; align-items: center;
  font-size: 14px; color: var(--text-dim); letter-spacing: 1px;
  /* 立ち絵の上に乗るため、読みやすさの下敷き */
  background: rgba(12,10,18,0.55); border-radius: 5px; padding: 4px 14px;
}
/* 画面右上の常設ボタン列（音・役表・きざし・メニュー）: 盤面の外、窓の隅に固定 */
#game-menu-bar {
  position: absolute; top: 14px; right: 16px; z-index: 50;
  display: flex; gap: 8px;
}
#game-menu-bar .btn-tiny {
  background: rgba(12,10,18,0.6); padding: 4px 10px; font-size: 12px;
}
/* タイトル画面右上の音声切り替え（対局中のボタン列と同じ見た目・同じ位置） */
#btn-mute-title {
  position: absolute; top: 14px; right: 16px; z-index: 5;
  background: rgba(12,10,18,0.6); padding: 4px 10px; font-size: 12px;
}
#setsu-label { color: var(--gold); letter-spacing: 3px; }
.score-chip b { color: var(--text); margin-left: 4px; font-size: 16px; }
#koi-label { color: #d89090; letter-spacing: 2px; }
#board-center { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: 100%; }
#field {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; align-content: center;
  height: 248px; padding: 12px 18px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 8px;
  background: rgba(255,255,255,0.02);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.5);
  /* 固定キャンバス内なので幅も固定（窓サイズの影響を受けない） */
  width: 640px;
  position: relative;
}
/* 空の儀式盤に浮かぶ環の紋（札の下にうっすら常在） */
#field::before {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 96px; height: 96px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(140,170,220,0.10);
  border-radius: 50%;
  box-shadow: 0 0 0 14px rgba(140,170,220,0.04), inset 0 0 0 26px rgba(140,170,220,0.03);
  pointer-events: none;
}
.stock-caption { font-size: 11px; color: var(--text-dim); letter-spacing: 2px; }
.stock-caption b { color: var(--text); }
#hidden-area, #draw-area { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#hidden-slot, #draw-slot { display: flex; gap: 5px; }
#draw-slot .mini-back { width: 34px; height: 49px; }
/* 山札の列は固定寸: めくり札(48×68)・残数の桁・山切れで中身が変わっても場が動かない */
#draw-area { width: 64px; flex: none; }
#draw-slot { height: 68px; align-items: center; }

/* --- 下段: プレイヤー --- */
/* 下段: 獲得札（左）・手札（中央・大きめ）・空き（右） */
#player-area {
  grid-area: player; display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end; gap: 18px;
  padding-bottom: 30px; /* 下に張り付きすぎないよう、場に寄せて持ち上げる */
}
/* 位置固定: 獲得札は左端、手札は中央の固定幅ボックス（枚数変動でUIが動かない） */
#player-caps-box {
  justify-self: start; width: 280px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 10px 12px;
  /* 暗い背景から浮かせる下敷き */
  background: rgba(18,14,28,0.55); border-radius: 6px;
}
#hand { display: flex; gap: 6px; justify-content: center; align-items: flex-end; padding-top: 10px; width: 464px; }
/* 手札は主役なので一回り大きく */
#hand .card { width: 88px; height: 126px; }
#hand .card .rank { font-size: 34px; }
#hand .card .symbol img.art { width: 60px; height: 60px; }
#hand .card .cname { font-size: 12px; }
/* 手札の扇: --rot/--arc は描画時に札ごとへ設定される */
#hand .card {
  transform: rotate(var(--rot, 0deg)) translateY(var(--arc, 0px));
  transform-origin: 50% 90%;
}
#hand .card.selectable:hover {
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--arc, 0px) - 9px));
}
#hand .card.selected {
  transform: rotate(var(--rot, 0deg)) translateY(calc(var(--arc, 0px) - 14px));
}
/* 配りのアニメーション */
.card.deal-in { animation: dealin .5s ease-out backwards; }
@keyframes dealin {
  from { transform: translateY(42px) rotate(0deg) scale(0.92); opacity: 0; }
}

/* 開式の一枚: 山札の上で表に返り、先手側の色に光る */
.card.opener-flip { animation: openerflip .6s ease-out; }
@keyframes openerflip {
  from { transform: rotateY(90deg) scale(0.9); opacity: 0.2; }
}
.card.opener-p { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(111,211,255,0.55); }
.card.opener-s { box-shadow: 0 0 0 2px #c9b6ef, 0 0 18px rgba(201,182,239,0.55); }

/* 先手があなたのとき: 手札がふっと応える */
#hand.first-flash .card { box-shadow: 0 0 14px rgba(111,211,255,0.4); }

/* 彼女の手番中: 淡く光をまとう */
#opponent-area.her-turn #seraphios { filter: drop-shadow(0 0 14px rgba(111,211,255,0.35)); }
.cap-caption { font-size: 11px; color: var(--text-dim); letter-spacing: 2px; }

/* --- カード --- */
.card {
  width: 74px; height: 106px; border-radius: 5px;
  background: #131020 center / cover no-repeat;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.55);
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 4px 6px; cursor: default; position: relative;
  transition: transform .15s, box-shadow .15s;
  user-select: none; flex: none;
}
.card.suit-hikari { background-image: url('../assets/card_frame_hikari.webp'); }
.card.suit-reiso  { background-image: url('../assets/card_frame_reiso.webp'); }
.card.suit-suzu   { background-image: url('../assets/card_frame_suzu.webp'); }
.card.suit-kage   { background-image: url('../assets/card_frame_kage.webp'); }
.card .symbol img.art { width: 50px; height: 50px; object-fit: cover; border-radius: 4px; }
.card .rank {
  font-size: 30px; color: var(--card-color); line-height: 1;
  text-shadow: 0 0 8px color-mix(in srgb, var(--card-color) 55%, transparent);
}
.card .symbol { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; }
.card .symbol svg { width: 32px; height: 32px; }
.card .cname { font-size: 11px; color: var(--text); letter-spacing: 1px; white-space: nowrap; }
.card.suit-kage .cname { color: #9a8cb8; }

.card.selectable { cursor: pointer; }
.card.selectable:hover { transform: translateY(-6px); box-shadow: 0 6px 14px rgba(0,0,0,.6), 0 0 10px var(--card-color); }
.card.selected { transform: translateY(-10px); box-shadow: 0 0 0 2px #fff, 0 0 16px var(--card-color); }
.card.match-target { cursor: pointer; box-shadow: 0 0 0 2px var(--accent), 0 0 14px rgba(111,211,255,.5); animation: targetpulse 1s ease-in-out infinite; }
@keyframes targetpulse { 0%,100% { box-shadow: 0 0 0 2px var(--accent), 0 0 8px rgba(111,211,255,.35) } 50% { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(111,211,255,.65) } }
.card.just-played { animation: cardin .35s ease-out; }
@keyframes cardin { from { transform: translateY(-16px); opacity: 0 } to { transform: none; opacity: 1 } }

/* 獲得の瞬間: 場の中央で光って浮き、獲得札置き場へ飛ぶ */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 85; }
.fx-card-wrap {
  position: fixed; border-radius: 5px;
  box-shadow: 0 0 0 3px #fff, 0 0 24px var(--card-color);
  animation: fxfloat .78s ease-out forwards;
}
@keyframes fxfloat {
  0% { transform: translateY(0) scale(0.9); opacity: 0.4; box-shadow: 0 0 0 0 #fff; }
  35% { transform: translateY(-12px) scale(1.06); opacity: 1; }
  100% { transform: translateY(-8px) scale(1); opacity: 1; }
}

/* 影札の獲得: 浮かばず沈み、赤い光が警告のように走る */
.fx-card-wrap.fx-kage {
  box-shadow: 0 0 0 3px rgba(205,55,65,0.9), 0 0 30px rgba(225,75,75,0.7);
  animation: fxsink .78s ease-out forwards, kageglow .9s ease-out;
}
@keyframes kageglow {
  0% { box-shadow: 0 0 0 0 rgba(205,55,65,0), 0 0 0 0 rgba(225,75,75,0); }
  40% { box-shadow: 0 0 0 5px rgba(230,65,75,1), 0 0 46px 10px rgba(235,90,90,0.9); }
  100% { box-shadow: 0 0 0 3px rgba(205,55,65,0.9), 0 0 30px rgba(225,75,75,0.7); }
}
@keyframes fxsink {
  0% { transform: translateY(0) scale(0.9); opacity: 0.4; }
  35% { transform: translateY(8px) scale(0.98); opacity: 1; }
  100% { transform: translateY(5px) scale(0.96); opacity: 1; }
}

/* 影に触れた瞬間の闇のパルス */
#dark-pulse {
  position: fixed; inset: 0; pointer-events: none; z-index: 84;
  background: radial-gradient(ellipse at 50% 45%, rgba(24,2,8,0) 35%, rgba(28,2,8,0.85) 100%);
  opacity: 0;
}
#dark-pulse.active { animation: darkpulse 1.2s ease-out; }
@keyframes darkpulse {
  0% { opacity: 0; }
  25% { opacity: 0.85; }
  60% { opacity: 0.5; }
  100% { opacity: 0; }
}


/* あなたが場に置いた札（供物の目印） */
.card.placed-p::before {
  content: '';
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 55%; height: 2px; border-radius: 1px;
  background: rgba(111,211,255,0.45);
}

/* 場と同じ数字を持つ手札の道しるべ */
.card.can-take::after {
  content: '';
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 7px var(--accent);
}

/* カード裏面（山札） */
.card.card-back { border-color: #3d3460; cursor: default; }
.card.card-back .back-inner {
  position: absolute; inset: 8px; border: 1px solid #4a3f75; border-radius: 3px;
  background:
    radial-gradient(circle at 50% 50%, rgba(111,211,255,0.12) 0 18%, transparent 20%),
    repeating-linear-gradient(45deg, transparent 0 6px, rgba(74,63,117,0.35) 6px 7px);
}

/* 彼女が見ている札（テル）: 微かな揺らめき（言語ヒント廃止に伴い少し強めに） */
.card.gazed { animation: gazeshimmer 2.6s ease-in-out infinite; }
@keyframes gazeshimmer {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 13px 2px rgba(201,182,239,0.48); }
}

/* 獲得札（小型表示・スート別グループ） */
.cap-area { display: flex; gap: 10px; flex-wrap: wrap; min-height: 40px; align-items: flex-end; justify-content: center; }
.cap-group { display: flex; }
.cap-mini {
  width: 26px; height: 38px; border-radius: 2px; flex: none;
  border: 1px solid var(--card-color); background: #241d33;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 10px; color: var(--card-color); margin-left: -8px;
}
.cap-mini:first-child { margin-left: 0; }
.cap-mini .m-rank { font-size: 11px; }

/* --- 役のきざしポップオーバー --- */
.side-box {
  background: rgba(22,18,31,0.92); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px; display: flex; flex-direction: column; min-height: 0;
}
#kizashi-panel {
  position: absolute; right: 16px; bottom: 24%;
  width: 250px; max-height: 42%; z-index: 60;
  box-shadow: 0 6px 30px rgba(0,0,0,0.6);
}
.side-title { font-size: 13px; color: var(--text-dim); letter-spacing: 2px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; }
#yaku-progress { font-size: 13px; overflow-y: auto; }
.yp-row { display: flex; justify-content: space-between; padding: 3px 2px; color: var(--text-dim); }
.yp-row.done { color: var(--gold); }
.yp-row.near { color: var(--text); }
.yp-row .yp-pts { font-size: 12px; }

/* ===== モーダル ===== */
.modal {
  position: absolute; inset: 0; z-index: 95;
  background: rgba(5,4,10,0.72);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 26px 34px; max-width: 440px; text-align: center;
  box-shadow: 0 0 50px rgba(0,0,0,0.8), 0 0 20px rgba(111,211,255,0.06);
  outline: 1px solid rgba(74,65,104,0.45); outline-offset: 5px;
}
.modal-wide { max-width: 560px; max-height: 86vh; overflow-y: auto; text-align: left; }
.modal-title { font-size: 20px; letter-spacing: 4px; color: #e8e2f2; margin-bottom: 14px; }
#koi-yaku-list { margin: 8px 0; }

/* 開式の一枚ダイアログ */
#opener-card-slot { display: flex; justify-content: center; margin: 6px 0 14px; }
#opener-first { font-size: 18px; letter-spacing: 4px; }
.opener-first-p { color: var(--accent); text-shadow: 0 0 12px rgba(111,211,255,0.45); }
.opener-first-s { color: #c9b6ef; text-shadow: 0 0 12px rgba(201,182,239,0.45); }

/* 役の表示（構成札つき） */
.yaku-row { margin-bottom: 10px; }
.yaku-row-label { color: var(--gold); letter-spacing: 2px; margin-bottom: 6px; }
.yaku-cards { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.card.card-s { width: 48px; height: 68px; padding: 3px 2px; border-radius: 4px; }
.card.card-s .rank { font-size: 17px; }
.card.card-s .symbol img.art { width: 24px; height: 24px; }
.card.card-s .cname { font-size: 8px; letter-spacing: 0; }
.rr-totals { margin-top: 10px; }
.modal-note b { color: var(--text); }
#yaku-banner { z-index: 97; }

/* 続唱カットイン: 薄赤の大文字が正面にフワッと浮かんで消える */
#zokusho-cutin {
  position: absolute; inset: 0; z-index: 88; /* 走査線(90)の下 */
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  pointer-events: none;
  background: radial-gradient(ellipse 55% 45% at 50% 50%, rgba(46,10,16,0.5), transparent 75%);
}
#zokusho-cutin .zk-text {
  font-size: 100px; letter-spacing: 36px; text-indent: 36px;
  color: #e8a8a8;
  text-shadow: 0 0 34px rgba(216,120,120,0.65), 0 3px 0 #000;
}
#zokusho-cutin .zk-sub { font-size: 14px; color: #c98a8a; letter-spacing: 3px; }
#zokusho-cutin.active { animation: zkfade 1.9s ease-in-out forwards; }
@keyframes zkfade { 0% { opacity: 0 } 20% { opacity: 1 } 70% { opacity: 1 } 100% { opacity: 0 } }
#zokusho-cutin.active .zk-text { animation: zksettle 1.9s ease-out; }
@keyframes zksettle { from { transform: scale(1.14); } 40% { transform: scale(1); } }
#koi-pts { font-size: 15px; color: var(--text); margin-bottom: 10px; }
.modal-buttons { display: flex; gap: 14px; justify-content: center; margin-top: 16px; }
.modal-note { font-size: 12px; color: var(--text-dim); margin-top: 14px; line-height: 1.7; }
#round-result-body { line-height: 1.9; color: var(--text); }
#round-result-body .rr-yaku { color: var(--gold); }
#round-result-body .rr-dim { color: var(--text-dim); font-size: 13px; }

.rules-body { font-size: 14px; line-height: 1.8; }
.rules-body p { margin-bottom: 10px; }
.rules-lead {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 10px 14px;
  background: rgba(111,211,255,0.05);
}
.rules-hint { color: var(--accent); }
/* 役表（実物カードの例つき） */
#rules-yaku-list { margin: 10px 0 14px; }
.ry-block { border: 1px solid var(--line); border-radius: 5px; padding: 9px 12px; margin-bottom: 8px; }
.ry-head { display: flex; align-items: center; gap: 10px; }
.ry-tag { font-size: 11px; color: var(--text-dim); border: 1px solid var(--line); border-radius: 3px; padding: 1px 6px; letter-spacing: 1px; }
.ry-name { color: var(--gold); letter-spacing: 2px; }
.ry-pts { color: var(--text-dim); font-size: 13px; margin-left: auto; }
.ry-cond { font-size: 12px; color: var(--text-dim); margin: 4px 0 7px; }
.ry-cards { justify-content: flex-start; }

/* エンディングの回想モーダル */
#modal-ending-view .modal-box { max-width: 560px; }
#ev-art {
  display: block; width: 100%; border-radius: 6px; margin: 4px 0 14px;
  border: 1px solid var(--line);
  outline: 1px solid rgba(74,65,104,0.45); outline-offset: 4px;
}
#ev-art[src=''] { display: none; }
#ev-body { white-space: pre-line; line-height: 2; font-size: 14px; color: var(--text); }

/* ===== エンディング ===== */
#screen-ending {
  background: radial-gradient(ellipse 60% 45% at 50% 35%, rgba(111,211,255,0.07), transparent 70%),
    linear-gradient(180deg, #0d0b16 0%, #070609 100%);
  padding: 40px;
}
#ending-title { font-size: 30px; letter-spacing: 4px; color: #e8e2f2; margin-bottom: 22px;
  text-shadow: 0 0 18px rgba(111,211,255,0.35); text-align: center; }
#screen-ending { overflow-y: auto; overflow-x: hidden; }
#ending-art {
  width: min(600px, 90vw); max-height: 38vh; object-fit: cover;
  border-radius: 6px; margin-bottom: 24px;
  border: 1px solid var(--line);
  outline: 1px solid rgba(74,65,104,0.45); outline-offset: 4px;
  box-shadow: 0 6px 50px rgba(0,0,0,0.75);
}
#ending-art[src=''] { display: none; }
#ending-body { max-width: 560px; line-height: 2.2; font-size: 16px; color: var(--text); white-space: pre-line; text-align: center; }
#ending-stats { display: flex; gap: 30px; margin: 34px 0 10px; }
.stat-col { text-align: center; }
.stat-name { font-size: 13px; color: var(--text-dim); letter-spacing: 2px; margin-bottom: 6px; }
.stat-bar { width: 110px; height: 8px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.stat-fill { height: 100%; transition: width 1.2s ease-out; }
.stat-rikai .stat-fill { background: #6fd3ff; }
.stat-keikai .stat-fill { background: #d8b46b; }
.stat-osen .stat-fill { background: #8d7bb0; }
.stat-val { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* 小さい画面向け（盤面はスケーリングで対応するため、タイトル文字のみ調整） */
@media (max-width: 900px) {
  .game-title { font-size: 52px; }
}
