/* ========== ベース ========== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  color: #333;
  background: #ececec;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

/* ========== ホーム (index.html) ========== */
.page-home {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.sheet {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 24px;
  padding: 56px 28px 40px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.sheet__close {
  position: absolute;
  top: 16px;
  right: 20px;
  background: transparent;
  border: none;
  font-size: 32px;
  color: #9aa0a6;
  cursor: pointer;
  line-height: 1;
}
.sheet__lead {
  text-align: center;
  margin-bottom: 56px;
}
.sheet__title {
  font-size: 20px;
  font-weight: 700;
  color: #4a4a4a;
  margin: 0 0 24px;
  line-height: 1.8;
}
.sheet__mascot {
  width: 110px;
  margin: 0 auto;
}
.sheet__actions {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.pill-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-radius: 999px;
  background: #5AC8E6;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s;
  box-shadow: 0 4px 0 rgba(0,0,0,0.08);
  user-select: none;
}
.pill-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0,0,0,0.08); }
.pill-btn__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pill-btn__body { display: flex; flex-direction: column; }
.pill-btn__label { font-size: 16px; }
.pill-btn__sub { font-size: 11px; font-weight: 500; opacity: 0.9; margin-top: 2px; }
.sheet__foot {
  text-align: center;
  margin-top: 36px;
  font-size: 13px;
  color: #7a8088;
}
.sheet__foot a { text-decoration: underline; }

/* ========== スキャン画面 (scan.html) ========== */
.page-scan { background: #000; color: #fff; }
.scan {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.scan__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: env(safe-area-inset-top, 12px) 16px 12px;
  padding-top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: rgba(0,0,0,0.35);
}
.scan__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: none;
  cursor: pointer;
}
.scan__title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.camera {
  position: relative;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.camera video,
.camera__still,
.camera canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#overlay { pointer-events: none; }
.camera__status {
  position: absolute;
  padding: 8px 14px;
  background: rgba(0,0,0,0.6);
  border-radius: 999px;
  font-size: 13px;
  z-index: 2;
}
.scan__footer {
  padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0,0,0,0.35);
}
.scan__footer--actions {
  background: rgba(0,0,0,0.5);
}

/* シャッターボタン */
.shutter {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 999px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.shutter:disabled { opacity: 0.4; cursor: default; }
.shutter__ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 4px solid rgba(255,255,255,0.9);
}
.shutter__core {
  position: absolute;
  inset: 8px;
  border-radius: 999px;
  background: #fff;
  transition: transform 0.1s;
}
.shutter:active .shutter__core { transform: scale(0.9); }

/* プレビュー */
.scan--preview .preview {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: #1a1a1a;
  overflow: auto;
}
.preview canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  background: #fff;
}

/* 四隅調整 */
.scan--adjust .adjust {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: #000;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
}
.adjust canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  touch-action: none;     /* ドラッグ中のスクロール抑止 */
  user-select: none;
  -webkit-user-select: none;
}
.btn {
  padding: 14px 28px;
  border-radius: 999px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-width: 130px;
}
.btn--primary { background: #5AC8E6; color: #fff; box-shadow: 0 4px 0 rgba(0,0,0,0.3); }
.btn--primary:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0,0,0,0.3); }
.btn--ghost { background: transparent; color: #fff; border: 2px solid rgba(255,255,255,0.4); }

/* ===== スキャン画面 ヘッダー右端の向き切替ボタン ===== */
.scan__title { flex: 1; }
.scan__rotate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  color: #fff;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.scan__rotate:active { background: rgba(255,255,255,0.28); }

/* 状態表示（縦/横）— body のクラスでどちらかだけ表示 */
.scan__rotate__state {
  display: none;
  align-items: center;
  gap: 5px;
  line-height: 1;
}
.scan__rotate__label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
body:not(.is-landscape-mode) .scan__rotate__state--portrait  { display: inline-flex; }
body.is-landscape-mode       .scan__rotate__state--landscape { display: inline-flex; }

/* ===== スキャン画面 横向きモード（ボタンで切替） ===== */
/* .scan を横並び(row)にして「カメラ | フッター(右)」の2カラム構成にする */
body.is-landscape-mode .scan {
  flex-direction: row;
}

/* ヘッダーは上端に絶対配置でカメラに重ねる */
body.is-landscape-mode .scan__header {
  position: absolute;
  top: 0;
  left: 0;
  right: 112px;        /* フッター幅を避ける */
  padding: 8px 14px 8px calc(env(safe-area-inset-left, 0px) + 14px);
  padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  background: linear-gradient(to bottom, rgba(0,0,0,0.55), rgba(0,0,0,0));
  z-index: 3;
}
body.is-landscape-mode .scan__title { font-size: 13px; }

/* フッターは row の2つめの子として右カラムに入る */
body.is-landscape-mode .scan__footer {
  position: static;
  width: 112px;
  flex: 0 0 112px;
  padding: 8px calc(env(safe-area-inset-right, 0px) + 10px) 8px 8px;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 3;
}
body.is-landscape-mode .scan__footer--actions { gap: 10px; }

body.is-landscape-mode .shutter { width: 64px; height: 64px; }

body.is-landscape-mode .btn {
  min-width: 0;
  width: 100%;
  padding: 10px 10px;
  font-size: 12px;
}

/* カメラ/プレビュー/調整 は残りの幅を取る（横並びで左カラム） */
body.is-landscape-mode .camera,
body.is-landscape-mode .scan--preview .preview,
body.is-landscape-mode .scan--adjust .adjust {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
}

/* ローディング */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  color: #fff;
}
.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== アルバム (album.html) ========== */
.page-album { background: #f7f7f7; }
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: #fff;
  box-shadow: 0 1px 0 rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: #555;
}
.topbar__back:hover { background: #f0f0f0; }
.topbar__title { font-size: 16px; font-weight: 700; margin: 0; }

.album { padding: 12px; max-width: 960px; margin: 0 auto; }
.album__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.album__card {
  display: block;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  aspect-ratio: 3 / 4;
  position: relative;
}
.album__card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.album__meta {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 6px 8px;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0));
  color: #fff;
  font-size: 11px;
}
.album__empty, .album__error {
  padding: 40px 20px;
  text-align: center;
  color: #777;
}

/* ========== ガチャ (gacha.html) ========== */
.page-gacha {
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.45), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(255,255,255,0.35), transparent 40%),
    linear-gradient(to bottom, #fbe9c1 0%, #f0cf84 100%);
  min-height: 100vh;
  min-height: 100dvh;
  color: #3e2810;
}

/* トップバー */
.gacha-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px;
}
.gacha-topbar__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border-radius: 999px;
  background: rgba(255,255,255,0.65);
  color: #5e3b1a;
  border: 2px solid #a17b4b;
  box-shadow: 0 2px 0 rgba(0,0,0,0.1);
}

/* コイン表示 */
.gacha-coins {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(to bottom, #8b5a2b, #603c15);
  color: #fff7e0;
  font-weight: 800;
  font-size: 11px;
  border: 2px solid #3e2810;
  box-shadow: 0 3px 0 rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.15);
  letter-spacing: 0.04em;
}
.coin-icon { display: inline-flex; filter: drop-shadow(0 1px 0 rgba(0,0,0,0.3)); }
.coins-label { opacity: 0.85; }
.coins-value { font-size: 18px; color: #fcd34d; line-height: 1; letter-spacing: 0; }

/* メイン */
.gacha {
  padding: 6px 14px 20px;
  max-width: 560px;
  margin: 0 auto;
}

/* バナー */
.gacha-banner {
  text-align: center;
  margin: 8px auto 24px;
}
.gacha-banner__ribbon {
  display: inline-block;
  position: relative;
  background: linear-gradient(to bottom, #b8823a, #7a5526);
  color: #fff7e0;
  padding: 12px 28px 14px;
  border-radius: 14px;
  border: 3px solid #5e3d1a;
  box-shadow: 0 4px 0 rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.25);
  max-width: 90%;
}
.gacha-banner__ribbon::before,
.gacha-banner__ribbon::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 20px; height: 20px;
  background: #8a5e28;
  border: 2px solid #5e3d1a;
  transform: translateY(-50%) rotate(45deg);
  z-index: -1;
}
.gacha-banner__ribbon::before { left: -10px; }
.gacha-banner__ribbon::after  { right: -10px; }
.gacha-banner__sub {
  margin: 0 0 3px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.95;
  letter-spacing: 0.04em;
}
.gacha-banner__main {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(0,0,0,0.18);
}

/* リール（宝箱の開口部） */
.reel-panel { margin-bottom: 22px; }
.reel-wrap {
  position: relative;
  background: linear-gradient(to bottom, #9c7343, #6b4a2b);
  border: 4px solid #4e3215;
  border-radius: 18px;
  padding: 6px;
  overflow: hidden;
  height: 108px;
  box-shadow: inset 0 3px 5px rgba(0,0,0,0.4), 0 4px 0 rgba(0,0,0,0.15);
}
.reel {
  display: flex;
  gap: 8px;
  padding: 4px;
  height: 100%;
  align-items: center;
  will-change: transform;
  transform: translateX(0);
}
.reel-cell {
  flex: 0 0 auto;
  width: 76px;
  height: 84px;
  background: #fbf0d4;
  border: 2px solid #a17b4b;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.08);
}
.reel-cell--R  { background: #dceafa; border-color: #6a9bc7; }
.reel-cell--SR { background: #fbe2c5; border-color: #c48d56; }
.reel-cell--UR {
  background: linear-gradient(135deg, #fff0b7, #f0c43e);
  border-color: #d4a416;
  box-shadow: inset 0 0 10px rgba(255,200,0,0.55);
}
.reel-cell__emoji { font-size: 40px; line-height: 1; }

.reel-pointer {
  position: absolute;
  top: 2px; bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 88px;
  border-radius: 14px;
  border: 3px solid #fcd34d;
  box-shadow: 0 0 18px rgba(252,211,77,0.8), inset 0 0 0 3px rgba(255,255,255,0.25);
  pointer-events: none;
}
.reel-gloss {
  position: absolute;
  inset: 0;
  background: linear-gradient(to right,
    rgba(78,50,21,0.9) 0%, rgba(78,50,21,0) 18%,
    rgba(78,50,21,0) 82%, rgba(78,50,21,0.9) 100%);
  pointer-events: none;
}

/* 月末限定シルエット */
.monthly {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255,255,255,0.55);
  border: 2px dashed #a17b4b;
  border-radius: 16px;
  padding: 10px 16px;
  margin: 0 auto 22px;
  max-width: 380px;
}
.monthly__silhouette {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #3a2a17;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  box-shadow: inset 0 -2px 4px rgba(255,255,255,0.1);
}
.monthly__silhouette::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px dashed rgba(161,123,75,0.7);
}
.monthly__qmark {
  color: #75593a;
  font-size: 32px;
  font-weight: 900;
  font-family: Georgia, serif;
}
.monthly__silhouette--owned {
  background: radial-gradient(circle, #fff9c4 0%, #fcd34d 100%);
}
.monthly__silhouette--owned .monthly__qmark { display: none; }
.monthly__silhouette--owned::before {
  content: '✨';
  font-size: 32px;
}
.monthly__text p { margin: 0; color: #5e3b1a; }
.monthly__caption { font-size: 14px; font-weight: 800; }
.monthly__sub { font-size: 12px; font-weight: 700; opacity: 0.85; margin-top: 2px; }

/* 引くボタン */
.draw-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
  padding: 0 6px;
}
.gacha-btn {
  flex: 1;
  max-width: 200px;
  padding: 14px 16px 12px;
  border: 3px solid rgba(0,0,0,0.18);
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  box-shadow: 0 5px 0 rgba(0,0,0,0.2);
  transition: transform 0.08s, box-shadow 0.08s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}
.gacha-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}
.gacha-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.gacha-btn--single { background: linear-gradient(to bottom, #7ddbf5 0%, #37a6d8 100%); }
.gacha-btn--ten    { background: linear-gradient(to bottom, #f5b5b5 0%, #d96868 100%); }
.gacha-btn__label { font-size: 17px; letter-spacing: 0.02em; }
.gacha-btn__cost  { font-size: 11px; opacity: 0.95; letter-spacing: 0.03em; }

/* フッター */
.gacha-foot { text-align: center; margin-top: 24px; }
.linklike {
  background: none;
  border: none;
  font-family: inherit;
  color: #8b5a2b;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}

/* 結果モーダル */
.gacha-result {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  animation: gachaFadeIn 0.2s;
}
@keyframes gachaFadeIn { from { opacity: 0; } to { opacity: 1; } }

.result-panel {
  position: relative;
  background: linear-gradient(to bottom, #fdf2d2, #f5d98f);
  border: 4px solid #8b5a2b;
  border-radius: 22px;
  padding: 20px 18px;
  max-width: 400px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.45);
}
.result-title {
  text-align: center;
  color: #c47a1a;
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 800;
  text-shadow: 0 2px 0 rgba(0,0,0,0.1);
}
.result-title__sparkle { display: inline-block; margin: 0 4px; animation: spinSparkle 1.6s ease-in-out infinite; }
@keyframes spinSparkle {
  0%, 100% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.25) rotate(8deg); }
}

.result-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.result-card {
  position: relative;
  background: #fff;
  border: 3px solid #a17b4b;
  border-radius: 14px;
  padding: 8px 6px;
  text-align: center;
  animation: popIn 0.35s ease-out both;
}
@keyframes popIn {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.result-card--R  { border-color: #5c96d1; background: #e8f2fb; }
.result-card--SR { border-color: #c48d56; background: #fbe7cf; }
.result-card--UR {
  border-color: #d4a416;
  background: linear-gradient(135deg, #fff6c7, #f7d86b);
  animation: popIn 0.35s ease-out both, sparkleGlow 1.4s ease-in-out 0.35s infinite;
}
@keyframes sparkleGlow {
  0%, 100% { box-shadow: 0 0 0 rgba(252,211,77,0); }
  50%      { box-shadow: 0 0 20px rgba(252,211,77,0.9); }
}

.result-card__rarity {
  font-size: 10px;
  font-weight: 800;
  color: #fff;
  background: #a17b4b;
  padding: 1px 6px;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 4px;
  letter-spacing: 0.05em;
}
.result-card--R  .result-card__rarity { background: #3d7cb9; }
.result-card--SR .result-card__rarity { background: #a65a1e; }
.result-card--UR .result-card__rarity { background: #c07e00; }

.result-card__emoji { font-size: 40px; line-height: 1; margin: 2px 0 4px; }
.result-card__name  { font-size: 11px; font-weight: 700; color: #3e2810; line-height: 1.3; }
.result-card__new {
  position: absolute;
  top: -8px;
  right: -6px;
  background: #ff5757;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 10px;
  transform: rotate(10deg);
  box-shadow: 0 2px 4px rgba(0,0,0,0.25);
  letter-spacing: 0.05em;
}

.gacha-btn--close {
  background: linear-gradient(to bottom, #b8823a, #7a5526);
  width: 100%;
  max-width: none;
  border-color: rgba(0,0,0,0.25);
}

/* ========== コレクション (collection.html) ========== */
.page-collection { /* page-gacha と同じ背景を継承 */ }

.collection {
  padding: 6px 14px 24px;
  max-width: 720px;
  margin: 0 auto;
}

/* カテゴリタブ */
.col-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  margin: 4px 0 14px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.col-tabs::-webkit-scrollbar { display: none; }

.col-tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  border: 2px solid #a17b4b;
  color: #5e3b1a;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.08s;
}
.col-tab:active { transform: translateY(1px); }
.col-tab--active {
  background: linear-gradient(to bottom, #b8823a, #7a5526);
  color: #fff7e0;
  border-color: #5e3d1a;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}
.col-tab__emoji { font-size: 15px; }

/* 図鑑フレーム（木枠） */
.col-frame {
  background: linear-gradient(to bottom, #9c7343, #6b4a2b);
  border: 4px solid #4e3215;
  border-radius: 18px;
  padding: 12px;
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.3), 0 4px 0 rgba(0, 0, 0, 0.15);
  position: relative;
}
.col-frame::before,
.col-frame::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, #f8e38a 0%, #d4a416 70%, #8a6100 100%);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.col-frame::before { top: 6px; left: 8px; }
.col-frame::after  { top: 6px; right: 8px; }

.col-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (min-width: 480px) {
  .col-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 640px) {
  .col-grid { grid-template-columns: repeat(5, 1fr); }
}

/* アイテムカード */
.col-item {
  position: relative;
  aspect-ratio: 1;
  background: #fbf0d4;
  border: 2px solid #a17b4b;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  transition: transform 0.1s;
}
.col-item:active { transform: scale(0.95); }
.col-item--R  { background: #dceafa; border-color: #6a9bc7; }
.col-item--SR { background: #fbe2c5; border-color: #c48d56; }
.col-item--UR {
  background: linear-gradient(135deg, #fff0b7, #f0c43e);
  border-color: #d4a416;
}
.col-item--locked {
  background: #5e3d1a;
  border-color: #3a2510;
  color: #a17b4b;
}

.col-item__emoji {
  font-size: 36px;
  line-height: 1;
  margin-top: 4px;
}
.col-item__name {
  font-size: 10px;
  font-weight: 700;
  color: #5e3b1a;
  text-align: center;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.col-item__count {
  font-size: 9px;
  font-weight: 700;
  color: #8b5a2b;
  letter-spacing: 0.02em;
}
.col-item--locked .col-item__count { color: #a17b4b; font-weight: 800; }
.col-item__qmark {
  font-size: 38px;
  color: #a17b4b;
  font-weight: 900;
  font-family: Georgia, serif;
  line-height: 1;
  margin-bottom: 4px;
}

.col-item__star {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fcd34d;
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
  border: 2px solid #fff;
  line-height: 1;
  padding-bottom: 1px;
}
.col-item__star--R  { background: #5c96d1; }
.col-item__star--SR { background: #e08b3f; }
.col-item__star--UR {
  background: radial-gradient(circle, #fff7b8, #f0c43e);
  color: #8a6100;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2), 0 0 10px rgba(252, 211, 77, 0.8);
}

/* 合計 */
.col-total {
  text-align: center;
  color: #5e3b1a;
  font-weight: 800;
  font-size: 13px;
  margin: 16px 0 4px;
  letter-spacing: 0.04em;
}

/* 詳細モーダル */
.col-detail {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  animation: gachaFadeIn 0.2s;
}

.detail-panel {
  position: relative;
  background: linear-gradient(to bottom, #fdf2d2, #f5d98f);
  border: 4px solid #8b5a2b;
  border-radius: 22px;
  padding: 22px 20px 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: popIn 0.35s ease-out;
}
.detail-panel::before,
.detail-panel::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, #f8e38a 0%, #d4a416 70%, #8a6100 100%);
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.detail-panel::before { top: 10px; left: 14px; }
.detail-panel::after  { top: 10px; right: 14px; }

.detail-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid #a17b4b;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  color: #5e3b1a;
  line-height: 1;
  z-index: 2;
}

.detail-image {
  width: 120px;
  height: 120px;
  margin: 10px auto 12px;
  background: #fff;
  border: 3px solid #a17b4b;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.1);
}
.detail-image--R  { background: #e8f2fb; border-color: #5c96d1; }
.detail-image--SR { background: #fbe7cf; border-color: #c48d56; }
.detail-image--UR {
  background: linear-gradient(135deg, #fff6c7, #f7d86b);
  border-color: #d4a416;
  animation: sparkleGlow 1.6s ease-in-out infinite;
}
.detail-image--locked {
  background: #3a2a17;
  color: #a17b4b;
  font-size: 56px;
  font-family: Georgia, serif;
  font-weight: 900;
}

.detail-name {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 800;
  color: #5e3b1a;
}
.detail-stars {
  font-size: 18px;
  color: #f0b90b;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  line-height: 1;
}
.detail-stars__empty { color: #c7b187; }
.detail-stars__label {
  display: block;
  font-size: 11px;
  color: #8b5a2b;
  font-weight: 800;
  letter-spacing: 0.06em;
  margin-top: 4px;
}
.detail-desc {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.6;
  color: #5e3b1a;
  background: rgba(255, 255, 255, 0.65);
  padding: 12px 14px;
  border-radius: 12px;
  border: 2px solid rgba(161, 123, 75, 0.4);
}
.detail-count {
  font-size: 12px;
  color: #8b5a2b;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.05em;
}

/* ========== ガチャ2（モダン リデザイン / gacha2.html） ========== */
.page-gacha2 .gacha { padding-bottom: 30px; }

.machine-area {
  position: relative;
  max-width: 280px;
  margin: 18px auto 32px;
  filter: drop-shadow(0 14px 20px rgba(180, 120, 80, 0.18));
}
.machine {
  position: relative;
  width: 100%;
  aspect-ratio: 0.76;
}

/* ドーム上部の赤キャップ（柔らかめのコーラル） */
.machine__top {
  position: absolute;
  top: 0;
  left: 24%;
  right: 24%;
  height: 12%;
  background: linear-gradient(to bottom,
    #ff8fa1 0%,
    #ec5d72 45%,
    #c93a4f 100%);
  border-radius: 50% 50% 14px 14px / 90% 90% 14px 14px;
  z-index: 3;
  box-shadow:
    inset 0 3px 8px rgba(255, 255, 255, 0.55),
    inset 0 -5px 8px rgba(150, 30, 50, 0.25),
    0 3px 6px rgba(200, 60, 80, 0.3);
}
.machine__crown {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 26px;
  color: #ffd93c;
  filter: drop-shadow(0 2px 3px rgba(200, 150, 20, 0.4))
          drop-shadow(0 0 10px rgba(255, 217, 60, 0.8));
  line-height: 1;
}

/* ガラスドーム（モダン・クリアな透明感） */
.machine__dome {
  position: absolute;
  top: 6%;
  left: 3%;
  right: 3%;
  height: 62%;
  background:
    radial-gradient(circle at 28% 22%, rgba(255, 255, 255, 0.9) 0%, transparent 46%),
    linear-gradient(135deg, rgba(255, 248, 240, 0.4) 0%, rgba(225, 235, 245, 0.25) 100%);
  border: 3px solid #ecc9cf;
  border-radius: 50% 50% 46% 46%;
  z-index: 1;
  overflow: hidden;
  box-shadow:
    inset 0 8px 18px rgba(255, 255, 255, 0.5),
    inset 0 -12px 24px rgba(180, 200, 220, 0.18),
    0 6px 14px rgba(180, 130, 80, 0.12);
}
.capsule-pool { position: absolute; inset: 0; }

.capsule {
  position: absolute;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  box-shadow: inset -3px -4px 5px rgba(0,0,0,0.08),
              inset 3px 3px 4px rgba(255,255,255,0.55);
  animation: capsuleFloat 3s ease-in-out infinite;
}
@keyframes capsuleFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(3px, -4px) rotate(-8deg); }
  50% { transform: translate(-2px, 3px) rotate(5deg); }
  75% { transform: translate(4px, 1px) rotate(-3deg); }
}
.machine.is-shaking .capsule {
  animation: capsuleShake 0.2s linear infinite !important;
}
@keyframes capsuleShake {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  20% { transform: translate(-3px, 3px) rotate(-10deg); }
  40% { transform: translate(4px, -2px) rotate(12deg); }
  60% { transform: translate(-2px, -3px) rotate(-6deg); }
  80% { transform: translate(3px, 2px) rotate(8deg); }
}

.machine__highlight {
  position: absolute;
  top: 8%;
  left: 15%;
  width: 32%;
  height: 28%;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.75), transparent 65%);
  border-radius: 50%;
  pointer-events: none;
}

/* 本体（モダンなクリーム色プラスチック） */
.machine__base {
  position: absolute;
  bottom: 0;
  left: 1%;
  right: 1%;
  height: 35%;
  background: linear-gradient(to bottom,
    #ffffff 0%,
    #fff5e1 45%,
    #f0d8aa 100%);
  border: 2px solid #e4cb95;
  border-radius: 18px;
  z-index: 2;
  box-shadow:
    inset 0 -4px 8px rgba(180, 130, 80, 0.12),
    inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

/* ゴールドトリム（層状グラデで金属感） */
.machine__trim {
  position: absolute;
  left: 2%;
  right: 2%;
  height: 7px;
  background: linear-gradient(to bottom,
    #fff1b8 0%,
    #f8c960 35%,
    #cd933a 70%,
    #a87328 100%);
  border-radius: 3px;
  box-shadow:
    0 1px 2px rgba(120, 80, 20, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}
.machine__trim--top    { top: -4px; }
.machine__trim--bottom { bottom: -4px; }

.machine__coin-slot {
  position: absolute;
  top: 13%;
  left: 50%;
  transform: translateX(-50%);
  width: 28%;
  height: 5px;
  background: linear-gradient(to bottom, #5a3520 0%, #2a1608 100%);
  border-radius: 3px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.machine__slot-hole {
  position: absolute;
  bottom: 24%;
  left: 26%;
  right: 26%;
  height: 28%;
  background: linear-gradient(to bottom, #6b4a2a 0%, #3d2410 100%);
  border: 2px solid #d4b68a;
  border-radius: 45% 45% 6px 6px;
  box-shadow:
    inset 0 4px 8px rgba(0, 0, 0, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.7);
}
.machine__slot-tray {
  position: absolute;
  bottom: 10%;
  left: 28%;
  right: 28%;
  height: 11%;
  background: linear-gradient(to bottom, #e4cb95 0%, #b8966a 100%);
  border: 1.5px solid #8a6a3a;
  border-radius: 5px 5px 8px 8px;
  box-shadow:
    inset 0 2px 3px rgba(100, 70, 30, 0.25),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}

/* クランク（本体正面の中央に配置） */
.crank {
  position: absolute;
  top: 72%;                   /* コイン投入口と取り出し口の中間 */
  left: calc(50% - 19px);     /* 水平中央（幅38pxの半分 = 19px） */
  width: 38px;
  height: 38px;
  background: radial-gradient(circle at 32% 32%,
    #fff6b8 0%,
    #f8c960 40%,
    #cd933a 90%,
    #a87328 100%);
  border-radius: 50%;
  border: 2px solid #8a6500;
  z-index: 4;
  box-shadow:
    0 3px 5px rgba(0, 0, 0, 0.3),
    inset 0 1px 2px rgba(255, 255, 255, 0.55),
    inset 0 -2px 3px rgba(100, 65, 10, 0.3);
}
.crank::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  margin-left: -2.5px;
  width: 5px;
  height: 12px;
  background: linear-gradient(to bottom, #a87328, #704a16);
  border-radius: 2.5px;
}
.crank::after {
  content: '';
  position: absolute;
  top: 10px;
  left: 50%;
  margin-left: -5.5px;
  width: 11px;
  height: 11px;
  background: radial-gradient(circle at 32% 32%,
    #ffa5a5,
    #ec5d72 60%,
    #a33445 100%);
  border-radius: 50%;
  border: 1.5px solid #7a2030;
  box-shadow:
    inset 0 1px 1.5px rgba(255, 255, 255, 0.35),
    inset 0 -1px 1.5px rgba(0, 0, 0, 0.25);
}
.machine.is-cranking .crank {
  animation: crankSpin 1.4s ease-in-out;
}
@keyframes crankSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* マシン全体の揺れ */
.machine.is-shaking {
  animation: machineWobble 0.18s ease-in-out infinite;
}
@keyframes machineWobble {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(-2px); }
}

/* 落ちてくるカプセル */
.falling-capsule {
  position: absolute;
  left: 50%;
  bottom: 7.5%;          /* トレイの天面あたり */
  margin-left: -32px;    /* 幅64pxの半分 */
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.18);
  box-shadow: 0 5px 10px rgba(0,0,0,0.32),
              inset -5px -6px 9px rgba(0,0,0,0.1),
              inset 5px 5px 6px rgba(255,255,255,0.55);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
}
.falling-capsule.is-falling {
  animation: capsuleDrop 1.3s cubic-bezier(0.34, 1.2, 0.5, 1) both;
}
/* 取り出し口の奥からにゅっと出てきて、トレイに落ちる */
@keyframes capsuleDrop {
  0%   { transform: translateY(-50px) scale(0.5);                 opacity: 0; }  /* 取り出し口の奥（見えない） */
  20%  { transform: translateY(-30px) scale(0.9);                 opacity: 1; }  /* 取り出し口の中で見え始める */
  42%  { transform: translateY(-5px)  scale(1)    rotate(180deg); opacity: 1; }  /* 口から出きる */
  58%  { transform: translateY(3px)   scale(1.04) rotate(270deg); opacity: 1; }  /* トレイに着地して少しつぶれる */
  72%  { transform: translateY(-2px)  scale(1)    rotate(330deg); opacity: 1; }  /* 小バウンド */
  86%  { transform: translateY(1px)   scale(1)    rotate(360deg); opacity: 1; }  /* おちつく */
  100% { transform: translateY(0)     scale(1.05) rotate(360deg); opacity: 0; }  /* フェードアウト */
}
