/* つきみ堂の三つ並べ — 色はCSS変数（mn.css の上書き） */
:root {
  --accent: #9b3d52; --accent-ink: #ffffff; --accent-soft: #f6e1e6;
  --bg: #f6f1e8; --wood: #b98a5a; --wood-2: #8e6440; --gold: #f3c75f; --gold-2: #fff3c4; --cell: rgba(255, 250, 240, .16);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent: #f0a6b8; --accent-ink: #20131a; --accent-soft: #3a2230;
    --bg: #14111d; --wood: #6c4c33; --wood-2: #4a3222; --cell: rgba(255, 245, 230, .08);
  }
}
:root[data-theme="dark"] {
  --accent: #f0a6b8; --accent-ink: #20131a; --accent-soft: #3a2230;
  --bg: #14111d; --wood: #6c4c33; --wood-2: #4a3222; --cell: rgba(255, 245, 230, .08);
}

/* タイトル */
.tm-hero { position: relative; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; background: linear-gradient(160deg, #241a35, #4a2b45 60%, #8a4b4f); }
.tm-hero img, .tm-hero video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.tm-hero-fallback { display: none; }
.tm-hero.noimg img { display: none; }
.tm-hero.noimg .tm-hero-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff4dc; font-family: var(--font-serif); }
.tm-hero.noimg .tm-hero-fallback b { font-size: clamp(34px, 11vw, 56px); letter-spacing: .2em; }
.tm-hero.noimg .tm-hero-fallback span { font-size: 15px; letter-spacing: .5em; opacity: .8; }
.tm-start .mn-title { font-family: var(--font-serif); }
.tm-progress { display: grid; gap: 4px; }
.tm-menu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.tm-menu-one { display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.3; }
.tm-menu-one .tm-gi { width: 44px; height: 44px; }
.tm-menu-one small { font-size: 12px; color: var(--text-sub); }

/* プレイ画面 */
.tm-play { display: flex; flex-direction: column; gap: 10px; }
.tm-hud { display: flex; gap: 10px; align-items: stretch; }
.tm-hud-l { flex: 1; min-width: 0; }
.tm-stage { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-goals { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-goal { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 16px; line-height: 1.2; }
.tm-goal b { font-variant-numeric: tabular-nums; min-width: 1.4em; text-align: center; }
.tm-goal.is-ok { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.tm-gi { position: relative; display: inline-block; width: 30px; height: 30px; flex: none; }
.tm-gi img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tm-gi.noimg::before { content: attr(data-ch); position: absolute; inset: 8%; border-radius: 50%; background: var(--c, #ccc); color: #2a1a12; font-weight: 900; font-size: 13px; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.tm-gi-wrap.noimg::before { background: repeating-linear-gradient(45deg, #efe2c9 0 5px, #dccaa6 5px 10px); border-radius: 6px; }
.tm-gi-make { color: var(--warn); font-size: 22px; line-height: 30px; text-align: center; }
.tm-hud-r { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; }
.tm-moves { display: flex; align-items: baseline; gap: 2px; padding: 2px 12px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); line-height: 1.2; }
.tm-moves b { font-size: 28px; font-variant-numeric: tabular-nums; }
.tm-moves small { font-size: 12px; }
.tm-moves.is-low { background: var(--bad); color: #fff; }
.tm-score { font-size: 14px; color: var(--text-sub); }
.tm-score b { color: var(--text); font-variant-numeric: tabular-nums; }

/* 盤：375px で縦に収まるよう、画面の高さでも幅を制限する */
.tm-board-wrap { display: flex; justify-content: center; }
.tm-board {
  position: relative; width: min(100%, calc((100vh - 250px) * 0.875)); width: min(100%, calc((100dvh - 250px) * 0.875)); min-width: 280px;
  aspect-ratio: 7 / 8; border-radius: 16px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  background-color: var(--wood); background-image: url("assets/board.webp"), linear-gradient(160deg, var(--wood), var(--wood-2)); background-size: cover; background-position: center;
  box-shadow: 0 6px 20px rgba(40, 20, 10, .25), inset 0 0 0 2px rgba(0, 0, 0, .12);
}
.tm-board:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tm-layer { position: absolute; inset: 0; background-image: linear-gradient(var(--cell) 1px, transparent 1px), linear-gradient(90deg, var(--cell) 1px, transparent 1px); background-size: calc(100% / 7) calc(100% / 8); }
.tm-p { position: absolute; left: 0; top: 0; width: calc(100% / 7); height: calc(100% / 8); transition: transform .24s cubic-bezier(.3, .1, .4, 1.15); will-change: transform; z-index: 1; }
.tm-p.no-tr { transition: none; }
.tm-face { position: absolute; inset: 5%; display: block; transition: transform .2s, opacity .2s, filter .2s; }
.tm-face img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; -webkit-user-drag: none; filter: drop-shadow(0 2px 2px rgba(40, 20, 10, .35)); }
/* 画像が無いときの代用（テスト用）：色つきの丸＋字 */
.tm-p.noimg .tm-face { border-radius: 50%; background: var(--c, #ccc); box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15), 0 2px 3px rgba(0, 0, 0, .25); display: flex; align-items: center; justify-content: center; inset: 10%; }
.tm-p.noimg::after { content: attr(data-ch); position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: clamp(14px, 4.5vw, 22px); color: #2a1a12; pointer-events: none; }
.tm-p[data-t="3"].noimg::after { color: #f6e7d0; }
.tm-w.noimg .tm-face { border-radius: 8px; background: repeating-linear-gradient(45deg, #efe2c9 0 6px, #dccaa6 6px 12px); }
/* 包み紙：あと1回で破れた見た目 */
.tm-w[data-hp="1"] .tm-face { clip-path: polygon(0 8%, 30% 0, 62% 10%, 100% 2%, 94% 52%, 100% 100%, 55% 92%, 20% 100%, 0 70%); opacity: .82; transform: rotate(-5deg) scale(.94); }
.tm-w.is-hit .tm-face { animation: tm-hit .35s; }
@keyframes tm-hit { 30% { transform: rotate(6deg) scale(1.08); } 60% { transform: rotate(-6deg) scale(.95); } }

/* 特別な駒：元の駒の画像に光の縁取りなどを足す */
.tm-p[data-s="1"] .tm-face::before, .tm-p[data-s="2"] .tm-face::before { content: ""; position: absolute; z-index: -1; border-radius: 99px; background: linear-gradient(90deg, transparent, var(--gold-2), var(--gold), var(--gold-2), transparent); box-shadow: 0 0 10px var(--gold); }
.tm-p[data-s="1"] .tm-face::before { left: -14%; right: -14%; top: 42%; height: 16%; }
.tm-p[data-s="2"] .tm-face::before { top: -14%; bottom: -14%; left: 42%; width: 16%; background: linear-gradient(180deg, transparent, var(--gold-2), var(--gold), var(--gold-2), transparent); }
.tm-p[data-s="1"] .tm-face img, .tm-p[data-s="2"] .tm-face img { filter: drop-shadow(0 0 4px var(--gold-2)) drop-shadow(0 0 2px #fff); }
.tm-p[data-s="3"] .tm-face { border-radius: 12px; box-shadow: 0 0 0 3px #d2423f, 0 0 0 5px var(--gold), 0 0 12px 3px rgba(210, 66, 63, .6); background: rgba(40, 10, 10, .35); }
.tm-p[data-s="4"] .tm-face img { filter: sepia(1) saturate(4) hue-rotate(-12deg) brightness(1.15) drop-shadow(0 0 6px var(--gold)); }
.tm-p[data-s="4"] .tm-face { border-radius: 50%; box-shadow: 0 0 14px 4px rgba(243, 199, 95, .7); animation: tm-kin 1.6s ease-in-out infinite; }
.tm-p[data-s="4"] .tm-face::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .8) 50%, transparent 65%); background-size: 250% 100%; animation: tm-shine 1.6s linear infinite; pointer-events: none; }
.tm-p.noimg[data-s="4"] .tm-face { background: linear-gradient(135deg, #fff1b8, #e0a92c 50%, #fff1b8); }
@keyframes tm-kin { 50% { box-shadow: 0 0 20px 7px rgba(243, 199, 95, .9); } }
@keyframes tm-shine { from { background-position: 150% 0; } to { background-position: -100% 0; } }

/* 状態 */
.tm-p.is-sel { z-index: 3; }
.tm-p.is-sel .tm-face { transform: scale(1.14); filter: drop-shadow(0 0 6px #fff); }
.tm-p.is-sel::before { content: ""; position: absolute; inset: 2%; border-radius: 12px; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--accent); }
.tm-p.is-cur::before { content: ""; position: absolute; inset: 2%; border-radius: 12px; border: 2px dashed #fff; }
.tm-p.is-hint .tm-face { animation: tm-hint 1s ease-in-out infinite; }
@keyframes tm-hint { 50% { transform: scale(1.16); filter: drop-shadow(0 0 8px #fff); } }
.tm-p.is-out { z-index: 2; pointer-events: none; }
.tm-p.is-out .tm-face { transform: scale(.2) rotate(25deg); opacity: 0; }
.tm-p.is-blast .tm-face { transform: scale(1.5); opacity: 0; filter: brightness(2); }
.tm-p.is-pop .tm-face { animation: mn-pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.tm-p.is-shuffle .tm-face { transform: scale(.6) rotate(-20deg); opacity: .4; }

/* 連鎖などの文字 */
.tm-fx { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; z-index: 5; }
.tm-fx-t { font-weight: 900; font-size: 26px; color: #fff; text-shadow: 0 2px 0 var(--accent), 0 0 10px rgba(0, 0, 0, .5); animation: tm-up 1.1s ease-out forwards; }
.tm-fx-t.big { font-size: 38px; font-family: var(--font-serif); }
.tm-fx-t.sp { font-size: 18px; color: var(--gold-2); text-shadow: 0 1px 0 #6a3a10, 0 0 8px rgba(0, 0, 0, .6); }
@keyframes tm-up { from { transform: translateY(14px) scale(.8); opacity: 0; } 20% { transform: none; opacity: 1; } 75% { opacity: 1; } to { transform: translateY(-24px); opacity: 0; } }

.tm-tools { display: flex; gap: 8px; justify-content: center; }
.tm-tools .mn-btn { min-height: 44px; flex: 1; max-width: 220px; }
.tm-tip { margin: 0; }

/* 結果・失敗 */
.tm-of { font-size: .38em; margin-left: 6px; color: var(--text); }
.tm-final .mn-big { font-family: var(--font-serif); }
.tm-eaten { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 12px; margin-top: 8px; }
.tm-eaten-one { display: inline-flex; align-items: center; gap: 2px; }
.tm-quote { font-family: var(--font-serif); font-size: 17px; }
.machi-scene.tm-noscene { background: linear-gradient(160deg, #241a35, #4a2b45 60%, #8a4b4f); }

@media (prefers-reduced-motion: reduce) {
  .tm-p, .tm-face { transition: none !important; }
  .tm-p.is-hint .tm-face { animation: none; transform: scale(1.1); filter: drop-shadow(0 0 8px #fff); }
}
.tm-p.is-out::after, .tm-p.is-shuffle::after { opacity: 0; transition: opacity .2s; }
.mn-daily-num { white-space: nowrap; }
