:root{
  --ink:#2b2118;
  --paper:#fdf6e3;
  --red:#e03b3b;
  --blue:#2f6fd0;
  --purple:#8a3fd1;
  --gold:#f5c542;
  --night1:#1a1033;
  --night2:#3a1d4d;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;height:100%}
body{
  font-family:"Hiragino Maru Gothic ProN","Yu Gothic","Noto Sans CJK JP","Noto Sans JP",sans-serif;
  color:var(--paper);
  background:
    radial-gradient(1200px 500px at 50% -10%, #55246b 0%, transparent 70%),
    linear-gradient(180deg, var(--night1) 0%, var(--night2) 60%, #4a2440 100%);
  background-attachment:fixed;
  font-size:17px;
  -webkit-font-smoothing:antialiased;
  overflow-x:hidden;
}
/* ちょうちんの ならび */
body::before{
  content:"";
  position:fixed; left:0; right:0; top:0; height:26px;
  background:
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(255,220,120,.0) 34px 40px),
    repeating-radial-gradient(circle at 20px 6px, #ff8a4c 0 9px, transparent 10px);
  background-size:auto, 40px 26px;
  opacity:.55; pointer-events:none; z-index:1;
}

#hud{
  position:sticky; top:0; z-index:20;
  display:flex; align-items:center; gap:14px;
  flex-wrap:wrap; row-gap:6px;          /* 狭い画面で潰れず折り返す */
  padding:10px 18px 8px;
  background:linear-gradient(180deg, rgba(20,10,35,.96), rgba(20,10,35,.72));
  border-bottom:2px solid rgba(245,197,66,.35);
  backdrop-filter:blur(3px);
}
.hud-title{font-size:22px; white-space:nowrap; font-weight:800; letter-spacing:.04em; color:var(--gold); text-shadow:0 2px 0 #6b3a12}
.hud-item{display:flex; align-items:baseline; gap:5px; white-space:nowrap; font-size:20px; font-weight:700;
  background:rgba(255,255,255,.08); padding:4px 12px; border-radius:999px}
.hud-item small{font-size:13px; opacity:.75; font-weight:600}
.hud-item .k{font-size:17px}
.hud-grow{flex:1}
.hud-btn{
  font-size:20px; width:42px; height:42px; border-radius:50%;
  border:2px solid rgba(255,255,255,.25); background:rgba(255,255,255,.1); color:#fff; cursor:pointer;
}
.hud-btn:hover{background:rgba(255,255,255,.22)}
#money.up{color:#7ef58a} #money.down{color:#ff8a8a}

#clockbar{height:6px; background:rgba(0,0,0,.35); position:sticky; top:60px; z-index:19}
#clockbar-fill{height:100%; width:0%; background:linear-gradient(90deg,#ffd36e,#ff7a4c); transition:width .3s linear}

main{
  display:grid; grid-template-columns:1fr 380px; gap:20px;
  padding:18px 18px 40px; max-width:1800px; margin:0 auto; position:relative; z-index:2;
}
@media (max-width:1100px){ main{grid-template-columns:1fr} }

.section-h{font-size:17px; margin:4px 0 10px; color:#ffe6a8; font-weight:800; letter-spacing:.04em}
.section-h small{font-weight:600; font-size:13px; opacity:.7; margin-left:8px}

#street{display:flex; flex-wrap:wrap; gap:16px}

/* ---------- やたい ---------- */
.stall{
  width:252px; cursor:pointer; position:relative;
  transition:transform .12s ease;
  filter:drop-shadow(0 8px 14px rgba(0,0,0,.45));
}
.stall:hover{transform:translateY(-4px)}
.stall.gone{opacity:.35; filter:grayscale(1); cursor:default}
.stall.gone:hover{transform:none}
.roof{
  height:34px; border-radius:8px 8px 0 0;
  background:repeating-linear-gradient(90deg,#e8413c 0 18px,#fdf6e3 18px 36px);
  border-bottom:4px solid #7a2f1f;
}
.body{
  background:linear-gradient(180deg,#f6ead0,#e6d3ae);
  color:var(--ink); padding:10px 12px 12px; border-radius:0 0 10px 10px;
  border:3px solid #9c6b3f; border-top:none;
}
.sign{
  background:#fffdf5; border:3px double #b3763f; border-radius:6px;
  text-align:center; padding:6px 4px 7px; margin-bottom:8px;
}
.sign .nm{font-size:23px; font-weight:900; letter-spacing:.02em; line-height:1.2}
.sign .claim{font-size:14px; font-weight:800; color:#c2452f; margin-top:2px}
.keeper{font-size:34px; line-height:1; text-align:center; margin:2px 0 6px}
.keeper .kq{font-size:13px; display:block; color:#5d4a33; font-weight:700; min-height:1.2em}
.paper{
  background:#fffdf5; border:1px dashed #a8815a; border-radius:5px;
  padding:6px 8px; font-size:14px; font-weight:700; line-height:1.55; color:#4a3a28;
}
.paper .num{color:#1c4fa1; font-size:15px}
.paper .rest{color:#a4451c}
.queue{margin-top:7px; font-size:19px; min-height:24px; letter-spacing:-2px}
.badge{
  position:absolute; top:-10px; right:-8px; background:var(--gold); color:#3a2400;
  font-weight:900; font-size:13px; padding:3px 9px; border-radius:999px; border:2px solid #8a5a12;
}
.badge.bad{background:var(--purple); color:#fff; border-color:#4d1c7d}
.badge.ok{background:#5bd07a; color:#0d3b1a; border-color:#1e6b34}

/* ---------- じぶんの みせ ---------- */
#mystall{
  background:linear-gradient(180deg,rgba(255,255,255,.12),rgba(255,255,255,.05));
  border:2px solid rgba(245,197,66,.5); border-radius:14px; padding:14px; margin-bottom:16px;
}
#mystall h2{margin:0 0 8px; font-size:18px; color:#ffe6a8}
.myname{
  width:100%; font-size:20px; font-weight:900; text-align:center; padding:6px;
  border-radius:8px; border:2px solid rgba(255,255,255,.3); background:#fffdf5; color:var(--ink);
  font-family:inherit;
}
.myrow{display:flex; justify-content:space-between; align-items:center; margin-top:10px; font-size:16px; font-weight:700}
.myrow .v{font-size:20px; color:#ffe6a8}
.stars{font-size:18px; letter-spacing:2px}
.setter{display:flex; align-items:center; justify-content:center; gap:12px; margin:10px 0 4px}
.setter button{
  width:46px; height:46px; font-size:26px; font-weight:900; border-radius:12px; cursor:pointer;
  border:2px solid #8a5a12; background:var(--gold); color:#3a2400;
}
.setter button:disabled{opacity:.35; cursor:default}
.setter .n{font-size:34px; font-weight:900; min-width:2ch; text-align:center}
.btn{
  display:block; width:100%; margin-top:10px; padding:12px; font-size:19px; font-weight:900;
  border-radius:12px; cursor:pointer; border:3px solid #8a5a12;
  background:linear-gradient(180deg,#ffd76b,#f0a92e); color:#3a2400; font-family:inherit;
}
.btn:hover{filter:brightness(1.06)}
.btn:disabled{opacity:.4; cursor:default; filter:grayscale(.4)}
.btn.sub{background:linear-gradient(180deg,#fff,#dcd2c2); border-color:#7a6a55; color:#2b2118}
.btn.danger{background:linear-gradient(180deg,#ff9a9a,#e05252); border-color:#8a1f1f; color:#3a0000}
.btn.small{font-size:16px; padding:9px}
.hint{font-size:13px; opacity:.8; margin-top:8px; line-height:1.5}

#logbox{background:rgba(0,0,0,.28); border-radius:12px; padding:12px}
#log{max-height:46vh; overflow-y:auto; font-size:15px; line-height:1.6}
#log div{padding:3px 0; border-bottom:1px dotted rgba(255,255,255,.13)}
#log .plus{color:#8ef59a; font-weight:800}
#log .minus{color:#ff9d9d; font-weight:800}
#log .big{color:var(--gold); font-weight:900}

/* ---------- トースト ---------- */
#toasts{position:fixed; right:18px; bottom:18px; z-index:40; display:flex; flex-direction:column; gap:8px; align-items:flex-end}
.toast{
  background:rgba(20,10,35,.94); border:2px solid var(--gold); border-radius:12px;
  padding:9px 14px; font-size:17px; font-weight:800; animation:pop .25s ease;
}
.toast.minus{border-color:#e05252} .toast.plus{border-color:#5bd07a}
@keyframes pop{from{transform:translateY(10px) scale(.9); opacity:0}}

/* ---------- モーダル ---------- */
#modal-layer{
  position:fixed; inset:0; z-index:50; background:rgba(8,4,16,.78);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal{
  background:linear-gradient(180deg,#f8eed6,#e8d6b4); color:var(--ink);
  border:5px solid #9c6b3f; border-radius:18px; padding:20px 22px;
  width:min(760px,96vw); max-height:92vh; overflow-y:auto; animation:pop .2s ease;
  box-shadow:0 20px 50px rgba(0,0,0,.6);
}
.modal h2{margin:0 0 10px; font-size:26px}
.modal p{line-height:1.7; margin:8px 0}
.modal .big-sign{background:#fffdf5; border:4px double #b3763f; border-radius:8px; text-align:center; padding:10px; margin-bottom:10px}
.modal .big-sign .nm{font-size:34px; font-weight:900}
.modal .big-sign .claim{font-size:18px; font-weight:800; color:#c2452f}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:12px}
@media (max-width:620px){ .grid2{grid-template-columns:1fr} }
.card{background:#fffdf5; border:2px solid #c9a878; border-radius:10px; padding:10px 12px}
.card h3{margin:0 0 6px; font-size:16px; color:#7a4a1f}
.card .line{font-size:17px; font-weight:700; line-height:1.7}
.card .line b{color:#1c4fa1; font-size:19px}
.modal .btns{display:flex; gap:10px; flex-wrap:wrap; margin-top:14px}
.modal .btns .btn{flex:1 1 180px; margin-top:0}
.tellbox{background:#fff4d6; border:2px dashed #c98f2f; border-radius:10px; padding:10px 12px; margin-top:12px}
.tellbox li{margin:4px 0; font-size:17px; font-weight:700; line-height:1.5}
.rule-table{width:100%; border-collapse:collapse; margin:10px 0; font-size:17px}
.rule-table td{border:2px solid #c9a878; padding:8px 10px; background:#fffdf5}
.rule-table td.g{color:#1a7a33; font-weight:900} .rule-table td.r{color:#c22; font-weight:900}
/* 金がくは 折り返さない（スマホで「+300え／ん」に 割れていた） */
.rule-table td.g, .rule-table td.r{white-space:nowrap; width:1%}

/* ---------- くじを ひく えんしゅつ ---------- */
.drawstage{text-align:center; padding:6px 0 2px; min-height:270px}
.box3d{
  width:150px; height:120px; margin:6px auto 10px; border-radius:10px;
  background:linear-gradient(180deg,#d8a463,#a9702f); border:4px solid #6d4318;
  position:relative; box-shadow:inset 0 -12px 20px rgba(0,0,0,.25);
}
.box3d::after{content:""; position:absolute; left:38px; top:-6px; width:74px; height:16px; background:#3b2410; border-radius:6px}
.box3d.shake{animation:shake .42s ease-in-out 3}
@keyframes shake{0%,100%{transform:translateX(0) rotate(0)}25%{transform:translateX(-8px) rotate(-4deg)}75%{transform:translateX(8px) rotate(4deg)}}
.ticket{
  width:210px; height:132px; margin:0 auto; background:#fffdf5; border:4px solid #b3763f; border-radius:10px;
  display:flex; align-items:center; justify-content:center; font-size:52px; font-weight:900;
  animation:unfold .45s ease; position:relative;
}
@keyframes unfold{from{transform:scaleY(.1) rotate(-6deg); opacity:.3}}
.ticket.hit{color:var(--red); border-color:var(--red)}
.ticket.miss{color:var(--blue); border-color:var(--blue)}
.ticket .stamp{
  position:absolute; right:-14px; bottom:-14px; transform:rotate(-14deg);
  background:var(--purple); color:#fff; font-size:22px; padding:4px 12px; border-radius:8px; border:3px solid #fff;
  animation:pop .3s ease;
}
.money-delta{font-size:34px; font-weight:900; margin-top:12px; animation:pop .3s ease}
.money-delta.plus{color:#1a7a33} .money-delta.minus{color:#c22}
.say{font-size:19px; font-weight:800; margin-top:8px; min-height:1.6em}
.fireworks{font-size:46px; letter-spacing:6px; text-align:center; animation:pop .4s ease}
.paper .prow{display:flex; justify-content:space-between; white-space:nowrap; gap:6px}
.paper .prow b{font-weight:900}
#modal-layer[hidden]{display:none !important}
.cta{
  display:inline-block; margin-left:14px; padding:3px 12px; border-radius:999px;
  background:rgba(245,197,66,.22); border:2px solid var(--gold); color:#ffe6a8;
  font-size:14px; font-weight:800; animation:ctapulse 1.6s ease-in-out infinite;
}
@keyframes ctapulse{50%{background:rgba(245,197,66,.45)}}
/* --- みんなの ようす（公開版の観客数） --- */
#world{background:rgba(0,0,0,.28); border-radius:12px; padding:12px; margin-bottom:16px}
#world .section-h{margin-bottom:8px}
.wrow{display:flex; justify-content:space-between; align-items:baseline; font-size:16px; font-weight:700; padding:2px 0}
.wrow b{font-size:21px; color:#ffe6a8}
.wrow b.p{color:#8ef59a}
.wrow.tot{opacity:.75; font-size:14px}
.wrow.tot b{font-size:17px}
.wbars{display:flex; align-items:flex-end; gap:6px; height:70px; margin:10px 0 2px}
.wbar{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end}
.wbar-stack{display:flex; align-items:flex-end; gap:2px; height:50px}
.wbar-come,.wbar-play{width:8px; border-radius:2px 2px 0 0; min-height:2px}
.wbar-come{background:#ffd36e} .wbar-play{background:#5bd07a}
.wbar-label{font-size:10px; opacity:.6; margin-top:3px}
.wlegend{font-size:12px; opacity:.75; display:flex; align-items:center; gap:5px}
.wlegend span{display:inline-block; width:10px; height:10px; border-radius:2px}
.wlegend .k-come{background:#ffd36e} .wlegend .k-play{background:#5bd07a}
.wstamp{font-size:11px; opacity:.5; margin-top:6px}
.wzero,.werr,.wload{font-size:15px; font-weight:700; line-height:1.6; padding:6px 0}
.wzero{color:#ffe6a8} .werr{color:#ff9d9d} .wload{opacity:.6}
.wzero small,.werr small{font-weight:600; opacity:.8; font-size:13px}
.wdev{font-size:11px; margin-top:4px; color:#ffd36e; opacity:.9; font-weight:700}

/* ================= スマホ（X経由の訪問者はほぼこちら） =================
   ⚠ 2026-09-06: 公開して12人来たのに 誰も くじを引かなかった。実測したら
   390px幅で HUD が崩れ、案内は「みぎの みせを ひらく」と言うのに 1カラムでは
   右に何も無かった。受け手と同じ経路（スマホ）で開いていなかったのが原因。
   → keel findings/完了と言う前に、受け手と同じ経路で取得して開く.md          */
main{
  grid-template-areas:"street mystall" "street side";
  align-items:start;
}
#street-wrap{grid-area:street}
#mystall{grid-area:mystall}
#side{grid-area:side}
.stall{width:min(252px,100%)}
.m-only{display:none}

@media (max-width:1100px){
  /* じぶんの みせ を いちばん上に（名前のとおり主語は「売る側」） */
  main{grid-template-columns:1fr; grid-template-areas:"mystall" "street" "side"}
  /* ただし まだ 1回も あそんでいない人だけは、くじを ひく所を 先に 出す */
  body.newcomer main{grid-template-areas:"street" "mystall" "side"}
  .d-only{display:none}
  .m-only{display:inline}
}
@media (max-width:700px){
  body{font-size:16px}
  #hud{padding:8px 10px 6px; gap:8px}
  .hud-title{font-size:17px; white-space:nowrap}
  .hud-item{font-size:16px; padding:3px 9px}
  .hud-item small{font-size:11px}
  .hud-item .k{font-size:14px}
  .hud-btn{width:34px; height:34px; font-size:16px}
  #clockbar{position:static}            /* HUDが折り返すと sticky の位置が合わない */
  main{padding:12px 10px 36px; gap:14px}
  .modal{padding:14px 15px}
  .modal h2{font-size:22px}
  .rule-table{font-size:15px}
  .modal .btns .btn{flex:1 1 100%}
  .cta{margin-left:0; margin-top:6px; display:block}
  /* スマホの やたいは よこいっぱい（252pxだと 右に 118px の すきまが 出て、
     しかも 2れつに すると 店の名まえが 折り返して にせくじの「1もじ ちがい」が
     読みにくくなる＝この ゲームの しんの ところ）。
     そのぶん たてに 長く なるので、はりがみを 2れつに して 背を ちぢめる。 */
  .stall{width:100%}
  .paper{display:grid; grid-template-columns:1fr 1fr; column-gap:14px}
}
