/* =========================================================================
   ソロナイン (Solo Nine) — デザイントークン & コンポーネント
   方針: 紙地＋ブリック1色、カバー色を主役に。レア度スコアは出さない。
   シェル: スマホ枠は使わず、通常のレスポンシブ1カラム。
        入口は「検索＋9スロットの棚」。大きな陳列はシェアカードで魅せる。
   ========================================================================= */

:root {
  /* --- color --- */
  --paper:        #efe7d6;
  --paper-2:      #e9e0cf;
  --ink:          #211f1b;
  --brick:        #b5462f;
  --paper-card:   #f6efe1;
  --paper-card-2: #f5efe1;
  --mat:          #e3d7bf;
  --mat-2:        #e6dcc7;
  --dark:         #1c1a16;
  --cream:        #f3ecde;
  --capsule-fg:   #f0e8d8;
  --line:         rgba(33, 31, 27, 0.14);

  --muted:    #7a6f5c;
  --muted-2:  #9a8d77;
  --muted-3:  #8a7d68;
  --muted-4:  #a89a82;
  --muted-tx: #5b5142;
  --seg-off:  #6b6151;

  /* --- type --- */
  --font-jp:      'Zen Kaku Gothic New', sans-serif;
  --font-display: 'Archivo', sans-serif;
  --font-mono:    'Space Mono', monospace;

  /* --- layout --- */
  --col: 470px;          /* コンテンツ最大幅 */
  --appbar-h: 52px;
  --r-tile: 6px;
  --r-card: 3px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--paper-2); }
::selection { background: var(--brick); color: var(--cream); }

@keyframes soloIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop    { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }
/* スロットにゲームが「ストンと落ちてはまる」演出 */
@keyframes slotIn {
  0%   { opacity: 0; transform: translateY(-16px) scale(1.14); }
  55%  { opacity: 1; transform: translateY(0) scale(0.95); }
  75%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}
/* はまった瞬間にブリックのリングがフラッシュ */
@keyframes flashRing {
  0%   { opacity: 0.95; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.14); }
}

/* ================================ shell ================================= */
.page {
  min-height: 100vh;
  background: radial-gradient(120% 80% at 50% 0%, #f3ecdd 0%, #e9e0cf 62%, #e2d8c4 100%);
}
.app {
  max-width: var(--col);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  box-shadow: 0 0 80px -30px rgba(28, 20, 10, 0.35);
  display: flex;
  flex-direction: column;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--appbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(239, 231, 214, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.appbar__brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-jp); font-weight: 900; font-size: 15px; letter-spacing: 0.01em; }
.appbar__mark  { width: 9px; height: 9px; background: var(--brick); flex: none; }
.appbar__right { display: flex; align-items: center; gap: 12px; }
.appbar__tag   { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; color: var(--muted-4); }
.counter       { font-family: var(--font-mono); font-size: 13px; letter-spacing: 0.14em; font-weight: 700; color: var(--muted); }
.counter.done  { color: var(--brick); }

.view { animation: soloIn 0.4s ease both; padding: 16px 18px 28px; flex: 1; }

.foot {
  text-align: center;
  padding: 18px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--muted-4);
  border-top: 1px solid var(--line);
}

/* ============================== type bits ============================== */
.section-kicker { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em; color: var(--muted-2); margin: 0 0 12px; text-transform: uppercase; }
.h2  { font-family: var(--font-jp); font-weight: 900; font-size: 23px; margin: 0 0 4px; }
.sub { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; font-weight: 500; }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; color: var(--brick); margin-bottom: 10px; }

/* ================================ buttons ============================== */
.btn-primary {
  width: 100%; border: none; border-radius: var(--r-card);
  background: var(--brick); color: #f6efe0;
  font-family: var(--font-jp); font-weight: 900; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.btn-primary .arr { font-family: var(--font-display); font-weight: 700; }
.btn-dark {
  border: none; border-radius: var(--r-card); background: var(--ink); color: var(--cream);
  font-family: var(--font-jp); font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-dark .arr { font-family: var(--font-display); }
.btn-outline {
  border: 1px solid rgba(33, 31, 27, 0.4); border-radius: var(--r-card); background: none; color: var(--ink);
  font-family: var(--font-jp); font-weight: 700; cursor: pointer;
}
.back {
  border: none; background: none; cursor: pointer;
  font-family: var(--font-display); font-size: 22px; color: var(--ink); padding: 0; line-height: 1;
}
.screen-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 18px; }
.screen-head__label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.18em; color: var(--muted); white-space: nowrap; }
.screen-head__spacer { width: 14px; }

/* =============================== Capsule =============================== */
.capsule {
  position: relative; width: 100%; aspect-ratio: 2 / 3;
  border-radius: var(--r-tile); overflow: hidden; container-type: inline-size;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 2px rgba(20, 16, 10, 0.18);
}
.capsule__img  { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.capsule__motif { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.16; }
.capsule__rule  { position: absolute; top: 7cqw; left: 8cqw; width: 7cqw; height: 0.9cqw; opacity: 0.55; }
.capsule__text  { position: absolute; left: 0; right: 0; bottom: 0; padding: 8.5cqw 8cqw 9cqw; display: flex; flex-direction: column; gap: 3cqw; }
.capsule__sub   { font-family: var(--font-mono); font-size: 4cqw; letter-spacing: 0.18em; text-transform: uppercase; opacity: 0.78; line-height: 1; }
.capsule__title { font-family: var(--font-display); font-weight: 800; font-size: 13.5cqw; line-height: 0.97; letter-spacing: -0.025em; }

/* ============================= BUILD (home) =========================== */
/* 1画面に収める: 見出し1行 → 検索ボックス（候補はドロップダウンで浮く）→ 3×3グリッド → CTA */
.build-view { display: flex; flex-direction: column; padding: 14px 16px 16px; }
.lead { font-size: 12.5px; color: var(--muted); font-weight: 500; margin: 0 0 12px; text-align: center; }
.lead .nine { font-family: var(--font-display); font-weight: 900; color: var(--brick); font-size: 15px; padding: 0 1px; }

/* 検索ボックス + 候補ドロップダウン（縦に伸ばさず浮かせる） */
.search-wrap { position: relative; margin-bottom: 14px; }
.search {
  display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px;
  background: var(--paper-card); border: 1px solid rgba(33, 31, 27, 0.16); border-radius: var(--r-card);
}
.search__icon  { font-family: var(--font-display); color: var(--muted-4); font-size: 15px; }
.search__input { flex: 1; border: none; background: none; outline: none; font-family: var(--font-jp); font-size: 15px; color: var(--ink); }
.search__clear { border: none; background: none; cursor: pointer; color: var(--muted-4); font-size: 16px; padding: 0; }

.dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 22px 44px -16px rgba(28, 20, 10, 0.5);
  max-height: 56vh; overflow-y: auto;
}
.dropdown__state { padding: 18px 16px; text-align: center; font-size: 12.5px; color: var(--muted-2); }
.dropdown .result-row { border: none; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; }
.dropdown .result-row:last-child { border-bottom: none; }

.result-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; }
.result-row__cap   { width: 38px; flex: none; }
.result-row__meta  { flex: 1; min-width: 0; }
.result-row__title { font-family: var(--font-jp); font-weight: 700; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-row__sub   { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; color: var(--muted-2); margin-top: 2px; text-transform: uppercase; }
.add-btn { flex: none; width: 34px; height: 34px; border-radius: 50%; font-family: var(--font-display); font-size: 18px; cursor: pointer; line-height: 1; }

/* 9本の棚: 3×3グリッド（検索で1個ずつ埋まる） */
.shelf-head2 { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.shelf-title { font-family: var(--font-jp); font-weight: 900; font-size: 14px; }
.shelf3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; width: 100%; max-width: 320px; margin: 0 auto; }
.shelf3 .cell { position: relative; animation: slotIn 0.42s cubic-bezier(.2,.8,.3,1.1) both; }
.shelf3 .cell.static { animation: none; }
.shelf3 .cell:not(.static)::after {
  content: ''; position: absolute; inset: -3px; border-radius: 9px;
  box-shadow: 0 0 0 2px var(--brick); pointer-events: none;
  animation: flashRing 0.55s ease-out forwards;
}
.shelf3 .remove {
  position: absolute; top: -6px; right: -6px; width: 21px; height: 21px; border-radius: 50%;
  border: none; background: var(--ink); color: var(--cream);
  font-family: var(--font-display); font-size: 12px; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.shelf3 .empty {
  aspect-ratio: 2 / 3; border: 1.5px dashed rgba(33, 31, 27, 0.25); border-radius: var(--r-tile);
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: border-color 0.15s, color 0.15s;
  font-family: var(--font-display); font-weight: 700; font-size: 20px; color: rgba(33, 31, 27, 0.25);
}
.shelf3 .empty.next { border-color: var(--brick); color: var(--brick); }
.shelf3 .empty:hover { border-color: var(--brick); }
.dev-link { border: 1px dashed rgba(33, 31, 27, 0.3); background: none; cursor: pointer; color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; padding: 3px 7px; border-radius: 3px; }
.shelf-hint2 { font-size: 11.5px; color: var(--muted); font-weight: 500; margin: 10px 0 0; text-align: center; }
.shelf-hint2.done { color: var(--brick); font-weight: 700; }
.autofill {
  border: none; background: none; cursor: pointer;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; white-space: nowrap;
  color: var(--brick); text-decoration: underline; text-underline-offset: 3px; padding: 0;
}

/* 完成CTA */
.cta-bar { position: sticky; bottom: 0; z-index: 30; margin: 14px -16px 0; padding: 12px 16px 14px;
  background: linear-gradient(rgba(239, 231, 214, 0), var(--paper) 36%); }
.btn-continue {
  width: 100%; height: 54px; border: none; border-radius: var(--r-card);
  font-family: var(--font-jp); font-weight: 900; font-size: 16px; letter-spacing: 0.03em; transition: all 0.2s;
}
.rec-link { display: block; width: 100%; margin-top: 10px; border: none; background: none; cursor: pointer;
  color: var(--muted-tx); font-family: var(--font-jp); font-weight: 700; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* ============================= CARD (HERO) ============================ */
.segmented { display: flex; gap: 6px; margin-bottom: 18px; background: var(--mat-2); padding: 4px; border-radius: var(--r-card); }
.seg { flex: 1; height: 34px; border: none; border-radius: 2px; font-family: var(--font-jp); font-weight: 700; font-size: 12px; cursor: pointer; }

.card-frame { filter: drop-shadow(0 20px 36px rgba(28, 20, 10, 0.32)); margin-bottom: 8px; }
.card-head__brand { font-family: var(--font-jp); font-weight: 900; font-size: 14px; letter-spacing: 0.02em; line-height: 1.1; }
.card-head__tag   { font-family: var(--font-mono); font-size: 8px; letter-spacing: 0.2em; opacity: 0.7; margin-top: 3px; white-space: nowrap; }
.card-head__by    { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.1em; opacity: 0.85; text-align: right; max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-head__mark  { width: 9px; height: 9px; background: var(--brick); flex: none; }

.nick {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px;
  background: var(--paper-card); border: 1px solid rgba(33, 31, 27, 0.16); border-radius: var(--r-card); margin: 18px 0 12px;
}
.nick__by    { font-family: var(--font-mono); font-size: 11px; color: var(--muted-2); }
.nick__input { flex: 1; border: none; background: none; outline: none; font-family: var(--font-jp); font-size: 14px; color: var(--ink); }

/* 共有URL = 匿名でも自分の棚/レコメンドに戻れる紐づけ */
.share-url {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 8px 0 14px;
  background: var(--mat-2); border: 1px dashed rgba(33, 31, 27, 0.3); border-radius: var(--r-card); margin-bottom: 6px;
}
.share-url__text { flex: 1; min-width: 0; font-family: var(--font-mono); font-size: 12px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.share-url__copy { flex: none; border: none; background: var(--ink); color: var(--cream); font-family: var(--font-jp); font-weight: 700; font-size: 11px; height: 30px; padding: 0 12px; border-radius: 2px; cursor: pointer; }
.share-note { font-size: 11px; line-height: 1.6; color: var(--muted); margin: 0 0 16px; font-weight: 500; }

.export-row { display: flex; gap: 10px; margin-bottom: 12px; }
.btn-png { flex: 2; height: 52px; border: none; border-radius: var(--r-card); background: var(--brick); color: #f6efe0; font-family: var(--font-jp); font-weight: 900; font-size: 15px; cursor: pointer; box-shadow: 0 10px 20px -8px rgba(181, 70, 47, 0.6); }
.btn-ogp { flex: 1; height: 52px; border: 1px solid rgba(33, 31, 27, 0.4); border-radius: var(--r-card); background: none; color: var(--ink); font-family: var(--font-jp); font-weight: 700; font-size: 13px; cursor: pointer; }
.card-view .btn-dark { width: 100%; height: 48px; font-size: 14px; }
.save-link { display: block; margin: 10px auto 0; border: none; background: none; cursor: pointer; color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-decoration: underline; text-underline-offset: 3px; }
.export-note { text-align: center; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; color: var(--muted-4); margin-top: 14px; }

/* =========================== RESULT / RECOMMEND ====================== */
.h1-result { font-family: var(--font-jp); font-weight: 900; font-size: 26px; line-height: 1.35; margin: 0 0 6px; }
.result-meta { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted-2); margin: 0 0 22px; }
.recs { display: flex; flex-direction: column; gap: 16px; }
.rec { display: flex; gap: 14px; padding: 14px; background: var(--paper-card); border: 1px solid rgba(33, 31, 27, 0.12); border-radius: 4px; }
.rec__cap   { width: 74px; flex: none; }
.rec__body  { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.rec__title { font-family: var(--font-display); font-weight: 800; font-size: 18px; color: var(--ink); line-height: 1.05; margin-bottom: 6px; }
.rec__reason { display: inline-block; align-self: flex-start; font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; color: var(--brick); border: 1px solid rgba(181, 70, 47, 0.4); border-radius: 2px; padding: 3px 6px; margin-bottom: 9px; }
.rec__blurb { font-size: 12.5px; line-height: 1.6; color: var(--muted-tx); margin: 0; font-weight: 500; }
.result-view .btn-primary { height: 54px; font-size: 16px; margin-top: 26px; box-shadow: 0 12px 24px -10px rgba(181, 70, 47, 0.7); }

/* =============================== REVEAL ============================== */
.reveal { min-height: 72vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.reveal__kicker { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.2em; color: var(--brick); margin-bottom: 28px; }
.flip-scene { perspective: 1200px; width: 174px; margin-bottom: 30px; }
.flip-card { position: relative; width: 100%; aspect-ratio: 2 / 3; transform-style: preserve-3d; transition: transform 1s cubic-bezier(0.7, 0.05, 0.2, 1); transform: rotateY(0deg); }
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face { position: absolute; inset: 0; backface-visibility: hidden; }
.flip-back {
  position: absolute; inset: 0; backface-visibility: hidden; transform: rotateY(180deg);
  background: var(--ink); border-radius: var(--r-tile);
  display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 22px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.flip-back__count { font-family: var(--font-display); font-weight: 900; font-size: 52px; color: var(--brick); line-height: 1; }
.flip-back__label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em; color: #cfc4af; margin-top: 8px; }
.flip-back__rule  { width: 30px; height: 1px; background: rgba(243, 236, 222, 0.25); margin: 16px 0; }
.flip-back__title { font-family: var(--font-jp); font-weight: 700; font-size: 13px; color: var(--cream); line-height: 1.5; }
.reveal__h { font-family: var(--font-jp); font-weight: 900; font-size: 23px; line-height: 1.5; margin: 0 0 14px; max-width: 320px; }
.reveal__h .num { color: var(--brick); }
.reveal__p { font-size: 14px; line-height: 1.8; color: var(--muted-tx); margin: 0 0 8px; font-weight: 500; max-width: 300px; }
.reveal__sig { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; color: var(--muted-3); margin-bottom: 34px; }
.reveal__actions { display: flex; gap: 10px; width: 100%; max-width: 320px; }
.reveal__actions .btn-outline, .reveal__actions .btn-dark { flex: 1; height: 50px; font-size: 14px; }
