/* ══ STELLA TAROT ══════════════════════════════════════════════
   夜空を背にした神秘的なタロット。スマホ縦持ちを基準に設計する。
   ────────────────────────────────────────────────────────────── */

:root {
  --void:       #06041a;
  --deep:       #0b0826;
  --panel:      rgba(28, 22, 66, .52);
  --panel-hi:   rgba(52, 42, 108, .55);
  --line:       rgba(184, 160, 255, .18);
  --line-gold:  rgba(214, 176, 108, .38);

  --gold:       #d9b877;
  --gold-hi:    #f4e3b6;
  --gold-dim:   rgba(217, 184, 119, .62);
  --violet:     #9a86f0;
  --violet-dim: rgba(154, 134, 240, .5);

  --ink:        #ece8ff;
  --ink-2:      rgba(236, 232, 255, .74);
  --ink-3:      rgba(236, 232, 255, .48);

  --serif: "Shippori Mincho", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
          "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --display: "Cormorant Garamond", var(--serif);

  --card-ar: 0.583;          /* タロットカードの 幅÷高さ */
  --tabbar-h: 62px;
  --appbar-h: calc(env(safe-area-inset-top, 0px) + 54px);
  --safe-b: env(safe-area-inset-b, 0px);
  --ease: cubic-bezier(.22, .68, .3, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* CSS で display を指定した要素にも hidden 属性を効かせる */
[hidden] { display: none !important; }

html {
  background: var(--void);
}

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── 星空 ────────────────────────────────────────────────── */

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  display: block;
}

.nebula {
  position: fixed;
  inset: -10%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(46% 32% at 18% 14%, rgba(96, 62, 172, .34), transparent 68%),
    radial-gradient(40% 30% at 86% 30%, rgba(38, 84, 168, .26), transparent 70%),
    radial-gradient(58% 40% at 50% 106%, rgba(122, 66, 158, .3), transparent 72%);
  filter: blur(18px);
  animation: drift 46s var(--ease) infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-1.5%, -1%, 0) scale(1); }
  to   { transform: translate3d(2%, 1.5%, 0) scale(1.07); }
}

/* ── アプリバー ──────────────────────────────────────────── */

.appbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: linear-gradient(to bottom, rgba(6, 4, 26, .92), rgba(6, 4, 26, .55) 70%, transparent);
  backdrop-filter: blur(10px);
}

.appbar__back {
  width: 40px; height: 40px;
  margin-left: -8px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
}
.appbar__back svg { width: 24px; height: 24px; }
.appbar__back:active { background: rgba(217, 184, 119, .12); }

.appbar__title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: .34em;
  text-indent: .34em;
  color: var(--gold-hi);
  text-shadow: 0 0 20px rgba(217, 184, 119, .38);
}
.appbar__title span { color: var(--ink-3); }
.appbar__title span::before { content: " "; }

/* ── レイアウト ──────────────────────────────────────────── */

#main {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 4px 18px calc(var(--tabbar-h) + var(--safe-b) + 28px);
}

.view { animation: rise .45s var(--ease) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

.lede {
  margin: 10px 2px 26px;
  font-family: var(--serif);
  font-size: .95rem;
  line-height: 2.05;
  color: var(--ink-2);
  letter-spacing: .04em;
}

.secthead {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 8px 0 18px;
}
.secthead h2 {
  margin: 0; font-family: var(--serif); font-size: 1.12rem;
  font-weight: 700; letter-spacing: .12em; color: var(--gold-hi);
}

.empty {
  margin: 56px 0;
  text-align: center;
  font-family: var(--serif);
  font-size: .9rem;
  line-height: 2.1;
  color: var(--ink-3);
}

/* ── スプレッド一覧 ──────────────────────────────────────── */

.spreadlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }

.spreaditem {
  position: relative;
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 16px;
  align-items: center;
  width: 100%;
  padding: 18px 18px 18px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(150deg, var(--panel-hi), var(--panel));
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: transform .22s var(--ease), border-color .22s var(--ease);
}
.spreaditem::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 88% 0%, rgba(217, 184, 119, .13), transparent 62%);
  pointer-events: none;
}
.spreaditem:active { transform: scale(.985); border-color: var(--line-gold); }

.spreaditem__glyph {
  height: 76px;
  display: grid; place-items: center;
}
.spreaditem__glyph svg {
  width: 100%;
  height: 100%;
  /* グリッド項目の自動最小サイズは viewBox の縦横比から算出されるため、
     解除しないと縦長の配置図（1枚引き・ケルト十字）が枠を突き抜ける */
  min-width: 0;
  min-height: 0;
}
.spreaditem__glyph rect {
  fill: rgba(154, 134, 240, .16);
  stroke: var(--gold-dim);
  stroke-width: 1.1;
}

.spreaditem__name {
  display: block;
  margin: 0;
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--gold-hi);
}
.spreaditem__sub {
  display: inline-block;
  margin-left: 8px;
  font-family: var(--sans);
  font-size: .68rem;
  font-weight: 400;
  letter-spacing: .1em;
  color: var(--ink-3);
  vertical-align: 2px;
}
.spreaditem__desc {
  display: block;
  margin: 5px 0 0;
  font-size: .78rem;
  line-height: 1.72;
  color: var(--ink-2);
}

/* ── 問いの入力 ──────────────────────────────────────────── */

.setup { display: grid; gap: 22px; }

.setup__name {
  margin: 6px 0 0;
  font-family: var(--serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--gold-hi);
}
.setup__desc {
  margin: -12px 0 0;
  font-size: .84rem;
  line-height: 1.9;
  color: var(--ink-2);
}

.field { display: block; position: relative; }
.field__label {
  display: block;
  margin-bottom: 9px;
  font-size: .8rem;
  letter-spacing: .08em;
  color: var(--gold);
}
.field__label em {
  font-style: normal;
  font-size: .72rem;
  color: var(--ink-3);
  letter-spacing: 0;
}
.field textarea {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(10, 8, 34, .62);
  color: var(--ink);
  font: inherit;
  font-size: .92rem;
  line-height: 1.85;
  resize: vertical;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.field textarea::placeholder { color: rgba(236, 232, 255, .3); }
.field textarea:focus {
  outline: 0;
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(217, 184, 119, .1);
}
.field__count {
  position: absolute; right: 4px; bottom: -20px;
  font-size: .68rem; color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.toggle {
  display: flex; align-items: center; gap: 14px;
  margin-top: 8px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(10, 8, 34, .42);
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle__track {
  flex: none;
  width: 46px; height: 27px;
  border-radius: 999px;
  background: rgba(120, 108, 190, .3);
  border: 1px solid var(--line);
  transition: background .24s var(--ease);
  display: grid; align-items: center;
}
.toggle__thumb {
  width: 21px; height: 21px; margin-left: 2px;
  border-radius: 50%;
  background: var(--ink-3);
  transition: transform .24s var(--ease), background .24s var(--ease);
}
.toggle input:checked + .toggle__track { background: rgba(217, 184, 119, .34); }
.toggle input:checked + .toggle__track .toggle__thumb {
  transform: translateX(19px);
  background: var(--gold-hi);
}
.toggle input:focus-visible + .toggle__track { box-shadow: 0 0 0 3px rgba(217, 184, 119, .25); }
.toggle__text { font-size: .88rem; letter-spacing: .03em; }
.toggle__text em {
  display: block; font-style: normal;
  font-size: .72rem; color: var(--ink-3); letter-spacing: 0;
}

/* ── ボタン ──────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 52px;
  padding: 0 26px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-size: .93rem;
  letter-spacing: .1em;
  cursor: pointer;
  transition: transform .18s var(--ease), opacity .18s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .38; pointer-events: none; }
.btn__glyph { color: var(--gold-hi); font-size: 1.05em; }

.btn--primary {
  background: linear-gradient(135deg, #3b2d7e, #241a5c 55%, #4a3491);
  border-color: var(--line-gold);
  color: var(--gold-hi);
  box-shadow: 0 8px 28px -12px rgba(154, 134, 240, .8),
              inset 0 1px 0 rgba(255, 255, 255, .1);
}
.btn--ghost {
  background: rgba(255, 255, 255, .04);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn--wide { width: 100%; }

.linkbtn {
  border: 0; background: none; padding: 4px 2px;
  font: inherit; font-size: .78rem;
  color: var(--ink-3); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.linkbtn--danger { color: rgba(240, 150, 150, .72); }

/* ── 盤面 ────────────────────────────────────────────────── */

.view--board { display: flex; flex-direction: column; gap: 18px; }

.board__hint {
  margin: 2px 0 0;
  text-align: center;
  font-family: var(--serif);
  font-size: .84rem;
  letter-spacing: .14em;
  color: var(--gold-dim);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }

.board__wrap { display: grid; place-items: center; }

/* 盤面は「幅」と「残りの画面の高さ」の小さい方に合わせる。
   幅だけで決めると、横に広く縦が短いPCのウィンドウで下がはみ出す。
   --avail は fitBoard() が実測して入れる（JSが動く前は制約なしとして扱う）。 */
.board {
  --board-max: 420px;
  position: relative;
  width: min(100%, var(--board-max), calc(var(--avail, 200vh) * var(--ratio)));
  aspect-ratio: var(--ratio);
}

.slot {
  position: absolute;
  width: calc(var(--cw) * 100%);
  aspect-ratio: var(--card-ar);
  translate: -50% -50%;
  perspective: 900px;
  cursor: pointer;
}
.slot[data-cross="1"] { rotate: 90deg; z-index: 3; }

.slot__inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform .68s var(--ease);
  border-radius: 8px;
}
.slot.is-open .slot__inner { transform: rotateY(180deg); }

.face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 22px -8px rgba(0, 0, 0, .85),
              0 0 0 1px rgba(217, 184, 119, .3);
}
.face--back {
  background: url("assets/card-back.svg") center/cover no-repeat, var(--deep);
}
.face--front {
  transform: rotateY(180deg);
  background: #f4efe2;
}
.face--front img { width: 100%; height: 100%; object-fit: cover; display: block; }
.face--front.is-rev img { transform: rotate(180deg); }

.slot:not(.is-open) .slot__inner { animation: hover 5s ease-in-out infinite; }
@keyframes hover {
  50% { transform: translateY(-4px); }
}

.slot__no {
  position: absolute;
  top: -7px; left: -7px;
  z-index: 4;
  width: 21px; height: 21px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--deep);
  border: 1px solid var(--line-gold);
  font-size: .62rem;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}
.slot[data-cross="1"] .slot__no { rotate: -90deg; }

.slot__label {
  position: absolute;
  left: 50%; top: calc(100% + 5px);
  translate: -50% 0;
  white-space: nowrap;
  font-size: .62rem;
  letter-spacing: .06em;
  color: var(--ink-3);
  pointer-events: none;
}
.slot[data-cross="1"] .slot__label { display: none; }
/* 枚数が多い配置では札が密集するため、名前は下の凡例にまとめる */
.board.is-dense .slot__label { display: none; }

.legend {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 5px 7px;
  margin-top: 4px;
}
.legend span {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 8, 34, .5);
  font-size: .66rem;
  letter-spacing: .04em;
  color: var(--ink-2);
}
.legend b {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(217, 184, 119, .16);
  color: var(--gold);
  font-size: .58rem; font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.board__actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  margin-top: 6px;
}

/* デッキが舞い降りる演出 */
.slot { animation: deal .5s var(--ease) both; }
@keyframes deal {
  from { opacity: 0; transform: translate(-50%, -50%) translateY(-38px) scale(.9); }
}

/* ── 鑑定結果 ────────────────────────────────────────────── */

.result__head { margin: 4px 0 18px; }
.result__title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.34rem;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--gold-hi);
}
.result__meta {
  margin: 6px 0 0;
  font-size: .75rem;
  color: var(--ink-3);
  letter-spacing: .04em;
}

.stats {
  display: flex; flex-wrap: wrap; gap: 7px;
  margin-bottom: 22px;
}
.stat {
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 8, 34, .5);
  font-size: .72rem;
  letter-spacing: .04em;
  color: var(--ink-2);
}
.stat b { color: var(--gold); font-weight: 600; }

.readlist { list-style: none; margin: 0 0 26px; padding: 0; display: grid; gap: 12px; }

.readitem {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: start;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(150deg, var(--panel-hi), var(--panel));
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  width: 100%;
  transition: transform .2s var(--ease);
}
.readitem:active { transform: scale(.985); }

.readitem__thumb {
  width: 58px; aspect-ratio: var(--card-ar);
  border-radius: 5px; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(217, 184, 119, .32);
  background: #f4efe2;
}
.readitem__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.readitem__thumb.is-rev img { transform: rotate(180deg); }

.readitem__pos {
  display: block;
  font-size: .68rem; letter-spacing: .12em;
  color: var(--violet);
}
.readitem__name {
  display: block;
  margin: 1px 0 4px;
  font-family: var(--serif);
  font-size: 1rem; font-weight: 700; letter-spacing: .06em;
  color: var(--gold-hi);
}
.readitem__ori {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 8px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: .62rem; font-weight: 400; letter-spacing: .06em;
  vertical-align: 2px;
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.readitem__ori.is-rev { border-color: rgba(240, 150, 150, .34); color: rgba(240, 170, 170, .9); }
.readitem__kw { display: block; margin: 0; font-size: .74rem; line-height: 1.7; color: var(--ink-2); }

.result__actions { display: grid; gap: 10px; }

/* ── プロンプト ──────────────────────────────────────────── */

.prompt__note {
  margin: 0 0 14px;
  font-size: .78rem; line-height: 1.8;
  color: var(--ink-2);
}
.prompt__box {
  width: 100%;
  height: 46vh;
  min-height: 220px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(6, 4, 22, .78);
  color: var(--ink-2);
  font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
  font-size: .74rem;
  line-height: 1.85;
  resize: none;
  white-space: pre-wrap;
}
.prompt__box:focus { outline: 0; border-color: var(--gold-dim); }
.prompt__actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; }

/* ── 履歴 ────────────────────────────────────────────────── */

.histlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.histitem {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(150deg, var(--panel-hi), var(--panel));
  overflow: hidden;
}
.histitem__main {
  display: block; width: 100%;
  padding: 15px 46px 15px 16px;
  border: 0; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer;
}
.histitem__top {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
.histitem__spread {
  font-family: var(--serif); font-size: .97rem; font-weight: 700;
  letter-spacing: .08em; color: var(--gold-hi);
}
.histitem__date { font-size: .68rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.histitem__q {
  margin: 5px 0 0;
  font-size: .78rem; line-height: 1.7; color: var(--ink-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.histitem__cards { display: flex; gap: 4px; margin-top: 10px; flex-wrap: wrap; }
.histitem__cards img {
  width: 26px; aspect-ratio: var(--card-ar);
  object-fit: cover; border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(217, 184, 119, .26);
}
.histitem__cards img.is-rev { transform: rotate(180deg); }
.histitem__del {
  position: absolute; top: 8px; right: 8px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: none; color: var(--ink-3);
  font-size: 1.1rem; cursor: pointer;
}
.histitem__del:active { background: rgba(255, 255, 255, .07); }

/* ── 事典 ────────────────────────────────────────────────── */

.libtools {
  position: sticky;
  top: var(--appbar-h);
  z-index: 10;
  margin: 0 -18px;
  padding: 8px 18px 12px;
  background: linear-gradient(to bottom, rgba(6, 4, 26, .95) 72%, rgba(6, 4, 26, 0));
  backdrop-filter: blur(10px);
}

#libSearch {
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 8, 34, .78);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font: inherit; font-size: .88rem;
}
#libSearch::placeholder { color: rgba(236, 232, 255, .3); }
#libSearch:focus { outline: 0; border-color: var(--gold-dim); }

.chips {
  display: flex; gap: 7px;
  margin-top: 11px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 8, 34, .6);
  color: var(--ink-3);
  font: inherit; font-size: .74rem; letter-spacing: .05em;
  cursor: pointer;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.chip.is-on {
  color: var(--gold-hi);
  border-color: var(--line-gold);
  background: rgba(217, 184, 119, .12);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(94px, 1fr));
  gap: 12px;
}
.gcard {
  border: 0; padding: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; text-align: center;
}
.gcard img {
  width: 100%; aspect-ratio: var(--card-ar);
  object-fit: cover;
  border-radius: 6px;
  background: #f4efe2;
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, .8), 0 0 0 1px rgba(217, 184, 119, .28);
  transition: transform .2s var(--ease);
}
.gcard:active img { transform: scale(.96); }
.gcard span {
  display: block;
  margin-top: 7px;
  font-size: .68rem;
  line-height: 1.5;
  color: var(--ink-2);
  letter-spacing: .02em;
}

/* ── タブバー ────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(8, 6, 28, .86);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  display: grid; place-items: center; gap: 3px;
  border: 0; background: none;
  color: var(--ink-3);
  font: inherit; font-size: .64rem; letter-spacing: .1em;
  cursor: pointer;
  transition: color .2s var(--ease);
}
.tab svg { width: 22px; height: 22px; }
.tab.is-on { color: var(--gold-hi); }
.tab.is-on svg { filter: drop-shadow(0 0 6px rgba(217, 184, 119, .6)); }

/* ── ボトムシート ────────────────────────────────────────── */

.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }

.sheet__scrim {
  position: absolute; inset: 0;
  background: rgba(4, 2, 16, .72);
  backdrop-filter: blur(3px);
  animation: fade .28s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }

.sheet__panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(to bottom, #17123c, var(--void) 42%);
  border-top: 1px solid var(--line-gold);
  box-shadow: 0 -18px 60px -20px rgba(0, 0, 0, .95);
  animation: slideup .34s var(--ease) both;
}
@keyframes slideup { from { transform: translateY(100%); } }

.sheet__grip {
  flex: none;
  width: 100%; height: 26px;
  border: 0; background: none;
  display: grid; place-items: center;
  cursor: pointer;
}
.sheet__grip::before {
  content: "";
  width: 42px; height: 4px;
  border-radius: 999px;
  background: rgba(236, 232, 255, .26);
}

.sheet__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 20px calc(26px + var(--safe-b));
}

/* カード詳細 */
.detail__hero {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 20px;
}
.detail__img {
  width: 116px; aspect-ratio: var(--card-ar);
  border-radius: 7px; overflow: hidden;
  background: #f4efe2;
  box-shadow: 0 8px 26px -10px rgba(0, 0, 0, .9), 0 0 0 1px rgba(217, 184, 119, .34);
}
.detail__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail__img.is-rev img { transform: rotate(180deg); }

.detail__pos {
  font-size: .68rem; letter-spacing: .14em; color: var(--violet);
}
.detail__name {
  margin: 3px 0 2px;
  font-family: var(--serif);
  font-size: 1.28rem; font-weight: 700; letter-spacing: .08em;
  color: var(--gold-hi);
}
.detail__en {
  margin: 0 0 9px;
  font-family: var(--display);
  font-size: .82rem; letter-spacing: .08em; color: var(--ink-3);
}
.detail__tags { display: flex; flex-wrap: wrap; gap: 6px; }
.detail__tags span {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: .66rem; color: var(--ink-2);
}

.detail__sec { margin-bottom: 18px; }
.detail__sec h4 {
  margin: 0 0 7px;
  font-size: .74rem; font-weight: 600; letter-spacing: .16em;
  color: var(--gold);
}
.detail__sec h4.is-rev { color: rgba(240, 170, 170, .92); }
.detail__sec p {
  margin: 0;
  font-size: .85rem; line-height: 1.95; color: var(--ink-2);
}
.detail__kw {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 0 0 9px; padding: 0; list-style: none;
}
.detail__kw li {
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(154, 134, 240, .15);
  border: 1px solid var(--line);
  font-size: .72rem; color: var(--ink);
}
.detail__sec--rev .detail__kw li {
  background: rgba(240, 150, 150, .12);
  border-color: rgba(240, 150, 150, .22);
}

.sheet__title {
  margin: 2px 0 14px;
  font-family: var(--serif);
  font-size: 1.16rem; font-weight: 700; letter-spacing: .1em;
  color: var(--gold-hi);
}

/* ── トースト ────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  z-index: 80;
  translate: -50% 0;
  padding: 11px 22px;
  border-radius: 999px;
  border: 1px solid var(--line-gold);
  background: rgba(18, 14, 46, .95);
  backdrop-filter: blur(8px);
  color: var(--gold-hi);
  font-size: .8rem; letter-spacing: .06em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .26s var(--ease), transform .26s var(--ease);
  transform: translateY(8px);
}
.toast.is-on { opacity: 1; transform: none; }

/* ── 縦が短い画面（ノートPCの横長ウィンドウなど） ────────────
   盤面に回せる高さを稼ぐため、盤面まわりの余白だけを詰める。 */

@media (max-height: 760px) {
  .view--board { gap: 12px; }
  .board__hint { font-size: .78rem; }
  .legend { gap: 4px 5px; }
  .legend span { padding: 2px 9px 2px 3px; font-size: .62rem; }
  .legend b { width: 14px; height: 14px; font-size: .55rem; }
  .board__actions .btn { min-height: 46px; }
  #main { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
}

/* ── 動きを減らす設定への配慮 ────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .slot__inner { transition: none; }
}

/* ── 広い画面 ────────────────────────────────────────────── */

@media (min-width: 620px) {
  #main { padding-left: 24px; padding-right: 24px; }
  .board { --board-max: 500px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .sheet__panel {
    left: 50%; right: auto;
    translate: -50% 0;
    width: min(600px, 100%);
    border-radius: 22px 22px 0 0;
  }
}
