:root {
  --bg: #0b1430;
  --bg2: #16224a;
  --silver: #d2d6e0;
  --gold: #d8b46a;
  --text: #efe6d6;
  --muted: #b8a991;
  --line: rgba(216, 180, 106, .3);
}
* { box-sizing: border-box; }
html { background: var(--bg); }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 120% 900px at top, #1d2e5e, var(--bg) 70%) no-repeat, var(--bg);
  color: var(--text);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
}
.site-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px 46px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='32'%3E%0A%3Crect width='80' height='32' fill='%23070c20'/%3E%0A%3Cg fill='none' stroke='%23d2d6e0' stroke-linecap='round'%3E%0A%3Cpath d='M0 1.2H80M0 30.8H80' stroke-width='1.6'/%3E%0A%3Cpath d='M0 4.3H80M0 27.7H80' stroke-width='.8' stroke-dasharray='1.8 1.4' opacity='.75'/%3E%0A%3Cpath d='M0 16C10 6 30 6 40 16S70 26 80 16' stroke-width='1.7'/%3E%0A%3Cpath d='M20 8.6c-4.5 2-4.5 7.6 0 8c3.2.3 4.2-3.4 1.4-4.2' stroke-width='1.3'/%3E%0A%3Cpath d='M60 23.4c4.5-2 4.5-7.6 0-8c-3.2-.3-4.2 3.4-1.4 4.2' stroke-width='1.3'/%3E%0A%3C/g%3E%0A%3Cg fill='%23d2d6e0'%3E%0A%3Cpath d='M31 10.8q2.5-5.8 7.6-5.6q-1.6 5-7.6 5.6z'/%3E%0A%3Cpath d='M49 21.2q-2.5 5.8-7.6 5.6q1.6-5 7.6-5.6z'/%3E%0A%3Cpath d='M9 10.8q-2.5-5.8-7.6-5.6q1.6 5 7.6 5.6z' opacity='.0'/%3E%0A%3Ccircle cx='0' cy='8' r='1.5'/%3E%3Ccircle cx='80' cy='8' r='1.5'/%3E%3Ccircle cx='40' cy='24' r='1.5'/%3E%0A%3Ccircle cx='-2.6' cy='8' r='.8'/%3E%3Ccircle cx='2.6' cy='8' r='.8'/%3E%3Ccircle cx='77.4' cy='8' r='.8'/%3E%3Ccircle cx='0' cy='5.4' r='.8'/%3E%3Ccircle cx='80' cy='5.4' r='.8'/%3E%3Ccircle cx='37.4' cy='24' r='.8'/%3E%3Ccircle cx='42.6' cy='24' r='.8'/%3E%3Ccircle cx='40' cy='26.6' r='.8'/%3E%0A%3C/g%3E%0A%3C/svg%3E") repeat-x left bottom, linear-gradient(#060a1c, #08102a);
  box-shadow: 0 3px 8px rgba(0, 0, 0, .45);
}

.logo { color: var(--gold); letter-spacing: .15em; }
.proto { font-size: 12px; color: var(--muted); }
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-weight: normal; color: var(--gold); font-size: 22px; text-align: center; margin: 12px 0; }
.lead { text-align: center; color: var(--muted); margin: 8px 0 16px; }
.msg { text-align: center; margin: 4px 0 12px; min-height: 1.6em; line-height: 1.6; }
footer {
  text-align: center; font-size: 11px; color: var(--muted); padding: 46px 16px 16px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='32'%3E%0A%3Crect width='80' height='32' fill='%23070c20'/%3E%0A%3Cg fill='none' stroke='%23d2d6e0' stroke-linecap='round'%3E%0A%3Cpath d='M0 1.2H80M0 30.8H80' stroke-width='1.6'/%3E%0A%3Cpath d='M0 4.3H80M0 27.7H80' stroke-width='.8' stroke-dasharray='1.8 1.4' opacity='.75'/%3E%0A%3Cpath d='M0 16C10 6 30 6 40 16S70 26 80 16' stroke-width='1.7'/%3E%0A%3Cpath d='M20 8.6c-4.5 2-4.5 7.6 0 8c3.2.3 4.2-3.4 1.4-4.2' stroke-width='1.3'/%3E%0A%3Cpath d='M60 23.4c4.5-2 4.5-7.6 0-8c-3.2-.3-4.2 3.4-1.4 4.2' stroke-width='1.3'/%3E%0A%3C/g%3E%0A%3Cg fill='%23d2d6e0'%3E%0A%3Cpath d='M31 10.8q2.5-5.8 7.6-5.6q-1.6 5-7.6 5.6z'/%3E%0A%3Cpath d='M49 21.2q-2.5 5.8-7.6 5.6q1.6-5 7.6-5.6z'/%3E%0A%3Cpath d='M9 10.8q-2.5-5.8-7.6-5.6q1.6 5 7.6 5.6z' opacity='.0'/%3E%0A%3Ccircle cx='0' cy='8' r='1.5'/%3E%3Ccircle cx='80' cy='8' r='1.5'/%3E%3Ccircle cx='40' cy='24' r='1.5'/%3E%0A%3Ccircle cx='-2.6' cy='8' r='.8'/%3E%3Ccircle cx='2.6' cy='8' r='.8'/%3E%3Ccircle cx='77.4' cy='8' r='.8'/%3E%3Ccircle cx='0' cy='5.4' r='.8'/%3E%3Ccircle cx='80' cy='5.4' r='.8'/%3E%3Ccircle cx='37.4' cy='24' r='.8'/%3E%3Ccircle cx='42.6' cy='24' r='.8'/%3E%3Ccircle cx='40' cy='26.6' r='.8'/%3E%0A%3C/g%3E%0A%3C/svg%3E") repeat-x left top, linear-gradient(#08102a, #060a1c);
}

/* ボタン */
.btn {
  display: block; margin: 12px auto; padding: 12px 32px;
  background: var(--gold); color: #0e1838; border: none; border-radius: 999px;
  font: inherit; font-size: 16px; cursor: pointer;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; color: var(--gold); border: 1px solid var(--gold); }
.row { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.row .btn { margin: 8px 0; }

/* 1. 相談内容 */
textarea {
  display: block; width: 100%; max-width: 640px; margin: 0 auto 20px; padding: 12px;
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  font: inherit; font-size: 16px; line-height: 1.6;
}

/* 2. スプレッド選択 */
#spread-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.spread-item {
  display: flex; gap: 14px; align-items: center; padding: 12px; text-align: left;
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  font: inherit; cursor: pointer;
}
.spread-item:hover { border-color: var(--gold); }
.spread-dia { position: relative; width: 120px; height: 110px; flex: none; }
.dia-card { position: absolute; background: rgba(216, 180, 106, .3); border: 1px solid var(--gold); border-radius: 2px; }
.spread-name { color: var(--gold); margin-bottom: 6px; }
.spread-desc { font-size: 14px; color: var(--muted); line-height: 1.6; }

/* カード裏面 */
.mcard, .fcard, .flycard, .face.back {
  background: url(../cards/small/back.webp) center / cover;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}

/* 3. シャッフル */
#mix {
  position: relative; height: 62vh; min-height: 360px; overflow: hidden;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .15);
  touch-action: none; cursor: grab;
}
.mcard { position: absolute; left: 0; top: 0; will-change: transform; }

/* 4. 盤面 */
#board { position: relative; height: 56vh; min-height: 320px; }
.slot { position: absolute; border: 1px dashed var(--line); border-radius: 6px; cursor: default; }
.slot-no {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--muted);
}
.slot.filled { border-color: transparent; }
.slot.filled .slot-no { display: none; }
.slot.active {
  border: 2px solid var(--gold); cursor: pointer;
  box-shadow: 0 0 18px 4px rgba(216, 180, 106, .55);
  animation: glow 1.6s ease-in-out infinite;
}
@keyframes glow { 50% { box-shadow: 0 0 6px 1px rgba(216, 180, 106, .3); } }

/* めくる */
.card { position: absolute; inset: 0; perspective: 900px; }
.inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .6s; }
.card.flipped .inner { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; border-radius: 6px; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.face.front { transform: rotateY(180deg); }
.face.front img { display: block; width: 100%; height: 100%; }
.card.rev .face.front img { transform: rotate(180deg); }

/* カードの山（扇） */
#fan { position: relative; height: 30vh; min-height: 210px; margin-top: 8px; }
#fan.done { display: none; }
.fcard {
  position: absolute; left: 0; top: 0; cursor: pointer;
  transform: translate(var(--x), calc(var(--y) - var(--lift, 0px))) rotate(var(--r));
  transition: transform .15s;
}
.fcard:hover { --lift: 14px; }
.fcard.taken { visibility: hidden; }
.flycard {
  position: fixed; z-index: 100; pointer-events: none;
  transition: transform .55s cubic-bezier(.3, .7, .3, 1);
}

/* 5. 結果 */
.r-meta { display: grid; gap: 12px; padding: 14px; margin-bottom: 16px; background: var(--bg2); border-radius: 10px; }
.r-meta span { font-size: 12px; color: var(--muted); }
.r-meta p { margin: 4px 0 0; white-space: pre-wrap; line-height: 1.6; }
.r-row { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid rgba(216, 180, 106, .2); }
.r-img { width: 80px; flex: none; border-radius: 5px; }
.r-img.rev { transform: rotate(180deg); }
.r-pos { font-size: 13px; color: var(--muted); }
.r-card { color: var(--gold); margin: 4px 0; }
.r-note { font-size: 14px; color: var(--muted); }
.r-summary { margin: 20px 0; padding: 14px; font-size: 14px; color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; }

@media (max-width: 700px) {
  #board { height: 46vh; min-height: 280px; }
  #mix { height: 58vh; }
}
