/* もこの きせかえ（本拠地 /kisekae/）。見本 v2（_brain/touch/drafts/coin/index.html。依頼主 2026-10-17「もこのきせかえ　はこれでOKです。」）の見た目のまま。
   CSP（style-src 'self'）のため、style 属性は書かない。動く値は kisekae.js が element.style（CSSOM）で渡す。 */
:root{
  --paper:#F5EFE2; --paper2:#EDE4D1; --ink:#3A2A22; --ink-soft:#6E5A4C;
  --hill:#C9D3AE; --hill2:#B5C196; --card:#FFFBF2; --line:#3A2A22;
  --accent:#C98B5B; --accent-ink:#FFF8EC; --ok:#7E9A5E; --muted:#A9998A;
  --sel:#E9C9A4; --tab:#E6DCC6;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --paper:#2A2420; --paper2:#231E1A; --ink:#F3E9DA; --ink-soft:#CDBDAA;
    --hill:#56603F; --hill2:#4A5336; --card:#3A322C; --line:#F3E9DA;
    --accent:#D79A68; --accent-ink:#2A1C12; --ok:#9DB57E; --muted:#8F8173; --sel:#6B5440; --tab:#352D27;
  }
}
:root[data-theme="dark"]{
  --paper:#2A2420; --paper2:#231E1A; --ink:#F3E9DA; --ink-soft:#CDBDAA;
  --hill:#56603F; --hill2:#4A5336; --card:#3A322C; --line:#F3E9DA;
  --accent:#D79A68; --accent-ink:#2A1C12; --ok:#9DB57E; --muted:#8F8173; --sel:#6B5440; --tab:#352D27;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{
  background:var(--paper);
  color:var(--ink);
  font-family:"Hiragino Maru Gothic ProN","BIZ UDPGothic","Yu Gothic UI","Meiryo",system-ui,sans-serif;
  -webkit-tap-highlight-color:transparent;
  overflow-x:hidden;
}
a{color:inherit}
.app{
  height:100dvh; max-width:1100px; margin:0 auto;
  display:flex; flex-direction:column;
  padding:max(10px,env(safe-area-inset-top)) 16px max(10px,env(safe-area-inset-bottom));
}
.top{display:flex; align-items:center; justify-content:space-between; gap:10px; flex:none}
.home{display:flex; align-items:center; gap:4px; font-size:13px; font-weight:700; color:var(--ink-soft); text-decoration:none;
  padding:6px 10px 6px 6px; border-radius:999px; background:var(--tab)}
.home:focus-visible{outline:3px solid var(--accent); outline-offset:2px}
.title{font-size:15px; font-weight:700; letter-spacing:.08em; color:var(--ink-soft); margin:0; flex:1; text-align:center; white-space:nowrap}
.purse{display:flex; flex-direction:column; align-items:flex-end; gap:2px}
.coin{
  display:flex; align-items:center; gap:6px;
  background:var(--card); border:2.5px solid var(--line); border-radius:999px;
  padding:3px 14px 3px 4px; font-weight:800; font-size:22px; line-height:1;
  box-shadow:0 3px 0 var(--paper2);
}
.coin img{width:34px; height:34px; display:block}
.coin .unit{font-size:13px; font-weight:700; color:var(--ink-soft)}
.coin.bump{animation:bump .5s cubic-bezier(.3,1.6,.5,1)}
@keyframes bump{0%{transform:scale(1)}40%{transform:scale(1.14)}100%{transform:scale(1)}}
.from{font-size:11.5px; color:var(--ink-soft); min-height:1.2em}

.main{flex:1; min-height:0; display:flex; flex-direction:column; gap:4px}
.stagewrap{flex:none; display:flex; flex-direction:column; align-items:center}
.stage{position:relative; height:min(42dvh, 420px); aspect-ratio:1/0.98; max-width:100%}
.stage svg.bg{position:absolute; inset:auto 0 0 0; width:100%; height:40%}
.shadow{position:absolute; left:50%; bottom:15.5%; width:36%; height:6%; transform:translateX(-50%);
  background:radial-gradient(closest-side, rgba(58,42,34,.22), rgba(58,42,34,0)); border-radius:50%;
  animation:shadow 3.2s ease-in-out infinite}
.moko{position:absolute; left:14%; right:14%; bottom:8%; aspect-ratio:1/1; transform-origin:50% 92%;
  animation:breathe 3.2s ease-in-out infinite}
.moko .body,.moko .joy{position:absolute; inset:0; width:100%; height:100%; display:block; user-select:none; -webkit-user-drag:none}
.moko .body{z-index:1}
.moko .joy{z-index:2; opacity:0; transition:opacity .07s}
.moko.happy .joy{opacity:1}
@keyframes breathe{0%,100%{transform:scale(1,1)}50%{transform:scale(1.018,.986)}}
@keyframes shadow{0%,100%{transform:translateX(-50%) scale(1)}50%{transform:translateX(-50%) scale(1.04)}}
.moko.hop{animation:hop .62s cubic-bezier(.3,.7,.4,1)}
@keyframes hop{
  0%{transform:scale(1,1)} 18%{transform:scale(1.06,.9)} 45%{transform:translateY(-7%) scale(.96,1.05)}
  72%{transform:translateY(0) scale(1.05,.94)} 100%{transform:scale(1,1)}
}
.moko.joyhop{animation:joyhop 1.1s cubic-bezier(.3,.7,.4,1)}
@keyframes joyhop{
  0%{transform:scale(1,1)} 10%{transform:scale(1.08,.88)} 28%{transform:translateY(-11%) scale(.94,1.07) rotate(-3deg)}
  44%{transform:translateY(0) scale(1.07,.92)} 58%{transform:translateY(-6%) scale(.97,1.04) rotate(3deg)}
  74%{transform:translateY(0) scale(1.04,.96)} 100%{transform:scale(1,1)}
}
.wear{position:absolute; pointer-events:none; transform-origin:50% 100%}
.wear img{width:100%; display:block}
.wear.sway{animation:sway 3.2s ease-in-out infinite}
@keyframes sway{0%,100%{transform:rotate(calc(var(--r,0deg) - 2deg))}50%{transform:rotate(calc(var(--r,0deg) + 2deg))}}
.wear.flap{animation:flap 1.6s ease-in-out infinite; transform-origin:50% 50%}
@keyframes flap{0%,100%{transform:scaleX(1)}50%{transform:scaleX(.93)}}
.wear.in{animation:drop .5s cubic-bezier(.25,1.5,.5,1)}
@keyframes drop{0%{opacity:0; transform:translateY(-18%) scale(.8) rotate(var(--r,0deg))}100%{opacity:1; transform:translateY(0) scale(1) rotate(var(--r,0deg))}}
.wear.in.flap{transform-origin:50% 50%}
.sparkle{position:absolute; width:20px; height:20px; margin:-10px 0 0 -10px; pointer-events:none; z-index:20}
.sparkle::before{content:""; position:absolute; inset:0; background:var(--accent);
  clip-path:polygon(50% 0,62% 38%,100% 50%,62% 62%,50% 100%,38% 62%,0 50%,38% 38%)}
.hint{text-align:center; font-size:15px; font-weight:700; margin:0; min-height:1.5em}

/* けだまが 0 の人へ: 遊ぶとたまる、の入口 */
.empty{flex:none; background:var(--card); border:2.5px solid var(--line); border-radius:16px; padding:10px 12px; margin:2px 0 8px;
  box-shadow:0 4px 0 var(--paper2)}
.empty[hidden]{display:none}
.empty-lead{margin:0 0 8px; font-weight:800; font-size:15px; text-align:center}
.empty-games{list-style:none; margin:0; padding:0; display:flex; flex-wrap:wrap; gap:6px; justify-content:center}
.empty-games a{display:inline-flex; align-items:center; gap:6px; text-decoration:none; font-weight:800; font-size:14px;
  background:var(--accent); color:var(--accent-ink); border:2.5px solid var(--line); border-radius:999px; padding:7px 14px;
  box-shadow:0 3px 0 #8C5E3B}
.empty-games a:active{transform:translateY(2px); box-shadow:0 1px 0 #8C5E3B}
.empty-games a:focus-visible{outline:3px solid var(--accent); outline-offset:2px}
.empty-games .no{font-size:12px; opacity:.85}
.empty-soon{margin:8px 0 0; font-size:11.5px; color:var(--ink-soft); text-align:center}

/* 棚のタブ */
.side{flex:1; min-height:0; display:flex; flex-direction:column}
.tabs{flex:none; display:flex; gap:6px; overflow-x:auto; padding:4px 2px 8px; scrollbar-width:none; scroll-snap-type:x proximity}
.tabs::-webkit-scrollbar{display:none}
.tab{
  flex:none; appearance:none; font:inherit; color:var(--ink); cursor:pointer;
  display:flex; align-items:center; gap:4px; padding:4px 12px 4px 6px; border-radius:999px;
  border:2px solid transparent; background:var(--tab); font-size:14px; font-weight:700; scroll-snap-align:start;
}
.tab img{width:28px; height:28px; object-fit:contain; display:block}
.tab[aria-selected="true"]{background:var(--card); border-color:var(--line); box-shadow:0 3px 0 var(--paper2)}
.tab:focus-visible{outline:3px solid var(--accent); outline-offset:2px}

/* 品の棚 */
.shelfbox{flex:1; min-height:0; overflow-y:auto; padding:2px 2px 6px; overscroll-behavior:contain}
.shelf{display:grid; grid-template-columns:repeat(4,1fr); gap:8px}
.item{
  position:relative; appearance:none; border:2.5px solid var(--line); background:var(--card);
  border-radius:16px; padding:6px 4px 4px; cursor:pointer; color:var(--ink);
  display:flex; flex-direction:column; align-items:center; gap:2px; min-height:92px;
  box-shadow:0 4px 0 var(--paper2); transition:transform .12s, box-shadow .12s, background .2s;
  font:inherit;
}
.item:active{transform:translateY(3px); box-shadow:0 1px 0 var(--paper2)}
.item .pic{height:52px; width:100%; display:flex; align-items:center; justify-content:center}
.item .pic img{max-height:52px; max-width:88%; display:block}
.item .price{display:flex; align-items:center; gap:3px; font-size:13.5px; font-weight:800}
.item .price img{width:18px; height:18px}
.item .tag{position:absolute; top:3px; left:5px; font-size:10px; font-weight:800; color:var(--ink-soft); letter-spacing:.02em}
.item.on{background:var(--sel)}
.item.own .price{color:var(--ok); font-size:12px}
.item.on:not(.own){border-style:dashed}
.item:focus-visible{outline:3px solid var(--accent); outline-offset:2px}

/* 買う帯（試着した時だけ出る） */
.buybar{flex:none; display:flex; flex-direction:column; align-items:center; gap:4px; min-height:62px; padding-top:6px}
.buybar.off{visibility:hidden}
.buy{
  appearance:none; border:2.5px solid var(--line); border-radius:999px; background:var(--accent); color:var(--accent-ink);
  font:inherit; font-size:17px; font-weight:800; padding:10px 22px; display:flex; align-items:center; gap:8px; cursor:pointer;
  box-shadow:0 4px 0 #8C5E3B; transition:transform .12s, opacity .2s;
}
.buy img{width:26px; height:26px}
.buy:active{transform:translateY(3px); box-shadow:0 1px 0 #8C5E3B}
.buy[disabled]{background:var(--paper2); color:var(--ink-soft); box-shadow:none; cursor:default}
.buy.gone{visibility:hidden}
.golink{font-size:12.5px; font-weight:700; color:var(--ink-soft)}
.golink[hidden]{display:none}
.flycoin{position:fixed; left:0; top:0; width:30px; height:30px; pointer-events:none; z-index:30}
.note{flex:none; font-size:11px; color:var(--muted); text-align:center; margin:4px 0 0}
.note a{color:var(--ink-soft)}
.note #noStore{display:block; color:var(--ink-soft); font-weight:700}
.note #noStore[hidden]{display:none}

/* パソコン・横向き: 舞台と棚を左右に */
@media (min-aspect-ratio:1/1) and (min-width:700px){
  .main{flex-direction:row; align-items:stretch; gap:24px}
  .stagewrap{flex:1.05; justify-content:center}
  .stage{height:min(62dvh, 470px)}
  .side{flex:1}
  .tabs{flex-wrap:wrap; overflow:visible}
  .hint{font-size:17px}
  .shelf{grid-template-columns:repeat(4,1fr)}
  .item{min-height:112px}
  .item .pic{height:66px}.item .pic img{max-height:66px}
}
/* 横向きで背の低いスマホ */
@media (min-aspect-ratio:1/1) and (max-height:520px){
  .main{flex-direction:row; gap:14px}
  .stagewrap{flex:.9; justify-content:center}
  .stage{height:min(66dvh, 300px)}
  .hint{font-size:13px}
  .side{flex:1.3}
  .shelf{grid-template-columns:repeat(5,1fr); gap:6px}
  .item{min-height:76px}.item .pic{height:40px}.item .pic img{max-height:40px}
  .buybar{min-height:50px}
  .buy{font-size:15px; padding:7px 16px}
  .note{display:none}
  .title{display:none}
}
@media (max-width:360px){
  .title{display:none}
}
@media (prefers-reduced-motion: reduce){
  *{animation:none !important; transition:none !important}
}
