/* style.css */
@font-face {
  font-family: 'MihoyoZenZero';
  src: url('font/mihoyo-zenzero.ttf') format('truetype');
}

:root {
  --bg:       #f4f4f9;
  --surface:  #ffffff;
  --surface2: #eeeeee;
  --accent:   #ffcc00;
  --text:     #333333;
  --muted:    #888888;
  --border:   #dddddd;
  --gold:     #aa8800;
  --font:     'MihoyoZenZero', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
  --radius:   12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
}

/* ヘッダー */
header {
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  text-align: center;
  padding: 16px 20px;
  position: relative;
}

/* 連続ログインストリーク */
.streak-display {
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: bold;
  margin: 4px 0 2px;
  letter-spacing: 0.05em;
}

/* 言語切り替え */
.lang-switch {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 13px;
  opacity: 0.8;
  white-space: nowrap;
}

.lang-switch label {
  cursor: pointer;
  margin-left: 6px;
}

header h1 {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  color: var(--text);
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

header p {
  color: var(--muted);
  font-size: 0.85rem;
}

/* メインコンテナ */
main {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* 入力セクション */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  margin-bottom: 24px;
}

.input-section label {
  display: block;
  color: var(--gold);
  font-size: 0.95rem;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

.input-section input[type="date"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 8px 10px;
  width: 100%;
  max-width: 260px;
  height: 40px;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.input-section input[type="date"]:focus {
  border-color: var(--accent);
}

.fortune-btn-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  margin-top: 8px;
}

.chara-deco {
  height: 90px;
  object-fit: contain;
  flex-shrink: 0;
  pointer-events: none;
}

.fortune-btn {
  display: block;
  margin: 20px 0 0;
  background: var(--accent);
  border: none;
  border-radius: 50px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  padding: 12px 40px;
  transition: opacity 0.2s;
  align-self: center;
}

.fortune-btn:hover { opacity: 0.8; }

/* セクション共通 */
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
}

.section-title {
  color: var(--gold);
  font-size: 0.82rem;
  letter-spacing: 0.15em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before, .section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-desc {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin: -8px 0 12px;
}

/* 運勢バッジ */
.fortune-badge {
  display: inline-block;
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  padding: 6px 24px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.fortune-大吉 { color: #cc2200; background: rgba(204, 34, 0, 0.08); border: 1px solid rgba(204,34,0,0.3); }
.fortune-中吉 { color: #cc6600; background: rgba(204, 102, 0, 0.08); border: 1px solid rgba(204,102,0,0.3); }
.fortune-小吉 { color: #aa8800; background: rgba(255, 204, 0, 0.15); border: 1px solid rgba(255,204,0,0.5); }
.fortune-末吉 { color: #448844; background: rgba(68, 136, 68, 0.08); border: 1px solid rgba(68,136,68,0.3); }
.fortune-凶   { color: var(--muted); background: var(--surface2); border: 1px solid var(--border); }
.fortune-超大吉 { color: #c084fc; background: rgba(155,89,182,0.12); border: 1px solid rgba(155,89,182,0.5); animation: ach-legend-shimmer 1.5s ease-in-out infinite; }
.fortune-大凶   { color: #c8b0e0; background: #1a1028; border: 1px solid #5a3870; }

/* 星座セクション */
.zodiac-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.zodiac-symbol {
  font-size: 2.2rem;
  line-height: 1;
}

.zodiac-info-name {
  font-size: 1.2rem;
  color: var(--text);
  font-weight: bold;
}

.zodiac-info-period {
  font-size: 0.78rem;
  color: var(--muted);
}

.zodiac-rows { display: grid; gap: 8px; }

.zodiac-row {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
}

.zodiac-cat {
  color: var(--gold);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

/* バイオリズム */
.bio-row {
  display: grid;
  grid-template-columns: 40px 1fr 60px 58px;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bio-label { font-size: 0.85rem; color: var(--muted); }

.bio-bar-wrap {
  background: var(--surface2);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.bio-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.8s ease;
}

.bio-bar.bio-high  { background: linear-gradient(90deg, #4a9eff, #00ccff); }
.bio-bar.bio-mid   { background: linear-gradient(90deg, #88aa66, #aaccaa); }
.bio-bar.bio-low   { background: linear-gradient(90deg, #cc8844, #eebb66); }

.bio-status { font-size: 0.78rem; text-align: right; }
.bio-status.bio-high  { color: #3388ee; }
.bio-status.bio-mid   { color: #558833; }
.bio-status.bio-low   { color: #cc7733; }

.bio-diff         { font-size: 0.72rem; text-align: right; }
.bio-diff-up      { color: #4caf50; }
.bio-diff-down    { color: #ef5350; }
.bio-diff-neutral { color: var(--muted); }

/* カードスキャッタエリア */
.card-select-label {
  font-size: 0.9rem;
  color: var(--gold);
  margin-bottom: 10px;
}

.card-scatter-area {
  position: relative;
  width: 100%;
  height: 300px;
  background: var(--surface2);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
  touch-action: none;
}

.scatter-card {
  position: absolute;
  width: 60px;
  height: 90px;
  top: 50%;
  left: 50%;
  margin-left: -30px;
  margin-top: -45px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.scatter-card img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  mix-blend-mode: multiply;
}

@keyframes pulse-selected {
  0%, 100% { box-shadow: 0 0 6px 2px rgba(210, 30, 30, 0.8); }
  50%       { box-shadow: 0 0 20px 10px rgba(210, 30, 30, 0.2); }
}

.scatter-card.selected {
  border-color: #d41e1e;
  animation: pulse-selected 1.4s ease-in-out infinite;
}

.scatter-card.dragging {
  cursor: grabbing;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  opacity: 0.9;
}

/* 占い済みオーバーレイ */
#daily-done-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  border-radius: 10px;
  pointer-events: all;
}

.daily-done-text {
  text-align: center;
  line-height: 1.6;
}

.daily-done-text span {
  display: block;
  color: #ff0000;
  font-size: 1.6rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-shadow: 0 0 14px rgba(255,255,255,1);
}

.daily-done-text small {
  display: block;
  color: #ff0000;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

.scatter-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.shuffle-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 7px 18px;
  transition: background 0.2s;
}

.shuffle-btn:hover { background: var(--border); }

.card-selected-name {
  font-size: 0.85rem;
  color: var(--gold);
  min-height: 1.2em;
}

/* 占うボタン無効状態 */
.fortune-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* タロット結果 */
.tarot-reveal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.tarot-new-badge {
  font-size: 1.1rem;
  font-weight: bold;
  color: #aa8800;
  letter-spacing: 0.12em;
  text-shadow: 0 0 8px rgba(255,204,0,0.6);
  animation: tarot-new-glow 1.2s ease-in-out infinite alternate;
}

@keyframes tarot-new-glow {
  from { opacity: 0.8; text-shadow: 0 0 6px rgba(255,204,0,0.4); }
  to   { opacity: 1.0; text-shadow: 0 0 14px rgba(255,204,0,0.9); }
}

.card-scene {
  position: relative;
  width: 200px;
  height: 300px;
  perspective: 800px;
  flex-shrink: 0;
  cursor: pointer;
}

.tarot-card {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 1.1s ease;
}

.tarot-card.flipped { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
}

.card-front { transform: rotateY(180deg); }

.card-front img, .card-back img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.tap-hint {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 8px;
  background: rgba(0, 0, 0, 0.52);
  color: #ffffff;
  font-size: 0.82rem;
  text-align: center;
  letter-spacing: 0.05em;
  pointer-events: none;
}

.tarot-info { width: 100%; }

/* タロット */
.tarot-hint {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin-bottom: 14px;
}

/* カードスプレッド */
.card-spread {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0 20px;
}

.spread-card {
  width: 80px;
  height: 120px;
  perspective: 500px;
  cursor: pointer;
  flex-shrink: 0;
}

.spread-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s ease, opacity 0.4s ease;
}

.spread-card:hover .spread-card-inner {
  transform: translateY(-8px);
}

.spread-card-inner.flipped {
  transform: rotateY(180deg) !important;
}

.spread-card-inner.fade-out {
  opacity: 0.15;
  pointer-events: none;
}

.spread-card-back,
.spread-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.spread-card-face { transform: rotateY(180deg); }

.spread-card-back img,
.spread-card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tarot-info { margin-top: 8px; }

@keyframes tarot-flipin {
  from { opacity: 0; transform: perspective(500px) rotateY(-80deg); }
  to   { opacity: 1; transform: perspective(500px) rotateY(0deg); }
}

.tarot-flipin {
  animation: tarot-flipin 0.9s ease both;
}

.tarot-name {
  font-size: 1.25rem;
  color: var(--text);
  font-weight: bold;
  margin-bottom: 6px;
  text-align: center;
}

.tarot-keyword {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

.tarot-message {
  font-size: 0.9rem;
  line-height: 1.7;
  background: var(--surface2);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: center;
}

/* 挨拶 */
.result-greeting {
  text-align: center;
  font-size: 1rem;
  color: var(--gold);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* 名前・生年月日 横並び */
.input-row {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 500px;
  margin: 14px auto 0;
  text-align: left;
}

/* 入力グリッド（名前・生年月日・性別） */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 500px;
  margin: 14px auto 0;
  text-align: left;
}

.input-name     { grid-column: 1; grid-row: 1; }
.input-birthday { grid-column: 2; grid-row: 1; }
.input-gender   { grid-column: 1 / 3; grid-row: 2; justify-self: center; }

.input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.input-group label {
  font-size: 0.82rem;
  color: var(--gold);
  letter-spacing: 0.03em;
  margin: 0;
}

.input-group input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 8px 10px;
  width: 100%;
  height: 40px;
  box-sizing: border-box;
  outline: none;
}

.input-group input:focus { border-color: var(--accent); }

/* 総合コメント */
.overall-comment {
  font-size: 0.92rem;
  line-height: 1.8;
}

/* ラッキー情報 */
.lucky-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lucky-item {
  background: var(--surface2);
  border-radius: 8px;
  padding: 10px 14px;
}

.lucky-item-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.lucky-item-value {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: bold;
}

/* 画像保存ボタン */
.save-img-btn {
  background-color: #007bff;
  border: 2px solid #007bff;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-family: var(--font);
  font-size: 16px;
  font-weight: bold;
  padding: 10px 60px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.save-img-btn:hover {
  background-color: #fff;
  color: #007bff;
  border-color: #007bff;
}
.save-img-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== アチーブメント ===== */
.achievement-count {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.achievement-list {
  display: flex;
  flex-direction: column;
}

.ach-group {
  border-bottom: 1px solid var(--border);
}
.ach-group:last-child { border-bottom: none; }

.ach-group-header {
  display: flex;
  align-items: center;
  padding: 10px 2px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.ach-group-header::-webkit-details-marker { display: none; }
.ach-group-header::after {
  content: '▶';
  font-size: 0.65rem;
  color: var(--muted);
  margin-left: 6px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
details[open] > .ach-group-header::after { transform: rotate(90deg); }

.ach-group-name {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text);
  flex: 1;
}

.ach-progress {
  font-size: 0.78rem;
  color: var(--muted);
  margin-right: 6px;
}
.ach-progress-complete { color: var(--gold); }

.ach-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 10px;
}

.ach-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 6px;
  border-radius: 6px;
}
.ach-unlocked { background: rgba(212,175,55,0.07); }
.ach-locked   { opacity: 0.55; }

.ach-icon {
  font-size: 0.9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  margin-top: 1px;
  color: var(--muted);
}
.ach-unlocked .ach-icon { color: var(--gold); }

.ach-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ach-name      { font-size: 0.82rem; font-weight: bold; color: var(--text); }
.ach-locked .ach-name { color: var(--muted); }
.ach-condition { font-size: 0.72rem; color: var(--muted); }

/* レアリティバッジ（小ラベル） */
.ach-rarity {
  font-size: 0.56rem;
  font-weight: bold;
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 5px;
  vertical-align: middle;
  flex-shrink: 0;
}
.rarity-badge-bronze { background: rgba(205,127,50,0.15); color: #b06010; border: 1px solid #cd7f32; }
.rarity-badge-silver { background: rgba(168,184,200,0.15); color: #5a7a96; border: 1px solid #a8b8c8; }
.rarity-badge-gold   { background: rgba(212,168,0,0.15);   color: #9a6c00; border: 1px solid #d4a800; }
.rarity-badge-legend { background: rgba(155,89,182,0.15);  color: #7a30b0; border: 1px solid #9b59b6; }

/* アチーブアイテム：アンロック時に背景をレアリティ色に */
.ach-item.rarity-bronze.ach-unlocked { background: rgba(205,127,50,0.13); border: 1px solid rgba(205,127,50,0.35); }
.ach-item.rarity-silver.ach-unlocked { background: rgba(168,184,200,0.13); border: 1px solid rgba(168,184,200,0.35); }
.ach-item.rarity-gold.ach-unlocked   { background: rgba(212,168,0,0.15);   border: 1px solid rgba(212,168,0,0.4); }
.ach-item.rarity-legend.ach-unlocked { background: rgba(155,89,182,0.15);  border: 1px solid rgba(155,89,182,0.45); animation: ach-legend-shimmer 2s ease-in-out infinite; }

@keyframes ach-legend-shimmer {
  0%,100% { box-shadow: inset 0 0 0 0 transparent; }
  50%      { box-shadow: inset 0 0 10px 0 rgba(155,89,182,0.3); }
}

/* ===== アルカナ図鑑 ===== */
.collection-count {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 72px); /* ② 1.5倍 */
  gap: 10px;
  justify-content: center;
}

.col-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative; /* z-index がグリッド内で有効になるよう必須 */
}

/* ① 高さを固定せず back.png の縦横比に任せる */
.col-scene {
  width: 72px;
  perspective: 600px;
  overflow: visible;
}

.col-card-inner {
  position: relative;
  /* transform-style / transition はアニメ中のみ付与 */
}

/* ③ シャドバ風ズームめくり演出（スケールと回転を分離してなめらかに） */

@keyframes col-zoom-reveal {
  0%,  100% { transform: scale(1); }
  50%        { transform: scale(4); }
}

@keyframes col-rotate-reveal {
  from { transform: rotateY(0deg); }
  to   { transform: rotateY(180deg); }
}

/* アニメーション中だけ 3D コンテキストを有効にする */
/* preserve-3d は内側の inner だけに持たせる。zoom 側に preserve-3d を付けると
   通常の stacking context が生成されず z-index が隣カードに効かなくなるため除外。 */
.col-card-zoom.col-reveal {
  animation: col-zoom-reveal 1.5s ease-in-out forwards;
  position: relative;
  z-index: 10;
}

.col-card-inner.col-reveal {
  animation: col-rotate-reveal 1.5s linear forwards;
  transform-style: preserve-3d;
  transition: none;
}

/* アニメーション中の裏面・表面：backface-visibility で制御 */
.col-card-inner.col-reveal .col-card-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.col-card-inner.col-reveal .col-card-front {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: rotateY(180deg); /* 初期は裏向き → 180deg で表になる */
  visibility: visible;
}

/* 裏面：通常フローで親の高さを確定させる */
.col-card-back {
  display: block;
  border-radius: 4px;
  overflow: hidden;
}

.col-card-back img {
  width: 72px;
  height: auto;
  display: block;
}

/* 表面：デフォルトは非表示。absolute で裏面に重ねる */
.col-card-front {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  overflow: hidden;
  visibility: hidden; /* backface-visibility に依存せず非表示 */
}

.col-card-front img {
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
}

/* 最終フリップ状態：3D 不要・シンプルに表示切り替え（実機・html2canvas 対応）
   裏面は visibility:hidden でレイアウト維持（高さの基準として残す）
   表面は absolute のまま・回転なし・可視化 */
.col-card-inner.col-flipped .col-card-back {
  visibility: hidden;
}

.col-card-inner.col-flipped .col-card-front {
  transform: none;
  visibility: visible;
}

/* ⑤ 未収録も元の色のまま（フィルターなし） */
/* .col-item-unknown は CSS 側では何もしない */

.col-item:not(.col-item-unknown) .col-scene { cursor: pointer; }

.col-label {
  font-size: 0.65rem;
  color: var(--muted);
  text-align: center;
  line-height: 1;
  min-height: 0.75rem; /* ② 未収録でも同じ高さを確保 */
}

.col-label-new {
  color: var(--gold);
  font-weight: bold;
}

/* 新規収録カードが表を向いたときの光演出 */
@keyframes col-glow {
  0%   { box-shadow: none; }
  50%  { box-shadow: 0 0 14px 4px rgba(255,204,0,0.55); }
  100% { box-shadow: none; }
}

[data-new="true"] .col-card-inner.col-flipped .col-card-front {
  animation: col-glow 1.4s ease 0.1s both;
}

/* ===== ④ コレクションモーダル ===== */
.col-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.col-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.col-modal-content {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 20px 22px;
  width: min(88vw, 560px);
  max-height: 97vh;
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.col-modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}

.col-modal-close:hover { color: var(--text); }

.col-modal-img {
  max-height: 65vh;
  width: auto;
  max-width: min(85%, 320px);
  border-radius: 6px;
  display: block;
  margin: 0 auto 16px;
}

.col-modal-name {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
  margin-bottom: 8px;
}

.col-modal-keyword {
  font-size: 0.85rem;
  color: var(--muted);
}

/* フッター */
footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

.twitter-icon {
  width: 30px;
  height: 30px;
  vertical-align: middle;
  margin-bottom: 4px;
}

.sad-label {
  color: var(--muted);
  font-size: 0.72rem;
  vertical-align: middle;
}

@media (max-width: 480px) {
  .lucky-grid { grid-template-columns: 1fr; }
  .zodiac-row { grid-template-columns: 48px 1fr; }
  .card-scatter-area { height: 408px; }
  /* スマホ入力グリッド: 名前が全幅、生年月日と性別を横並び */
  .input-name     { grid-column: 1 / 3; grid-row: 1; }
  .input-birthday { grid-column: 1;     grid-row: 2; }
  .input-gender   { grid-column: 2;     grid-row: 2; justify-self: stretch; }
  .input-gender .gender-radios { gap: 10px; }
  /* ヘッダー：言語ボタンと重ならないよう上部に余白 */
  header { padding-top: 44px; }
  .lang-switch { top: 10px; font-size: 12px; }
}

/* ===== 奈落のアルカナ ヒント演出 ===== */
@keyframes scatter-abyss-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.card-scatter-area.abyss-active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 20%, rgba(15, 0, 35, 0.82) 100%);
  animation: scatter-abyss-fadein 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 500;
  border-radius: inherit;
}

@keyframes rare-bad-toast-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes rare-bad-toast-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes rare-bad-glow {
  0%, 100% { box-shadow: 0 0 14px 4px rgba(100, 0, 200, 0.5), inset 0 0 10px rgba(80, 0, 160, 0.2); }
  50%       { box-shadow: 0 0 30px 10px rgba(130, 0, 240, 0.75), inset 0 0 20px rgba(100, 0, 200, 0.3); }
}

#rare-bad-toast {
  position: fixed;
  transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #090012 0%, #1c0038 50%, #090012 100%);
  border: 1px solid rgba(130, 50, 255, 0.65);
  border-radius: 10px;
  padding: 10px 26px;
  text-align: center;
  z-index: 3000;
  pointer-events: none;
  min-width: 220px;
}
#rare-bad-toast.show {
  animation: rare-bad-toast-in 0.45s ease-out forwards,
             rare-bad-glow     1.6s ease-in-out 0.45s infinite;
}
#rare-bad-toast.hide {
  animation: rare-bad-toast-out 0.42s ease-in forwards;
}
.rare-bad-toast-msg {
  font-size: 0.9rem;
  font-weight: bold;
  color: #c89aff;
  letter-spacing: 0.1em;
}

/* ===== アチーブメントトースト ===== */
@keyframes ach-toast-in {
  from { transform: translateX(-50%) translateY(120px); opacity: 0; }
  to   { transform: translateX(-50%) translateY(0);     opacity: 1; }
}
@keyframes ach-toast-out {
  from { transform: translateX(-50%) translateY(0);     opacity: 1; }
  to   { transform: translateX(-50%) translateY(120px); opacity: 0; }
}
@keyframes ach-toast-glow {
  0%,100% { box-shadow: 0 0 8px 1px rgba(255,204,0,0.35); }
  50%      { box-shadow: 0 0 18px 5px rgba(255,204,0,0.65); }
}

.ach-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: #1e2140;
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 12px 20px 14px;
  text-align: center;
  width: min(70vw, 420px);
  z-index: 2000;
  pointer-events: none;
}

.ach-toast-show {
  animation: ach-toast-in 0.38s ease-out forwards,
             ach-toast-glow 1.5s ease-in-out 0.38s infinite;
}
/* レアリティ別トースト：シマーグラデーション背景 */
@keyframes ach-toast-shimmer {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes ach-legend-glow {
  0%,100% { box-shadow: 0 0 10px 2px rgba(155,89,182,0.4); }
  50%      { box-shadow: 0 0 22px 7px rgba(155,89,182,0.75); }
}

/* 基底スタイル：グラデーション背景と枠線のみ（animation はここに置かない） */
.ach-toast.rarity-bronze {
  background: linear-gradient(45deg, #a57e65 0%, #a57e65 45%, #f3cfb8 70%, #a57e65 85%, #a57e65 100%);
  background-size: 800% 400%;
  border-color: #cd7f32;
  box-shadow: 0 0 14px 2px rgba(205,127,50,0.5);
}
.ach-toast.rarity-silver {
  background: linear-gradient(45deg, #757575 0%, #9e9e9e 45%, #e8e8e8 70%, #9e9e9e 85%, #757575 100%);
  background-size: 800% 400%;
  border-color: #a8b8c8;
  box-shadow: 0 0 14px 2px rgba(168,184,200,0.5);
}
.ach-toast.rarity-gold {
  background: linear-gradient(45deg, #daaf08 0%, #daaf08 45%, #fee9a0 70%, #daaf08 85%, #daaf08 100%);
  background-size: 800% 400%;
  border-color: #d4a800;
  box-shadow: 0 0 14px 2px rgba(212,168,0,0.55);
}
.ach-toast.rarity-legend {
  background: linear-gradient(45deg, #5a1090 0%, #8b3cc8 45%, #d4a8ff 70%, #8b3cc8 85%, #5a1090 100%);
  background-size: 800% 400%;
  border-color: #9b59b6;
  box-shadow: 0 0 14px 2px rgba(155,89,182,0.6);
}

/* 表示アニメーション：スライドイン＋シマーをここで定義（詳細度 0,2,0 で hide より優先） */
.ach-toast-show.rarity-bronze,
.ach-toast-show.rarity-silver,
.ach-toast-show.rarity-gold {
  animation: ach-toast-in      0.38s ease-out forwards,
             ach-toast-shimmer 5s    infinite cubic-bezier(.62,.28,.23,.99) 0.38s both;
}
.ach-toast-show.rarity-legend {
  animation: ach-toast-in      0.38s ease-out forwards,
             ach-toast-shimmer 4s    infinite cubic-bezier(.62,.28,.23,.99) 0.38s both,
             ach-legend-glow   1.2s  ease-in-out 0.38s infinite;
}

/* 退場アニメーション：hide を rarity より詳細度高く定義してスライドアウトを確保 */
.ach-toast-hide.rarity-bronze,
.ach-toast-hide.rarity-silver,
.ach-toast-hide.rarity-gold,
.ach-toast-hide.rarity-legend {
  animation: ach-toast-out 0.42s ease-in forwards;
}

/* ブロンズ・シルバー・ゴールドは明るい背景なので暗い文字色に */
.ach-toast.rarity-bronze .ach-toast-label,
.ach-toast.rarity-silver .ach-toast-label,
.ach-toast.rarity-gold   .ach-toast-label { color: rgba(0,0,0,0.55); }
.ach-toast.rarity-bronze .ach-toast-name,
.ach-toast.rarity-silver .ach-toast-name,
.ach-toast.rarity-gold   .ach-toast-name  { color: #1a1000; }
.ach-toast.rarity-bronze .ach-toast-condition,
.ach-toast.rarity-silver .ach-toast-condition,
.ach-toast.rarity-gold   .ach-toast-condition { color: rgba(0,0,0,0.6); }

/* レジェンドは暗い紫背景なので明るい文字色に */
.ach-toast.rarity-legend .ach-toast-label     { color: #e0c0ff; }
.ach-toast.rarity-legend .ach-toast-name      { color: #ffffff; }
.ach-toast.rarity-legend .ach-toast-condition { color: #d0a8f8; }

.ach-toast-hide {
  animation: ach-toast-out 0.42s ease-in forwards;
}

.ach-toast-label {
  font-size: 0.68rem;
  color: var(--gold);
  letter-spacing: 0.12em;
  margin-bottom: 5px;
}

.ach-toast-name {
  font-size: 0.95rem;
  font-weight: bold;
  color: var(--text);
  margin-bottom: 4px;
}

.ach-toast-condition {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ===== 性別ラジオ ===== */
.gender-row {
  margin-top: 10px;
  justify-content: center;
}

.gender-group {
  flex: 0 0 auto;
  align-items: center;
}

.gender-radios {
  display: flex;
  gap: 20px;
  align-items: center;
  height: 40px;
}

.gender-radio-label {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  margin: 0 !important;
  letter-spacing: normal;
}

.gender-radio-label input[type="radio"] {
  width: auto;
  height: auto;
  accent-color: var(--gold);
  margin: 0;
  flex-shrink: 0;
}

/* ===== おまけ：干支・厄年 ===== */
.extra-fortune-details { cursor: default; }

@keyframes extra-summary-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.extra-fortune-summary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #ff0000;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 2px 0;
  animation: extra-summary-blink 1.6s ease-in-out infinite;
}
.extra-fortune-summary::-webkit-details-marker { display: none; }
.extra-fortune-summary::after {
  content: '▶';
  font-size: 0.65rem;
  color: #ff0000;
  transition: transform 0.2s;
}
details#extra-fortune-section[open] > .extra-fortune-summary {
  color: var(--gold);
  animation: none;
}
details#extra-fortune-section[open] > .extra-fortune-summary::after {
  transform: rotate(90deg);
  color: var(--muted);
}

.extra-fortune-content {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.extra-block {
  background: var(--surface2);
  border-radius: 8px;
  padding: 12px 14px;
}

.extra-block-title {
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.extra-eto {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.extra-eto-name {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
}

.extra-eto-desc {
  font-size: 0.8rem;
  color: var(--muted);
}

.extra-yaku-row {
  display: flex;
  gap: 10px;
}

.extra-yaku-half {
  flex: 1;
  min-width: 0;
}

.extra-yaku-safe   { font-size: 0.9rem; color: #448844; }
.extra-yaku-result { font-size: 1rem; font-weight: bold; }
.extra-yaku-warn   { font-size: 1rem; font-weight: bold; color: #cc6600; }
.extra-yaku-dai    { font-size: 1rem; font-weight: bold; color: #cc2200; }
.extra-yaku-note   { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

.extra-yaku-next {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
  padding: 4px 8px;
  border-top: 1px solid var(--border);
}
