/* かさねて和菓子屋（/wagashi/）: 入口はサイトの明るい地のまま、遊ぶ画面（.wg-game）は画面全体を使う
   色: 地＝木の床 --wbg・札＝生成り --wpanel・文字＝こげ茶 --wink・主のボタン＝毛せんの赤 --wred */
:root { --wbg: #ecdcbf; --wpanel: #fffaf0; --wline: #dfcba6; --wink: #3d2b1f; --wmut: #7d6a55; --wred: #c8432f; --wgreen: #2f8f5f; }

/* ── 入口 ── */
.wg-top { display: grid; gap: 16px; padding-top: 8px; }
.wg-hero { position: relative; margin: 0; border-radius: 20px; overflow: hidden; background: #bfe3f2; aspect-ratio: 16 / 11; box-shadow: 0 18px 40px -26px rgba(70, 45, 20, .8); }
.wg-hero canvas { display: block; width: 100%; height: 100%; }
.wg-hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(61, 43, 31, .72), rgba(61, 43, 31, .3) 24%, rgba(61, 43, 31, 0) 40%); }
.wg-hero-cap { position: absolute; left: 16px; right: 16px; top: 12px; z-index: 1; display: grid; gap: 0; color: #fff; text-shadow: 0 2px 12px rgba(40, 25, 10, .55); }
.wg-eb { font-size: 12px; font-weight: 800; letter-spacing: .12em; color: #ffe3a3; }
.wg-hero-cap b { font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif; font-weight: 900; font-size: clamp(26px, 8vw, 40px); line-height: 1.2; letter-spacing: .06em; }
.wg-top .lead b { color: #a8331f; }
.wg-start { display: grid; gap: 10px; }
.wg-start .btn.go { --go: var(--wred); --go-step: #8e2a1d; --go-soft: rgba(142, 42, 29, .5); }
.wg-start .btn[hidden] { display: none; }
.wg-note { font-size: 13px; color: var(--muted); }
.wg-h2 { font-size: 20px; margin-top: 12px; }
.wg-how { margin: 0; padding: 0; list-style: none; counter-reset: wg; display: grid; gap: 10px; }
.wg-how li { counter-increment: wg; position: relative; display: grid; gap: 2px; padding: 12px 14px 12px 50px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.wg-how li::before { content: counter(wg); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--wred); color: #fff; font: 800 14px/1 var(--f-round); }
.wg-how b { font-size: 15.5px; }
.wg-how span { font-size: 13.5px; color: var(--ink2); line-height: 1.6; }
.wg-how span b { font-size: inherit; }
.wg-faq details { border-bottom: 1px solid var(--line); padding: 10px 2px; }
.wg-faq summary { cursor: pointer; font-weight: 700; }
.wg-faq p { margin-top: 6px; font-size: 14px; color: var(--ink2); }

/* ── 遊ぶ画面 ── */
html.wg-lock, html.wg-lock body { overflow: hidden; overscroll-behavior: none; }
.wg-game { position: fixed; inset: 0; z-index: 2147483000; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); background: var(--wbg); color: var(--wink); font-family: var(--f-body); line-height: 1.5; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.wg-game button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.wg-hud { display: flex; align-items: center; gap: 6px; padding: max(6px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px), calc(50vw - 560px)) 6px max(8px, env(safe-area-inset-left, 0px), calc(50vw - 560px)); background: linear-gradient(#f6e8cc, #ecdcbf); border-bottom: 1px solid var(--wline); }
.wg-counts { display: flex; align-items: center; min-width: 0; margin-right: auto; border-radius: 999px; background: var(--wpanel); border: 1px solid var(--wline); padding: 2px 4px; }
.wg-count { display: inline-flex; align-items: center; gap: 2px; padding: 3px 6px; border: 0; background: none; border-radius: 999px; white-space: nowrap; }
.wg-count svg { width: 20px; height: 20px; flex: none; }
.wg-count b { font: 800 15px/1 var(--f-round); font-variant-numeric: tabular-nums; }
.wg-count + .wg-count { border-left: 1px solid var(--wline); border-radius: 0; }
.wg-energy { border-radius: 0 999px 999px 0 !important; }
.wg-energy.zero b { color: var(--wred); }
.wg-count.pop b { animation: wg-pop .35s ease-out; }
.wg-hbtn { position: relative; display: grid; justify-items: center; gap: 0; width: 44px; height: 42px; padding: 3px 0 2px; border-radius: 12px; border: 1px solid var(--wline); background: var(--wpanel); }
.wg-hbtn svg { width: 22px; height: 22px; }
.wg-hbtn span { font-size: 10.5px; font-weight: 800; line-height: 1.1; }
.wg-hbtn.ready { border-color: #e0a020; background: #fff3c4; animation: wg-glow 1.4s ease-in-out infinite; }
.wg-dot { position: absolute; top: -3px; right: -3px; width: 11px; height: 11px; border-radius: 50%; background: #e0452e; border: 2px solid #fff; }
.wg-dot[hidden] { display: none; }
.wg-menu-btn { display: grid; gap: 3px; place-content: center; width: 38px; height: 42px; border: 1px solid var(--wline); border-radius: 12px; background: var(--wpanel); }
.wg-menu-btn i { display: block; width: 16px; height: 2px; border-radius: 2px; background: var(--wink); }
/* せまい画面（tools/test/wagashi-flow.mjs が幅320〜430で、いちばん長い表示「9999・9999・999」を測る） */
@media (max-width: 374px) {
  .wg-hud { gap: 4px; padding-left: max(6px, env(safe-area-inset-left, 0px)); padding-right: max(6px, env(safe-area-inset-right, 0px)); }
  .wg-count { padding: 3px 4px; }
  .wg-count svg { width: 17px; height: 17px; }
  .wg-count b { font-size: 13.5px; }
  .wg-hbtn { width: 40px; }
  .wg-menu-btn { width: 32px; }
}
.wg-stage { position: relative; min-height: 0; overflow: hidden; }
#wg-play { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.wg-msgs { position: absolute; left: 0; right: 0; bottom: 8px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 10px; pointer-events: none; }
.wg-banner { width: max-content; max-width: 100%; padding: 7px 13px; border-radius: 12px; background: rgba(61, 43, 31, .9); color: #fff; font-size: 13.5px; font-weight: 700; line-height: 1.45; text-align: center; box-shadow: 0 10px 26px -14px rgba(0, 0, 0, .7); }
.wg-banner.in { animation: wg-in .25s ease-out; }
.wg-banner.hot { background: rgba(200, 67, 47, .95); }
.wg-banner[hidden] { display: none; }
.wg-toast { width: max-content; max-width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 13px; border-radius: 12px; background: rgba(255, 250, 240, .97); border: 1px solid var(--wline); color: var(--wink); font-size: 13.5px; font-weight: 700; line-height: 1.45; box-shadow: 0 10px 26px -14px rgba(0, 0, 0, .5); }
.wg-toast[hidden] { display: none; }
.wg-toast.in { animation: wg-in .2s ease-out; }
.wg-toast-act { pointer-events: auto; flex: none; min-height: 34px; padding: 4px 12px; border-radius: 10px; border: 0; background: var(--wink); color: #fff !important; font-weight: 800 !important; }

/* 札（お店・図鑑・元気・メニュー・共有） */
.wg-sheet { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 12px; background: rgba(61, 43, 31, .45); animation: wg-fade .2s ease-out; }
.wg-sheet[hidden] { display: none; }
.wg-card { position: relative; width: min(420px, 100%); max-height: calc(100% - 4px); overflow: auto; overscroll-behavior: contain; padding: 18px 16px 16px; border-radius: 20px; background: var(--wpanel); box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .6); display: grid; gap: 12px; animation: wg-up .25s ease-out; user-select: text; -webkit-user-select: text; }
.wg-card h2 { font: 800 20px/1.35 var(--f-round); text-align: center; padding: 0 28px; }
.wg-card h2 svg { width: 22px; height: 22px; vertical-align: -4px; }
.wg-card .sub { font-size: 13.5px; color: var(--wmut); text-align: center; margin: -4px 0 0; }
.wg-card .sub b { color: var(--wink); }
.wg-x { position: absolute; top: 8px; right: 8px; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--wline); background: #fff; font: 700 22px/1 var(--f-round) !important; display: grid; place-items: center; }
.wg-shopview { display: grid; place-items: center; }
.wg-shopview canvas { border-radius: 14px; box-shadow: 0 8px 20px -12px rgba(70, 45, 20, .6); max-width: 100%; height: auto !important; }
.wg-decos { display: grid; gap: 8px; }
.wg-deco { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; background: #fff; border: 1px solid var(--wline); }
.wg-deco canvas { border-radius: 10px; }
.wg-deco b { display: block; font-size: 15px; line-height: 1.3; }
.wg-deco small { display: block; font-size: 12px; color: var(--wmut); line-height: 1.4; }
.wg-deco.got { background: #eef7ec; border-color: #bfe0c4; }
.wg-buy { min-width: 74px; min-height: 42px; padding: 4px 10px; border-radius: 12px; border: 1.5px solid var(--wline); background: #f6efe2; font-weight: 800 !important; font-variant-numeric: tabular-nums; }
.wg-buy span { display: inline-flex; align-items: center; gap: 4px; }
.wg-buy.can { background: var(--wred); border-color: var(--wred); color: #fff !important; box-shadow: 0 3px 0 #8e2a1d; }
.wg-buy:disabled { cursor: default; opacity: .75; }
.wg-deco.got .wg-buy { background: none; border-color: transparent; color: var(--wgreen) !important; opacity: 1; }
.wg-ci { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff1a8, #f1c84a 55%, #b8862a); box-shadow: inset 0 0 0 1px #a8781e; }
.wg-next { font-size: 13px; color: var(--wmut); line-height: 1.6; margin: 0; }
.wg-next b { color: var(--wink); }
.wg-have { font-size: 13px; color: var(--wmut); text-align: center; margin: -4px 0 0; }
.wg-have b { color: var(--wink); font-size: 15px; }
.wg-up h2 { color: #a8331f; }
.wg-eb2 { text-align: center; font-size: 12.5px; font-weight: 800; letter-spacing: .1em; color: var(--wmut); margin: 0; }
.wg-adds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.wg-adds li { display: flex; align-items: center; gap: 8px; }
.wg-li-dot { flex: none; width: 10px; height: 10px; margin: 0 15px; border-radius: 50%; background: var(--wred); }
.wg-acts { display: grid; gap: 8px; }
.wg-acts .btn { min-height: 48px; font-size: 16px; }
.wg-card .btn.go.wg-main { --go: var(--wred); --go-step: #8e2a1d; --go-soft: rgba(142, 42, 29, .5); color: #fff; font: 700 16px/1.3 var(--f-round); }
.wg-card .btn.sub { color: var(--wink); font: 700 16px/1.3 var(--f-round); }
.wg-card .note { font-size: 13px; color: var(--wmut); margin: 0; }
.wg-zukan-card { width: min(460px, 100%); }
.wg-zrow h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14.5px; margin: 0 0 6px; }
.wg-zrow h3 small { font-size: 12px; color: var(--wmut); font-weight: 700; }
.wg-zrow ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.wg-zrow li { display: grid; justify-items: center; gap: 2px; padding: 6px 2px 5px; border-radius: 12px; background: #fff; border: 1px solid var(--wline); text-align: center; }
.wg-zrow li span { font-size: 11px; font-weight: 700; line-height: 1.3; }
.wg-zrow li.no span { color: #b3a284; }
.wg-menu-list { display: grid; gap: 8px; }
.wg-menu-list button { min-height: 48px; border-radius: 12px; border: 1px solid var(--wline); background: #fff; font-weight: 700 !important; }
.wg-help { display: grid; gap: 8px; font-size: 13.5px; line-height: 1.6; }
.wg-help p { margin: 0; }
/* 共有のかたまり（../js/share.js の shareBlock）。.wg-game button の font: inherit・color: inherit が共有の部品の字に効かないように戻す */
.wg-sharebox .section { margin-top: 0; gap: 10px; }
.wg-sharebox .share > h2 { font: 800 18px/1.3 var(--f-round); text-align: left; padding: 0 40px 0 0; }
.wg-sharebox .btn { min-height: 50px; color: #fff; font: 700 16px/1.3 var(--f-round); }
.wg-sharebox .seg button { font: 700 13px/1.5 var(--f-body); }
.wg-sharebox .share-apps { grid-template-columns: repeat(auto-fit, minmax(124px, 1fr)); }
.wg-sharebox .seg button:not([aria-pressed="true"]) { color: var(--wmut); }
.wg-lock .toast, .wg-lock .share-sheet { z-index: 2147483100; }
.wg-lock .pc-cols .toast { left: 50%; }

@keyframes wg-pop { 0% { transform: scale(1.4); } 100% { transform: none; } }
@keyframes wg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes wg-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wg-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes wg-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(224, 160, 32, .0); } 50% { box-shadow: 0 0 0 4px rgba(224, 160, 32, .35); } }
@media (prefers-reduced-motion: reduce) { .wg-banner.in, .wg-toast.in, .wg-card, .wg-sheet, .wg-count.pop b, .wg-hbtn.ready { animation: none; } }
