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

:root {
  --gold: #ffd54f;
  --gold-deep: #f0a929;
  --ink: #10233c;
  --panel: rgba(8, 18, 34, 0.55);
  --line: rgba(255, 255, 255, 0.12);
  --glow-blue: #4da3ff;
  --card-radius: 6px;
  --shadow-card: 0 4px 10px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.4);
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background:
    radial-gradient(1200px 700px at 50% -10%, rgba(64, 130, 209, 0.35), transparent 60%),
    radial-gradient(900px 600px at 85% 110%, rgba(38, 166, 154, 0.18), transparent 60%),
    linear-gradient(160deg, #0a1f3d 0%, #10345c 50%, #081a33 100%);
  background-attachment: fixed;
  color: #fff;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

button {
  font-family: inherit;
}

body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none;
}

/* ---------- ホーム画面 ---------- */
#home-screen {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  padding: 56px 24px 48px;
  text-align: center;
  overflow: hidden;
}

/* 背景の装飾リング（ゆっくり漂うモンスターボール型の輪） */
.home-deco {
  position: fixed;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.06);
  pointer-events: none;
  z-index: 0;
}

.home-deco::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: calc(50% - 1px);
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
}

.deco-1 { width: 340px; height: 340px; top: -110px; left: -100px; animation: deco-float 14s ease-in-out infinite; }
.deco-2 { width: 220px; height: 220px; bottom: -60px; right: -50px; animation: deco-float 18s ease-in-out infinite reverse; }
.deco-3 { width: 120px; height: 120px; top: 40%; right: 6%; animation: deco-float 11s ease-in-out infinite; }

@keyframes deco-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-24px) rotate(10deg); }
}

.home-hero {
  position: relative;
  z-index: 1;
  margin-bottom: 30px;
}

.home-logo-ball {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #e3350d 0%, #e3350d 46%, #1b1b1b 46%, #1b1b1b 54%, #f5f5f5 54%, #dfe3e8 100%);
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), inset 0 -4px 10px rgba(0, 0, 0, 0.25);
  animation: ball-bounce 3.2s ease-in-out infinite;
}

.home-logo-ball::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  border: 5px solid #1b1b1b;
  box-shadow: 0 0 0 3px #fff inset;
}

@keyframes ball-bounce {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-8px) rotate(4deg); }
}

#home-screen h1 {
  font-size: 2.2rem;
  line-height: 1.35;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.6);
}

.title-grad {
  background: linear-gradient(92deg, #ffe082, #ffd54f 40%, #ffb300 70%, #ffe082);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

#home-screen .subtitle {
  color: #a5c9ec;
  margin-bottom: 4px;
}

.home-buttons {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  margin-bottom: 34px;
}

.big-btn {
  position: relative;
  width: 320px;
  padding: 17px;
  font-size: 1.12rem;
  font-weight: bold;
  letter-spacing: 0.05em;
  color: #fff;
  background: linear-gradient(160deg, #ef5350, #b71c1c);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  overflow: hidden;
}

.big-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -80%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: skewX(-20deg);
  transition: left 0.45s ease;
}

.big-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  filter: brightness(1.08);
}

.big-btn:hover:not(:disabled)::after {
  left: 130%;
}

.big-btn:nth-child(2) {
  background: linear-gradient(160deg, #42a5f5, #0d47a1);
}

#btn-goto-pvp {
  background: linear-gradient(160deg, #26a69a, #00695c);
}

.big-btn:disabled {
  background: #546e7a;
  opacity: 0.6;
  cursor: not-allowed;
}

.rules-box {
  position: relative;
  z-index: 1;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 26px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.rules-box h3 {
  margin-bottom: 10px;
  color: var(--gold);
  letter-spacing: 0.06em;
}

.rules-box li {
  margin: 6px 0 6px 20px;
  color: #d7e7f7;
  font-size: 0.92rem;
}

.credit {
  margin-top: 12px;
  font-size: 0.75rem;
  color: #90a4ae;
}

/* ---------- カード ---------- */
.cardface {
  width: 100px;
  aspect-ratio: 245 / 342;
  border-radius: var(--card-radius);
  overflow: hidden;
  background: #263238;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow-card);
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
}

/* Battle screen uses a denser card size everywhere so 1280x800 fits with no
   page scroll (see #battle-screen rules below for the exact overrides). */

.cardface img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cardface:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6);
  z-index: 6;
}

.cardface.fallback {
  border: 3px solid #9e9e9e;
  background: linear-gradient(170deg, #fefce8, #fde68a);
  color: #1c1917;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  text-align: center;
}

.fb-name {
  font-size: 0.62rem;
  font-weight: bold;
}

.fb-icon {
  font-size: 1.7rem;
}

.fb-hp {
  font-size: 0.62rem;
  font-weight: bold;
}

.cardface.large {
  width: 260px;
  cursor: default;
}

.cardface.large:hover {
  transform: none;
}

/* スリーブ（裏面）: sleeves.js のSVGをそのまま流し込む */
.cardback {
  width: 100px;
  aspect-ratio: 245 / 342;
  border-radius: var(--card-radius);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: var(--shadow-card);
  background: #0a1f42;
}

.cardback svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* 公式デッキシールド: assets/sleeves/ に切り出し済み（245x342）なので
   そのまま全面表示するだけでよい。 */
.cardback .official-img,
.sleeve-thumb .official-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 光沢（スリーブの質感） */
.cardback::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.13) 46%, transparent 58%);
  pointer-events: none;
}

/* ---------- カード拡大プレビュー ---------- */
#hover-preview {
  position: fixed;
  z-index: 320;
  width: 250px;
  pointer-events: none;
  animation: preview-in 0.14s ease-out;
  filter: drop-shadow(0 16px 30px rgba(0, 0, 0, 0.65));
}

#hover-preview .cardface.preview {
  width: 250px;
  cursor: default;
  border-radius: 12px;
}

#hover-preview .cardface.preview:hover {
  transform: none;
}

@keyframes preview-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- 場のポケモン ---------- */
.pkm {
  position: relative;
  width: 80px;
  cursor: pointer;
  flex-shrink: 0;
}

.pkm .pkm-face {
  width: 80px;
}

.pkm-overlays {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}

.dmg-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: radial-gradient(circle at 35% 30%, #ff6659, #c62828);
  color: #fff;
  font-weight: bold;
  font-size: 0.68rem;
  border-radius: 50%;
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.status-row {
  position: absolute;
  top: 36px;
  right: 2px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}

.status-badge {
  font-size: 0.58rem;
  color: #fff;
  font-weight: bold;
  border-radius: 6px;
  padding: 1px 5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.guard-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 1rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

.tool-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  background: #5c4326;
  color: #fff;
  font-size: 0.6rem;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  pointer-events: auto;
  z-index: 2;
}

.pkm-foot {
  margin-top: 3px;
}

.hp-bar {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 3px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.hp-fill {
  height: 100%;
  transition: width 0.3s;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.hp-num {
  font-size: 0.66rem;
  text-align: center;
  color: #e3f2fd;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.energy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  min-height: 16px;
  margin-top: 1px;
}

.energy-chip {
  font-size: 0.62rem;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

.energy-chip.dce {
  background: #9e9e9e;
  border-radius: 8px;
  width: auto;
  padding: 0 4px;
  font-weight: bold;
}

.pkm.selectable .pkm-face {
  outline: 4px solid var(--gold);
  animation: glow 0.9s infinite;
  box-shadow: 0 0 18px rgba(255, 213, 79, 0.65);
}

@keyframes glow {
  0%, 100% { outline-color: var(--gold); }
  50% { outline-color: #fff59d; }
}

.empty-slot {
  width: 80px;
  aspect-ratio: 245 / 342;
  border: 2px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--card-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.03);
  transition: border-color 0.15s, background 0.15s;
}

/* ---------- 対戦画面レイアウト（1280x800でスクロールなしに収める） ---------- */
#battle-screen {
  display: flex;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
}

#board {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px 8px;
  overflow: hidden;
  min-width: 0;
}

#side-panel {
  width: 220px;
  background: linear-gradient(180deg, rgba(4, 10, 20, 0.72), rgba(4, 10, 20, 0.55));
  border-left: 1px solid var(--line);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  backdrop-filter: blur(4px);
}

#side-panel h3 {
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--gold);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

#log {
  flex: 1;
  overflow-y: auto;
  font-size: 0.7rem;
  line-height: 1.35;
}

#log p {
  padding: 2px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #eceff1;
}

#log p:last-child {
  color: #fff;
  background: rgba(77, 163, 255, 0.12);
  border-radius: 4px;
}

/* 相手側／自分側のプレイマット */
.side-area {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 14px;
  padding: 4px 6px;
}

#cpu-area {
  background: linear-gradient(180deg, rgba(183, 28, 28, 0.14), rgba(183, 28, 28, 0.03) 80%);
  border: 1px solid rgba(255, 138, 128, 0.12);
}

#player-area {
  background: linear-gradient(0deg, rgba(21, 101, 192, 0.16), rgba(21, 101, 192, 0.03) 80%);
  border: 1px solid rgba(144, 202, 249, 0.14);
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

/* ---------- 山札／サイド／トラッシュ（盤面配置） ---------- */
.zone-rack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  width: 58px;
}

.zone-rack-left {
  width: 76px;
}

/* ---------- サイド（2列×3段固定グリッド） ---------- */
.prize-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: pointer;
}

.prize-grid-cells {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}

.prize-cell {
  position: relative;
  width: 32px;
}

.prize-cell .cardback {
  width: 32px;
  border-radius: 3px;
}

.prize-card-empty {
  width: 32px;
  aspect-ratio: 245 / 342;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.15);
}

.prize-num {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--gold);
  font-size: 0.55rem;
  font-weight: bold;
  border-radius: 50%;
  width: 13px;
  height: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.prize-cell.taken .prize-num {
  color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.35);
}

.zone-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.zone-label {
  font-size: 0.58rem;
  color: #b0bec5;
  text-align: center;
  line-height: 1;
  letter-spacing: 0.05em;
}

.zone-visual {
  position: relative;
  width: 46px;
  transition: transform 0.15s;
}

/* 山札の「重なり」表現 */
.zone-deck .zone-visual::before,
.zone-deck .zone-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px;
  background: rgba(10, 25, 50, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  z-index: -1;
}

.zone-deck .zone-visual::before { transform: translate(2px, 2px); }
.zone-deck .zone-visual::after { transform: translate(4px, 4px); opacity: 0.6; }

.zone-visual .cardback,
.zone-visual .cardface {
  width: 46px;
  border-radius: 4px;
}

.zone-empty {
  width: 46px;
  aspect-ratio: 245 / 342;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.35);
  font-size: 0.7rem;
}

.zone-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: radial-gradient(circle at 35% 30%, #ff6659, #b71c1c);
  color: #fff;
  font-weight: bold;
  font-size: 0.62rem;
  border-radius: 50%;
  min-width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.zone-stack.clickable {
  cursor: pointer;
}

.zone-stack.clickable:hover .zone-visual {
  transform: translateY(-2px);
}

.deck-name {
  color: var(--gold);
  font-size: 0.68rem;
  width: 58px;
  text-align: center;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bench-row {
  display: flex;
  gap: 5px;
  justify-content: center;
  min-height: 108px;
  border-radius: 10px;
}

.active-row {
  display: flex;
  justify-content: center;
  min-height: 112px;
}

.active-row .pkm,
.active-row .pkm .pkm-face,
.active-row .empty-slot {
  width: 84px;
}

.active-row .pkm .pkm-face {
  box-shadow: 0 0 14px rgba(255, 213, 79, 0.25), var(--shadow-card);
}

/* ---------- センターバー ---------- */
#center-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 3px 12px;
  min-height: 30px;
  flex-wrap: wrap;
  flex-shrink: 0;
  position: relative;
}

#center-bar::before,
#center-bar::after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  border-radius: 1px;
}

#stadium-slot {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  overflow: hidden;
  cursor: default;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(255, 213, 79, 0.35);
}

#stadium-slot.empty {
  visibility: hidden;
}

#stadium-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: pointer;
}

#turn-indicator {
  font-weight: bold;
  font-size: 0.82rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  padding: 3px 14px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

#turn-indicator.my-turn {
  background: linear-gradient(160deg, #ffca28, #ff8f00);
  border-color: #ffe082;
  color: #1c1917;
  box-shadow: 0 0 14px rgba(255, 179, 0, 0.65);
  animation: my-turn-pulse 1.6s ease-in-out infinite;
}

@keyframes my-turn-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 179, 0, 0.45); }
  50% { box-shadow: 0 0 20px rgba(255, 179, 0, 0.85); }
}

#turn-flags {
  display: flex;
  gap: 6px;
}

.flag {
  font-size: 0.65rem;
  background: rgba(76, 175, 80, 0.85);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.flag.used {
  background: rgba(120, 120, 120, 0.55);
  border-color: transparent;
  text-decoration: line-through;
  opacity: 0.75;
}

#prompt-banner {
  background: linear-gradient(160deg, #42a5f5, #1565c0);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 4px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  animation: pulse 1.2s infinite;
  box-shadow: 0 0 12px rgba(66, 165, 245, 0.5);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

#cancel-selection {
  background: #6b7280;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}

/* ---------- 手札・操作 ---------- */
/* overflow は visible のまま：スクロールコンテナにするとホバーで持ち上げた
   カードが上端で切れてしまう。枚数が増えたときは renderHand() が --overlap
   を詰めて必ず幅内に収める。ホバーは控えめな持ち上げ（xross-stars 準拠）。 */
#player-hand {
  display: flex;
  align-items: flex-end;
  gap: 0;
  justify-content: center;
  padding: 16px 12px 4px;
  overflow: visible;
  min-height: 108px;
  flex-shrink: 0;
}

#player-hand .hand-card {
  width: 70px;
  margin-right: var(--overlap, -28px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  transition: transform 0.15s ease, box-shadow 0.15s;
  touch-action: none;
}

#player-hand .hand-card:hover {
  transform: translateY(-14px) scale(1.35);
  z-index: 30;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.6);
}

#player-hand .hand-card:last-child {
  margin-right: 0;
}

#player-hand .hand-card.dimmed {
  opacity: 0.5;
  pointer-events: none;
}

#player-hand .hand-card.dragging {
  opacity: 0.25;
  filter: grayscale(0.4);
}

/* ドロー演出中はカード本体を隠し、フライヤーが到着してから表示する
   （getBoundingClientRect で実際の着地位置を取るため先に配置だけしておく）*/
.hand-card.pending-draw,
.opp-hand-card.pending-draw {
  opacity: 0;
}

/* 引いたばかりのカードは少しのあいだ金色に光る */
#player-hand .hand-card.just-drawn {
  animation: just-drawn 2s ease-out;
}

@keyframes just-drawn {
  0% { box-shadow: 0 0 18px 5px rgba(255, 215, 94, 0.9); }
  70% { box-shadow: 0 0 12px 3px rgba(255, 215, 94, 0.5); }
  100% { box-shadow: var(--shadow-card); }
}

/* ---------- 相手の手札（裏向き＋枚数） ---------- */
#cpu-hand {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 52px;
  padding: 2px 0;
  flex-shrink: 0;
}

#cpu-hand .opp-hand-card {
  width: 34px;
  margin-right: -14px;
  border-radius: 3px;
  cursor: default;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

#cpu-hand .opp-hand-card:last-of-type {
  margin-right: 10px;
}

.opp-hand-count {
  font-size: 0.68rem;
  color: #ffcdd2;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 138, 128, 0.3);
  padding: 2px 10px;
  border-radius: 10px;
  white-space: nowrap;
}

/* ---------- ドロー演出（山札→手札のフライヤー） ---------- */
.draw-flyer {
  position: fixed;
  z-index: 350;
  pointer-events: none;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 24px 6px rgba(255, 215, 94, 0.55), 0 10px 30px rgba(0, 0, 0, 0.6);
}

.draw-flyer .cardface,
.draw-flyer .cardback {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  cursor: default;
}

.draw-flyer .cardface:hover {
  transform: none;
}

#player-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 2px 0 4px;
  flex-shrink: 0;
}

#concede {
  background: #455a64;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 6px 16px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

#concede:hover {
  background: #607d8b;
}

#end-turn {
  background: linear-gradient(160deg, #ef5350, #b71c1c);
  color: #fff;
  font-weight: bold;
  font-size: 0.88rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  padding: 6px 28px;
  cursor: pointer;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.12s, filter 0.12s;
}

#end-turn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

#end-turn:disabled {
  background: #6b7280;
  border-color: transparent;
  cursor: not-allowed;
  opacity: 0.55;
}

/* ---------- ドラッグ&ドロップ ---------- */
/* つかんだカード本体（カーソルに追従するゴースト） */
#drag-ghost {
  position: fixed;
  z-index: 400;
  pointer-events: none;
  transform: translate(-50%, -58%) rotate(5deg) scale(1.1);
  transition: transform 0.12s ease;
  filter: drop-shadow(0 20px 26px rgba(0, 0, 0, 0.6));
  animation: ghost-pickup 0.14s ease-out;
}

#drag-ghost.over-target {
  transform: translate(-50%, -58%) rotate(0deg) scale(1.16);
}

#drag-ghost .cardface {
  width: 100%;
  cursor: grabbing;
  border: 2px solid rgba(255, 255, 255, 0.5);
}

@keyframes ghost-pickup {
  from { transform: translate(-50%, -58%) rotate(0deg) scale(1); }
  to { transform: translate(-50%, -58%) rotate(5deg) scale(1.1); }
}

/* 受け入れ可能なドロップ先 */
.drop-target {
  outline: 3px dashed rgba(102, 187, 106, 0.85);
  outline-offset: 2px;
  border-radius: 8px;
  animation: drop-breathe 1.1s ease-in-out infinite;
}

@keyframes drop-breathe {
  0%, 100% { outline-color: rgba(102, 187, 106, 0.85); }
  50% { outline-color: rgba(165, 214, 167, 0.95); }
}

/* いまカーソルが乗っているドロップ先 */
.drop-hover {
  outline: 4px solid #ffd54f !important;
  outline-offset: 2px;
  border-radius: 8px;
  background: rgba(255, 213, 79, 0.12);
  animation: none;
}

#center-bar.drop-target,
#player-area.drop-target {
  outline: 3px dashed rgba(102, 187, 106, 0.85);
  border-radius: 8px;
}

/* ---------- トースト通知 ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translate(-50%, 20px);
  background: rgba(8, 18, 34, 0.92);
  border: 1px solid rgba(255, 213, 79, 0.6);
  color: #fff;
  font-weight: bold;
  font-size: 0.9rem;
  padding: 10px 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 500;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- モーダル ---------- */
#modal,
#info-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 18, 0.7);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#modal-content {
  background: linear-gradient(175deg, #fffdf2, #fdf6d8);
  color: #1c1917;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  padding: 20px 24px;
  max-width: 640px;
  width: 94%;
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65);
  animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#modal-title {
  margin-bottom: 10px;
  font-size: 1.05rem;
}

#modal-body {
  font-size: 0.88rem;
  margin-bottom: 12px;
}

#modal-body .note {
  color: #b91c1c;
  font-size: 0.8rem;
  margin: 4px 0;
}

/* 自分のカードの行動メニュー: カード画像を並べて即座に内容を確認できる */
.menu-card-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.menu-card-layout .cardface.menu-card {
  width: 168px;
  cursor: default;
  border-radius: 8px;
}

.menu-card-layout .cardface.menu-card:hover {
  transform: none;
}

.menu-card-note {
  flex: 1;
  min-width: 0;
}

#modal-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 46vh;
  overflow-y: auto;
  justify-content: center;
}

#modal-cards .cardface.choice,
#modal-cards .cardback.choice {
  width: 96px;
}

#modal-cards .selected {
  outline: 4px solid #f59e0b;
  border-radius: var(--card-radius);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.55);
}

#modal-cards .not-selectable {
  opacity: 0.35;
  filter: grayscale(0.8);
  cursor: default;
}

#modal-cards .not-selectable:hover {
  transform: none;
}

/* picked-cards tray inside the chooser modal: click a tray card to deselect */
#modal-picked {
  margin-bottom: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px dashed rgba(217, 119, 6, 0.6);
}

#modal-picked .picked-label {
  font-size: 0.78rem;
  font-weight: bold;
  color: #b45309;
  margin-bottom: 6px;
}

#modal-picked-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}

/* empty slot: the exact .cardface.choice box (same width + aspect-ratio),
   so picking a card never changes the tray height */
#modal-picked-cards .tray-placeholder {
  background: transparent;
  border: 2px dashed rgba(180, 83, 9, 0.5);
  box-sizing: border-box;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a8a29e;
  font-size: 0.72rem;
  cursor: default;
}

#modal-picked-cards .tray-placeholder:hover {
  transform: none;
  box-shadow: none;
}

#modal-picked-cards .cardface.choice {
  width: 72px;
  cursor: pointer;
}

#modal-picked-cards .tray-card:hover {
  outline: 3px solid #dc2626;
  border-radius: var(--card-radius);
  opacity: 0.85;
}

#modal-cards .deny-shake {
  animation: deny-shake 0.3s ease-in-out;
}

@keyframes deny-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* board-peek mode: the choice modal hides, this transparent overlay blocks
   board clicks, and any click brings the selection back */
#peek-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  cursor: pointer;
}

#peek-overlay #peek-return {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* all modals: buttons (決定／キャンセル／選択肢など) in a single centered
   row, wrapping only when they don't fit */
#modal-options {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.menu-btn {
  padding: 10px 14px;
  font-size: 0.92rem;
  font-weight: bold;
  border: 2px solid #f59e0b;
  background: #fef3c7;
  color: #1c1917;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  line-height: 1.4;
  transition: background 0.12s, transform 0.12s;
}

.menu-btn small {
  font-weight: normal;
  color: #57534e;
}

.menu-btn:hover:not(:disabled) {
  background: #fde68a;
  transform: translateX(2px);
}

.menu-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.menu-btn.cancel {
  border-color: #9ca3af;
  background: #e5e7eb;
  text-align: center;
}

/* 確認系（決定／閉じる／キャンセル）は中央寄せのコンパクト表示 */
.menu-btn.compact {
  align-self: center;
  width: auto;
  min-width: 180px;
  padding: 9px 30px;
  text-align: center;
}

#info-close {
  align-self: center;
  min-width: 180px;
  text-align: center;
}

/* カード情報モーダル */
#info-content {
  background: linear-gradient(175deg, #fffdf2, #fdf6d8);
  color: #1c1917;
  border-radius: 16px;
  padding: 20px;
  max-width: 640px;
  width: 94%;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  gap: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.65);
  animation: modal-in 0.16s ease-out;
}

#info-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#info-text {
  font-size: 0.86rem;
  flex: 1;
}

#info-text p {
  margin-bottom: 8px;
}

/* ---------- デッキ構築 ---------- */
#builder-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#builder-header {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  background: rgba(4, 10, 20, 0.6);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  backdrop-filter: blur(4px);
}

#builder-header button {
  padding: 7px 14px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: linear-gradient(160deg, #42a5f5, #1565c0);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: filter 0.12s, transform 0.12s;
}

#builder-header button:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

#builder-header #builder-back {
  background: #546e7a;
}

#builder-header #builder-delete {
  background: linear-gradient(160deg, #e53935, #8e0000);
}

#builder-name {
  padding: 7px 10px;
  border-radius: 8px;
  border: none;
  width: 220px;
  font-size: 0.9rem;
}

#builder-total {
  margin-left: auto;
  font-weight: bold;
  font-size: 1rem;
  padding: 4px 12px;
  border-radius: 10px;
}

#builder-total.ok {
  background: #2e7d32;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

#builder-total.ng {
  background: #c62828;
}

#builder-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#builder-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px;
  overflow: hidden;
}

#builder-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

#builder-filters select,
#builder-filters input {
  padding: 6px 10px;
  border-radius: 8px;
  border: none;
  font-size: 0.85rem;
}

#builder-pool {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-content: flex-start;
  padding: 4px;
}

.pool-cell {
  width: 110px;
  position: relative;
}

.pool-card {
  width: 110px;
}

.pool-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.pool-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  background: #eceff1;
  transition: background 0.12s, transform 0.12s;
}

.pool-btn:hover {
  background: var(--gold);
  transform: scale(1.12);
}

.pool-count {
  min-width: 22px;
  text-align: center;
  font-weight: bold;
  color: #90a4ae;
}

.pool-count.has {
  color: var(--gold);
  font-size: 1.05rem;
}

#builder-right {
  width: 280px;
  background: rgba(4, 10, 20, 0.55);
  border-left: 1px solid var(--line);
  padding: 12px;
  overflow-y: auto;
  flex-shrink: 0;
}

#builder-right h3 {
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

#builder-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#builder-deck h4 {
  flex-basis: 100%;
  margin: 10px 0 4px;
  color: #90caf9;
  font-size: 0.85rem;
}

/* デッキ内容もカード画像で表示（4a）。＋/－ はホバーで重ねて出す（4b）。 */
.deck-cell {
  width: 60px;
  position: relative;
}

.deck-card {
  width: 60px;
  cursor: pointer;
}

.deck-card-count {
  position: absolute;
  right: 2px;
  bottom: 2px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--gold);
  font-size: 0.62rem;
  font-weight: bold;
  padding: 1px 4px;
  border-radius: 6px;
  pointer-events: none;
}

.deck-card-controls {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: var(--card-radius);
  opacity: 0;
  transition: opacity 0.12s;
}

.deck-cell:hover .deck-card-controls {
  opacity: 1;
}

.deck-card-controls .pool-btn {
  width: 20px;
  height: 20px;
  font-size: 0.85rem;
}

.deck-card-controls .pool-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.deck-card-controls .pool-btn:disabled:hover {
  background: #eceff1;
  transform: none;
}

#builder-errors {
  margin-top: 12px;
  list-style: none;
}

#builder-errors li {
  color: #ef9a9a;
  font-size: 0.8rem;
  margin: 4px 0;
}

/* ---------- スリーブ選択 ---------- */
.sleeve-title {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.sleeve-note {
  font-size: 0.72rem;
  color: #90a4ae;
  margin-bottom: 10px;
}

.sleeve-group-label {
  font-size: 0.74rem;
  font-weight: bold;
  color: #90caf9;
  margin: 10px 0 6px;
  letter-spacing: 0.04em;
}

.sleeve-grid {
  display: grid;
  /* minmax(0, 1fr) ではなく単純な 1fr だと、各セルの内容（画像の実サイズ等）に
     引っ張られてトラック幅が列ごとにバラバラになり、公式スリーブの表示サイズが
     大中小に見えてしまう＆グリッドが横にはみ出す原因になっていた。 */
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sleeve-choice {
  min-width: 0;
}

/* 公式デッキシールドは数が多いので専用のスクロール枠＋検索欄に隔離する */
.sleeve-search {
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.sleeve-scroll {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.sleeve-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 10px;
  border: 2px solid transparent;
  transition: border-color 0.12s, background 0.12s, transform 0.12s;
}

.sleeve-choice:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.sleeve-choice.selected {
  border-color: var(--gold);
  background: rgba(255, 213, 79, 0.12);
  box-shadow: 0 0 10px rgba(255, 213, 79, 0.35);
}

.sleeve-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 245 / 342;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.sleeve-thumb svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sleeve-name {
  font-size: 0.64rem;
  color: #cfd8dc;
  text-align: center;
  line-height: 1.2;
}

.sleeve-choice.selected .sleeve-name {
  color: var(--gold);
  font-weight: bold;
}

#builder-filter-impl-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: #eceff1;
  cursor: pointer;
  padding: 4px 8px;
}

#builder-filter-impl-label input {
  width: auto;
  padding: 0;
}

#builder-pool-count {
  margin-left: auto;
  font-size: 0.78rem;
  color: #90a4ae;
  align-self: center;
}

#builder-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 0 2px;
  flex-shrink: 0;
}

#builder-pager button {
  padding: 6px 14px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(160deg, #42a5f5, #1565c0);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

#builder-pager button:disabled {
  background: #455a64;
  opacity: 0.5;
  cursor: default;
}

#builder-page-info {
  font-size: 0.85rem;
  color: #cfd8dc;
  min-width: 90px;
  text-align: center;
}

.pool-unimpl-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  background: rgba(198, 40, 40, 0.85);
  color: #fff;
  font-size: 0.6rem;
  padding: 1px 5px;
  border-radius: 4px;
  pointer-events: none;
}

/* ---------- カードプレイ演出 ---------- */
#announce-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(15, 40, 80, 0.55), rgba(2, 8, 18, 0.75));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 200;
  cursor: pointer;
}

#announce-card {
  width: 190px;
  animation: announce-pop 0.9s ease-out;
  position: relative;
}

#announce-card .cardface {
  width: 190px;
  cursor: default;
  border-radius: 10px;
  box-shadow: 0 0 40px rgba(255, 213, 79, 0.45), 0 20px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

/* きらめきスイープ */
#announce-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 48%, transparent 62%);
  background-size: 250% 100%;
  animation: announce-shine 0.9s ease-out 0.25s both;
  pointer-events: none;
}

@keyframes announce-shine {
  from { background-position: 130% 0; }
  to { background-position: -60% 0; }
}

#announce-text {
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 213, 79, 0.5);
  color: #fff59d;
  font-weight: bold;
  font-size: 1.05rem;
  padding: 8px 22px;
  border-radius: 12px;
  text-align: center;
  letter-spacing: 0.04em;
}

@keyframes announce-pop {
  0% { transform: scale(0.4) rotate(-6deg); opacity: 0; }
  60% { transform: scale(1.06) rotate(1deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ---------- コイントス演出 ---------- */
#coin-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(15, 40, 80, 0.55), rgba(2, 8, 18, 0.78));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
  cursor: pointer;
}

#coin-scene {
  perspective: 600px;
  width: 110px;
  height: 110px;
}

#coin-3d {
  position: relative;
  width: 110px;
  height: 110px;
  transform-style: preserve-3d;
  animation: coin-spin 0.9s ease-out forwards;
}

#coin-3d.tails {
  animation-name: coin-spin-tails;
}

.coin-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.95rem;
  color: #5d4037;
  background:
    radial-gradient(circle at 35% 30%, #fff9c4, #ffca28 60%, #f57f17);
  border: 5px solid #f9a825;
  backface-visibility: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), inset 0 -3px 8px rgba(0, 0, 0, 0.2);
}

.coin-face::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px dashed rgba(141, 110, 99, 0.5);
}

.coin-back {
  transform: rotateY(180deg);
  background: radial-gradient(circle at 35% 30%, #eceff1, #b0bec5 60%, #78909c);
  border-color: #90a4ae;
  color: #37474f;
}

@keyframes coin-spin {
  0% { transform: rotateY(0deg) translateY(0); }
  40% { transform: rotateY(900deg) translateY(-46px); }
  100% { transform: rotateY(1080deg) translateY(0); }
}

@keyframes coin-spin-tails {
  0% { transform: rotateY(0deg) translateY(0); }
  40% { transform: rotateY(900deg) translateY(-46px); }
  100% { transform: rotateY(1260deg) translateY(0); }
}

#coin-result {
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 213, 79, 0.5);
  color: #fff59d;
  font-weight: bold;
  font-size: 1.1rem;
  padding: 6px 20px;
  border-radius: 12px;
  min-height: 1.4em;
}

/* ---------- ダメージ演出 ---------- */
.pkm.shake {
  animation: pkm-shake 0.4s;
}

.pkm.shake .pkm-face::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 82, 82, 0.35);
  animation: hit-flash 0.4s ease-out forwards;
  pointer-events: none;
}

@keyframes hit-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes pkm-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(1.5deg); }
  60% { transform: translateX(-4px) rotate(-1deg); }
  80% { transform: translateX(3px); }
}

.dmg-popup {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  color: #ff5252;
  font-weight: bold;
  font-size: 1.15rem;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 2px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: dmg-popup-rise 0.8s ease-out forwards;
  z-index: 20;
}

@keyframes dmg-popup-rise {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  20% { opacity: 1; transform: translate(-50%, -6px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -32px) scale(1); }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 980px) {
  #battle-screen {
    flex-direction: column;
    height: auto;
  }

  #side-panel {
    width: 100%;
    height: 150px;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .pkm,
  .pkm .pkm-face,
  .empty-slot {
    width: 82px;
  }

  .active-row .pkm,
  .active-row .pkm .pkm-face,
  .active-row .empty-slot {
    width: 92px;
  }

  #builder-main {
    flex-direction: column;
  }

  #builder-right {
    width: 100%;
    max-height: 260px;
    border-left: none;
    border-top: 1px solid var(--line);
  }

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

  #hover-preview {
    display: none;
  }
}

/* Prize pick modal: fixed 2x3 grid (slots 1-6, taken slots stay empty).
   Always exactly 6 cells, so it never needs its own inner scrollbar — a
   smaller fixed card size than the generic chooser keeps the whole grid
   comfortably inside the modal (only #modal-content may ever scroll). */
#modal-cards.prize-grid-choice {
  display: grid;
  grid-template-columns: repeat(2, 78px);
  gap: 8px;
  justify-content: center;
  max-height: none;
  overflow: visible;
}

#modal-cards.prize-grid-choice .cardface.choice,
#modal-cards.prize-grid-choice .cardback.choice {
  width: 78px;
}

.prize-empty-cell {
  width: 78px;
  aspect-ratio: 245 / 342;
  border: 2px dashed rgba(0, 0, 0, 0.3);
  border-radius: var(--card-radius);
  position: relative;
  opacity: 0.45;
}

/* ---- auth box (home) ---- */
#auth-forms { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#auth-forms input { padding: 6px 10px; border-radius: 8px; border: 1px solid #ccc; }
#auth-logged-in { display: flex; gap: 12px; align-items: center; }
#auth-logged-in.hidden, #auth-forms.hidden { display: none; }
