/* ニコとモモのミニゲーム（game.html 専用）
   手描き水彩の空気感 × PC/スマホ快適な操作性 × ランキング＆Xシェア映え */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.mg-section {
  --mg-top: 84px;
  padding: 24px 0 60px;
  background:
    radial-gradient(ellipse at 10% 6%, rgba(235, 189, 85, 0.2), transparent 44%),
    radial-gradient(ellipse at 88% 18%, rgba(142, 193, 217, 0.16), transparent 46%),
    radial-gradient(ellipse at 72% 88%, rgba(229, 150, 156, 0.16), transparent 48%);
}

.mg-section > .wrap {
  max-width: 1060px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(430px, calc((100svh - var(--mg-top) - 24px) * 0.5658));
  grid-template-areas:
    "head stage"
    "picker stage"
    "board stage";
  grid-template-rows: auto auto 1fr;
  gap: 14px 36px;
  align-items: start;
}

.mg-head { grid-area: head; padding-top: 6px; }
.mg-head .section-title { font-size: clamp(1.45rem, 2.7vw, 2.1rem); margin-bottom: 4px; }
.mg-head .section-sub { font-size: 0.88rem; color: var(--ink-soft); margin: 0; line-height: 1.6; }

.mg-picker {
  grid-area: picker;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-content: start;
}

.mg-board { grid-area: board; }
.mg-stage-col { grid-area: stage; width: 100%; }

/* ---------- ゲーム選択タブ ---------- */

.mg-pick {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  text-align: left;
  background: rgba(251, 247, 238, 0.92);
  border: 2px solid var(--ink-line);
  border-radius: 18px;
  box-shadow: var(--shadow-ink);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.mg-pick:hover { transform: translate(-1px, -2px); box-shadow: var(--shadow-lift); }
.mg-pick.is-active {
  background: linear-gradient(155deg, #fff8e2 0%, var(--mustard-soft) 100%);
  border-color: var(--ink);
  box-shadow: 4px 4px 0 rgba(53, 40, 31, 0.22);
}
.mg-pick:focus-visible { outline: 3px solid var(--terracotta); outline-offset: 3px; }

.mg-pick-art { display: flex; align-items: center; }
.mg-pick-art img { width: 42px; height: 42px; filter: drop-shadow(1px 2px 0 rgba(53, 40, 31, 0.12)); }
.mg-pick-art img + img { margin-left: -10px; }

.mg-pick-text { min-width: 0; width: 100%; }
.mg-pick-text b {
  display: block;
  font-family: var(--font-round);
  font-size: 0.98rem;
  line-height: 1.3;
  letter-spacing: 0.01em;
}
.mg-pick-text small {
  display: block;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.4;
  margin-top: 2px;
}

.mg-pick-best {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-round);
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(255, 253, 248, 0.92);
  border: 1.5px solid var(--ink-line);
  color: var(--ink-soft);
}
.mg-pick.is-active .mg-pick-best {
  border-color: var(--ink);
  color: var(--ink);
  background: #fffdf8;
}

/* ---------- みんなのランキングボード（アトリエ表彰台） ---------- */

.mg-board {
  background: rgba(251, 247, 238, 0.96);
  border: 2px solid var(--ink);
  border-radius: 22px;
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-lift);
  position: relative;
  overflow: hidden;
}

.mg-board::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    var(--mustard) 0 18px,
    var(--rose) 18px 36px,
    var(--sky) 36px 54px,
    var(--meadow) 54px 72px
  );
  opacity: 0.85;
}

.mg-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 12px;
}

.mg-board-kicker {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--terracotta);
}

.mg-board-title {
  margin: 0;
  font-family: var(--font-round);
  font-size: 1.15rem;
  line-height: 1.25;
}

.mg-board-tools { display: flex; align-items: center; gap: 6px; }

.mg-board-mode {
  padding: 2px 8px;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  background: var(--paper-deep);
  color: var(--ink-soft);
}

.mg-board-refresh {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-line);
  background: #fffdf8;
  font-size: 0.95rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  transition: transform 0.25s ease, border-color 0.2s;
}
.mg-board-refresh:hover { border-color: var(--ink); transform: rotate(90deg); }
.mg-board-refresh.is-spin { animation: mg-spin 0.6s linear infinite; }
@keyframes mg-spin { to { transform: rotate(360deg); } }

/* 表彰台（1〜3位） */
.mg-podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}
.mg-podium:empty { display: none; }

.mg-pod-card {
  position: relative;
  flex: 1 1 0;
  max-width: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 6px 9px;
  border-radius: 16px;
  border: 1.5px solid var(--ink);
  background: #fffdf8;
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.14);
  min-width: 0;
}

.mg-pod-card.rank-1 {
  order: 2;
  padding-top: 13px;
  background: linear-gradient(180deg, #fff7d6 0%, #fce8a6 100%);
  box-shadow: 3px 3px 0 rgba(53, 40, 31, 0.18);
}
.mg-pod-card.rank-2 {
  order: 1;
  background: linear-gradient(180deg, #f5fafd 0%, #dfeff6 100%);
}
.mg-pod-card.rank-3 {
  order: 3;
  background: linear-gradient(180deg, #fff4f5 0%, #f7e1e2 100%);
}
.mg-pod-card.is-mine {
  outline: 2.5px solid var(--terracotta);
  outline-offset: 1px;
}

.mg-pod-medal {
  font-family: var(--font-round);
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.mg-pod-card.rank-1 .mg-pod-medal { font-size: 0.84rem; color: #9a5b08; }
.mg-pod-card.rank-2 .mg-pod-medal { color: #3d6b82; }
.mg-pod-card.rank-3 .mg-pod-medal { color: #9c4a52; }

.mg-pod-name {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--ink);
}

.mg-pod-score {
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.25;
  margin-top: 2px;
  color: var(--ink);
}
.mg-pod-card.rank-1 .mg-pod-score { font-size: 1.18rem; }

.mg-pod-sub {
  font-size: 0.66rem;
  color: var(--ink-soft);
  margin-top: 1px;
}

/* 4〜10位リスト */
.mg-rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.mg-rank-list:empty { display: none; }

.mg-rank-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 11px;
  background: rgba(255, 253, 248, 0.85);
  border: 1px solid rgba(53, 40, 31, 0.14);
  font-family: var(--font-round);
  font-size: 0.86rem;
}

.mg-rank-row.is-mine {
  background: var(--mustard-soft);
  border-color: var(--terracotta);
  box-shadow: 2px 2px 0 rgba(201, 103, 75, 0.2);
}

.mg-rank-num {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--paper-deep);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.mg-rank-row.is-top1 .mg-rank-num { background: var(--mustard); color: var(--ink); }
.mg-rank-row.is-top2 .mg-rank-num { background: var(--sky-soft); color: var(--ink); }
.mg-rank-row.is-top3 .mg-rank-num { background: var(--rose-soft); color: var(--ink); }

.mg-rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.mg-rank-score {
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}
.mg-rank-score b { font-size: 0.94rem; }
.mg-rank-score small { font-size: 0.68rem; color: var(--ink-soft); }

.mg-board-empty {
  margin: 8px 0 12px;
  padding: 18px 12px;
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.78);
  border: 1.5px dashed var(--ink-line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  font-family: var(--font-round);
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.mg-board-empty[hidden] { display: none; }

.mg-board-foot {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--ink-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-round);
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.mg-board-mine b { color: var(--ink); font-size: 0.88rem; }
.mg-board-tip { font-size: 0.72rem; }

/* ---------- ゲーム枠 ---------- */

.mg-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 430 / 760;
  overflow: hidden;
  border: 2.5px solid var(--ink);
  border-radius: 26px;
  background: #faebda;
  box-shadow: var(--shadow-lift);
  scroll-margin-top: calc(var(--mg-top) + 8px);
  container-type: inline-size;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mg-frame.is-playing {
  touch-action: none;
}

.mg-frame[hidden] { display: none; }
.mg-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD 共通ボタン */
.mg-hud-btns {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.mg-round-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: rgba(255, 252, 246, 0.92);
  font-size: 0.95rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.14);
  pointer-events: auto;
  transition: transform 0.12s ease;
}
.mg-round-btn:active { transform: translate(1px, 1px); box-shadow: none; }
.mg-sound-mini[aria-pressed="true"] { background: var(--mustard-soft); }
.mg-exit-btn { display: none; }

/* ---------- オーバーレイパネル（タイトル・一時停止・結果） ---------- */

.mg-panel {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 6%;
  text-align: center;
  background: rgba(246, 240, 228, 0.34);
  backdrop-filter: blur(2px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.mg-panel[hidden] { display: none; }
.mg-panel.is-guard { pointer-events: none; }

.mg-panel-inner {
  width: 100%;
  max-width: 380px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mg-card {
  width: 100%;
  padding: 16px 14px 14px;
  background: rgba(255, 252, 246, 0.96);
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow-ink);
  position: relative;
}

.mg-card.is-celebrate {
  background: linear-gradient(180deg, #fffdf5 0%, #fff4d8 100%);
  border-color: var(--ink);
}

.mg-eyebrow {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--terracotta);
}

.mg-title {
  margin: 0;
  font-family: var(--font-round);
  font-size: clamp(1.2rem, 6.8cqw, 1.82rem);
  line-height: 1.25;
  letter-spacing: 0.03em;
}

.mg-cast {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 8px 0 6px;
}
.mg-cast img {
  width: 52px;
  height: 52px;
  filter: drop-shadow(1px 2px 0 rgba(53, 40, 31, 0.14));
}

.mg-result-big {
  margin: 2px 0 4px;
  font-family: var(--font-round);
  font-size: 1.02rem;
  color: var(--ink);
}
.mg-result-big b {
  font-size: 2.1rem;
  line-height: 1;
  color: var(--ink);
  margin-right: 3px;
}
.mg-result-big .mg-new-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--terracotta);
  color: #fff;
  font-size: 0.72rem;
  vertical-align: middle;
}

.mg-tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 2px auto 6px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--mustard-soft);
  border: 1.5px solid var(--ink);
  font-family: var(--font-round);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
}
.mg-tier-badge[hidden],
.mg-result-big[hidden] { display: none; }

.mg-message {
  margin: 0 0 6px;
  font-family: var(--font-round);
  font-size: 0.88rem;
  line-height: 1.55;
}

.mg-record {
  margin: 0;
  font-family: var(--font-round);
  color: var(--ink-soft);
  font-size: 0.86rem;
}

/* ---------- 高得点 名前入力 & 登録完了ボックス ---------- */

.mg-entry-box {
  width: 100%;
  margin-top: 10px;
  padding: 12px 12px 11px;
  background: rgba(255, 252, 246, 0.97);
  border: 2px solid var(--terracotta);
  border-radius: 18px;
  box-shadow: 3px 3px 0 rgba(201, 103, 75, 0.2);
  text-align: left;
}
.mg-entry-box[hidden] { display: none; }

.mg-entry-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 0 0 8px;
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--terracotta);
}

.mg-entry-form {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.mg-entry-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 11px;
  font-family: var(--font-round);
  font-size: 16px; /* iOS Safari 自動ズーム防止のため 16px 以上を維持 */
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  -webkit-user-select: text;
  user-select: text;
}
.mg-entry-input:focus {
  outline: 2.5px solid var(--mustard);
  outline-offset: 1px;
}

.mg-entry-submit {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 12px;
  background: var(--mustard);
  color: var(--ink);
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 0.88rem;
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.16);
}
.mg-entry-submit:disabled { opacity: 0.55; cursor: wait; }

.mg-entry-error {
  margin: 6px 0 0;
  font-size: 0.74rem;
  color: #b43c2a;
  font-family: var(--font-round);
}

.mg-entry-done {
  text-align: center;
  font-family: var(--font-round);
}
.mg-entry-done-head {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--terracotta);
  margin: 0 0 6px;
}
.mg-entry-mini-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  text-align: left;
}
.mg-entry-note {
  margin: 0;
  font-family: var(--font-round);
  font-size: 0.8rem;
  color: var(--ink-soft);
  text-align: center;
}

/* ---------- Xシェア & 記念カード保存 ---------- */

.mg-share-row {
  width: 100%;
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mg-share-row[hidden] { display: none; }

.btn-x-share,
.btn-card-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 14px;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 0.84rem;
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.18);
  transition: transform 0.12s ease;
}
.btn-x-share:active,
.btn-card-save:active { transform: translate(1px, 1px); box-shadow: none; }

.btn-x-share {
  background: #231b16;
  color: #fffdf8;
}
.btn-x-share .x-mark { font-size: 0.96rem; line-height: 1; }

.btn-card-save {
  background: #fffdf8;
  color: var(--ink);
}

/* スタート・サブボタン */
.mg-start {
  width: 100%;
  margin-top: 10px;
  padding: 13px 12px;
  font-size: 1.08rem;
  border-radius: 16px;
}

.mg-sub-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.mg-pill-btn {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: rgba(255, 252, 246, 0.92);
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--ink);
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.12);
}
.mg-pill-btn[hidden] { display: none; }

.mg-hint {
  margin: 10px 0 0;
  font-size: 0.72rem;
  line-height: 1.65;
  color: var(--ink-soft);
  background: rgba(255, 252, 246, 0.86);
  border-radius: 12px;
  padding: 6px 10px;
  width: 100%;
}
.mg-hint[hidden] { display: none; }

.hint-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .hint-touch { display: inline; }
  .hint-pc { display: none; }
}

/* ---------- 枠内ランキングシート ---------- */

.mg-sheet {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 5%;
  background: rgba(53, 40, 31, 0.36);
  backdrop-filter: blur(3px);
}
.mg-sheet[hidden] { display: none; }

.mg-sheet-card {
  width: 100%;
  max-height: 88%;
  display: flex;
  flex-direction: column;
  background: var(--paper-card);
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow-lift);
  overflow: hidden;
}

.mg-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--mustard-soft);
  border-bottom: 1.5px solid var(--ink);
}
.mg-sheet-head h3 {
  margin: 0;
  font-family: var(--font-round);
  font-size: 1rem;
}
.mg-sheet-close { width: 32px; height: 32px; font-size: 0.85rem; }

.mg-sheet-body {
  padding: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

/* ---------- セリフ吹き出し ---------- */

.mg-talk {
  position: absolute;
  z-index: 3;
  top: 66px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-6px) scale(0.96);
  transition: opacity 0.22s, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mg-talk.is-show { opacity: 1; transform: none; }
.mg-talk img {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  filter: drop-shadow(2px 2px 0 rgba(53, 40, 31, 0.16));
}
.mg-talk p {
  position: relative;
  margin: 0;
  padding: 6px 12px;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 0.9rem;
  background: rgba(255, 252, 246, 0.96);
  border: 1.5px solid var(--ink);
  border-radius: 14px;
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.14);
}
.mg-talk p::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 9px;
  height: 9px;
  background: rgba(255, 252, 246, 0.96);
  border-left: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  transform: translateY(-50%) rotate(45deg);
}

/* ---------- ① ホットケーキタワー ---------- */

.tw-hud {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.tw-hud[hidden] { display: none; }

.tw-score-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 4px 12px 5px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.92);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.14);
  font-family: var(--font-round);
}
.tw-score-pill b { font-size: 1.65rem; line-height: 1; }
.tw-score-pill small { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); }

.tw-combo-badge {
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--mustard);
  border: 1.5px solid var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink);
}
.tw-combo-badge[hidden] { display: none; }

.tw-eaten {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 3px 9px 3px 4px;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 0.86rem;
  background: rgba(255, 252, 246, 0.92);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.12);
}

.tw-alt-badge {
  position: absolute;
  z-index: 3;
  top: 58px;
  right: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.82);
  border: 1px solid rgba(53, 40, 31, 0.28);
  font-family: var(--font-round);
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--ink);
  pointer-events: none;
}
.tw-alt-badge[hidden] { display: none; }

/* ---------- ② まて！ぴったり3びょう ---------- */

.mt { background: #faebda; }

.mt-sky {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 82% 14%, rgba(255, 245, 200, 0.9) 0%, rgba(255, 245, 200, 0) 34%),
    linear-gradient(180deg, #e7f3f9 0%, #faebda 44%, #f4e2c9 100%),
    url("assets/scenes3d/hero-meadow-bg.webp") 38% 100% / auto 64% no-repeat;
}
.mt-sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/scenes3d/hero-meadow-bg.webp") 38% 100% / auto 62% no-repeat;
  opacity: 0.92;
}

/* ピクニックのフラッグガーランド */
.mt-garland {
  position: absolute;
  top: 0;
  left: -4%;
  right: -4%;
  height: 22px;
  z-index: 2;
  display: flex;
  justify-content: space-around;
  pointer-events: none;
}
.mt-garland span {
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 17px solid var(--mustard);
  filter: drop-shadow(0 1px 0 rgba(53, 40, 31, 0.25));
}
.mt-garland span:nth-child(3n+2) { border-top-color: var(--rose); }
.mt-garland span:nth-child(3n) { border-top-color: var(--sky); }

.mt-hud {
  position: absolute;
  z-index: 4;
  top: 14px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mt-hud[hidden] { display: none; }

.mt-rounds { display: flex; gap: 4px; }
.mt-rounds span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-round);
  background: rgba(255, 252, 246, 0.85);
  border: 1.5px solid var(--ink-line);
}
.mt-rounds span.is-current { border-color: var(--ink); background: #fff; transform: scale(1.08); }
.mt-rounds span.is-done { background: var(--sky-soft); border-color: var(--ink); }
.mt-rounds span.is-great { background: var(--mustard); border-color: var(--ink); }

.mt-score {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.92);
  border: 1.5px solid var(--ink);
  font-family: var(--font-round);
  font-size: 0.95rem;
}

.mt-stage {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 62px 16px 18px;
  text-align: center;
  cursor: pointer;
}
.mt-stage[hidden] { display: none; }

.mt-niko {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  min-height: 58px;
}
.mt-niko img {
  width: 56px;
  height: 56px;
  filter: drop-shadow(2px 2px 0 rgba(53, 40, 31, 0.14));
}
.mt-bubble {
  position: relative;
  margin: 0;
  padding: 6px 14px;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 1rem;
  background: rgba(255, 252, 246, 0.96);
  border: 1.5px solid var(--ink);
  border-radius: 15px;
  box-shadow: 2px 2px 0 rgba(53, 40, 31, 0.14);
}
.mt-bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 9px;
  height: 9px;
  background: rgba(255, 252, 246, 0.96);
  border-left: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  transform: translateY(-50%) rotate(45deg);
}

.mt-dog-arena {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.mt-dog-wrap {
  position: relative;
  width: min(56%, 220px);
  aspect-ratio: 1;
}
.mt-dog-shadow {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 2%;
  height: 14%;
  border-radius: 50%;
  background: rgba(53, 40, 31, 0.16);
}
.mt-dog {
  position: relative;
  width: 100%;
  height: 100%;
  filter: drop-shadow(2px 4px 0 rgba(53, 40, 31, 0.16));
  transform-origin: 50% 90%;
}

.mt-bone {
  position: absolute;
  left: 50%;
  bottom: -18%;
  width: 34%;
  height: auto;
  transform: translateX(-50%) rotate(-8deg);
  transition: opacity 0.2s, transform 0.25s;
  filter: drop-shadow(2px 2px 0 rgba(53, 40, 31, 0.15));
}
.mt-bone.is-gone { opacity: 0; transform: translate(-50%, -30%) scale(0.4); }

.mt-dog.is-wait { animation: mt-bob 1.05s ease-in-out infinite; }
.mt-dog.is-itchy { animation: mt-itch 0.22s linear infinite; }
.mt-dog.is-wild { animation: mt-itch 0.11s linear infinite; }
.mt-dog.is-jump { animation: mt-jump 0.52s cubic-bezier(0.34, 1.56, 0.64, 1) 2; }
.mt-dog.is-nod { animation: mt-bob 0.48s ease-in-out 2; }

@keyframes mt-bob { 50% { transform: translateY(-5px) scaleY(1.02); } }
@keyframes mt-itch { 25% { transform: translateX(-3px) rotate(-1.8deg); } 75% { transform: translateX(3px) rotate(1.8deg); } }
@keyframes mt-jump { 40% { transform: translateY(-18%) rotate(-5deg); } 70% { transform: translateY(0) scale(1.05, 0.95); } }

.mt-stamp {
  position: absolute;
  top: 4%;
  right: 6%;
  padding: 5px 14px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--mustard);
  color: var(--ink);
  font-family: var(--font-round);
  font-weight: 800;
  font-size: 0.98rem;
  box-shadow: 3px 3px 0 rgba(53, 40, 31, 0.2);
  transform: rotate(6deg);
  animation: mt-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mt-stamp.is-miss { background: var(--rose-soft); }
.mt-stamp[hidden] { display: none; }

@keyframes mt-pop {
  from { opacity: 0; transform: scale(0.5) rotate(-8deg); }
  to { opacity: 1; transform: scale(1) rotate(6deg); }
}

.mt-sparkle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.mt-sparkle {
  position: absolute;
  font-size: 1.1rem;
  animation: mt-spark 0.85s ease-out forwards;
}
@keyframes mt-spark {
  0% { opacity: 1; transform: translate(0, 0) scale(0.6); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.25) rotate(40deg); }
}

.mt-clock-box {
  width: 100%;
  margin: 12px 0 8px;
}

.mt-timer {
  font-family: var(--font-round);
  font-weight: 800;
  font-size: clamp(2.5rem, 14cqw, 3.8rem);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 3px 3px 0 rgba(255, 252, 246, 0.95);
}

/* 3.00秒タイミング可視化ゲージ */
.mt-gauge {
  width: 86%;
  margin: 6px auto 2px;
}
.mt-gauge[hidden] { display: none; }
.mt-gauge-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.9);
  border: 1.5px solid var(--ink);
  overflow: visible;
}
.mt-gauge-target {
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 8px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: var(--mustard);
  border: 1.5px solid var(--ink);
}
.mt-gauge-pin {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--terracotta);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1.5px var(--ink);
  transform: translate(-50%, -50%);
  transition: left 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mt-gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-family: var(--font-round);
  font-size: 0.68rem;
  color: var(--ink-soft);
}
.mt-gauge-labels b { color: var(--ink); }

.mt-message {
  min-height: 2.2em;
  margin: 4px 0 0;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 0.94rem;
  line-height: 1.5;
  text-shadow: 0 0 6px #fbf7ee, 0 0 3px #fbf7ee;
}

.mt-action {
  width: 88%;
  min-height: 58px;
  padding: 14px 12px;
  font-size: 1.28rem;
  font-weight: 800;
  border-radius: 20px;
  border: 2px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.mt-action:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}
.mt-action.is-calm { background: var(--mustard); color: var(--ink); }

.mt-tap-note {
  margin: 6px 0 0;
  font-family: var(--font-round);
  font-size: 0.72rem;
  color: var(--ink-soft);
}

/* まて！5回終了サマリー（コンパクトチップ表示） */
.mt-summary { background: rgba(246, 240, 228, 0.56); }
.mt-chips {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}
.mt-chip {
  padding: 5px 2px;
  border-radius: 10px;
  background: var(--paper);
  border: 1.5px solid var(--ink-line);
  font-family: var(--font-round);
  text-align: center;
}
.mt-chip.is-great { background: var(--mustard-soft); border-color: var(--ink); }
.mt-chip small { display: block; font-size: 0.64rem; color: var(--ink-soft); }
.mt-chip b { display: block; font-size: 0.78rem; line-height: 1.25; }
.mt-chip span { display: block; font-size: 0.68rem; color: var(--terracotta); font-weight: 700; }

/* タップ波紋フィードバック */
.mg-ripple {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2.5px solid rgba(201, 103, 75, 0.65);
  background: rgba(255, 248, 224, 0.35);
  pointer-events: none;
  z-index: 6;
  transform: translate(-50%, -50%) scale(0.4);
  animation: mg-rip 0.36s ease-out forwards;
}
@keyframes mg-rip {
  to { opacity: 0; transform: translate(-50%, -50%) scale(2.2); }
}

/* ---------- スマホ・タブレット最適化（899px以下） ---------- */

@media (max-width: 899px) {
  .mg-section { --mg-top: 96px; padding: 10px 0 40px; }
  .mg-section > .wrap {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "picker"
      "stage"
      "board";
    gap: 10px;
    justify-items: stretch;
  }

  .mg-head { padding-top: 0; }
  .mg-head .section-eyebrow { margin-bottom: 2px; font-size: 0.68rem; }
  .mg-head .section-title { font-size: 1.32rem; margin-bottom: 0; }
  .mg-head .section-sub { display: none; }

  .mg-picker { gap: 8px; }
  .mg-pick {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "art best"
      "text text";
    align-items: center;
    gap: 4px 6px;
    padding: 8px 10px 9px;
    border-radius: 15px;
  }
  .mg-pick-art { grid-area: art; }
  .mg-pick-art img { width: 30px; height: 30px; }
  .mg-pick-art img + img { margin-left: -8px; }
  .mg-pick-text { grid-area: text; }
  .mg-pick-text b {
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mg-pick-text small { display: none; }
  .mg-pick-best {
    grid-area: best;
    position: static;
    justify-self: end;
    font-size: 0.64rem;
    padding: 2px 7px;
    white-space: nowrap;
  }

  .mg-stage-col { display: flex; justify-content: center; }
  .mg-frame {
    width: min(100%, 420px, calc((100dvh - 180px) * 0.5658));
    border-radius: 22px;
  }

  /* スマホ集中プレイモード（スタートで自動全画面化・戻るで解除） */
  body.is-mg-play {
    overflow: hidden;
    overscroll-behavior: none;
  }
  body.is-mg-play .site-header,
  body.is-mg-play .site-footer {
    visibility: hidden;
  }
  .mg-frame.is-mobile-full {
    position: fixed;
    inset: 0;
    z-index: 120;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    aspect-ratio: auto;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .mg-frame.is-mobile-full canvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 430 / 760;
    object-fit: contain;
  }
  .mg-frame.is-mobile-full .tw-hud,
  .mg-frame.is-mobile-full .mt-hud {
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }
  .mg-frame.is-mobile-full .tw-alt-badge {
    top: calc(max(12px, env(safe-area-inset-top)) + 48px);
    right: max(12px, env(safe-area-inset-right));
  }
  .mg-frame.is-mobile-full .mg-talk {
    top: calc(max(12px, env(safe-area-inset-top)) + 56px);
  }
  .mg-frame.is-mobile-full .mt-stage {
    padding-top: calc(max(12px, env(safe-area-inset-top)) + 54px);
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
  .mg-frame.is-mobile-full .mg-panel {
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }
  .mg-frame.is-mobile-full .mg-exit-btn {
    display: grid;
  }
}

@media (max-width: 480px) {
  .mg-section > .wrap { padding-inline: 10px; }
  .mg-frame:not(.is-mobile-full) {
    width: min(100%, calc((100dvh - 170px) * 0.5658));
    border-radius: 20px;
  }
  .mg-board { padding: 14px 12px 12px; border-radius: 18px; }
  .mg-podium { gap: 6px; }
  .mg-pod-name { font-size: 0.78rem; }
  .mg-pod-score { font-size: 0.96rem; }
}

@media (prefers-reduced-motion: reduce) {
  .mt-dog, .mt-stamp, .mt-sparkle, .mg-ripple { animation: none !important; }
  .mg-talk { transition: none; }
}
