:root {
  color-scheme: dark;
  --bg: #100d0a;
  --panel: #1b1611;
  --panel-2: #241c14;
  --text: #f6efe4;
  --muted: #b9aa95;
  --gold: #c7a55b;
  --gold-2: #e0c886;
  --line: rgba(199, 165, 91, .32);
  --shadow: 0 22px 65px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  background:
    radial-gradient(circle at 50% 0%, rgba(96, 68, 33, .18), transparent 36rem),
    linear-gradient(180deg, #15100c, var(--bg));
  color: var(--text);
}

button, select { font: inherit; }

.white-flash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #fff;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.white-flash.is-active {
  opacity: 1;
  visibility: visible;
}
.white-flash.is-fading {
  opacity: 0;
  visibility: visible;
  transition: opacity .5s ease;
}

body.draw-focus {
  overflow-x: hidden;
}
body.draw-focus .hero,
body.draw-focus .question-panel,
body.draw-focus .result-panel {
  display: none !important;
}
body.draw-focus .app-shell {
  width: min(980px, calc(100% - 20px));
  padding: 10px 0 20px;
}
body.draw-focus .selection-stage {
  margin: 0 auto;
  min-height: calc(100vh - 20px);
}

.app-shell {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
  padding: 36px 0 64px;
}

.hero { text-align: center; margin-bottom: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--gold); letter-spacing: .2em; font-size: .82rem; }
.hero h1 { margin: 0; font-size: clamp(2.2rem, 7vw, 4.4rem); font-weight: 600; letter-spacing: .08em; }
.lead { color: var(--muted); margin: 12px 0 8px; }
.version { display: inline-block; color: var(--muted); font-size: .78rem; }

.panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(36, 28, 20, .96), rgba(24, 19, 14, .96));
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.question-panel { max-width: 760px; margin: 0 auto; padding: 24px; }
.question-panel h2 { margin: 0 0 10px; font-size: 1.08rem; color: var(--gold-2); }
.start-copy { margin: 0 0 14px; color: var(--muted); line-height: 1.7; }
.deck-note { margin: 12px 0 16px; color: var(--muted); font-size: .9rem; }

.primary-button, .secondary-button {
  border-radius: 999px;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease, border-color .16s ease, opacity .16s ease;
}
.primary-button:hover, .secondary-button:hover { transform: translateY(-1px); filter: brightness(1.06); }
.primary-button:active, .secondary-button:active { transform: translateY(0); }
.primary-button:disabled, .secondary-button:disabled { opacity: .65; cursor: not-allowed; transform: none; filter: none; }
.primary-button {
  width: 100%;
  border: 1px solid #e7ce8b;
  background: linear-gradient(180deg, #d8ba73, #987637);
  color: #160f08;
  font-weight: 700;
  padding: 14px 20px;
}
.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  color: var(--text);
  padding: 11px 18px;
}

.theme-selector {
  width: 100%;
  min-height: 48px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(199, 151, 55, 0.45);
  border-radius: 10px;
  background: #0f0c09;
  color: var(--text);
}
.theme-selector:focus { outline: 2px solid rgba(225, 180, 72, 0.35); outline-offset: 2px; }


.selection-stage {
  max-width: 960px;
  padding: clamp(18px, 3vw, 28px);
  text-align: center;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  overflow: hidden;
}
.selection-copy { position: relative; z-index: 5; }
.selection-eyebrow { margin: 0 0 7px; color: var(--gold); letter-spacing: .18em; font-size: .78rem; }
.selection-copy h2 { margin: 0; font-size: clamp(1.45rem, 3.6vw, 2.25rem); }
.selection-text { margin: 10px 0 0; min-height: 1.6em; color: var(--muted); }

/* Ver.1.1r5: 9枚扇状表示の横スワイプ案内 */
.fan-shell {
  position: relative;
  width: 100%;
  min-width: 0;
}

.fan-viewport {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(199,165,91,.35) transparent;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.fan-swipe-arrow {
  position: absolute;
  top: 54%;
  z-index: 95;
  display: grid;
  place-items: center;
  width: 34px;
  height: 52px;
  border: 1px solid rgba(224, 200, 134, .58);
  border-radius: 999px;
  background: rgba(15, 12, 9, .74);
  box-shadow: 0 0 18px rgba(199, 165, 91, .18);
  color: var(--gold-2);
  font-family: Georgia, serif;
  font-size: 2rem;
  line-height: 1;
  opacity: 0;
  transform: translateY(-50%) scale(.92);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  user-select: none;
}
.fan-swipe-left { left: 4px; }
.fan-swipe-right { right: 4px; }
.fan-shell.is-swipe-ready .fan-swipe-arrow.is-visible {
  opacity: .94;
  transform: translateY(-50%) scale(1);
}

.fan-swipe-hint {
  position: absolute;
  left: 50%;
  top: 8px;
  z-index: 94;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border: 1px solid rgba(224, 200, 134, .38);
  border-radius: 999px;
  background: rgba(15, 12, 9, .76);
  box-shadow: 0 6px 18px rgba(0,0,0,.22);
  color: var(--gold-2);
  font-size: .78rem;
  letter-spacing: .04em;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -6px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
  user-select: none;
}
.fan-swipe-hint strong { font-weight: 600; }
.fan-shell.is-swipe-ready.has-horizontal-scroll .fan-swipe-hint {
  opacity: .92;
  transform: translate(-50%, 0);
}
.fan-track {
  position: relative;
  width: 900px;
  height: 500px;
  margin: 0 auto;
  perspective: 1400px;
}
.fan-card {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 122px;
  aspect-ratio: 2 / 3;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  transform-origin: 50% 112%;
  transform: translate(-50%, -50%) translate(0px, 110px) rotate(0deg) scale(.2);
  opacity: 0;
  transition:
    transform .72s cubic-bezier(.18,.8,.2,1),
    opacity .48s ease;
  transition-delay: var(--delay);
  z-index: var(--z);
}
.fan-card.is-dealt {
  transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(1);
  opacity: 1;
}
.fan-card.is-ready {
  transition-delay: 0s;
}
.fan-card.is-dealt.is-ready:not(.is-picked):not(.is-dismissed):hover,
.fan-card.is-dealt.is-ready:not(.is-picked):not(.is-dismissed):focus-visible {
  transform: translate(-50%, -50%) translate(var(--tx), calc(var(--ty) - 14px)) rotate(var(--rot)) scale(1);
  outline: none;
  z-index: 60;
}

.fan-card.is-dealt.is-ready:not(.is-picked):not(.is-dismissed):hover img,
.fan-card.is-dealt.is-ready:not(.is-picked):not(.is-dismissed):focus-visible img {
  border-color: rgba(239, 211, 137, .95);
  box-shadow:
    0 0 0 2px rgba(199,165,91,.20),
    0 0 22px rgba(224,200,134,.24),
    inset 0 0 0 2px rgba(199,165,91,.10);
}

.fan-card.is-picked {
  transform: translate(-50%, -50%) translate(0px, -10px) rotate(0deg) scale(1.34);
  opacity: 1;
  z-index: 80;
  transition-delay: 0s;
  transition-duration: .68s, .42s;
}
.fan-card.is-dismissed {
  transform: translate(-50%, -50%) translate(var(--dismiss-x), calc(var(--ty) + 42px)) rotate(var(--rot)) scale(.78);
  opacity: 0;
  pointer-events: none;
  transition-delay: 0s;
  transition-duration: .58s, .42s;
}
.fan-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid rgba(224,200,134,.6);
  background: #090705;
  box-shadow:
    0 18px 28px rgba(0,0,0,.42),
    inset 0 0 0 2px rgba(199,165,91,.1);
  transition: border-color .18s ease, box-shadow .18s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.chosen-reveal {
  align-self: center;
  justify-self: center;
  padding-top: 14px;
}
.chosen-card-shell {
  width: min(310px, 72vw);
  aspect-ratio: 2 / 3;
  margin: 0 auto;
  perspective: 1600px;
  animation: chosenArrive .48s cubic-bezier(.2,.8,.2,1) both;
}
.chosen-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .82s cubic-bezier(.2,.7,.2,1);
}
.chosen-card-inner.is-flipping { transform: rotateY(180deg); }
.chosen-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(224,200,134,.55);
  background: #0e0b08;
  box-shadow: 0 22px 60px rgba(0,0,0,.5), inset 0 0 0 3px rgba(199,165,91,.08);
}
.chosen-card-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chosen-card-front { transform: rotateY(180deg); }
.chosen-card-front img {
  transform: rotate(0deg);
  transition: transform .58s cubic-bezier(.2,.75,.2,1);
}
.chosen-card-front.is-reversed img { transform: rotate(180deg); }
.reveal-text { margin: 16px 0 0; color: var(--gold-2); min-height: 1.6em; }

@keyframes chosenArrive {
  from { opacity: 0; transform: translateY(30px) scale(.82); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-panel {
  margin-top: 28px;
  padding: clamp(18px, 4vw, 34px);
  display: grid;
  grid-template-columns: minmax(250px, 390px) 1fr;
  gap: clamp(24px, 5vw, 48px);
  align-items: start;
  animation: resultEnter .58s cubic-bezier(.2,.75,.2,1) both;
}
@keyframes resultEnter {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
.card-stage { position: sticky; top: 18px; }
.card-frame {
  position: relative;
  width: min(100%, 390px);
  aspect-ratio: 2 / 3;
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid rgba(224,200,134,.48);
  background: #0e0b08;
  box-shadow: 0 22px 60px rgba(0,0,0,.5), inset 0 0 0 3px rgba(199,165,91,.08);
  overflow: hidden;
}
.card-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 35px rgba(199,165,91,.08);
  z-index: 3;
}
.card-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  border-radius: 17px;
  background: #080604;
  transition: transform .45s ease;
}
.card-frame.is-reversed img { transform: rotate(180deg); }

.missing-image {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  border-radius: 17px;
  background: linear-gradient(135deg, rgba(199,165,91,.08), transparent 55%), #12100d;
  border: 1px dashed rgba(199,165,91,.35);
  color: var(--muted);
  padding: 18px;
}
.missing-image strong { color: var(--gold-2); font-size: 1.25rem; }
.missing-image span { word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }

.result-copy { min-width: 0; }
.orientation { margin: 0 0 8px; color: var(--gold-2); font-weight: 700; letter-spacing: .08em; }
.result-copy h2 { margin: 0; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.2; }
.card-number { margin: 8px 0 12px; color: var(--muted); }
.reading-theme {
  display: inline-block;
  margin: 0 0 12px;
  padding: 7px 12px;
  border: 1px solid rgba(199,165,91,.38);
  border-radius: 999px;
  background: rgba(199,165,91,.07);
  color: var(--gold-2);
  font-size: .9rem;
}
.result-block { border-top: 1px solid rgba(255,255,255,.08); padding: 18px 0 0; margin-top: 18px; }
.result-block h3 { margin: 0 0 8px; color: var(--gold-2); font-size: 1rem; }
.result-block p { margin: 0; line-height: 1.9; }
.cat-comment { margin-top: 22px; padding: 15px 17px; border-left: 3px solid var(--gold); background: rgba(199,165,91,.075); line-height: 1.75; }
.actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 10px; }
.share-note { margin: 12px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.6; }
.share-status {
  min-height: 1.5em;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 760px) {
  .app-shell { padding-top: 22px; }
  body.draw-focus .app-shell { width: min(100% - 10px, 760px); padding-top: 5px; }
  .selection-stage { min-height: calc(100vh - 10px); padding: 16px 6px; border-radius: 14px; }
  .fan-shell { margin-top: 8px; }
  .fan-viewport { margin-top: 0; }
  .fan-track { width: 760px; height: 430px; }
  .fan-swipe-arrow { width: 32px; height: 48px; font-size: 1.85rem; }
  .fan-swipe-left { left: 2px; }
  .fan-swipe-right { right: 2px; }
  .fan-swipe-hint { top: 6px; padding: 6px 11px; font-size: .74rem; }
  .fan-card { width: 104px; top: 55%; }
  .result-panel { grid-template-columns: 1fr; }
  .card-stage { position: static; }
  .card-frame { width: min(82vw, 350px); }
  .chosen-card-shell { width: min(72vw, 290px); }
  .actions > button { flex: 1 1 160px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.fan-card:not(.is-dealt) { pointer-events: none; }

/* Ver.1.1r4: 本体・共有結果ページ共通デザインの自前共有メニュー */
body.share-menu-open { overflow: hidden; }
.share-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  background: rgba(0, 0, 0, .62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.share-menu-backdrop[hidden] { display: none; }
.share-menu {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86vh, 720px);
  overflow-y: auto;
  padding: 16px 18px 18px;
  border: 1px solid rgba(199,165,91,.46);
  border-radius: 24px 24px 16px 16px;
  background: linear-gradient(180deg, rgba(38,29,20,.995), rgba(20,16,12,.995));
  box-shadow: 0 -18px 70px rgba(0,0,0,.55);
  animation: share-menu-rise .22s ease-out;
}
.share-menu-handle {
  width: 48px;
  height: 5px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: rgba(224,200,134,.38);
}
.share-menu-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(199,165,91,.28);
  border-radius: 50%;
  background: rgba(255,255,255,.035);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}
.share-menu-eyebrow { margin: 0 48px 4px 0; color: var(--gold); font-size: .74rem; letter-spacing: .18em; }
.share-menu h2 { margin: 0 48px 7px 0; font-size: clamp(1.45rem, 5vw, 2rem); }
.share-menu-lead { margin: 0 0 16px; color: var(--muted); font-size: .86rem; line-height: 1.65; }
.share-menu-options { display: grid; gap: 10px; }
.share-option {
  width: 100%;
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 11px 13px;
  border: 1px solid rgba(199,165,91,.30);
  border-radius: 16px;
  background: rgba(255,255,255,.035);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
}
.share-option:hover { transform: translateY(-1px); border-color: rgba(224,200,134,.68); background: rgba(199,165,91,.08); }
.share-option:active { transform: translateY(0); }
.share-option:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.share-option-icon {
  flex: 0 0 52px;
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(224,200,134,.28);
  border-radius: 12px;
  background: rgba(0,0,0,.18);
  color: var(--gold-2);
  font-family: system-ui, sans-serif;
  font-size: .82rem;
  font-weight: 800;
}
.share-option-copy { min-width: 0; display: grid; gap: 3px; }
.share-option-copy strong { font-size: .98rem; font-weight: 700; }
.share-option-copy small { color: var(--muted); font-size: .76rem; line-height: 1.45; }
.share-menu-status { min-height: 1.35em; margin: 12px 2px 0; color: var(--gold-2); font-size: .8rem; line-height: 1.55; }
.share-menu-cancel {
  width: 100%;
  margin-top: 10px;
  padding: 10px 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
@keyframes share-menu-rise { from { transform: translateY(28px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (min-width: 761px) {
  .share-menu-backdrop { align-items: center; }
  .share-menu { border-radius: 22px; animation-name: share-menu-pop; }
  @keyframes share-menu-pop { from { transform: translateY(10px) scale(.985); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
}

