/* ============================================================
   デイミツ (Daily Mission) — ゲーム本体（モバイルファースト / PWA）
   トーン: 夜空グラデ＋カードのレア感（ゴールド）＋クリアの緑。
   ============================================================ */

:root {
  --violet:      #6d5efc;   /* テーマ色 */
  --violet-hi:   #8f83ff;
  --violet-lo:   #4e3fd6;
  --gold:        #ffc24d;   /* レア感・報酬 */
  --gold-lo:     #d99a2b;
  --clear:       #3ddc97;   /* クリアの緑 */
  --ink:         #f4f2ff;
  --ink-soft:    #b8b2e0;
  --bg:          #141026;
  --bg-2:        #241a52;
  --surface:     rgba(255, 255, 255, 0.06);
  --surface-2:   rgba(255, 255, 255, 0.10);
  --border:      rgba(255, 255, 255, 0.14);
  --danger:      #ff6b8a;

  --radius-sm: 8px;
  --radius:    16px;
  --radius-lg: 26px;
  --shadow:    0 24px 60px rgba(8, 4, 30, 0.55);

  --font: "Hiragino Kaku Gothic ProN", "Noto Sans JP", system-ui, -apple-system,
          "Segoe UI", Roboto, sans-serif;

  /* レアリティ色 */
  --r-n:  #9aa7c7;
  --r-r:  #8f83ff;
  --r-sr: #ffc24d;
  --r-ur: #3ddc97;
}

/* 切り替え要素の hidden を確実に効かせる（display:flex に負けない） */
[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, var(--bg-2) 0%, var(--bg) 60%) fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

/* ---- スキップリンク / フォーカス ---- */
.skip-link {
  position: fixed;
  top: -60px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--violet);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: top .18s ease;
}
.skip-link:focus,
.skip-link:focus-visible { top: 12px; outline: 3px solid var(--gold); outline-offset: 2px; }

:where(button, input, a, [tabindex]):focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ---- 共通ボタン ---- */
.btn {
  padding: 12px 18px;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  color: #fff;
  background: var(--surface-2);
}
.btn--primary {
  background: linear-gradient(120deg, var(--violet-lo), var(--violet) 60%, var(--violet-hi));
  box-shadow: 0 10px 26px rgba(109, 94, 252, 0.45);
}
.btn--gold {
  color: #3a2a00;
  background: linear-gradient(120deg, var(--gold-lo), var(--gold));
  box-shadow: 0 8px 20px rgba(255, 194, 77, 0.35);
}
.btn--ghost {
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
}
.btn--danger { color: var(--danger); border-color: rgba(255, 107, 138, 0.4); }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }

/* ============================================================
   合言葉ゲート
   ============================================================ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.gate__card {
  width: min(420px, 100%);
  padding: 34px 28px 30px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
  backdrop-filter: blur(10px);
}

.gate__badge {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--gold);
}

.gate__title {
  margin: 0 0 6px;
  font-size: clamp(28px, 7vw, 38px);
  font-weight: 900;
  background: linear-gradient(120deg, var(--ink), var(--violet-hi) 55%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.gate__lead { margin: 0 0 22px; color: var(--ink-soft); font-size: 15px; }
.gate__form { text-align: left; }
.gate__label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.gate__inputrow { display: flex; gap: 8px; }
.gate__input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  font: inherit;
  font-size: 16px; /* iOS のズーム防止 */
  color: var(--ink);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  -webkit-text-security: disc;   /* type=text のまま伏せ字（IME を殺さない） */
}
.gate__input.is-revealed { -webkit-text-security: none; }
.gate__toggle {
  flex: 0 0 auto;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.gate__toggle[aria-pressed="true"] { color: var(--ink); background: var(--surface-2); }
.gate__error {
  min-height: 1.2em;
  margin: 10px 2px 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
}
.gate__submit {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(120deg, var(--violet-lo), var(--violet) 60%, var(--violet-hi));
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(109, 94, 252, 0.45);
}
.gate__submit[disabled] { opacity: .6; cursor: progress; }

/* ============================================================
   アプリシェル
   ============================================================ */
.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(76px + env(safe-area-inset-bottom));
}

.app__head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 2px 12px;
}
.app__title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(120deg, var(--ink), var(--violet-hi) 55%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.app__date { margin: 0; flex: 1; font-size: 12px; color: var(--ink-soft); }
.app__tickets {
  margin: 0;
  padding: 4px 12px;
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(255, 194, 77, 0.1);
  border: 1px solid rgba(255, 194, 77, 0.3);
  border-radius: 999px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.view__h { margin: 18px 0 10px; font-size: 15px; font-weight: 800; color: var(--ink-soft); }
.view__sub { font-size: 13px; color: var(--gold); margin-left: 6px; }

/* ---- ホーム: きょうのミッション ---- */
.hero {
  margin-top: 12px;
  padding: 26px 20px 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.hero__label {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .18em;
  color: var(--gold);
}
.hero__label--clear { color: var(--clear); letter-spacing: .06em; }
.hero__icon { margin: 0; font-size: 64px; line-height: 1.2; }
.hero__name { margin: 6px 0 6px; font-size: 24px; font-weight: 900; }
.hero__desc { margin: 0 0 18px; font-size: 14px; color: var(--ink-soft); line-height: 1.7; }
.hero__play { width: min(300px, 100%); padding: 16px; font-size: 16px; animation: claim-pulse 1.6s ease-in-out infinite; }
@keyframes claim-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.hero__note { margin: 14px 0 0; font-size: 12px; color: var(--ink-soft); }
.hero__reward { display: flex; justify-content: center; margin: 12px 0 4px; }
.hero__poster { width: 33%; max-width: 120px; }
.hero.is-cleared {
  background: linear-gradient(180deg, #646773, #474a55);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 18px 42px rgba(8, 4, 30, 0.35);
}
.hero.is-cleared .hero__label--clear { color: #f1f2f4; }
.hero__cleared-message {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 800;
  color: #f1f2f4;
}
.hero.is-cleared .hero__note { color: #d5d7de; }
.hero__tap { display: block; width: 100%; padding: 0; background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.home__streak {
  margin: 14px 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
}
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- ミニゲーム画面 ---- */
.mg {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 90% at 50% -10%, var(--bg-2) 0%, var(--bg) 60%) fixed;
}
.mg__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 14px;
}
.mg__name { margin: 0; font-size: 18px; font-weight: 900; }
.mg__root {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
  text-align: center;
}
.mg__status { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.7; }
.mg__status b { color: var(--gold); }

/* ナンバータッチ */
.mg-numgrid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: min(360px, 100%);
}
.mg-num {
  padding: 14px 0;
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.mg-num.is-done {
  color: var(--clear);
  background: rgba(61, 220, 151, 0.12);
  border-color: rgba(61, 220, 151, 0.45);
}
.mg-numbers__time {
  margin: 0;
  font-size: 42px;
  font-weight: 900;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.mg-numbers__time.is-warning { color: var(--danger); }
.mg-numbers__countdown {
  min-height: 1.2em;
  margin: -8px 0 0;
  font-size: 32px;
  font-weight: 900;
  color: var(--gold);
}
.mg-num:disabled:not(.is-done) {
  opacity: .45;
  cursor: not-allowed;
}
.mg-num.is-miss { animation: shake .25s ease; border-color: var(--danger); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* もぐらタッチ */
.mg-molegrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(340px, 100%);
}
.mg-hole {
  aspect-ratio: 1;
  font: inherit;
  font-size: 40px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mg-hole.is-up { background: rgba(255, 194, 77, 0.14); border-color: rgba(255, 194, 77, 0.5); }

/* れんだチャレンジ */
.mg-rush__time { margin: 0; font-size: 40px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
.mg-rush__btn {
  width: min(280px, 80vw);
  aspect-ratio: 1;
  font: inherit;
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, var(--violet-hi), var(--violet-lo));
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 14px 40px rgba(109, 94, 252, 0.5);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.mg-rush__btn:active { transform: scale(.96); }
.mg-rush__btn span { display: block; font-size: 30px; }

/* ぴったりストップ */
.mg-stop__time { margin: 0; font-size: 56px; font-weight: 900; font-variant-numeric: tabular-nums; }
.mg-stop__btn { width: min(280px, 100%); padding: 18px; font-size: 18px; touch-action: manipulation; }
.mg-stop__time.is-running { color: var(--gold); text-shadow: 0 0 24px rgba(255, 194, 77, 0.45); }

/* ---- ミニゲーム演出（MgFx）: 表示専用レイヤー。操作は全て透過 ---- */
.mgfx__canvas,
.mgfx__pops {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.mgfx__canvas { z-index: 55; }
.mgfx__pops { z-index: 56; }

/* ふきだし文字（+1・ほめことば） */
.mgfx-pop {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: 18px;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(8, 4, 30, 0.8);
  white-space: nowrap;
  animation: mgfx-rise .85s ease-out forwards;
}
.mgfx-pop--praise { font-size: 24px; color: var(--clear); }
.mgfx-pop--count { color: var(--ink); }
.mgfx-pop--fever {
  font-size: 28px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 194, 77, 0.9);
}
@keyframes mgfx-rise {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  18%  { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* 中央ドーンのバナー（クリア！・PERFECT!! など） */
.mgfx-banner {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  margin: 0;
  font-weight: 900;
  font-size: 44px;
  letter-spacing: .04em;
  color: var(--gold);
  text-shadow: 0 0 28px rgba(255, 194, 77, 0.65), 0 4px 18px rgba(8, 4, 30, 0.9);
  white-space: nowrap;
  animation: mgfx-bang 1.4s cubic-bezier(.2, 1.4, .4, 1) forwards;
}
.mgfx-banner--clear { font-size: 52px; }
.mgfx-banner--sub {
  top: 50%;
  font-size: 20px;
  color: var(--ink);
  text-shadow: 0 2px 12px rgba(8, 4, 30, 0.9);
  white-space: normal;
  width: max-content;
  max-width: 88vw;
  text-align: center;
}
.mgfx-banner--miss { color: var(--danger); text-shadow: 0 0 22px rgba(255, 107, 138, 0.6), 0 4px 18px rgba(8, 4, 30, 0.9); }
.mgfx-banner--perfect {
  background: linear-gradient(90deg, #ffc24d, #ff6b8a, #8f83ff, #3ddc97);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(255, 194, 77, 0.8));
}
.mgfx-banner--great { color: var(--violet-hi); text-shadow: 0 0 26px rgba(143, 131, 255, 0.7); }
.mgfx-banner--ok { color: var(--clear); text-shadow: 0 0 26px rgba(61, 220, 151, 0.6); }
@keyframes mgfx-bang {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(2.6); }
  22%  { opacity: 1; transform: translate(-50%, -50%) scale(.92); }
  32%  { transform: translate(-50%, -50%) scale(1.06); }
  42%  { transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -58%) scale(1.02); }
}

/* 全画面フラッシュ */
.mgfx-flash {
  position: absolute;
  inset: 0;
  animation: mgfx-flash ease-out forwards;
}
@keyframes mgfx-flash {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* 画面シェイク（強さ3段階） */
.is-mgshake-1 { animation: mgfx-shake1 .3s ease; }
.is-mgshake-2 { animation: mgfx-shake2 .4s ease; }
.is-mgshake-3 { animation: mgfx-shake3 .45s ease; }
@keyframes mgfx-shake1 {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-2px, -2px); }
}
@keyframes mgfx-shake2 {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(8px, -5px); }
  60% { transform: translate(-6px, -3px); }
  80% { transform: translate(5px, 3px); }
}
@keyframes mgfx-shake3 {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-12px, 6px) rotate(-.5deg); }
  35% { transform: translate(12px, -8px) rotate(.5deg); }
  55% { transform: translate(-9px, -5px); }
  75% { transform: translate(8px, 5px); }
}

/* 雰囲気モード: フィーバー（れんだ15回〜）と残りわずか警告 */
.mg.is-mgfever { animation: mgfx-fever 1s ease-in-out infinite; }
@keyframes mgfx-fever {
  0%, 100% { background-color: rgba(255, 194, 77, 0); }
  50% { background-color: rgba(255, 194, 77, 0.08); }
}
.mg.is-mgwarn { animation: mgfx-warn .5s ease-in-out infinite; }
@keyframes mgfx-warn {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 107, 138, 0); }
  50% { box-shadow: inset 0 0 60px 8px rgba(255, 107, 138, 0.25); }
}

/* ワンショットの部品アニメ */
.is-zoom { animation: mgfx-zoom .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes mgfx-zoom {
  0% { transform: scale(2.4); opacity: .2; }
  100% { transform: scale(1); opacity: 1; }
}
.is-beat { animation: mgfx-beat .3s ease; }
@keyframes mgfx-beat {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.25); }
}
.mg-num.is-pop { animation: mgfx-numpop .35s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes mgfx-numpop {
  0% { transform: scale(1); }
  45% { transform: scale(1.25) rotate(3deg); }
  100% { transform: scale(1); }
}
.mg-hole.is-up { animation: mgfx-moleup .3s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes mgfx-moleup {
  0% { transform: scale(.7); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.mg-hole.is-hit { animation: mgfx-squish .35s ease; }
@keyframes mgfx-squish {
  0% { transform: scale(1); }
  35% { transform: scale(1.15, .7); }
  70% { transform: scale(.92, 1.08); }
  100% { transform: scale(1); }
}
.mg-rush__btn.is-tap { animation: mgfx-tap .22s ease; }
@keyframes mgfx-tap {
  0% { transform: scale(1); box-shadow: 0 14px 40px rgba(109, 94, 252, 0.5); }
  40% { transform: scale(.9); box-shadow: 0 6px 24px rgba(109, 94, 252, 0.8), 0 0 34px rgba(143, 131, 255, 0.6); }
  100% { transform: scale(1); box-shadow: 0 14px 40px rgba(109, 94, 252, 0.5); }
}
.mg.is-mgfever .mg-rush__btn {
  box-shadow: 0 14px 46px rgba(255, 194, 77, 0.55), 0 0 40px rgba(255, 194, 77, 0.35);
  border-color: rgba(255, 194, 77, 0.6);
}

/* 動きを減らす設定では FX のアニメを止める（Canvas 粒は JS 側で削減） */
@media (prefers-reduced-motion: reduce) {
  .mgfx-pop, .mgfx-banner { animation: mgfx-fade 1.1s ease forwards; }
  @keyframes mgfx-fade {
    0% { opacity: 0; }
    15%, 75% { opacity: 1; }
    100% { opacity: 0; }
  }
  .is-mgshake-1, .is-mgshake-2, .is-mgshake-3,
  .mg.is-mgfever, .mg.is-mgwarn,
  .is-zoom, .is-beat, .mg-num.is-pop, .mg-hole.is-hit, .mg-rush__btn.is-tap { animation: none; }
}

/* ---- 広告バナー（クリア後に下部へ・見ると消える） ---- */
.adb {
  position: fixed;
  left: 50%;
  bottom: calc(64px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 25;
  width: min(560px, 100%);
  padding: 0 8px;
}
.adb__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: linear-gradient(180deg, #fffef8, #f3edd9);
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(8, 4, 30, 0.45);
  animation: adb-in .35s ease;
}
@keyframes adb-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.adb__tag {
  flex: 0 0 auto;
  padding: 2px 6px;
  font-size: 9px;
  font-weight: 900;
  color: #6b6b6b;
  border: 1px solid #b5b5b5;
  border-radius: 4px;
  background: #fff;
}
.adb__emoji { font-size: 28px; }
.adb__body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adb__name { font-size: 13px; font-weight: 900; color: #2a2416; }
.adb__copy { font-size: 11px; color: #6f6547; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.adb__cta {
  flex: 0 0 auto;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 900;
  color: #3a2a00;
  background: linear-gradient(120deg, var(--gold-lo), var(--gold));
  border-radius: 8px;
}

/* ============================================================
   ポスターカード（映画ポスター風フレーム）— 図鑑/演出/詳細で共通
   絵(art or 絵文字)＋箔＋枠＋タイトル帯。レア度(tier)で質感が段階変化。
   ============================================================ */
.poster {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(160deg, #2a3350, #12162b);
  box-shadow: 0 10px 30px rgba(6, 3, 24, 0.5);
  user-select: none;
  -webkit-user-select: none;
}
.poster--common    { background: linear-gradient(160deg, #2a3350, #12162b); }
.poster--rare      { background: linear-gradient(160deg, #2b2a63, #141034); }
.poster--epic      { background: linear-gradient(160deg, #3a2f4e, #1a1330); }
.poster--legendary { background: linear-gradient(160deg, #3b2f22, #1a1330); }

.poster__art {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.poster__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.poster__emoji { font-size: clamp(38px, 22cqw, 96px); filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5)); }
.poster { container-type: inline-size; }

/* 箔（epic/legendary のみ・斜めに走る光） */
.poster__foil { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 1; }
.poster--epic .poster__foil,
.poster--legendary .poster__foil {
  opacity: 1;
  mix-blend-mode: screen;
  background: linear-gradient(115deg, transparent 22%, rgba(255,255,255,.16) 38%, rgba(180,220,255,.12) 46%, transparent 60%);
  background-size: 300% 300%;
  animation: foil-move 4.5s ease-in-out infinite;
}
.poster--legendary .poster__foil {
  background: linear-gradient(115deg, transparent 16%, rgba(255,120,200,.16) 30%, rgba(120,200,255,.16) 42%, rgba(255,230,140,.2) 52%, transparent 66%);
  background-size: 300% 300%;
}
@keyframes foil-move { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* 枠（レア度で色・発光） */
.poster__frame { position: absolute; inset: 0; border-radius: 14px; pointer-events: none; z-index: 2; }
.poster--common .poster__frame    { box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.poster--rare .poster__frame      { box-shadow: inset 0 0 0 1.5px rgba(143,131,255,.7), inset 0 0 22px rgba(143,131,255,.25); }
.poster--epic .poster__frame      { box-shadow: inset 0 0 0 2px rgba(255,194,77,.8), inset 0 0 26px rgba(255,194,77,.28); }
.poster--legendary .poster__frame { box-shadow: inset 0 0 0 2px rgba(255,216,120,.9), inset 0 0 34px rgba(255,180,80,.4); }
.poster--legendary { animation: leg-glow 3s ease-in-out infinite; }
@keyframes leg-glow {
  0%, 100% { box-shadow: 0 10px 30px rgba(6,3,24,.5), 0 0 0 rgba(255,194,77,0); }
  50%      { box-shadow: 0 10px 30px rgba(6,3,24,.5), 0 0 26px rgba(255,194,77,.4); }
}

/* タイトル帯（下部スクリム） */
.poster__scrim {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2;
  padding: 34% 10px 9px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  background: linear-gradient(to top, rgba(6,3,20,.95) 0%, rgba(6,3,20,.72) 42%, rgba(6,3,20,0) 100%);
}
.poster__series { font-size: 7px; letter-spacing: .28em; font-weight: 800; color: rgba(255,255,255,.55); }
.poster__title { font-size: clamp(11px, 8.5cqw, 17px); font-weight: 900; line-height: 1.2; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.poster__meta { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.poster__rarity { font-size: 8px; font-weight: 900; padding: 1px 7px; border-radius: 999px; color: #10102a; white-space: nowrap; }
.poster__rarity--common    { background: #9aa7c7; }
.poster__rarity--rare      { background: #8f83ff; color: #fff; }
.poster__rarity--epic      { background: linear-gradient(120deg, #ffd873, #ffb43d); }
.poster__rarity--legendary { background: linear-gradient(120deg, #fff0b8, #ffc24d 50%, #ff8a3d); }
.poster__no { font-size: 8px; color: rgba(255,255,255,.6); font-variant-numeric: tabular-nums; letter-spacing: .04em; }

/* バッジ */
.poster__new {
  position: absolute; top: 6px; left: 6px; z-index: 3;
  padding: 2px 7px; font-size: 9px; font-weight: 900; color: #3a2a00;
  background: linear-gradient(120deg, #ffd873, #ffb43d);
  border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.poster__fav { position: absolute; top: 5px; right: 8px; z-index: 3; font-size: 15px; color: #ffc24d; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.poster__count {
  position: absolute; right: 7px; bottom: 7px; z-index: 3;
  padding: 1px 6px; font-size: 9px; font-weight: 800; color: #fff;
  background: rgba(0,0,0,.55); border-radius: 999px;
}

/* 未獲得（シルエット＋通し番号＋短いヒント） */
.poster--locked { background: linear-gradient(160deg, #1a1a2e, #0e0e1c); }
.poster--locked .poster__silh { font-size: clamp(40px, 26cqw, 96px); font-weight: 900; color: rgba(255,255,255,.12); }
.poster__title--locked { color: rgba(255,255,255,.42); letter-spacing: .18em; }
.poster__hint { font-size: 8px; color: rgba(255,255,255,.4); line-height: 1.4; margin-top: 2px; }

/* ---- 図鑑（コレクション） ---- */
.zukan__bars { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.zukan__progress { display: flex; align-items: center; gap: 10px; }
.zukan__meter { flex: 1; height: 8px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.zukan__meterfill { height: 100%; background: linear-gradient(90deg, var(--violet), var(--gold)); border-radius: 999px; transition: width .5s ease; }
.zukan__pct { font-size: 12px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px;
  font: inherit; font-size: 12px; font-weight: 800;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.is-on { color: #10102a; background: var(--gold); border-color: transparent; }
.chip--sort { margin-left: auto; }

.zukan__h { margin: 16px 0 8px; font-size: 13px; font-weight: 800; color: var(--ink-soft); display: flex; align-items: baseline; gap: 8px; }
.zukan__h small { font-size: 11px; font-weight: 700; color: rgba(184,178,224,.65); }
.zukan__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.zukan__empty { padding: 24px 8px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.zukan__cell {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 12px;
}
.zukan__cell[disabled] { cursor: default; }
.zukan__cell:not([disabled]):active { transform: scale(.97); }
@media (min-width: 460px) { .zukan__grid { grid-template-columns: repeat(4, 1fr); } }

/* ============================================================
   カード獲得演出（reveal.js が制御する専用画面）
   ============================================================ */
.reveal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 40%, rgba(20, 10, 45, 0.9), rgba(4, 2, 14, 0.97));
  --aura: #8f83ff;
  --glow: 16px;
  animation: reveal-in .3s ease;
}
@keyframes reveal-in { from { opacity: 0; } to { opacity: 1; } }
.reveal.is-blackout { background: #000; }
.reveal.is-blackout .reveal__fx,
.reveal.is-blackout .reveal__rays { opacity: 0; }

.reveal__fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; }
.reveal__rays {
  position: absolute; inset: -30%;
  z-index: 0; pointer-events: none;
  background: repeating-conic-gradient(from 0deg at 50% 42%, rgba(255,216,120,.15) 0deg 5deg, transparent 5deg 20deg);
  filter: blur(2px);
  opacity: .55;
  animation: rays-spin 18s linear infinite;
}
@keyframes rays-spin { to { transform: rotate(360deg); } }

.reveal__skip {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  z-index: 5;
  padding: 8px 14px;
  font: inherit; font-size: 12px; font-weight: 800;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.reveal__stage {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

/* 溜めの種火 */
.reveal__orb {
  display: none;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, #fff, var(--aura) 45%, transparent 72%);
  box-shadow: 0 0 60px var(--aura);
  animation: orb-pulse .9s ease-in-out infinite;
}
.reveal.is-charging .reveal__orb { display: block; }
.reveal--epic .reveal__orb { width: 150px; height: 150px; }
.reveal--legendary .reveal__orb { width: 184px; height: 184px; animation-duration: .6s; }
@keyframes orb-pulse { 0%, 100% { transform: scale(.72); opacity: .7; } 50% { transform: scale(1.08); opacity: 1; } }

/* legendary の紋章 */
.reveal__sigil {
  position: absolute; top: 34%; left: 50%;
  z-index: 2; pointer-events: none;
  font-size: 130px; color: var(--aura);
  text-shadow: 0 0 34px var(--aura);
  opacity: 0; transform: translate(-50%, -50%) scale(.4);
}
.reveal__sigil.is-on { animation: sigil-in 1.7s ease forwards; }
@keyframes sigil-in {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.3) rotate(-40deg); }
  40% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.7) rotate(20deg); }
}

/* 公開されるカード */
.reveal__cardwrap { width: min(64vw, 300px); opacity: 0; transform: scale(.6) translateY(10px); }
.reveal__cardwrap.is-in { animation: card-pop .5s cubic-bezier(.2, .8, .3, 1.2) forwards; }
@keyframes card-pop { to { opacity: 1; transform: scale(1) translateY(0); } }
.reveal__card { filter: drop-shadow(0 0 var(--glow) var(--aura)); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.reveal.is-charging .reveal__cardwrap { display: none; }

.reveal__label { margin: 0; font-size: 15px; font-weight: 900; color: #fff; letter-spacing: .05em; opacity: 0; transform: translateY(8px); }
.reveal__label.is-in { animation: label-in .4s ease forwards; }
@keyframes label-in { to { opacity: 1; transform: none; } }
.reveal__new { margin: 0; font-size: 18px; font-weight: 900; color: var(--gold); animation: claim-pulse 1s ease-in-out infinite; }
.reveal__actions { display: flex; gap: 10px; }

/* ============================================================
   カード詳細（大きく見せる・裏返し・メタ情報・シェア）
   ============================================================ */
.cd {
  width: min(440px, 94vw);
  max-height: 92dvh;
  padding: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #1d1640, #120d2a);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.cd::backdrop { background: rgba(6, 3, 20, 0.78); backdrop-filter: blur(3px); }
.cd__scroll { max-height: 92dvh; overflow-y: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.cd__x {
  position: absolute; top: 10px; right: 10px; z-index: 4;
  width: 34px; height: 34px;
  font: inherit; font-size: 15px; color: var(--ink);
  background: rgba(0,0,0,.4);
  border: 1px solid var(--border);
  border-radius: 10px; cursor: pointer;
}
.cd__flip {
  width: min(66vw, 240px);
  margin: 8px auto 16px;
  aspect-ratio: 2 / 3;
  perspective: 1100px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cd__face {
  position: absolute; inset: 0;
  border-radius: 14px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform .6s cubic-bezier(.2, .7, .3, 1.05);
}
.cd__flipbox { position: relative; width: 100%; height: 100%; }
.cd__front { transform: rotateY(0deg); }
.cd__back {
  transform: rotateY(180deg);
  display: flex; align-items: center; justify-content: center;
  padding: 22px 18px;
  background: linear-gradient(160deg, var(--bg-2), var(--bg));
  border: 1px solid var(--border);
}
.cd__flip.is-flipped .cd__front { transform: rotateY(-180deg); }
.cd__flip.is-flipped .cd__back { transform: rotateY(0deg); }
.cd__story { margin: 0; font-size: 13px; line-height: 1.9; color: var(--ink); text-align: left; }
.cd__fliphint { margin: -8px 0 14px; font-size: 11px; color: var(--ink-soft); text-align: center; }

.cd__name { margin: 0 0 6px; font-size: 20px; font-weight: 900; text-align: center; }
.cd__sub { margin: 0 0 14px; display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; }
.cd__kind { font-size: 11px; font-weight: 700; color: var(--ink-soft); }
.cd__desc { margin: 0 0 14px; font-size: 13px; line-height: 1.8; color: var(--ink); text-align: center; }
.cd__meta { margin: 0 0 16px; display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; }
.cd__meta dt { font-size: 11px; color: var(--ink-soft); }
.cd__meta dd { margin: 0; font-size: 12px; font-weight: 700; text-align: right; word-break: break-word; }
.cd__meta dd a { color: var(--violet-hi); }
.cd__row { display: flex; gap: 10px; }
.cd__row .btn { flex: 1; }
.cd__fav.is-on { color: #10102a; background: linear-gradient(120deg, var(--gold-lo), var(--gold)); border-color: transparent; }

/* ---- ダイアログ共通 ---- */
.dlg {
  width: min(420px, 92vw);
  padding: 20px;
  color: var(--ink);
  background: linear-gradient(180deg, #1d1640, #150f30);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}
.dlg::backdrop { background: rgba(8, 4, 24, 0.66); backdrop-filter: blur(2px); }
.dlg__title { margin: 0 0 14px; font-size: 17px; font-weight: 800; }
.dlg__hint { margin: 12px 0; font-size: 12px; color: var(--ink-soft); }
.dlg__row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

/* ---- 広告ビューア ---- */
.ad__label {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .2em;
  color: var(--ink-soft);
}
.ad__emoji { margin: 0; font-size: 64px; }
.ad__name { margin: 6px 0 4px; font-size: 20px; font-weight: 900; }
.ad__copy { margin: 0 0 16px; font-size: 14px; color: var(--gold); font-weight: 700; }
.ad__bar { height: 10px; background: rgba(0, 0, 0, 0.35); border-radius: 999px; overflow: hidden; }
.ad__fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--clear)); }

/* ---- せってい ---- */
.settings { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.settings .btn { width: 100%; text-align: center; }
.settings__group {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.settings__label { margin: 0 0 10px; font-size: 13px; font-weight: 800; }
.settings__group .chips { justify-content: flex-start; }
.settings__hint { margin: 10px 0 0; font-size: 11px; color: var(--ink-soft); line-height: 1.6; }
.settings__version {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  user-select: none;
  -webkit-user-select: none;
}
.settings__note { margin: 4px 0 0; font-size: 11px; color: var(--ink-soft); line-height: 1.7; }

.site__footer { margin-top: 40px; text-align: center; }
.site__copy {
  margin: 0;
  font-size: 13px;
  color: rgba(184, 178, 224, 0.7);
  user-select: none;
  -webkit-user-select: none;
}

/* ---- チートパネル（設定画面に常時表示） ---- */
.settings__cheat { text-align: left; border-color: rgba(255, 194, 77, 0.3); }
.cheat__grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.cheat__grid .btn { padding: 10px 8px; font-size: 12px; }
.cheat__h { margin: 16px 0 2px; font-size: 12px; font-weight: 800; color: var(--gold); text-align: left; }
.cheat__row { display: flex; gap: 8px; margin-top: 8px; }
.cheat__select {
  flex: 1; min-width: 0;
  padding: 10px 8px;
  font: inherit; font-size: 13px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.cheat__row .btn { flex: 0 0 auto; width: auto; } /* .settings .btn の width:100% に勝つ */
.cheat__note { margin: 12px 0 0; font-size: 12px; color: var(--ink-soft); }

/* ---- トースト ---- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(400px, 92vw);
  pointer-events: none;
}
.toast {
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 700;
  background: linear-gradient(180deg, #262052, #1b1540);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: toast-in .25s ease;
}
.toast b { color: var(--gold); }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: all .35s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---- タブバー ---- */
.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 30;
  width: min(560px, 100%);
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(16, 12, 38, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.tabbar__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tabbar__btn span { font-size: 20px; }
.tabbar__btn.is-active { color: var(--gold); background: rgba(255, 194, 77, 0.08); }

/* ============================================================
   管理パネル
   ============================================================ */
.admin {
  width: min(560px, 92vw);
  max-height: 86dvh;
  padding: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #1d1640, #150f30);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.admin::backdrop { background: rgba(8, 4, 24, 0.66); backdrop-filter: blur(2px); }
.admin__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.admin__title { margin: 0; font-size: 17px; font-weight: 800; }
.admin__close {
  width: 34px; height: 34px;
  font: inherit; font-size: 15px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
.admin__mock { margin: 0; padding: 10px 18px; font-size: 12px; color: var(--gold); background: rgba(255,194,77,.08); }
.admin__body { padding: 18px; overflow-y: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.stat {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.stat__k { margin: 0 0 4px; font-size: 12px; color: var(--ink-soft); }
.stat__v { margin: 0; font-size: 24px; font-weight: 900; }

.admin h3 { margin: 18px 0 10px; font-size: 13px; color: var(--ink-soft); font-weight: 700; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 96px; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.bars__bar { width: 100%; min-height: 2px; background: linear-gradient(180deg, var(--violet-hi), var(--violet-lo)); border-radius: 4px 4px 0 0; }
.bars__col[aria-selected="true"] .bars__bar { background: linear-gradient(180deg, var(--gold), #d99a2b); }
.bars__lbl { font-size: 9px; color: var(--ink-soft); }

.rows { display: flex; flex-direction: column; gap: 6px; }
.row { display: grid; grid-template-columns: 5.5em 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.row__meter { height: 8px; background: var(--surface); border-radius: 999px; overflow: hidden; }
.row__fill { height: 100%; background: var(--violet); border-radius: 999px; }
.row__n { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.hash-box {
  margin-top: 8px;
  padding: 12px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  word-break: break-all;
  color: var(--ink-soft);
  background: rgba(0,0,0,.3);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* ============================================================
   モーション配慮
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
