/* ==========================================================
   さんむの生き物 — デザイントークン
   里山の緑 × 水辺のミント。レアリティは自然光の差し色で語る。
   ========================================================== */
:root {
  --bg: #eaf6df;
  --surface: #f7fff1;
  --surface-2: #e4f4d8;
  --line: rgba(68, 112, 72, 0.18);
  --text: #183423;
  --muted: #5d7a63;
  --brass: #9ed66b;
  --brass-bright: #4f8f34;

  --c-n: #86d7a7;
  --c-r: #5cc8b1;
  --c-sr: #8bd96f;
  --c-ssr: #f3d35b;

  --font-display: "Shippori Mincho B1", "Hiragino Mincho ProN", serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", sans-serif;

  --radius: 10px;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  background:
    radial-gradient(900px 520px at 75% -8%, rgba(149, 213, 117, 0.42) 0%, transparent 62%),
    radial-gradient(780px 480px at 8% 108%, rgba(109, 196, 161, 0.28) 0%, transparent 58%),
    linear-gradient(180deg, rgba(205, 238, 185, 0.74), transparent 390px),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
}

/* ---------- ヘッダー ---------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(16px, 4vw, 48px) 12px;
}

.site-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(20px, 3vw, 28px);
  letter-spacing: 0.14em;
  color: var(--brass-bright);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.wallet {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(247, 255, 241, 0.84);
  box-shadow: 0 10px 24px rgba(47, 94, 55, 0.08);
}

.wallet-label {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--brass);
}

.wallet-amount {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  min-width: 4ch;
  text-align: right;
}

/* ---------- タブ ---------- */
.tab-nav {
  display: flex;
  gap: 4px;
  padding: 0 clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
}

.tab-btn {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.12em;
  padding: 10px 18px;
  cursor: pointer;
  transition: color 0.2s;
}

.tab-btn:hover { color: var(--text); }

.tab-btn.is-active {
  color: var(--brass-bright);
  border-bottom-color: var(--brass);
}

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 48px) 80px;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.panel-head { margin-bottom: 24px; }

.panel-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.1em;
}

.panel-sub { margin: 0; color: var(--muted); font-size: 13px; }

.section-title {
  margin: 36px 0 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--brass-bright);
}

/* ---------- ボタン共通 ---------- */
.btn {
  appearance: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
}

.btn:hover:not(:disabled) { border-color: var(--brass); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn:focus-visible,
.tab-btn:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.btn-primary {
  color: #f7fff1;
  background: linear-gradient(180deg, #25613d, #153421);
  border-color: rgba(158, 214, 107, 0.48);
  text-shadow: 0 1px 1px rgba(0, 42, 18, 0.45);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #2d7048, #1a432a);
}

.btn-ghost { background: transparent; }

.btn-small { font-size: 12px; padding: 5px 12px; border-radius: 999px; }

.btn-danger {
  border-color: rgba(220, 90, 90, 0.5);
  color: #e79a9a;
  background: transparent;
}
.btn-danger:hover:not(:disabled) { border-color: #dc5a5a; }

/* ==========================================================
   調査ガチャの観察盤（シグネチャ要素：里山レーダー）
   ========================================================== */
.altar {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
}

.astrolabe-wrap {
  position: relative;
  width: min(320px, 78vw);
  aspect-ratio: 1;
}

.astrolabe { width: 100%; height: 100%; display: block; }

.astrolabe {
  position: relative;
  z-index: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.58), transparent 18%),
    radial-gradient(circle at 64% 68%, rgba(27, 130, 103, 0.34), transparent 34%),
    linear-gradient(145deg, #9be7e2 0%, #45b6b8 42%, #2a8cc4 100%);
  box-shadow:
    inset -22px -28px 42px rgba(19, 72, 76, 0.24),
    inset 18px 14px 28px rgba(255, 255, 255, 0.25),
    0 24px 60px rgba(58, 124, 82, 0.22);
}

.pity-track {
  fill: none;
  stroke: var(--line);
  stroke-width: 3;
}

.pity-fill {
  fill: none;
  stroke: var(--brass);
  stroke-width: 3;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 160px 160px;
  filter: drop-shadow(0 0 8px rgba(158, 214, 107, 0.62));
  transition: stroke-dashoffset 0.6s ease;
}

.astrolabe-disc {
  transform-origin: 160px 160px;
  animation: disc-rotate 90s linear infinite;
}

.astrolabe-disc .ring { fill: none; stroke: rgba(232, 255, 228, 0.58); stroke-width: 1; }
.astrolabe-disc .spoke { stroke: rgba(232, 255, 228, 0.26); stroke-width: 1; }
.astrolabe-disc .continent {
  fill: rgba(71, 151, 67, 0.76);
  stroke: rgba(232, 255, 218, 0.34);
  stroke-width: 1.2;
}
.astrolabe-disc .leaf {
  fill: rgba(154, 222, 126, 0.78);
  stroke: rgba(230, 255, 206, 0.42);
  stroke-width: 0.8;
}
.astrolabe-disc .drop {
  fill: rgba(98, 210, 181, 0.72);
  stroke: rgba(215, 255, 242, 0.35);
  stroke-width: 0.8;
}
.astrolabe-disc .trail { stroke: rgba(119, 206, 154, 0.42); stroke-width: 0.9; stroke-linecap: round; }

@keyframes disc-rotate {
  to { transform: rotate(360deg); }
}

.altar.is-summoning .astrolabe-disc {
  animation: disc-rotate 1.8s linear infinite;
}

.astrolabe-wrap::before,
.astrolabe-wrap::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  pointer-events: none;
}

.astrolabe-wrap::before {
  inset: 4%;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.32), transparent 15%),
    radial-gradient(circle at 50% 52%, rgba(96, 185, 128, 0.2), transparent 61%);
  box-shadow: 0 0 0 1px rgba(83, 146, 83, 0.16), 0 0 44px rgba(66, 153, 105, 0.24);
  animation: field-pulse 4.2s ease-in-out infinite;
}

.astrolabe-wrap::after {
  inset: 22%;
  border: 1px solid rgba(126, 219, 159, 0.24);
  animation: field-ripple 2.8s ease-out infinite;
}

@keyframes field-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.96); }
  50% { opacity: 0.9; transform: scale(1.04); }
}

@keyframes field-ripple {
  0% { transform: scale(0.7); opacity: 0.55; }
  100% { transform: scale(1.58); opacity: 0; }
}

.pity-readout {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.pity-count {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 44px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.pity-label {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.altar-caption {
  margin: 18px 0 26px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.1em;
}

.draw-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-draw {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 180px;
  padding: 14px 28px;
}

.btn-draw .draw-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.16em;
}

.btn-draw .draw-cost {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.btn-draw-multi {
  color: #f7fff1;
  background: linear-gradient(180deg, #42641f, #153421 70%);
  border-color: rgba(216, 245, 143, 0.55);
}
.btn-draw-multi .draw-name { color: #f2ffd8; }
.btn-draw-multi .draw-cost { color: rgba(247, 255, 241, 0.78); }

.draw-note { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ==========================================================
   召喚結果オーバーレイ
   ========================================================== */
.summon-overlay[hidden] { display: none; }

.summon-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background:
    radial-gradient(circle at 50% 43%, rgba(69, 182, 184, 0.42) 0%, rgba(69, 182, 184, 0.22) 23%, transparent 43%),
    radial-gradient(circle at 50% 45%, rgba(116, 196, 88, 0.24) 0%, transparent 34%),
    radial-gradient(900px 560px at 78% 8%, rgba(180, 230, 125, 0.56), transparent 62%),
    radial-gradient(760px 520px at 8% 96%, rgba(111, 198, 171, 0.34), transparent 60%),
    linear-gradient(180deg, #f3fbeb 0%, #dbf0d0 48%, #c7e6bc 100%);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.summon-overlay::before,
.summon-overlay::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border-radius: 50%;
}

.summon-overlay::before {
  width: min(560px, 82vw);
  aspect-ratio: 1;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.7), transparent 16%),
    radial-gradient(circle at 43% 45%, rgba(91, 172, 74, 0.72) 0 12%, transparent 13%),
    radial-gradient(circle at 59% 35%, rgba(74, 151, 72, 0.66) 0 14%, transparent 15%),
    radial-gradient(circle at 53% 67%, rgba(69, 154, 77, 0.58) 0 11%, transparent 12%),
    linear-gradient(145deg, rgba(164, 236, 229, 0.88), rgba(67, 177, 190, 0.82) 45%, rgba(45, 135, 193, 0.78));
  box-shadow:
    inset -30px -34px 52px rgba(26, 84, 92, 0.24),
    inset 20px 16px 34px rgba(255, 255, 255, 0.22),
    0 28px 90px rgba(74, 146, 96, 0.25);
  opacity: 0.62;
  animation: summon-earth-drift 14s ease-in-out infinite alternate;
}

.summon-overlay::after {
  width: 130vw;
  height: 38vh;
  left: -15vw;
  bottom: -20vh;
  background:
    radial-gradient(ellipse at 22% 40%, rgba(113, 178, 70, 0.35), transparent 34%),
    radial-gradient(ellipse at 62% 36%, rgba(95, 165, 78, 0.28), transparent 32%),
    linear-gradient(180deg, rgba(112, 172, 79, 0.18), rgba(68, 128, 63, 0.26));
  filter: blur(2px);
}

@keyframes summon-earth-drift {
  from { transform: translate(-50%, -50%) rotate(-5deg) scale(0.98); }
  to   { transform: translate(-50%, -51%) rotate(7deg) scale(1.03); }
}

.summon-stage {
  position: relative;
  z-index: 1;
  width: min(880px, 94vw);
  padding: 40px 16px 72px;
  text-align: center;
}

.summon-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--flash-color, #fff) 72%, white) 0%, transparent 54%),
    radial-gradient(circle at 50% 72%, rgba(116, 190, 94, 0.18), transparent 54%);
}

.summon-flash.is-flashing { animation: flash 0.7s ease-out; }

@keyframes flash {
  0% { opacity: 0; }
  25% { opacity: 0.62; }
  100% { opacity: 0; }
}

/* ---------- 発見演出（水辺レーダー） ---------- */
.ritual {
  --ritual-color: #86d7a7;
  position: relative;
  width: min(340px, 78vw);
  aspect-ratio: 1;
  margin: 24px auto;
}

.ritual[hidden] { display: none; }

.ritual-circle { width: 100%; height: 100%; display: block; overflow: visible; }

.rc-ring {
  fill: none;
  stroke: var(--ritual-color);
  transition: stroke 0.5s;
}

.rc-leaf {
  fill: var(--ritual-color);
  stroke: rgba(244, 255, 239, 0.52);
  stroke-width: 1;
  transition: fill 0.5s;
}

.rc-ripple {
  fill: none;
  stroke: var(--ritual-color);
  stroke-width: 1.4;
  opacity: 0.5;
}

.rc-draw {
  stroke-dasharray: 1160;
  stroke-dashoffset: 1160;
  animation: rc-draw 0.9s ease-out forwards;
}

@keyframes rc-draw { to { stroke-dashoffset: 0; } }

.rc-spin-cw  { transform-origin: 200px 200px; animation: disc-rotate 14s linear infinite; }
.rc-spin-ccw { transform-origin: 200px 200px; animation: disc-rotate 20s linear infinite reverse; }

.ritual.is-charged .rc-spin-cw  { animation-duration: 2.6s; }
.ritual.is-charged .rc-spin-ccw { animation-duration: 3.6s; }

.ritual-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #f5ffe8;
  box-shadow:
    0 0 18px 6px var(--ritual-color),
    0 0 64px 26px color-mix(in srgb, var(--ritual-color) 40%, transparent);
  animation: core-pulse 0.9s ease-in-out infinite alternate;
  transition: box-shadow 0.5s;
}

@keyframes core-pulse {
  from { transform: scale(0.8); }
  to   { transform: scale(1.4); }
}

.ritual.is-charged .ritual-core { animation-duration: 0.35s; }

.ritual-particles { position: absolute; inset: 0; pointer-events: none; }

.ritual-particles span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 4px;
  border-radius: 999px 0 999px 0;
  background: var(--ritual-color);
  opacity: 0;
  animation: rp-converge 1.2s linear infinite;
  animation-delay: var(--delay);
}

@keyframes rp-converge {
  0%   { transform: rotate(var(--a)) translateX(var(--d)) scale(1); opacity: 0; }
  15%  { opacity: 1; }
  100% { transform: rotate(var(--a)) translateX(5px) scale(0.4); opacity: 0; }
}

/* 爆発 */
.ritual.is-bursting .ritual-circle { animation: rc-out 0.5s ease-in forwards; }

@keyframes rc-out { to { transform: scale(1.3); opacity: 0; } }

.ritual.is-bursting .ritual-core { animation: core-burst 0.55s ease-out forwards; }

@keyframes core-burst { to { transform: scale(16); opacity: 0; } }

.ritual.is-bursting .ritual-particles span {
  animation: rp-explode 0.7s ease-out forwards;
  animation-delay: 0s;
}

@keyframes rp-explode {
  0%   { transform: rotate(var(--a)) translateX(6px); opacity: 1; }
  100% { transform: rotate(var(--a)) translateX(calc(var(--d) * 1.7)); opacity: 0; }
}

.ritual::before {
  content: "";
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  border: 2px solid var(--ritual-color);
  opacity: 0;
  pointer-events: none;
}

.ritual.is-bursting::before { animation: shockwave 0.6s ease-out forwards; }

@keyframes shockwave {
  0%   { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(3.2); opacity: 0; }
}

/* 画面の揺れ（SSR 演出） */
.summon-stage.is-shaking { animation: stage-shake 0.45s; }

@keyframes stage-shake {
  0%, 100% { transform: none; }
  20% { transform: translate(-7px, 4px); }
  40% { transform: translate(6px, -5px); }
  60% { transform: translate(-5px, -3px); }
  80% { transform: translate(4px, 3px); }
}

.result-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

.result-cards[hidden] { display: none; }

/* ---------- カード（裏面から 3D 回転で開示） ---------- */
.card {
  --glow: var(--c-n);
  position: relative;
  width: 132px;
  height: 226px;
  perspective: 700px;
  isolation: isolate;
  opacity: 0;
}

.card.is-dealt { animation: card-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.15) forwards; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(26px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}

.card[data-rarity="R"]   { --glow: var(--c-r); }
.card[data-rarity="SR"]  { --glow: var(--c-sr); }
.card[data-rarity="SSR"] { --glow: var(--c-ssr); }

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.3, 1.05);
  z-index: 1;
}

.card.is-flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
}

.card-back {
  border: 1px solid rgba(158, 214, 107, 0.4);
  background:
    radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.42), transparent 22%),
    linear-gradient(145deg, #c7ef8d 0%, #6ebf55 48%, #28783f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s, border-color 0.3s;
  overflow: hidden;
}

.card-back::before {
  content: "";
  position: absolute;
  width: 156px;
  height: 214px;
  border-radius: 78% 0 78% 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.28), transparent 35%),
    linear-gradient(160deg, rgba(220,255,162,0.95), rgba(53,142,59,0.96));
  transform: rotate(-34deg) translate(7px, -1px);
  box-shadow:
    inset 0 0 0 2px rgba(255,255,255,0.25),
    0 18px 34px rgba(20,80,42,0.24);
}

.card-back::after {
  content: "";
  position: absolute;
  width: 120px;
  height: 2px;
  background: rgba(245, 255, 211, 0.72);
  transform: rotate(-35deg);
  box-shadow:
    18px -18px 0 -0.5px rgba(245, 255, 211, 0.46),
    34px -34px 0 -0.7px rgba(245, 255, 211, 0.32),
    -18px 18px 0 -0.5px rgba(245, 255, 211, 0.46),
    -34px 34px 0 -0.7px rgba(245, 255, 211, 0.32);
}

.card-back .seal {
  position: relative;
  z-index: 1;
  width: 58px;
  height: 58px;
  fill: none;
  stroke: rgba(19, 74, 34, 0.76);
  stroke-width: 1.55;
  opacity: 0.9;
}

/* めくれる直前、裏面がレアリティ色に灯る */
.card.is-hinting .card-back {
  border-color: var(--glow);
  box-shadow: 0 0 22px color-mix(in srgb, var(--glow) 60%, transparent);
}

.card-front {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px 12px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--glow) 55%, transparent);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--glow) 12%, var(--surface)) 0%, var(--surface) 65%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--glow) 30%, transparent);
}

.card[data-rarity="SSR"] .card-front {
  box-shadow:
    0 0 22px color-mix(in srgb, var(--c-ssr) 45%, transparent),
    0 0 60px color-mix(in srgb, var(--c-ssr) 20%, transparent);
}

/* SSR：回転する光背 */
.card.is-ssr::before {
  content: "";
  position: absolute;
  inset: -28px;
  z-index: 0;
  pointer-events: none;
  background: repeating-conic-gradient(
    rgba(243, 211, 91, 0) 0deg 11deg,
    rgba(243, 211, 91, 0.34) 14deg 17deg,
    rgba(243, 211, 91, 0) 20deg 30deg
  );
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%);
  mask: radial-gradient(circle, #000 25%, transparent 70%);
  opacity: 0;
  transition: opacity 0.45s;
}

.card.is-ssr.is-flipped::before {
  opacity: 1;
  animation: rays-spin 10s linear infinite;
}

@keyframes rays-spin { to { transform: rotate(360deg); } }

/* SSR：きらめきの走査光 */
.card.is-ssr.is-flipped .card-front::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.35) 50%, transparent 68%);
  transform: translateX(-130%);
  animation: shine 0.9s 0.5s ease-out forwards;
}

@keyframes shine { to { transform: translateX(130%); } }

.card-art {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  background: radial-gradient(circle at 50% 40%, #1f5133 0%, #0d2417 75%);
  display: block;
}

.card-art-img {
  object-fit: contain;
  border: 1px solid color-mix(in srgb, var(--glow) 35%, transparent);
}

.card-art-fallback {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  padding: 10px;
  overflow: hidden;
  text-align: center;
  border: 1px dashed color-mix(in srgb, var(--glow) 48%, transparent);
  background:
    radial-gradient(circle at 50% 34%, color-mix(in srgb, var(--glow) 26%, transparent), transparent 55%),
    linear-gradient(160deg, #1e5a3a, #173623 62%, #0d2417);
}

.card-art-fallback strong {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--glow) 82%, #fff);
  color: #07150f;
  font-size: 20px;
  line-height: 1;
}

.card-art-fallback span {
  max-width: 100%;
  font-size: 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-art-fallback .fallback-habitat {
  color: var(--muted);
  font-size: 9px;
}

.card-art .cstar { fill: color-mix(in srgb, var(--glow) 80%, #fff); }
.card-art .cline { stroke: color-mix(in srgb, var(--glow) 55%, transparent); stroke-width: 1; }

.card-rarity {
  display: inline-block;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--glow);
}

.card-epithet {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}

.card-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

.card-badge {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--brass);
  color: #2f681d;
}

.summon-close {
  margin-top: 32px;
  min-width: 160px;
  color: #f7fff1;
}

.summon-skip {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

/* ==========================================================
   図鑑
   ========================================================== */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 14px;
}

.dex-card {
  --glow: var(--c-n);
  border: 1px solid color-mix(in srgb, var(--glow) 40%, transparent);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px 8px 12px;
  text-align: center;
  position: relative;
}

.dex-card[data-rarity="R"]   { --glow: var(--c-r); }
.dex-card[data-rarity="SR"]  { --glow: var(--c-sr); }
.dex-card[data-rarity="SSR"] { --glow: var(--c-ssr); }

.dex-card.is-locked { filter: grayscale(1) brightness(0.55); }

/* 入手済みカードはクリックで詳細を開ける */
button.dex-card {
  appearance: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
}

button.dex-card:hover,
button.dex-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--glow);
  box-shadow: 0 0 16px color-mix(in srgb, var(--glow) 35%, transparent);
}

/* ---------- 星霊詳細 ---------- */
.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(6, 8, 16, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.detail-overlay[hidden] { display: none; }

.detail-box {
  position: relative;
  width: min(400px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 54px 28px 28px;
  text-align: center;
}

.detail-back {
  position: absolute;
  top: 14px;
  left: 14px;
}

.detail-art {
  --glow: var(--c-n);
  width: 180px;
  margin: 0 auto 16px;
}

.detail-art[data-rarity="R"]   { --glow: var(--c-r); }
.detail-art[data-rarity="SR"]  { --glow: var(--c-sr); }
.detail-art[data-rarity="SSR"] { --glow: var(--c-ssr); }

.detail-art .card-art {
  border: 1px solid color-mix(in srgb, var(--glow) 45%, transparent);
  border-radius: 8px;
  box-shadow: 0 0 26px color-mix(in srgb, var(--glow) 25%, transparent);
}

.detail-epithet {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.detail-name {
  margin: 2px 0 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: 0.1em;
}

.detail-taxonomy {
  margin: 10px 0 0;
  color: var(--brass-bright);
  font-size: 12px;
  line-height: 1.6;
}

.detail-desc {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 2;
  text-align: left;
}

.detail-meta {
  display: flex;
  gap: 28px;
  justify-content: center;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-meta div { display: flex; align-items: baseline; gap: 8px; }

.detail-meta dt { color: var(--muted); font-size: 12px; }

.detail-meta dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
  font-weight: 700;
}

.detail-download { margin-top: 18px; }

.dex-card.is-locked .card-name::after { content: ""; }

.dex-count {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================
   統計・テーブル
   ========================================================== */
.stats-table-wrap { overflow-x: auto; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.stats-table th,
.stats-table td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-table th {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.stats-table .bar-col { width: 40%; }

.rarity-chip {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 1px 10px;
  border-radius: 4px;
  color: var(--bg);
}

.rarity-chip[data-rarity="N"]   { background: var(--c-n); }
.rarity-chip[data-rarity="R"]   { background: var(--c-r); }
.rarity-chip[data-rarity="SR"]  { background: var(--c-sr); }
.rarity-chip[data-rarity="SSR"] { background: var(--c-ssr); }

.dist-bar {
  position: relative;
  height: 10px;
  min-width: 160px;
  border-radius: 5px;
  background: var(--surface-2);
  overflow: hidden;
}

.dist-bar .actual {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 5px;
  background: var(--brass);
}

.dist-bar .expected {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text);
  opacity: 0.7;
}

.history-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}

.history-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.history-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.history-flag {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--brass);
  color: var(--brass-bright);
}

.empty-note { color: var(--muted); font-size: 13px; padding: 16px 4px; }

/* ==========================================================
   確率設定
   ========================================================== */
.settings-form { max-width: 620px; }

.rate-rows { display: flex; flex-direction: column; gap: 8px; }

.rate-row {
  display: grid;
  grid-template-columns: 64px 1fr 110px;
  align-items: center;
  gap: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.rate-row input[type="range"] { accent-color: var(--brass); width: 100%; }

.rate-num {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
}

input[type="number"], select {
  font-family: var(--font-body);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  width: 78px;
}

select { width: auto; }

.rate-sum {
  margin: 10px 2px 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.rate-sum.is-invalid { color: #e79a9a; }
.rate-sum.is-valid   { color: #9fd8a4; }

.setting-row {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }

.switch input { position: absolute; opacity: 0; }

.switch-track {
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.2s, background 0.2s;
}

.switch input:checked + .switch-track { background: rgba(201, 164, 94, 0.35); border-color: var(--brass); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: var(--brass-bright); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--brass); outline-offset: 2px; }

.num-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.settings-actions { display: flex; gap: 12px; margin-top: 24px; }

.settings-msg { min-height: 1.5em; font-size: 13px; color: #9fd8a4; margin: 10px 2px; }
.settings-msg.is-error { color: #e79a9a; }

.danger-title { color: #e79a9a; }

.pw-input {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  width: 160px;
}

/* ---------- 管理者確認モーダル ---------- */
.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 8, 16, 0.85);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-modal[hidden] { display: none; }

.admin-box {
  width: min(360px, 92vw);
  padding: 28px 26px 22px;
  border: 1px solid rgba(201, 164, 94, 0.4);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.admin-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.12em;
  color: var(--brass-bright);
}

.admin-desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.admin-box .pw-input { width: 100%; }

.admin-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

/* ---------- モーション配慮 ---------- */
@media (prefers-reduced-motion: reduce) {
  .astrolabe-disc,
  .altar.is-summoning .astrolabe-disc { animation: none; }
  .card.is-dealt { animation: none; opacity: 1; }
  .card-inner { transition: none; }
  .card.is-ssr.is-flipped::before,
  .card.is-ssr.is-flipped .card-front::after { animation: none; }
  .summon-flash.is-flashing { animation: none; }
  .summon-stage.is-shaking { animation: none; }
  .pity-fill { transition: none; }
}

/* ---------- モバイル ---------- */
@media (max-width: 560px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .tab-btn { padding: 10px 12px; font-size: 13px; }
  .btn-draw { min-width: 150px; }
  .card { width: calc(33.3% - 10px); min-width: 96px; }
  .rate-row { grid-template-columns: 48px 1fr 100px; gap: 8px; }
}
