/* ホーム（たまごガチャ）とスクラッチで共通の、遊びの部品 */

/* 気分チップ（2列、最後の1つは全幅） */
.mood-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.mood-grid .mood-chip:last-child:nth-child(odd) { grid-column: 1 / -1; }
.mood-chip {
  min-height: var(--chip-min); padding: 0 var(--space-3); border-radius: var(--radius-pill);
  border: 1px solid transparent; background: var(--color-primary-soft); color: var(--color-text);
  font: 500 0.875rem/1.3 var(--font-body); cursor: pointer;
  transition: background var(--motion-state), color var(--motion-state);
}
.mood-chip[aria-checked="true"] { background: var(--color-primary); color: #fff; font-weight: 700; }
.mood-chip[aria-checked="true"]::before { content: "✓ "; }

/* 2択の切り替え（1回／10連、たまご／スクラッチ） */
.segment {
  display: grid; grid-template-columns: 1fr 1fr; padding: 3px; gap: 3px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-card);
}
.segment > * {
  display: grid; place-items: center; min-height: 48px; padding: 8px 12px; border: 0; border-radius: var(--radius-sm); background: none;
  color: var(--color-text); font: 500 16px/1.4 var(--font-body); text-decoration: none; cursor: pointer;
}
.segment > [aria-checked="true"], .segment > [aria-current="page"] { background: var(--color-primary); color: #fff; font-weight: 700; }

.play-hint { text-align: center; color: var(--color-text); font-weight: 500; }
.play-note { text-align: center; color: var(--color-muted); font-size: 14px; line-height: 1.65; }

/* ---------- たまごの舞台 ---------- */
.egg-stage {
  position: relative; height: 180px; overflow: hidden; border-radius: var(--radius-panel);
  background: radial-gradient(ellipse at 50% 30%, #FFFFFF 0%, var(--color-primary-soft) 70%);
  border: 1px solid var(--color-border);
  touch-action: none; user-select: none; -webkit-user-select: none;
}
/* ティールのアーチ（遊具） */
.stage-arch {
  position: absolute; left: 9%; right: 9%; top: 8px; bottom: 20px; pointer-events: none;
  border: 10px solid var(--color-teal); border-bottom: 0; border-radius: 160px 160px 0 0;
  box-shadow: inset 0 2px 0 rgb(255 255 255 / 24%);
}
.stage-arch i { position: absolute; width: 14px; height: 14px; background: var(--color-gold); clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%); }
.stage-arch i:nth-child(1) { left: 4%; top: 30%; }
.stage-arch i:nth-child(2) { right: 4%; top: 30%; }
.stage-arch i:nth-child(3) { left: 22%; top: 48%; width: 10px; height: 10px; background: #fff; }
.stage-arch i:nth-child(4) { right: 22%; top: 48%; width: 10px; height: 10px; background: #fff; }
.egg-cords, .egg-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.egg-cords { overflow: visible; }
.egg-cords line { stroke: var(--color-gold); stroke-width: 2; stroke-linecap: round; }
.egg-layer { pointer-events: none; }
.egg-hint {
  position: absolute; left: 0; right: 0; bottom: 30px; z-index: 2; margin: 0 auto; width: fit-content; padding: 4px 12px;
  border-radius: var(--radius-pill); background: var(--color-surface); color: var(--color-primary);
  font: 700 0.875rem/1.4 var(--font-heading);
}

/* たまご（素材画像。★3はラズベリー、★4は金、★5は虹） */
.hang-egg { position: absolute; left: 0; top: 0; width: 76px; height: 76px; margin: -4px 0 0 -38px; pointer-events: auto; cursor: grab; }
.hang-egg.is-small { width: 54px; height: 54px; margin-left: -27px; }
.hang-egg.is-grabbed { cursor: grabbing; }
.egg-skin, .big-egg span, .ten-egg .egg-skin {
  position: absolute; inset: 0; background: url("themes/retro/egg.png") center top / contain no-repeat;
  filter: saturate(1.1) brightness(1) drop-shadow(0 4px 6px rgb(41 38 53 / 16%));
}
.r4 .egg-skin, .big-egg.r4 span { filter: sepia(1) saturate(3) hue-rotate(-12deg) brightness(1.05) drop-shadow(0 0 8px rgb(183 121 22 / 55%)); }
/* ★5 は、たまごの形に切り抜いた虹のグラデーションを重ねる（動かさない） */
.r5 .egg-skin::after, .big-egg.r5 span::after {
  content: ""; position: absolute; inset: 0; mix-blend-mode: color;
  background: linear-gradient(120deg, #C52F60, #B77916, #16796F, #7152B8);
  -webkit-mask: url("themes/retro/egg.png") center top / contain no-repeat;
  mask: url("themes/retro/egg.png") center top / contain no-repeat;
}
.r5 .egg-skin, .big-egg.r5 span { filter: saturate(1.2) brightness(1.05) drop-shadow(0 0 10px rgb(113 82 184 / 55%)); }

.zip-text {
  position: absolute; font: 800 1.25rem/1 var(--font-heading); color: var(--color-primary); pointer-events: none;
  animation: zip-fade .6s ease-out forwards;
}
@keyframes zip-fade { from { opacity: 0; transform: translateY(8px); } 30% { opacity: 1; } to { opacity: 0; transform: translateY(-24px); } }

/* 大きなたまご（落下 → パカッ） */
.egg-big { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.big-egg { position: relative; width: 150px; height: 150px; animation: big-drop .42s cubic-bezier(.3, 1.4, .5, 1) both; }
.big-top { clip-path: inset(0 0 43% 0); transform-origin: 80% 57%; }
.big-bottom { clip-path: inset(57% 0 0 0); }
.big-egg.is-open .big-top { animation: top-off .28s ease-out forwards; }
.big-egg.is-open .big-bottom { animation: bottom-off .28s ease-out forwards; }
@keyframes big-drop { from { transform: translateY(-160%); } to { transform: none; } }
@keyframes top-off { to { transform: translate(40px, -90px) rotate(40deg); opacity: 0; } }
@keyframes bottom-off { to { transform: translateY(30px); opacity: 0; } }
.egg-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.egg-flash.is-on { animation: egg-flash .35s ease-out; }
@keyframes egg-flash { from { opacity: .85; } to { opacity: 0; } }

/* ---------- 10連の開封ボード ---------- */
.ten-board { position: absolute; inset: 0; display: grid; grid-template-rows: 1fr auto; padding: 16px 12px 12px; background: rgb(255 248 238 / 92%); }
.ten-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 16px 12px; }
.ten-egg {
  position: relative; aspect-ratio: 1; width: 80px; max-width: 100%; min-height: 80px; justify-self: center; padding: 0; border: 0; background: none; cursor: pointer;
  border-radius: var(--radius-sm); animation: big-drop .35s cubic-bezier(.3, 1.4, .5, 1) both;
}
.ten-egg .egg-skin { filter: saturate(1.15) brightness(.82); }
.ten-egg.r4 .egg-skin { filter: sepia(1) saturate(3) hue-rotate(-12deg) brightness(1.05); }
.ten-egg.r5 .egg-skin { filter: saturate(1.2) brightness(1.05); }
.ten-egg .ten-star { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); font: 700 14px/1.4 var(--font-body); color: var(--color-text); background: var(--color-surface); border-radius: 4px; padding: 1px 3px; }
.ten-egg.is-open { cursor: default; animation: none; }
.ten-egg.is-open .egg-skin { display: none; }
.ten-egg .ten-thumb { position: absolute; inset: 10% 0; background: var(--color-stage); border-radius: 0; overflow: hidden; animation: pop-in .25s ease-out; }
.ten-egg .ten-thumb img { width: 100%; height: 100%; object-fit: contain; }
@keyframes pop-in { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.ten-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding-top: var(--space-2); font: 500 0.875rem/1 var(--font-body); font-variant-numeric: tabular-nums; }
.ten-bar .button { min-height: 48px; padding: 0 var(--space-4); }

/* ---------- 結果 ---------- */
.result-head { display: flex; align-items: center; justify-content: center; gap: var(--space-2); }
.result-head h2 { font-size: 1.75rem; }
.result-card { display: grid; gap: var(--space-3); }
.result-card .media { border-radius: 0; }
.result-card .card-title { font-size: 1rem; }
.result-enter { animation: result-in var(--motion-enter) var(--ease-ui) both; }
@keyframes result-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .big-egg, .ten-egg, .zip-text { animation: none !important; }
}

/* ホームの密度を上げて、たまごと操作を最初の画面に収める */
.page.is-play.egg-page { gap: 8px; padding-top: 12px; }
.egg-intro { gap: 8px; }
.egg-page .mood-grid { gap: 4px; }
/* アーチの台座 */
.stage-base {
  position: absolute; left: 6%; right: 6%; bottom: 8px; height: 20px; border-radius: 50%;
  background: var(--color-teal); border-top: 4px solid var(--color-teal-soft); pointer-events: none;
}
.hang-egg:not(.is-small) { width: 96px; height: 96px; margin: -4px 0 0 -48px; }
.egg-hint span { font-size: 20px; line-height: 1; }
/* 1回のたまごの横に、レア度を文字で出す */
.egg-rarity { position: absolute; left: 100%; top: 28px; margin-left: 4px; }
/* 10連の房（吊るしているとき）は高さを足し、開封中は中身に合わせて伸ばす */
.egg-stage.is-ten { height: 260px; }
.egg-stage.is-opening-ten { height: auto; min-height: 0; }
.is-opening-ten .ten-board { position: relative; inset: auto; padding: 16px; }
.is-opening-ten .stage-arch, .is-opening-ten .stage-base { display: none; }

/* ---------- ホーム: ガチャのバナー（横スワイプ） ---------- */
.carousel { display: grid; gap: var(--space-3); }
.carousel-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: 100%; gap: var(--space-3);
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel-track:focus-visible { box-shadow: var(--focus-ring); }
.banner-slide {
  scroll-snap-align: center; display: grid; align-content: start; overflow: hidden;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-panel);
}
.banner { position: relative; aspect-ratio: 16 / 9; background: linear-gradient(135deg, var(--color-primary-soft), var(--color-teal-soft)); }
.banner-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.banner-art.is-placeholder { background: radial-gradient(circle at 70% 40%, #fff 0 12%, transparent 13%), linear-gradient(135deg, var(--color-primary-soft), var(--color-gold-soft)); }
.banner-text {
  position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: 2px; padding: 28px 16px 12px;
  background: linear-gradient(transparent, rgb(41 38 53 / 78%)); color: #fff;
}
.banner-text h2 { font-size: 1.5rem; font-weight: 800; color: #fff; text-shadow: 0 2px 0 rgb(41 38 53 / 50%); }
.banner-text p { font-size: 14px; line-height: 1.5; }
.banner-body { display: grid; gap: var(--space-3); padding: var(--space-3) var(--space-4) var(--space-4); }
.pickup-label { font: 700 0.875rem/1.4 var(--font-body); color: var(--color-muted); }
.pickup { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.pickup li { display: grid; gap: 4px; justify-items: center; }
.pickup .media { width: 100%; }
.pickup .rarity { height: 20px; font-size: 12px; padding: 0 5px; }
.banner-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: var(--space-2); }
.banner-actions.is-single { grid-template-columns: 1fr; }
.carousel-nav { display: flex; align-items: center; justify-content: center; gap: var(--space-3); }
.carousel-arrow {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text); font: 700 22px/1 var(--font-body); cursor: pointer;
}
.dots { display: flex; gap: 6px; }
.dot { width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%; background: var(--color-border); cursor: pointer; }
.dot[aria-current="true"] { width: 22px; border-radius: 4px; background: var(--color-primary); }

/* ---------- ガチャ画面（1ページ全体を使う） ---------- */
.gacha-bar { display: grid; gap: 2px; }
.gacha-bar h1 { font-size: 1.375rem; }
.text-link.is-back { justify-self: start; min-height: 32px; }
.text-link.is-back::after { content: none; }
.text-link.is-back::before { content: "‹ "; }
.egg-stage.is-full { height: min(62dvh, 520px); min-height: 360px; }
.egg-stage.is-full.is-ten { height: min(62dvh, 520px); }
.egg-stage.is-full .hang-egg:not(.is-small) { width: 120px; height: 120px; margin-left: -60px; }
.egg-stage.is-full .big-egg { width: 200px; height: 200px; }
