@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;700&display=swap');

:root {
  /* BlackGold theme — see brand-original-backup/game.css for original */
  --bg-card: rgba(28,24,16,.78);
  --bg-card-hover: rgba(40,32,20,.88);
  --border: rgba(212,175,55,.25);
  --text: #e8d394;
  --text-light: #a89368;
  --accent: #d4af37;
  --accent-light: #f3d27a;
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'Noto Sans TC', sans-serif;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    url('../images/brand/bg_logo.svg') no-repeat center center,
    url('../images/brand/bg_pre-pc.png') no-repeat top center,
    url('../images/brand/bg-pc.jpg') no-repeat top center;
  background-size: 400px, cover, cover;
}

/* Floating logo top-left, click to return home */
.game-home-link {
  position: fixed;
  top: 0.5rem;
  left: 0.8rem;
  z-index: 100;
  display: flex;
  align-items: center;
  background: rgba(20,18,12,.85);
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(212,175,55,.15);
  text-decoration: none;
  transition: background .15s;
}
.game-home-link:hover {
  background: rgba(20,18,12,.95);
}
.game-header-logo {
  height: 28px;
  width: auto;
  display: block;
}

.game-loading {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; font-size: 1.2rem; color: var(--text-light);
}

/* ===== Mode Selection ===== */
.mode-select-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 2rem; padding: 2rem;
}
.mode-logo { width: 300px; filter: drop-shadow(0 2px 8px rgba(0,0,0,.2)); }
.mode-title { color: var(--text); font-size: 1.1rem; font-weight: 500; margin: 0; }
.mode-buttons { display: flex; gap: 1.5rem; flex-wrap: wrap; justify-content: center; }
.mode-btn {
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  padding: 2rem 3rem; border-radius: 16px; border: 2px solid var(--border);
  background: var(--bg-card); cursor: pointer; transition: all .2s;
  min-width: 200px;
}
.mode-btn:hover { background: var(--bg-card-hover); transform: translateY(-4px); box-shadow: 0 8px 24px rgba(212,175,55,.15); border-color: var(--accent-light); }
.mode-icon { font-size: 2.5rem; }
.mode-label { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.mode-desc { font-size: .85rem; color: var(--text-light); }

/* ===== Lobby ===== */
.lobby-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 1.5rem; padding: 2rem;
}
.lobby-title { color: var(--text); font-size: 1.5rem; font-weight: 700; }
.lobby-actions { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.lobby-btn {
  padding: 1rem 2rem; border-radius: 12px; border: 2px solid var(--border);
  background: var(--bg-card); cursor: pointer; font-size: 1.1rem; color: var(--text);
  transition: all .2s;
}
.lobby-btn:hover { background: var(--accent); color: #fff; }
.lobby-input {
  padding: .8rem 1.2rem; border-radius: 8px; border: 2px solid var(--border);
  font-size: 1.5rem; text-align: center; letter-spacing: .3em; width: 160px;
  text-transform: uppercase; font-weight: 700; color: var(--text);
}
.lobby-input:focus { outline: none; border-color: var(--accent-light); }
.lobby-room-code {
  font-size: 3rem; font-weight: 900; letter-spacing: .4em; color: var(--accent);
  background: var(--bg-card); padding: 1rem 2rem; border-radius: 12px;
  border: 2px solid var(--border);
}
.lobby-status { color: var(--text-light); font-size: 1rem; }
.lobby-waiting { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

/* ===== Deck Select ===== */

.deck-select {
  max-width: 1100px; margin: 0 auto; padding: 1rem;
}
.deck-select-header {
  text-align: center; margin-bottom: 1rem;
}
.deck-header-top {
  display: flex; justify-content: center; align-items: center; gap: 1rem; margin-bottom: 0.5rem;
}
.deck-header-top h2 {
  font-size: 1.4rem; color: var(--accent);
}
.deck-back-btn { font-size: 0.8rem !important; }
.deck-clear-btn { font-size: 0.75rem !important; color: var(--text-light) !important; }
.deck-hint {
  font-size: 0.72rem; color: var(--text-light); margin-top: 0.3rem;
}
.remove-x {
  background: none; border: none; color: #d32f2f; cursor: pointer;
  font-size: 0.8rem; padding: 0 3px; margin-left: 4px; font-family: inherit;
}
.remove-x:hover { color: #f44336; }
.deck-status {
  display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap;
}
.deck-count {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 0.3rem 0.8rem; border-radius: 9999px; font-size: 0.8rem;
}
.deck-count.count-ok {
  background: rgba(74,175,80,.15); border-color: #4caf50; color: #2e7d32;
}

.deck-tabs {
  display: flex; justify-content: center; gap: 0.4rem; margin-bottom: 0.8rem;
}
.deck-tab {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 0.4rem 1.2rem; border-radius: 9999px; font-size: 0.85rem;
  cursor: pointer; font-family: inherit; color: var(--text-light);
  transition: all .15s;
}
.deck-tab:hover { border-color: var(--accent); }
.deck-tab.active {
  background: var(--accent); color: #0a0707; border-color: var(--accent);
}

.deck-filters {
  display: flex; gap: 0.6rem; align-items: center; margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.deck-search {
  flex: 1; min-width: 200px;
  background: rgba(20,18,12,.9); border: 1px solid var(--border);
  padding: 0.4rem 0.8rem; border-radius: 9999px;
  font-size: 0.85rem; font-family: inherit; color: var(--text);
}
.deck-search:focus { outline: none; border-color: var(--accent); }
.deck-color-filters { display: flex; gap: 3px; }
.color-filter {
  background: rgba(20,18,12,.8); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 9999px; font-size: 0.75rem;
  cursor: pointer; font-family: inherit;
  color: var(--text-light);
  transition: all .15s;
}
.color-filter:hover { border-color: var(--accent); color: var(--text); }
.color-filter.active { background: var(--accent); color: #0a0707; border-color: var(--accent); }

.deck-main-area {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 0.8rem;
  align-items: start;
}
.deck-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
  max-height: 55vh; overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

/* Recommended decks panel */
.deck-recommended {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 0.8rem;
  max-height: 55vh; overflow-y: auto;
}
.deck-recommended h4 {
  font-size: 0.85rem; color: var(--accent); margin-bottom: 0.6rem;
  border-bottom: 1px solid var(--border); padding-bottom: 0.3rem;
}
.recommended-deck-item {
  background: rgba(20,18,12,.6);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem;
  margin-bottom: 0.5rem;
}
.rec-deck-name {
  font-weight: 700; font-size: 0.78rem; margin-bottom: 0.2rem;
  color: var(--text);
}
.rec-deck-desc {
  font-size: 0.65rem; color: var(--text-light); margin-bottom: 0.4rem;
}
.rec-deck-btn {
  width: 100%; padding: 0.3rem; font-size: 0.72rem;
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  cursor: pointer; font-family: inherit;
}
.rec-deck-btn:hover { background: var(--accent-light); }

/* DeckLog code import (above recommended decks list) */
.dl-code-import {
  background: rgba(20,18,12,.6);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  margin-bottom: 0.7rem;
}
.dl-code-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}
.dl-code-input:focus {
  border-color: var(--accent);
}
.dl-code-btn {
  width: 100%;
  padding: 0.35rem;
  font-size: 0.74rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}
.dl-code-btn:hover { background: var(--accent-light); }
.dl-code-btn:disabled { opacity: 0.5; cursor: wait; }
.dl-code-status {
  margin-top: 0.4rem;
  font-size: 0.7rem;
  line-height: 1.35;
  min-height: 0;
  word-break: break-word;
}
.dl-code-status.loading { color: var(--text-light); }
.dl-code-status.ok      { color: #2e8a50; font-weight: 600; }
.dl-code-status.warn    { color: #b87500; }
.dl-code-status.err     { color: #b44040; }
.dl-code-hint {
  margin: 0.4rem 0 0;
  font-size: 0.62rem;
  color: var(--text-light);
  line-height: 1.4;
}
.dl-code-hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: rgba(0,0,0,.06);
  padding: 0 4px;
  border-radius: 3px;
}
.rec-deck-h4 {
  margin-top: 0.8rem !important;
}

/* Support subtype filter */
.deck-support-filters {
  display: flex; gap: 3px; flex-wrap: wrap;
}
.support-filter {
  background: rgba(20,18,12,.8); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 9999px; font-size: 0.72rem;
  cursor: pointer; font-family: inherit;
  color: var(--text-light);
  transition: all .15s;
}
.support-filter:hover { border-color: var(--accent); color: var(--text); }
.support-filter.active {
  background: var(--accent); color: #0a0707; border-color: var(--accent);
}
.deck-card-item {
  position: relative; cursor: pointer; border-radius: var(--radius);
  overflow: hidden; border: 2px solid transparent;
  transition: border-color .15s, transform .15s;
  background: #fff;
}
.deck-card-item:hover { border-color: var(--accent-light); transform: translateY(-2px); }
.deck-card-item.deck-card-selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(212,175,55,.3); }
.deck-card-item img { width: 100%; display: block; }
.deck-card-info {
  padding: 0.3rem 0.4rem; font-size: 0.7rem;
}
.deck-card-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-card-meta { color: var(--text-light); font-size: 0.65rem; }
.deck-card-count {
  position: absolute; top: 4px; right: 4px;
  background: var(--accent); color: #fff;
  padding: 1px 6px; border-radius: 9999px; font-size: 0.7rem; font-weight: 700;
}
.deck-card-maxed { opacity: 0.6; }
.deck-card-maxed .deck-card-count { background: #888; }
.deck-card-in-deck { cursor: pointer; }
.deck-card-in-deck:hover { border-color: #d32f2f; }
.count-over { background: rgba(211,47,47,.15) !important; border-color: #d32f2f !important; color: #d32f2f !important; }
.deck-valid-hint { display: block; font-size: 0.75rem; color: var(--text-light); margin-top: 0.4rem; }
.deck-bloom-filters { display: flex; gap: 3px; }
.bloom-filter {
  background: rgba(20,18,12,.8); border: 1px solid var(--border);
  padding: 2px 10px; border-radius: 9999px; font-size: 0.75rem;
  cursor: pointer; font-family: inherit;
  color: var(--text-light);
  transition: all .15s;
}
.bloom-filter:hover { border-color: var(--accent); color: var(--text); }
.bloom-filter.active { background: var(--accent); color: #0a0707; border-color: var(--accent); }
.deck-section-label {
  grid-column: 1 / -1; font-weight: 700; color: var(--accent);
  padding: 0.3rem 0; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.deck-empty-msg {
  grid-column: 1 / -1; text-align: center; padding: 2rem; color: var(--text-light);
}
.deck-confirm {
  text-align: center; margin-top: 1rem;
}

/* ===== Mulligan Screen ===== */

.mulligan-screen {
  max-width: 960px; margin: 0 auto; padding: 2rem 1rem; text-align: center;
}
.mulligan-screen h2 { color: var(--accent); margin-bottom: 0.5rem; }
.mulligan-info {
  display: flex; justify-content: center; gap: 1rem; margin-bottom: 0.8rem;
  font-size: 0.85rem; color: var(--text-light);
}
.mulligan-warning {
  color: #d32f2f; font-weight: 600; font-size: 0.9rem; margin: 0.5rem 0;
}
.mulligan-hand {
  display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap;
  margin: 1rem 0;
}
.mulligan-card {
  width: 120px; border-radius: var(--radius); overflow: hidden;
  border: 2px solid var(--border); background: #fff;
  transition: all .15s; cursor: default; position: relative;
}
.mulligan-card img { width: 100%; display: block; }
.mulligan-card-name {
  padding: 0.2rem 0.3rem; font-size: 0.7rem; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mulligan-card-meta {
  padding: 0 0.3rem 0.2rem; font-size: 0.6rem; color: var(--text-light);
}
.mulligan-debut { border-color: var(--accent); }
.mulligan-badge {
  position: absolute; top: 4px; left: 4px;
  background: var(--accent); color: #fff;
  padding: 1px 6px; border-radius: 9999px; font-size: 0.6rem; font-weight: 700;
}
.mulligan-selected-return {
  border-color: #d32f2f !important; opacity: 0.5;
  transform: translateY(8px);
}
.mulligan-selected-return::after {
  content: '放回'; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(211,47,47,.9); color: #fff;
  padding: 2px 10px; border-radius: 9999px; font-size: 0.75rem; font-weight: 700;
}
.mulligan-actions {
  margin-top: 1rem; display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.mulligan-btn { font-size: 1rem !important; padding: 0.6rem 2rem !important; }
.mulligan-select-hint {
  font-size: 0.85rem; color: var(--accent); font-weight: 600;
}

/* ===== Setup Screen ===== */

.setup-screen {
  max-width: 900px; margin: 0 auto; padding: 2rem 1rem; text-align: center;
}
.setup-screen h2 { color: var(--accent); margin-bottom: 0.5rem; }
.setup-screen p { color: var(--text-light); margin-bottom: 1.5rem; }
.setup-hand {
  display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap;
}
.setup-card {
  width: 140px; cursor: pointer; border-radius: var(--radius);
  overflow: hidden; border: 2px solid transparent; transition: all .15s;
  background: #fff;
}
.setup-card img { width: 100%; display: block; }
.setup-card-name { padding: 0.3rem; font-size: 0.75rem; font-weight: 700; }
.setup-card-meta { padding: 0 0.3rem 0.3rem; font-size: 0.65rem; color: var(--text-light); }
.setup-eligible { border-color: var(--accent-light); }
.setup-eligible:hover { transform: translateY(-4px); box-shadow: 0 4px 15px rgba(212,175,55,.25); }
.setup-ineligible { opacity: 0.4; cursor: not-allowed; }

/* ===== Turn Transition ===== */

.turn-transition {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(212,175,55,.6); backdrop-filter: blur(10px);
}
.transition-content {
  text-align: center; color: #fff;
}
.transition-content h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.transition-content p { margin-bottom: 1.5rem; opacity: 0.8; }
.transition-btn { font-size: 1.1rem; padding: 0.7rem 2.5rem; }

/* ===== Game Board ===== */

.game-container {
  display: grid;
  grid-template-columns: 1fr 210px;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  gap: 0;
  /* Session 2 fix: overflow VISIBLE so hand-card hover lift can escape
     upward into the battlefield area. Body still constrains via 100vh. */
  overflow: visible;
}
body { overflow: hidden; }  /* belt: still prevent page scroll on viewport */

/* ===== Top HUD ===== */
.top-hud {
  grid-column: 1 / -1; grid-row: 1;
  padding: 0.5rem 1rem;
  background: linear-gradient(180deg, rgba(20,18,12,.9) 0%, rgba(20,18,12,.75) 100%);
  border-bottom: 2px solid var(--border);
  box-shadow: 0 2px 12px rgba(212,175,55,.08);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.top-hud.hud-my-turn { border-bottom-color: #2e7d32; box-shadow: 0 2px 18px rgba(46,125,50,.25); }
.top-hud.hud-opp-turn { border-bottom-color: #b45050; box-shadow: 0 2px 18px rgba(180,80,80,.22); }

.phase-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  max-width: 1400px; margin: 0 auto;
}
.phase-bar-left { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.phase-bar-right { flex: 1; display: flex; justify-content: center; }

.turn-number {
  font-weight: 700; font-size: 0.75rem; color: var(--text-light);
  letter-spacing: 0.1em;
  padding: 4px 10px;
  background: rgba(212,175,55,.08);
  border-radius: 6px;
}
.player-badge {
  display: inline-flex; align-items: center; gap: 7px;
  color: #fff;
  padding: 6px 16px; border-radius: 9999px;
  font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.02em;
  margin-left: 0.6rem;
}
.badge-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #fff;
  animation: badge-pulse 1.4s ease-in-out infinite;
}
@keyframes badge-pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(20,18,12,.7); } 50% { opacity: .5; box-shadow: 0 0 0 5px rgba(255,255,255,0); } }
/* Theme-aligned: purple base + gold highlight for "my turn", muted purple for opponent */
.badge-my-turn {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  box-shadow: 0 2px 12px rgba(212,175,55,.35), 0 0 0 2px rgba(245,194,74,.55);
  animation: badge-my-glow 2.2s ease-in-out infinite;
}
@keyframes badge-my-glow {
  0%, 100% { box-shadow: 0 2px 12px rgba(212,175,55,.35), 0 0 0 2px rgba(245,194,74,.55); }
  50%      { box-shadow: 0 2px 18px rgba(212,175,55,.5), 0 0 0 3px rgba(255,215,120,.85); }
}
.badge-my-turn .badge-dot { background: #ffdf7a; box-shadow: 0 0 6px rgba(255,223,122,.9); }
.badge-opp-turn {
  background: linear-gradient(135deg, rgba(212,175,55,.55) 0%, rgba(168,147,104,.6) 100%);
  color: rgba(232,211,148,.92);
  box-shadow: 0 2px 6px rgba(212,175,55,.2);
}
.badge-opp-turn .badge-dot { background: rgba(20,18,12,.7); }

.phase-steps { display: flex; align-items: center; gap: 2px; flex-wrap: nowrap; }
.phase-step {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 9999px;
  font-size: 0.78rem;
  background: rgba(212,175,55,.06); color: var(--text-light);
  transition: all 0.2s;
}
.phase-label { font-weight: 500; }
.phase-step.phase-passed {
  background: rgba(212,175,55,.12); color: var(--text);
}
.phase-step.phase-active {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  color: #fff; font-weight: 700;
  box-shadow: 0 2px 8px rgba(212,175,55,.3);
  transform: scale(1.08);
}
.phase-sep { color: rgba(212,175,55,.25); font-weight: 300; font-size: 0.9rem; }

.game-over-bar { justify-content: center; padding: 0.5rem; }
.game-over-text { font-size: 1.6rem; font-weight: 700; color: var(--accent); }

.board {
  grid-column: 1; grid-row: 2;
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.player-field {
  flex: 1;
  min-height: 0;
  padding: 0.4rem 0.6rem;
  display: flex; align-items: center; justify-content: center;
}
.opponent-field {
  transform: rotate(180deg);
  transform-origin: center center;
}

/* Playsheet field — image as background, zones positioned absolutely */
.playsheet-field {
  position: relative;
  height: 100%;
  aspect-ratio: 2040 / 1044;
  max-width: 100%;
}
.playsheet-bg {
  width: 100%; height: 100%; display: block;
  border-radius: 8px;
  pointer-events: none;
  user-select: none;
}
/* Mirroring is handled by .opponent-field rotation above */

.zone-pos {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
}

/* Zone positions in % of playsheet image (2040x1044, clean version)
   Layout reference (numbered playsheet):
   ┌─────────────────────────────────────────────────────────────┐
   │[9]   [3]    [2]    [1]                       [7]            │
   │Cheer Collab Center Oshi                      HoloP          │
   │                                                  [5] Deck   │
   │             ─── ステージ ───                                │
   │[8]Life                                                       │
   │       [4 Backstage — wide rectangle]         [6] Archive    │
   └─────────────────────────────────────────────────────────────┘
*/

/* Exact positions measured from marked playsheet (red boxes) */

/* Life — top-left, horizontal card slot */
.zone-life          { top: 4.4%;  left: 2.8%;  width: 15.1%; height: 21.3%; }

/* Holo Power — top-right, horizontal card slot */
.zone-holo-power    { top: 4.5%;  left: 82.1%; width: 15.2%; height: 21.3%; }

/* Collab — vertical card */
.zone-collab        { top: 11.1%; left: 26.7%; width: 10.9%; height: 29.8%; }

/* Center — vertical card */
.zone-center        { top: 11.0%; left: 45.8%; width: 10.9%; height: 29.7%; }

/* Oshi — vertical card */
.zone-oshi-pos      { top: 11.1%; left: 65.7%; width: 10.9%; height: 29.6%; }

/* Deck — right side, below Holo Power, vertical face-down */
.zone-deck          { top: 31.6%; left: 86.4%; width: 10.9%; height: 29.7%; }

/* Cheer Deck — bottom-left, vertical face-down */
.zone-cheer-deck    { top: 65.4%; left: 2.8%;  width: 10.9%; height: 29.7%; }

/* Backstage — 3 slots from 39.3% to 76.6%, total width 37.3% */
.zone-backstage     { top: 65.2%; left: 39.3%; width: 37.3%; height: 29.7%; }

/* Archive — bottom-right, vertical */
.zone-archive       { top: 65.2%; left: 86.3%; width: 10.9%; height: 29.7%; }

/* ── Zone slot styles ── */
.zone-card-slot {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.zone-card-slot.empty-slot {
  border: 1px dashed rgba(212,175,55,.3);
  border-radius: 4px;
}
.zone-card-slot .card-with-attachments,
.zone-card-slot .game-card,
.zone-card-slot > .card-back {
  width: auto; height: 100%; max-width: 100%;
  border-radius: 3px;
}
.zone-card-slot .card-with-attachments .game-card { height: 100%; }
.zone-card-slot .card-img {
  height: 100%; width: auto;
}

.zone-pos .zone-label {
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  background: rgba(20,18,12,.85);
  padding: 0 5px;
  border-radius: 3px;
  white-space: nowrap;
  color: var(--text);
  pointer-events: none;
  z-index: 5;
}

.zone-count-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: var(--accent);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  z-index: 4;
}

/* Deck stack: face-down card with count */
.deck-stack {
  position: relative;
}
.deck-stack .card-back {
  height: 100%; width: auto;
  aspect-ratio: 5 / 7;
  box-shadow: -2px 2px 0 rgba(0,0,0,.15), -4px 4px 0 rgba(0,0,0,.1);
}

/* Horizontal stack (Life, Holo Power): horizontal cards stacked vertically with peek */
.horizontal-stack {
  position: relative;
  width: 100%; height: 100%;
}
.h-stack-card {
  position: absolute;
  width: 95%;
  height: auto;
  aspect-ratio: 7 / 5;
  border-radius: 3px;
  left: 50%;
  transform: translateX(-50%);
  /* Each card peeks below the previous one */
  top: calc(var(--idx) * 11%);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
  z-index: calc(10 - var(--idx));
  background-size: cover;
  background-position: center;
}

/* Backstage row: 3 equal vertical card slots */
.backstage-row {
  position: relative;
  width: 100%; height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6%;
  align-items: center;
  justify-items: center;
}
.backstage-row.empty-row {
  display: flex;
  align-items: center;
  justify-content: center;
}
.backstage-slot {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  min-width: 0; min-height: 0;
  /* overflow visible so attached cheer cards can extend beyond the slot */
}
.backstage-slot .card-with-attachments,
.backstage-slot .game-card {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 3px;
}
.backstage-slot .card-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
}

/* Oshi position card */
.oshi-pos-card {
  position: relative;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.oshi-pos-card img {
  max-width: 100%; max-height: 100%;
  border-radius: 4px;
  border: 2px solid rgba(255,215,0,.6);
}
.oshi-pos-card .oshi-sp-used {
  position: absolute;
  top: 2px; right: 2px;
  background: #f44336;
  color: #fff;
  font-size: 0.55rem;
  padding: 1px 5px;
  border-radius: 3px;
}
.oshi-empty {
  font-size: 0.7rem;
  color: var(--text-light);
  text-align: center;
}

.board-divider {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 0.15rem; background: rgba(212,175,55,.06);
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 0.7rem;
}
.vs-text { font-weight: 700; color: var(--accent); font-size: 0.9rem; }

/* Opponent hand count display */
.opp-hand-count {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-160%);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 20;
}
.opp-hand-label {
  font-size: 0.65rem;
  color: var(--text-light);
  font-weight: 600;
  white-space: nowrap;
}
.opp-hand-cards {
  display: flex;
  margin-left: 2px;
}
.opp-hand-back {
  width: 22px;
  height: 32px;
  background: linear-gradient(135deg, #d4af37 0%, #f3d27a 100%);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 2px;
  margin-left: calc(var(--i) * -12px);
  box-shadow: 1px 1px 3px rgba(0,0,0,.3);
  position: relative;
  z-index: calc(10 - var(--i));
}
.opp-hand-back::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 1px;
}

/* ===== Zones ===== */

.zone {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.zone-label {
  font-size: 0.6rem; color: var(--text-light); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.zone-count {
  font-size: 0.65rem; font-weight: 700; color: var(--accent);
}
.zone-empty-slot {
  width: 70px; height: 98px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; color: var(--text-light);
}
.zone-row .zone-cards-row {
  display: flex; gap: 4px; flex-wrap: wrap; justify-content: center;
}
.zone-more {
  display: flex; align-items: center; font-size: 0.7rem; color: var(--text-light);
}

/* ===== Cards ===== */

.game-card {
  position: relative; border-radius: 4px; overflow: hidden;
  border: 1px solid rgba(0,0,0,.1);
  transition: transform .15s, box-shadow .15s;
  cursor: default;
}
.card-field { width: 70px; }
.card-hand { width: 130px; }
.card-mini { width: 50px; }
.game-card img, .card-img { width: 100%; display: block; }
/* Card backs */
.card-back {
  width: 100%; aspect-ratio: 5/7;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
}
.card-back-main {
  background-image: url('../images/brand/card-back-main.jpg');
}
.card-back-cheer {
  background-image: url('../images/brand/card-back-cheer.jpg');
}
.card-back-holopower {
  background-image: url('../images/brand/card-back-holopower.jpg');
  aspect-ratio: 7/5; /* horizontal */
}
.card-back-life {
  background-image: url('../images/brand/card-back-life.jpg');
  aspect-ratio: 7/5; /* horizontal */
}
.card-rest { transform: rotate(90deg); margin: 10px 0; }
.card-selectable { cursor: pointer; }
.card-selectable:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(212,175,55,.3); }
.card-targetable { cursor: crosshair; }
.card-targetable::after {
  content: ''; position: absolute; inset: -2px;
  border: 2px solid #f44336; border-radius: 6px;
  animation: pulse-border 1s infinite;
}
.card-selected { box-shadow: 0 0 0 3px var(--accent) !important; }

.card-damage-badge {
  position: absolute; top: 2px; left: 2px;
  background: #f44336; color: #fff;
  padding: 0 4px; border-radius: 4px; font-size: 0.6rem; font-weight: 700;
}
/* Card wrapper — game-card sits on top, cheer cards behind */
.card-with-attachments {
  position: relative;
  display: inline-block;
}
.card-with-attachments > .game-card {
  position: relative;
  z-index: 5;
}

/* Attached cheer cards: hidden BEHIND the member card, peeking from RIGHT */
.card-cheer-badges {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.attached-cheer-card {
  position: absolute;
  left: calc((var(--idx) + 1) * 22%);
  top: calc(var(--idx) * 14%);
  width: 100%;
  height: 100%;
  border-radius: 3px;
  box-shadow: 1px 1px 4px rgba(0,0,0,.4);
  z-index: calc(1 + var(--idx));
  pointer-events: auto;
  object-fit: contain;
  cursor: pointer;
}
/* Attached support cards (tool/mascot): hidden BEHIND the member card on LEFT side */
.card-support-badges {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}
.attached-support-card {
  position: absolute;
  right: calc((var(--idx) + 1) * 22%);
  top: calc(var(--idx) * 14%);
  width: 100%;
  height: 100%;
  border-radius: 3px;
  box-shadow: -1px 1px 4px rgba(0,0,0,.4);
  z-index: calc(1 + var(--idx));
  pointer-events: auto;
  object-fit: contain;
  cursor: pointer;
}

.card-support-count {
  position: absolute; top: 2px; right: 2px;
  background: var(--accent); color: #fff;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.55rem; font-weight: 700;
}

@keyframes pulse-border {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Oshi Display ===== */

.oshi-display { display: flex; align-items: center; }
.oshi-card-mini { display: flex; align-items: center; gap: 0.4rem; }
.oshi-mini-img { width: 36px; height: auto; border-radius: 4px; border: 1px solid var(--border); }
.oshi-mini-name { font-size: 0.75rem; font-weight: 600; }
.oshi-sp-used { font-size: 0.6rem; color: #f44336; margin-left: 0.3rem; }

/* ===== Hand ===== */

.hand-area {
  grid-column: 1; grid-row: 3;
  padding: 0.3rem; background: rgba(20,18,12,.6);
  backdrop-filter: blur(4px); border-top: 1px solid var(--border);
  /* Session 2 fix: overflow VISIBLE so the hover-scaled card can extend
     up over the battlefield instead of being clipped at hand-area boundary.
     Horizontal overflow is rare (hand limit ~7), and the rendered cards
     squish gracefully via flex. */
  overflow: visible;
  min-height: 90px;
  position: relative;
  z-index: 5;  /* sit above board for hover-lift escape */
}
.hand-cards {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  align-items: flex-end;
}
.hand-card-wrap {
  flex-shrink: 0;
  transition: transform .15s;
  position: relative;  /* anchor for .drag-play-armed::after hint */
}
.hand-card-wrap .game-card,
.hand-card-wrap .card-with-attachments {
  width: 80px;
}
.hand-card-wrap .card-hand {
  width: 80px;
}
.hand-playable { cursor: pointer; cursor: grab; }
/* Session 2: outer wrapper hover lift removed — the inner
   .card-with-attachments hover does the heavier lift (translateY -90px
   scale 1.9). Keep wrapper as a click target only. */
.hand-card-wrap.dragging {
  opacity: 0.4;
  transform: scale(0.9);
}
.zone-pos.drop-hint {
  outline: 2px dashed rgba(255,215,0,0.5);
  outline-offset: 2px;
}
.zone-pos.drop-hover {
  outline: 3px solid rgba(255,215,0,0.9);
  outline-offset: 2px;
  background: rgba(255,215,0,0.1);
}
.game-card.drop-hover {
  outline: 3px solid #4fc3f7;
  outline-offset: 2px;
  border-radius: 6px;
}

/* Draw card animation: slide in from right (deck side) with fade */
.card-draw-animating {
  animation: card-draw-in 0.55s cubic-bezier(0.22, 0.68, 0.32, 1) both;
  transform-origin: right center;
}
@keyframes card-draw-in {
  0% {
    opacity: 0;
    transform: translateX(80vw) translateY(-30vh) rotate(-25deg) scale(0.6);
  }
  60% {
    opacity: 1;
    transform: translateX(0) translateY(-8px) rotate(2deg) scale(1.05);
  }
  100% {
    opacity: 1;
    transform: translateX(0) translateY(0) rotate(0deg) scale(1);
  }
}
/* Card placement animation: pop in when placed on stage */
.card-place-anim {
  animation: card-place 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes card-place {
  0%   { opacity: 0; transform: scale(0.3) translateY(40px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Bloom animation: glow + scale */
.card-bloom-anim {
  animation: card-bloom 0.5s ease-out both;
}
@keyframes card-bloom {
  0%   { filter: brightness(2) saturate(0.5); transform: scale(1.15); }
  100% { filter: brightness(1) saturate(1); transform: scale(1); }
}

.hand-empty {
  display: flex; align-items: center; color: var(--text-light); font-size: 0.85rem;
}

/* ===== Side Panels ===== */

.side-panels {
  grid-column: 2; grid-row: 2 / 4;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  background: rgba(20,18,12,.5);
  backdrop-filter: blur(4px);
  min-height: 0;
}

.action-panel-wrap {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.action-panel {
  padding: 0.6rem; display: flex; flex-direction: column; gap: 0.4rem;
}
.action-panel-center {
  justify-content: center;
}
.action-section-label {
  font-size: 0.75rem; font-weight: 700; color: var(--accent);
  padding: 0.2rem 0; text-transform: uppercase; letter-spacing: 0.03em;
}
.action-btn {
  background: rgba(20,18,12,.9); border: 1px solid var(--border);
  padding: 0.45rem 0.8rem; border-radius: 9999px; font-size: 0.78rem;
  cursor: pointer; font-family: inherit; color: var(--text);
  transition: all .15s; text-align: left;
}
.action-btn:hover:not(:disabled) { border-color: var(--accent); background: rgba(212,175,55,.06); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.action-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
  text-align: center; font-weight: 600;
}
.action-btn.action-primary:hover { background: var(--accent-light); }
.action-btn.action-art { border-left: 3px solid var(--accent-light); }
.action-btn.action-oshi { border-left: 3px solid #b8860b; }
.action-btn.action-sp { border-left: 3px solid #f44336; }
.action-btn.action-manual { font-size: 0.7rem; color: var(--text-light); }
.action-divider { border: none; border-top: 1px solid var(--border); margin: 0.3rem 0; }

/* Image-based primary button (continue / end phase) */
.action-btn-image {
  position: relative;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  transition: transform .12s, box-shadow .12s;
  box-shadow: 0 2px 6px rgba(212,175,55,.2);
}
.action-btn-image:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(212,175,55,.35);
}
.action-btn-image:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.action-btn-image img {
  width: 100%;
  height: auto;
  display: block;
}
.action-btn-image-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  text-shadow: 0 2px 4px rgba(0,0,0,.6), 0 0 8px rgba(0,0,0,.4);
  letter-spacing: 0.05em;
}
.action-hint {
  font-size: 0.78rem; color: var(--text-light); padding: 0.5rem;
  text-align: center; font-style: italic;
}

/* Floating log toggle button on the left edge, vertically centered */
.log-toggle-btn {
  position: fixed;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(20,18,12,.9);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 80;
  box-shadow: 0 2px 8px rgba(212,175,55,.2);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s;
}
.log-toggle-btn:hover {
  background: #fff;
  transform: translateY(-50%) scale(1.05);
}

/* Log popup panel sliding out from left button */
.log-popup {
  position: fixed;
  left: 56px;
  top: 50%;
  transform: translateY(-50%);
  width: 280px;
  max-height: 60vh;
  background: rgba(20,18,12,.97);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(212,175,55,.25);
  z-index: 80;
  padding: 0.6rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.log-popup[hidden] { display: none; }
.game-log { display: flex; flex-direction: column; height: 100%; max-height: 60vh; }
.log-title { font-size: 0.78rem; font-weight: 700; color: var(--accent); margin-bottom: 0.4rem; }
.log-entries { flex: 1; overflow-y: auto; font-size: 0.72rem; color: var(--text-light); }
.log-entry { padding: 2px 0; border-bottom: 1px solid rgba(0,0,0,.05); }

/* ===== Card Preview Popup ===== */

.card-preview-popup {
  /* z-index 150: above board (5) but below selection modals (200) so it
     never covers an active SEARCH_SELECT prompt. */
  position: fixed; top: 10px; left: 10px; z-index: 150;
  pointer-events: none;
}
.card-preview-popup[hidden] { display: none; }
.card-preview {
  display: flex; gap: 0.8rem; background: rgba(20,18,12,.95);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 0.8rem; box-shadow: 0 8px 30px rgba(212,175,55,.2);
  max-width: 500px;
}
.preview-img { width: 160px; border-radius: 4px; }
.preview-info { flex: 1; font-size: 0.75rem; }
.preview-name { font-size: 0.95rem; font-weight: 700; color: var(--accent); }
.preview-id { font-size: 0.7rem; color: var(--text-light); margin-bottom: 0.3rem; }
.preview-type { font-size: 0.75rem; margin-bottom: 0.3rem; }
.preview-stat { font-size: 0.72rem; color: var(--text-light); }
.preview-effect { margin-top: 0.4rem; padding-top: 0.3rem; border-top: 1px solid var(--border); }
.preview-effect-label { font-weight: 600; font-size: 0.72rem; }
.preview-effect-text { font-size: 0.68rem; color: var(--text-light); line-height: 1.5; margin-top: 2px; }

/* ===== Hints & Toasts ===== */

.action-hint-float {
  position: fixed; bottom: 140px; left: 50%;
  transform: translateX(-50%);
  background: var(--accent); color: #fff;
  padding: 0.5rem 1.2rem; border-radius: 9999px;
  font-size: 0.85rem; font-weight: 500; z-index: 150;
  box-shadow: 0 4px 15px rgba(212,175,55,.3);
  animation: hint-in .3s ease;
}
.game-error-toast {
  position: fixed; bottom: 140px; left: 50%;
  transform: translateX(-50%);
  background: #f44336; color: #fff;
  padding: 0.5rem 1.2rem; border-radius: 9999px;
  font-size: 0.85rem; z-index: 150;
  animation: hint-in .3s ease;
}
@keyframes hint-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Target select modal (bloom, arts target, etc.) */
.target-select-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(212,175,55,.4); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.target-select-modal {
  background: rgba(20,18,12,.97); border-radius: 12px;
  padding: 1.2rem; min-width: 280px; max-width: 400px;
  box-shadow: 0 8px 30px rgba(212,175,55,.25);
  text-align: center;
}
.target-select-title {
  font-size: 0.95rem; font-weight: 700; color: var(--accent);
  margin-bottom: 1rem;
}
.target-select-options {
  display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem;
}
.target-select-btn {
  background: rgba(20,18,12,.9); border: 1px solid var(--border);
  padding: 0.6rem 1rem; border-radius: 8px; font-size: 0.85rem;
  cursor: pointer; font-family: inherit; color: var(--text);
  transition: all .15s; text-align: left;
}
.target-select-btn:hover {
  border-color: var(--accent); background: rgba(212,175,55,.06);
}
.target-select-cancel {
  background: none; border: 1px solid var(--border);
  padding: 0.4rem 1.5rem; border-radius: 9999px; font-size: 0.78rem;
  cursor: pointer; font-family: inherit; color: var(--text-light);
}
.target-select-cancel:hover { border-color: var(--accent); }

/* Search select modal (deck search with card images) */
.search-select-modal {
  background: rgba(20,18,12,.97); border-radius: 12px;
  padding: 1.2rem; max-width: 600px; width: 95%; max-height: 80vh;
  box-shadow: 0 8px 30px rgba(212,175,55,.25);
  text-align: center; overflow-y: auto;
}
.search-select-title {
  font-size: 0.95rem; font-weight: 700; color: var(--accent);
  margin-bottom: 1rem;
}
.search-select-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.6rem; margin-bottom: 1rem;
}
.search-select-card {
  cursor: pointer; border: 2px solid var(--border);
  border-radius: 6px; overflow: hidden; background: #fff;
  transition: all .15s;
}
.search-select-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(212,175,55,.25);
}
.search-select-card img {
  width: 100%; display: block;
}
.search-select-name {
  padding: 0.2rem; font-size: 0.65rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Order-to-bottom UI */
.order-bottom-modal { max-width: 700px; }
.order-bottom-hint { color: rgba(232,211,148,.7); font-size: .85rem; margin-bottom: .5rem; }
.order-bottom-label { color: rgba(168,147,104,.6); font-size: .8rem; margin-top: .8rem; border-top: 1px solid rgba(255,255,255,.15); padding-top: .5rem; }
.order-bottom-list { display: flex; flex-direction: column; gap: 2px; margin: .3rem 0; }
.order-bottom-item { color: rgba(232,211,148,.8); font-size: .8rem; padding: 2px 8px; background: rgba(255,255,255,.08); border-radius: 4px; }
.order-bottom-undo { margin-top: .5rem; font-size: .8rem; }
.order-remaining { cursor: pointer; transition: transform .15s; }
.order-remaining:hover { transform: scale(1.08); outline: 2px solid #4fc3f7; border-radius: 6px; }

/* Removed 2026-04-29: .play-zone-overlay & friends.
 * Activity/item supports are now played by dragging the hand card upward
 * by ≥ 110 px. See `.drag-play-armed` rules at end of file. */

/* Cost icons on buttons */
.cost-icon-sm { width: 16px; height: 16px; vertical-align: middle; margin: 0 1px; }
.btn-cost { margin-left: 4px; }

/* Floating damage number */
.floating-damage {
  position: fixed;
  z-index: 300;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 48px;
  font-weight: 900;
  color: #ff1744;
  text-shadow: 0 0 8px rgba(255,23,68,.6), 2px 2px 0 #000, -1px -1px 0 #000;
  pointer-events: none;
  transform: translate(-50%, -50%);
  animation: float-damage 1.2s ease-out forwards;
}
@keyframes float-damage {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
  30%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -120%) scale(0.8); }
}

/* Opponent action toast */
.action-toast {
  position: fixed;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  background: rgba(212,175,55,.9);
  color: #fff;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 200;
  pointer-events: none;
  animation: toast-in-out 2.5s ease-out forwards;
  max-width: 80vw;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
@keyframes toast-in-out {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  10%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-5px); }
}

/* Knockdown flash */
.knockdown-flash {
  position: fixed; inset: 0; z-index: 280;
  background: rgba(255,23,68,.25);
  pointer-events: none;
  animation: ko-flash 0.6s ease-out forwards;
}
@keyframes ko-flash {
  0%   { opacity: 1; }
  30%  { opacity: 0.6; }
  100% { opacity: 0; }
}

/* Dice roll UI */
.dice-overlay {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(212,175,55,.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.dice-container {
  text-align: center;
}
.dice-face {
  font-size: 5rem;
  width: 120px; height: 120px;
  background: #fff;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 0.8rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.3);
  animation: dice-spin 0.6s ease-out;
  font-family: 'Noto Sans TC', sans-serif;
}
.dice-result-text {
  color: #fff; font-size: 1.1rem; font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,.5);
}
@keyframes dice-spin {
  0% { transform: rotate(0deg) scale(0.3); opacity: 0; }
  50% { transform: rotate(720deg) scale(1.2); opacity: 1; }
  100% { transform: rotate(1080deg) scale(1); opacity: 1; }
}


/* ===== Manual Adjust Modal ===== */
.manual-modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(212,175,55,.4); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.manual-modal {
  background: rgba(20,18,12,.97); border-radius: 12px;
  max-width: 700px; width: 95%; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 8px 40px rgba(212,175,55,.25);
}
.manual-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.8rem 1rem; border-bottom: 1px solid var(--border);
}
.manual-modal-header h3 { font-size: 1rem; color: var(--accent); }
.manual-close {
  background: none; border: none; font-size: 1.5rem;
  cursor: pointer; color: var(--text-light); line-height: 1;
}
.manual-modal-body { padding: 1rem; }
.manual-section { margin-bottom: 1rem; }
.manual-section h4 {
  font-size: 0.8rem; color: var(--accent); margin-bottom: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.manual-member-row {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem; border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 0.4rem; background: rgba(20,18,12,.5);
}
.manual-card-thumb { width: 40px; height: auto; border-radius: 3px; }
.manual-member-info { flex: 1; }
.manual-member-info strong { font-size: 0.8rem; display: block; }
.manual-member-info span { font-size: 0.65rem; color: var(--text-light); }
.manual-member-actions { display: flex; gap: 3px; flex-wrap: wrap; }
.manual-btn {
  background: rgba(20,18,12,.8); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 6px; font-size: 0.65rem;
  cursor: pointer; font-family: inherit; color: var(--text);
  transition: all .1s;
}
.manual-btn:hover { border-color: var(--accent); background: rgba(212,175,55,.06); }
.manual-btn-wide { width: 100%; text-align: center; padding: 6px; font-size: 0.75rem; }
.manual-other-actions { display: flex; flex-direction: column; gap: 4px; }

/* Effect prompt modal */
.effect-prompt-modal { max-width: 520px; }
.effect-prompt-card {
  display: flex; gap: 0.8rem; margin-bottom: 0.8rem;
}
.effect-prompt-img { width: 120px; border-radius: 4px; }
.effect-prompt-info { flex: 1; }
.effect-prompt-info strong { font-size: 0.9rem; display: block; margin-bottom: 0.3rem; }
.effect-prompt-text {
  font-size: 0.78rem; color: var(--text-light); line-height: 1.6;
  white-space: pre-wrap;
}
.effect-prompt-hint {
  font-size: 0.72rem; color: var(--text-light); font-style: italic;
  margin-bottom: 0.8rem;
}
.effect-dismiss-btn { width: 100%; }

/* ===== Responsive ===== */

@media (max-width: 768px) {
  .game-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
  }
  .side-panels {
    grid-column: 1; grid-row: 4;
    flex-direction: row; border-left: none; border-top: 1px solid var(--border);
    max-height: 200px;
  }
  .action-panel-wrap, .log-panel { flex: 1; }
  .card-hand { width: 90px; }
  .card-field { width: 55px; }
  .deck-card-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .deck-main-area { grid-template-columns: 1fr; }
  .deck-recommended { max-height: 200px; }
}

/* ═══════════════════════════════════════════════════════════
   Enhanced animations — inspired by hyperframes GSAP effects
   ═══════════════════════════════════════════════════════════ */

/* Flash-through-white transition (for bloom) — shader-style burst */
.card-bloom-anim {
  animation: card-bloom-flash 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-origin: center center;
}
@keyframes card-bloom-flash {
  0%   { filter: brightness(1) saturate(1); transform: scale(1); }
  20%  { filter: brightness(3) saturate(0) blur(1px); transform: scale(1.25) rotate(-2deg); }
  35%  { filter: brightness(2.5) saturate(0.3); transform: scale(1.18) rotate(1deg); box-shadow: 0 0 40px rgba(20,18,12,0.9), 0 0 80px rgba(255,215,0,0.6); }
  60%  { filter: brightness(1.3) saturate(1.2); transform: scale(1.08); box-shadow: 0 0 20px rgba(255,215,0,0.4); }
  100% { filter: brightness(1) saturate(1); transform: scale(1); box-shadow: none; }
}

/* Art attack — attacker lunges toward opponent then snaps back */
.card-art-attack {
  animation: art-lunge 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  z-index: 100;
}
@keyframes art-lunge {
  0%   { transform: translateY(0) scale(1); filter: brightness(1); }
  20%  { transform: translateY(-10px) scale(1.08); filter: brightness(1.3) saturate(1.4); }
  45%  { transform: translateY(-50px) scale(1.15) rotate(-3deg); filter: brightness(1.5) saturate(1.5); box-shadow: 0 10px 30px rgba(255,100,100,0.5); }
  70%  { transform: translateY(-30px) scale(1.05) rotate(1deg); filter: brightness(1.2); }
  100% { transform: translateY(0) scale(1) rotate(0); filter: brightness(1); }
}

/* Target recoil — hit impact shake */
.card-hit-shake {
  animation: hit-shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}
@keyframes hit-shake {
  0%, 100% { transform: translateX(0) rotate(0); filter: brightness(1); }
  10%      { transform: translateX(-8px) rotate(-2deg); filter: brightness(2) saturate(0); }
  20%      { transform: translateX(9px) rotate(3deg); filter: brightness(0.6) saturate(0) hue-rotate(-30deg); }
  35%      { transform: translateX(-12px) rotate(-4deg); filter: brightness(1.5) saturate(0.3); }
  50%      { transform: translateX(8px) rotate(2deg); filter: brightness(1); }
  65%      { transform: translateX(-4px) rotate(-1deg); }
  80%      { transform: translateX(2px) rotate(0.5deg); }
}

/* Card deal — 3D flip from deck position (initial hand draw) */
.card-deal-anim {
  animation: card-deal 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
  transform-style: preserve-3d;
  perspective: 800px;
}
@keyframes card-deal {
  0%   { opacity: 0; transform: translateX(40vw) translateY(-20vh) rotateY(180deg) scale(0.5); }
  50%  { opacity: 1; transform: translateX(10vw) translateY(-5vh) rotateY(90deg) scale(0.8); }
  80%  { opacity: 1; transform: translateX(0) translateY(-5px) rotateY(0) scale(1.05); }
  100% { opacity: 1; transform: translateX(0) translateY(0) rotateY(0) scale(1); }
}

/* Knockdown — card falls with rotation and fade */
.card-knockdown-anim {
  animation: card-knockdown 0.9s cubic-bezier(0.55, 0.085, 0.68, 0.53) both;
  transform-origin: bottom center;
}
@keyframes card-knockdown {
  0%   { opacity: 1; transform: translateY(0) rotate(0) scale(1); filter: brightness(1); }
  30%  { opacity: 1; transform: translateY(-10px) rotate(-5deg) scale(1.05); filter: brightness(1.8) saturate(0); }
  60%  { opacity: 0.7; transform: translateY(20px) rotate(20deg) scale(0.95); filter: brightness(0.5) blur(1px); }
  100% { opacity: 0; transform: translateY(80px) rotate(60deg) scale(0.7); filter: brightness(0.2) blur(3px); }
}

/* Particle burst for knockdown — radial glow rays */
.knockdown-flash {
  background: radial-gradient(circle at center,
    rgba(255,235,100,0.4) 0%,
    rgba(255,100,100,0.25) 40%,
    transparent 70%);
}

/* Placement settle — slight bounce after pop-in */
.card-place-anim {
  animation: card-place-settle 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes card-place-settle {
  0%   { opacity: 0; transform: scale(0.3) translateY(40px); filter: brightness(1.5); }
  60%  { opacity: 1; transform: scale(1.12) translateY(-6px); filter: brightness(1.2); }
  80%  { transform: scale(0.98) translateY(2px); filter: brightness(1.05); }
  100% { opacity: 1; transform: scale(1) translateY(0); filter: brightness(1); }
}

/* Oshi/SP skill activation — golden radial pulse */
.card-oshi-activate {
  animation: oshi-burst 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes oshi-burst {
  0%   { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.8), 0 0 0 0 rgba(255, 200, 100, 0.6); }
  40%  { box-shadow: 0 0 40px 20px rgba(255, 215, 0, 0.6), 0 0 60px 30px rgba(255, 200, 100, 0.3); filter: brightness(1.3); }
  100% { box-shadow: 0 0 60px 40px rgba(255, 215, 0, 0), 0 0 80px 60px rgba(255, 200, 100, 0); }
}

/* Collab move — slide from backstage to collab position */
.card-collab-move {
  animation: collab-slide 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes collab-slide {
  0%   { transform: translateX(30px) scale(0.9); filter: brightness(1.4); }
  60%  { transform: translateX(-5px) scale(1.08); filter: brightness(1.2); box-shadow: 0 0 20px rgba(100,180,255,0.5); }
  100% { transform: translateX(0) scale(1); filter: brightness(1); box-shadow: none; }
}

/* ===== Tutorial Mode ===== */

.mode-btn.mode-tutorial {
  border-color: #f5c24a;
  background: linear-gradient(180deg, #fffaec 0%, #fff5d8 100%);
}
.mode-btn.mode-tutorial:hover {
  border-color: #e0a83a;
  box-shadow: 0 8px 24px rgba(245, 194, 74, 0.4);
}

.tutorial-overlay { pointer-events: none; }
.tutorial-overlay > * { pointer-events: auto; }

.tutorial-prompt-panel {
  position: fixed; left: 20px; top: 50%; transform: translateY(-50%);
  max-width: 320px; width: calc(100% - 32px);
  background: linear-gradient(180deg, rgba(35, 30, 70, 0.96) 0%, rgba(55, 45, 95, 0.96) 100%);
  color: #fff;
  border-radius: 14px; box-shadow: 4px 0 28px rgba(0,0,0,.35);
  padding: 16px 20px; z-index: 9000;
  border: 2px solid rgba(245, 194, 74, 0.6);
  font-family: inherit;
}
.tutorial-prompt-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.tutorial-lesson-title { color: #f5c24a; font-weight: 700; }
.tutorial-progress { color: rgba(255,255,255,0.7); font-size: 0.8rem; }
.tutorial-prompt-text { font-size: 1rem; line-height: 1.55; margin-bottom: 10px; }
.tutorial-prompt-actions { display: flex; gap: 8px; justify-content: flex-end; }
.tutorial-btn {
  background: rgba(255,255,255,0.12); color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 6px 14px; border-radius: 8px; cursor: pointer;
  font-size: 0.85rem; transition: all 0.15s;
}
.tutorial-btn:hover { background: rgba(255,255,255,0.22); }
.tutorial-btn-primary {
  background: #f5c24a; color: #3a2d6b; border-color: #e0a83a; font-weight: 700;
}
.tutorial-btn-primary:hover { background: #e8b53a; }

.tutorial-prompt-panel.tutorial-shake {
  animation: tutorial-shake 0.4s;
  border-color: #ff6b6b;
}
@keyframes tutorial-shake {
  0%, 100% { transform: translateY(-50%); }
  20% { transform: translateY(-50%) translateX(-8px); }
  40% { transform: translateY(-50%) translateX(8px); }
  60% { transform: translateY(-50%) translateX(-5px); }
  80% { transform: translateY(-50%) translateX(5px); }
}

.tutorial-toast {
  position: fixed; top: 40px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: rgba(72, 196, 120, 0.95); color: #fff;
  padding: 10px 22px; border-radius: 999px;
  font-size: 0.95rem; font-weight: 600;
  box-shadow: 0 4px 18px rgba(72, 196, 120, 0.5);
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  z-index: 9500; pointer-events: none;
}
.tutorial-toast.tutorial-toast-show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* NOTE: do NOT set `position: relative` here — it would break zones that rely on
   `.zone-pos { position: absolute }` for their top/left %. Use only outline/shadow. */
.tutorial-highlight-pulse {
  animation: tutorial-pulse 1.2s ease-in-out infinite;
  outline: 3px solid rgba(245, 194, 74, 0.85);
  outline-offset: 2px;
  border-radius: 6px;
}
@keyframes tutorial-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 194, 74, 0.7), 0 0 0 0 rgba(245, 194, 74, 0); outline-color: rgba(245, 194, 74, 0.85); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 194, 74, 0.15), 0 0 18px 4px rgba(245, 194, 74, 0.5); outline-color: rgba(255, 220, 120, 1); }
}

.tutorial-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
}
.tutorial-modal {
  background: #fff; border-radius: 16px;
  padding: 28px 32px;
  max-width: 520px; width: calc(100% - 32px);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  text-align: center;
  border-top: 6px solid #f5c24a;
  animation: tutorial-modal-in 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes tutorial-modal-in {
  0% { opacity: 0; transform: scale(0.9) translateY(20px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
.tutorial-modal-title {
  font-size: 1.4rem; font-weight: 700; margin-bottom: 12px;
  color: var(--text, #333);
}
.tutorial-modal-body {
  color: var(--text-light, #666);
  line-height: 1.6; margin-bottom: 18px;
  font-size: 0.95rem;
}
.tutorial-modal-actions {
  display: flex; gap: 10px; justify-content: center;
}
.tutorial-modal-actions .tutorial-btn {
  background: #eee; color: #333; border-color: #ccc;
  padding: 10px 22px; font-size: 0.95rem;
}
.tutorial-modal-actions .tutorial-btn:hover { background: #e2e2e2; }
.tutorial-modal-actions .tutorial-btn-primary {
  background: #f5c24a; color: #3a2d6b; border-color: #e0a83a;
}
.tutorial-modal-actions .tutorial-btn-primary:hover { background: #e8b53a; }

.tutorial-modal-victory {
  border-top-color: #48c478;
}
.tutorial-modal-victory .tutorial-modal-title {
  color: #2a8a52;
}

/* ===== Tutorial lesson picker ===== */

.tutorial-picker-screen {
  min-height: 100vh;
  padding: 2rem 3rem;
  display: flex; flex-direction: column; gap: 1.5rem;
  max-width: 1100px; margin: 0 auto;
}
.tutorial-picker-header {
  position: relative;
  text-align: center;
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
}
.tutorial-picker-back {
  position: absolute; left: 0; top: 1.5rem;
  background: rgba(20,18,12,.75);
  border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 8px;
  cursor: pointer; font-family: inherit; color: var(--text);
  font-size: 0.85rem;
  transition: all 0.15s;
}
.tutorial-picker-back:hover { background: #fff; border-color: var(--accent-light); }
.tutorial-picker-title-main {
  color: var(--accent); font-size: 1.8rem; font-weight: 700;
  margin: 0 0 0.5rem;
}
.tutorial-picker-subtitle {
  color: var(--text-light); font-size: 0.9rem; margin: 0;
}
.tutorial-picker-sections {
  display: flex; flex-direction: column; gap: 1.8rem;
}
.tutorial-picker-section-label {
  font-size: 0.8rem; font-weight: 700; color: var(--accent);
  letter-spacing: 0.08em;
  padding: 0.3rem 0 0.6rem;
  text-transform: uppercase;
}
.tutorial-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 0.8rem;
}
.tutorial-picker-card {
  text-align: left;
  background: rgba(20,18,12,.85);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  color: var(--text);
  position: relative;
  overflow: hidden;
}
.tutorial-picker-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(245,194,74,0.08) 0%, transparent 50%);
  opacity: 0; transition: opacity 0.25s;
  pointer-events: none;
}
.tutorial-picker-card:hover {
  border-color: #f5c24a;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(212,175,55,0.15);
}
.tutorial-picker-card:hover::before { opacity: 1; }
.tutorial-picker-num {
  display: inline-block;
  font-size: 0.7rem; font-weight: 700; color: #b08810;
  background: rgba(245,194,74,0.15);
  padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}
.tutorial-picker-title {
  font-size: 1rem; font-weight: 700;
  color: var(--text);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}
.tutorial-picker-intro {
  font-size: 0.8rem; color: var(--text-light);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== UI Improvements: Active field glow, action button icons, HP bar ===== */

/* Active player field — subtle golden glow to indicate whose turn */
.player-field.field-active {
  position: relative;
  transition: all 0.3s ease;
}
.player-field.field-active::before {
  content: '';
  position: absolute; inset: 6px;
  border: 2px solid rgba(245, 194, 74, 0.55);
  border-radius: 10px;
  pointer-events: none;
  animation: field-glow 2s ease-in-out infinite;
  z-index: 1;
}
@keyframes field-glow {
  0%, 100% { box-shadow: 0 0 12px rgba(245, 194, 74, 0.2), inset 0 0 8px rgba(245, 194, 74, 0.1); border-color: rgba(245, 194, 74, 0.5); }
  50%      { box-shadow: 0 0 22px rgba(245, 194, 74, 0.45), inset 0 0 14px rgba(245, 194, 74, 0.15); border-color: rgba(255, 215, 120, 0.9); }
}
.player-field.field-idle {
  filter: brightness(0.92) saturate(0.88);
  transition: all 0.3s ease;
}

/* Action button icon + label layout */
.action-btn {
  display: flex; align-items: center; gap: 8px;
}
.action-btn .btn-icon {
  font-size: 1rem; flex-shrink: 0;
  width: 20px; text-align: center;
}
.action-btn .btn-label {
  flex: 1;
}
.action-btn .btn-badge {
  background: rgba(212,175,55,.15);
  padding: 1px 7px; border-radius: 9999px;
  font-size: 0.68rem; font-weight: 700; color: var(--accent);
  flex-shrink: 0;
}
.action-btn.action-oshi .btn-badge {
  background: rgba(184, 134, 11, 0.2); color: #b8860b;
}
.action-btn.action-sp .btn-badge {
  background: rgba(244, 67, 54, 0.15); color: #d32f2f;
}
.action-btn .btn-arrow {
  font-weight: 700; margin-left: 4px;
}
.action-btn.action-primary {
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(212,175,55,.25);
}
.action-btn.action-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(243,210,122,.35);
}

/* Art button — multi-row layout with damage + cost */
.action-btn.action-art {
  flex-direction: column; align-items: stretch;
  padding: 0.5rem 0.7rem;
  gap: 3px;
  text-align: left;
}
.action-btn.action-art .art-btn-row1 {
  display: flex; align-items: center; gap: 6px; width: 100%;
}
.action-btn.action-art .art-btn-pos {
  font-size: 0.6rem; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  background: var(--accent-light); color: #fff;
}
.action-btn.action-art .art-btn-name {
  flex: 1; font-weight: 600; font-size: 0.8rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.action-btn.action-art .art-btn-dmg {
  font-weight: 700; font-size: 0.9rem; color: #d32f2f;
  background: rgba(244, 67, 54, 0.1);
  padding: 1px 8px; border-radius: 4px;
}
.action-btn.action-art .art-btn-row2 {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.65rem; color: var(--text-light);
}
.action-btn.action-art .art-btn-cost { display: inline-flex; gap: 2px; }
.action-btn.action-art .art-btn-sp {
  background: rgba(184, 134, 11, 0.12); color: #8a6b0a;
  padding: 1px 5px; border-radius: 3px;
  display: inline-flex; align-items: center; gap: 2px;
}
.action-btn.action-art .art-btn-from {
  margin-left: auto;
  font-size: 0.62rem; opacity: 0.7;
}

/* HP bar on member cards */
.card-hp-bar {
  position: absolute;
  bottom: 3px; left: 3px; right: 3px;
  height: 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.3);
  z-index: 3;
}
.card-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #4caf50 0%, #8bc34a 100%);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1), background 0.3s;
  border-radius: 3px;
}
.card-hp-bar.hp-mid .card-hp-fill {
  background: linear-gradient(90deg, #ff9800 0%, #ffc107 100%);
}
.card-hp-bar.hp-low .card-hp-fill {
  background: linear-gradient(90deg, #d32f2f 0%, #f44336 100%);
  animation: hp-low-pulse 1s ease-in-out infinite;
}
@keyframes hp-low-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}
.card-hp-text {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  letter-spacing: 0.02em;
}


/* ============================================================ */
/* ===== Session 1 VFX polish (Shadowverse-inspired) ===== */
/* ============================================================ */

/*
 * Goal: bring the table-side feel closer to Shadowverse without changing
 * any DOM structure. All hooks are CSS classes / data-attributes added by
 * GameBoard / CardRenderer at render time.
 *
 * Conventions:
 *   .vfx-idle          — subtle breathing on stage members (auto-applied
 *                        to .zone-card-slot .game-card and .backstage-slot
 *                        .game-card via :not(.card-rest))
 *   .vfx-active        — golden pulse (member can attack / oshi can use)
 *   .vfx-just-placed   — short flash + scale when a card lands on stage
 *   .vfx-just-drew     — brief glow on hand cards drawn this draw step
 *   .vfx-effect-toast  — floating handler-result text (small, near origin)
 *   #vfx-attack-arrow  — single SVG element follows cursor when targeting
 */

/* Idle breathing: only stage members, not rested, not currently animating */
@keyframes vfx-breath {
  0%, 100% { transform: scale(1); filter: brightness(1); }
  50%      { transform: scale(1.012); filter: brightness(1.03); }
}
.zone-card-slot .game-card:not(.card-rest):not(.card-bloom-anim):not(.vfx-just-placed),
.backstage-slot .game-card:not(.card-rest):not(.card-bloom-anim):not(.vfx-just-placed) {
  animation: vfx-breath 4s ease-in-out infinite;
  transform-origin: center center;
}

/* Active golden pulse: cards that can act this turn (attack / collab / oshi) */
@keyframes vfx-active-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,200,80,0.6), 0 0 0 0 rgba(255,200,80,0.2); }
  50%      { box-shadow: 0 0 0 4px rgba(255,200,80,0.45), 0 0 14px 6px rgba(255,200,80,0.4); }
}
.game-card.vfx-active {
  animation: vfx-active-pulse 1.6s ease-in-out infinite, vfx-breath 4s ease-in-out infinite;
  border-color: rgba(255,200,80,0.7);
}

/* Just-placed: card drops in with brief scale + flash overlay */
@keyframes vfx-place-flash {
  0%   { transform: scale(0.7) translateY(-20px); opacity: 0; filter: brightness(2); }
  40%  { transform: scale(1.12) translateY(0);    opacity: 1; filter: brightness(1.5); }
  70%  { transform: scale(0.96);                  filter: brightness(1.1); }
  100% { transform: scale(1);                     filter: brightness(1); }
}
.game-card.vfx-just-placed {
  animation: vfx-place-flash 0.55s cubic-bezier(.34,1.56,.64,1) forwards;
}

/* Just-drew: hand card has a brief golden border-glow as it lands in hand */
@keyframes vfx-draw-glow {
  0%   { box-shadow: 0 0 0 0 rgba(255,210,90,0); }
  20%  { box-shadow: 0 0 0 3px rgba(255,210,90,0.7), 0 0 20px 8px rgba(255,210,90,0.5); }
  100% { box-shadow: 0 0 0 0 rgba(255,210,90,0); }
}
.game-card.vfx-just-drew {
  animation: vfx-draw-glow 0.9s ease-out forwards;
}

/* Hand-card hover lift: rises and scales aggressively; CSS :has() pushes neighbours aside.
   Session 2 fix: now that .hand-area + .game-container are overflow:visible,
   the lift can extend well above the hand-area into the battlefield, mirroring
   Shadowverse's "raise card to inspect" affordance. transform-origin is set
   to bottom so the card grows upward instead of upward-AND-outward. */
.hand-area .card-with-attachments,
.hand-area .game-card {
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1),
              box-shadow 0.22s,
              z-index 0s 0.22s;  /* z-index resets after lift ends */
  transform-origin: center bottom;
}
/* Hover-bounce fix:
   :hover detection on the OUTER .hand-card-wrap (which never transforms,
   so its hit-test box stays at the original card position), with the
   transform applied to the INNER .card-with-attachments. Previously the
   :hover was on the same element being lifted — when it flew up -90px,
   the cursor was no longer over its (now displaced) hit box, :hover
   dropped, the card fell back to the original position under the cursor,
   :hover re-fired, and the loop oscillated. Putting the hover trigger
   on the stationary wrapper keeps :hover stable while the visual lifts. */
.hand-card-wrap:hover > .card-with-attachments,
.hand-card-wrap:focus-within > .card-with-attachments {
  transform: translateY(-90px) scale(1.9);
  z-index: 999;
  transition: transform 0.22s cubic-bezier(.2,.8,.2,1),
              box-shadow 0.22s,
              z-index 0s;
  box-shadow: 0 18px 40px rgba(0,0,0,.45), 0 0 0 3px rgba(255,210,90,0.7);
}
/* Sibling slide: when one hand-card is hovered, neighbours move slightly aside.
   Uses :has() — supported in all modern browsers (Chrome 105+, Safari 15.4+).
   Anchored on the stationary .hand-card-wrap (not the lifted inner element). */
.hand-cards:has(.hand-card-wrap:hover) .hand-card-wrap {
  transition: transform 0.2s ease;
}
.hand-cards:has(.hand-card-wrap:hover) .hand-card-wrap:not(:hover) > .card-with-attachments {
  transform: scale(0.95);
}

/* Effect toast (handler-result tip) — small float text near origin */
@keyframes vfx-effect-toast-float {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.85); }
  15%  { opacity: 1; transform: translate(-50%, -8px) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -32px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -42px) scale(0.95); }
}
.vfx-effect-toast {
  position: fixed;
  z-index: 320;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(212,175,55,0.95) 0%, rgba(36,32,80,0.95) 100%);
  color: #fff;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.1) inset;
  white-space: nowrap;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translate(-50%, 0);
  animation: vfx-effect-toast-float 1.6s cubic-bezier(.2,.8,.4,1) forwards;
}
.vfx-effect-toast.tone-damage {
  background: linear-gradient(135deg, rgba(220,40,60,0.95) 0%, rgba(150,20,30,0.95) 100%);
}
.vfx-effect-toast.tone-heal {
  background: linear-gradient(135deg, rgba(60,200,140,0.95) 0%, rgba(20,140,90,0.95) 100%);
}
.vfx-effect-toast.tone-buff {
  background: linear-gradient(135deg, rgba(255,180,40,0.95) 0%, rgba(200,120,20,0.95) 100%);
}

/* Attack-target arrow (single shared SVG follows cursor when targeting) */
#vfx-attack-arrow {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 290;
  pointer-events: none;
  display: none;  /* JS toggles via .visible class */
}
#vfx-attack-arrow.visible { display: block; }
#vfx-attack-arrow .vfx-arrow-path {
  fill: none;
  stroke: url(#vfx-arrow-grad);
  stroke-width: 6;
  stroke-linecap: round;
  filter: drop-shadow(0 2px 6px rgba(255,80,40,0.6));
  animation: vfx-arrow-flow 0.6s linear infinite;
}
#vfx-attack-arrow .vfx-arrow-head {
  fill: #ff6b3a;
  filter: drop-shadow(0 2px 6px rgba(255,80,40,0.6));
}
@keyframes vfx-arrow-flow {
  0%   { stroke-dasharray: 0 14 8; stroke-dashoffset: 0; }
  100% { stroke-dasharray: 0 14 8; stroke-dashoffset: -22; }
}

/* Reduced motion: respect user preference */
@media (prefers-reduced-motion: reduce) {
  .game-card.vfx-active,
  .zone-card-slot .game-card,
  .backstage-slot .game-card {
    animation: none !important;
  }
  .vfx-effect-toast { animation-duration: 0.4s; }
}


/* Session 2: audio mute toggle (top-right floating button) */
.audio-mute-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 220;
  background: rgba(20,18,12,0.92);
  border: 1px solid var(--border, rgba(0,0,0,0.15));
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s, background 0.15s;
  user-select: none;
}
.audio-mute-btn:hover { transform: scale(1.08); background: #fff; }
.audio-mute-btn.muted { opacity: 0.55; }


/* ============================================================ */
/* ===== Drag-up support play (Session 2 hand-gesture) ===== */
/* ============================================================ */

/*
 * Activity/item support cards (支援・物品 / 支援・活動 / 支援・工作人員)
 * are played by dragging the hand card upward by ≥ 110 px. No special
 * play zone is shown — the gesture itself is the affordance. While
 * dragging:
 *   .dragging          — opacity 0.4 + slight scale (existing)
 *   .drag-play-armed   — added when cursor is past the threshold; pulses
 *                        a green border + scale to signal "release to play"
 */

@keyframes drag-play-armed-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(80,220,140,0.0),
                0 0 0 0 rgba(80,220,140,0.0);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(80,220,140,0.65),
                0 0 22px 8px rgba(80,220,140,0.55);
  }
}

.hand-card-wrap.drag-play-armed,
.hand-card-wrap.drag-play-armed .game-card,
.hand-card-wrap.drag-play-armed .card-with-attachments {
  animation: drag-play-armed-pulse 0.7s ease-in-out infinite;
  border-color: rgba(80,220,140,0.85) !important;
  filter: brightness(1.12) saturate(1.15);
}

/* Tiny "↑ 釋放使用" hint that floats above the dragged card while armed. */
.hand-card-wrap.drag-play-armed::after {
  content: '↑ 釋放使用';
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(40, 140, 80, 0.95);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  pointer-events: none;
  animation: drag-play-armed-pulse 0.7s ease-in-out infinite;
}
