/* ふうせん我慢：縁日のポスター風。クリーム・紺・赤・黄・青 */
:root {
  --ink: #2b3a55;
  --paper: #fff7e3;
  --paper2: #ffecc2;
  --red: #e8453c;
  --yellow: #ffc933;
  --blue: #3a8fe0;
  --sky: #bfe6fb;
  --muted: #6b7690;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: #f4e7c5;
  background-image: radial-gradient(#ecd9a8 1.5px, transparent 1.6px); background-size: 18px 18px;
  line-height: 1.7;
}
button { font-family: inherit; color: inherit; }
.hidden { display: none !important; }

/* ---- ゲーム画面 ---- */
#stage {
  position: relative; width: 100%; max-width: 480px; height: 100vh; height: 100svh; margin: 0 auto;
  overflow: hidden; background: var(--sky);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#hud { position: absolute; left: 0; right: 0; top: 0; padding: calc(10px + env(safe-area-inset-top)) 12px 0; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
.tag {
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 12px; padding: 2px 10px 3px; font-weight: 800; font-size: 13px; line-height: 1.35; box-shadow: 0 3px 0 var(--ink);
}
.tag b { font-size: 20px; margin: 0 1px; }
.tag small { font-size: 11px; font-weight: 700; color: var(--muted); margin-right: 3px; }
#hTotalTag { margin-left: auto; }
#btnSound {
  pointer-events: auto; cursor: pointer; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 12px; padding: 4px 10px; font-size: 12px; font-weight: 800;
  box-shadow: 0 3px 0 var(--ink); min-height: 38px; touch-action: manipulation;
}
#btnSound[aria-pressed="false"] { background: #e3dccb; color: var(--muted); }

#chip {
  position: absolute; left: 50%; top: calc(62px + env(safe-area-inset-top)); transform: translateX(-50%); pointer-events: none;
  display: flex; align-items: center; gap: 7px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 999px; padding: 2px 13px 2px 6px;
  font-size: 12.5px; font-weight: 800; white-space: nowrap; box-shadow: 0 3px 0 var(--ink);
}
#chipDot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); background: var(--red); }

#meter { position: absolute; left: 0; right: 0; bottom: calc(86px + env(safe-area-inset-bottom)); text-align: center; pointer-events: none; }
#meter .big { font-size: 46px; font-weight: 800; line-height: 1.1; color: #fff; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; letter-spacing: .01em; }
#meter .big small { font-size: 22px; margin-left: 3px; }
#meter .pts { display: inline-block; margin-top: 2px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 999px; padding: 0 12px; font-weight: 800; font-size: 14px; box-shadow: 0 3px 0 var(--ink); }

#hint {
  position: absolute; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); transform: translateX(-50%); pointer-events: none;
  background: var(--ink); color: #fff; border-radius: 999px; padding: 6px 18px; font-weight: 800; font-size: 14px; white-space: nowrap;
  animation: hintPulse 1.3s ease-in-out infinite;
}
@keyframes hintPulse { 50% { transform: translateX(-50%) scale(1.05); } }

#pop { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; opacity: 0; }
#pop .m { display: block; font-size: 48px; font-weight: 800; line-height: 1.15; color: #fff; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; }
#pop .s { display: inline-block; margin-top: 4px; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 999px; padding: 0 12px; font-weight: 800; font-size: 14px; }
#pop.show { animation: popIn 1.25s ease-out forwards; }
#pop.burst .m { color: var(--yellow); font-size: 64px; }
#pop.gold .m { color: var(--yellow); }
@keyframes popIn {
  0% { opacity: 0; transform: scale(.4) translateY(10px); }
  14% { opacity: 1; transform: scale(1.18) translateY(0); }
  26% { transform: scale(1); }
  75% { opacity: 1; transform: translateY(-14px); }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* ---- 重ね画面 ---- */
.ov { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 18px; touch-action: pan-y; overflow-y: auto; }
.card {
  position: relative; width: 100%; max-width: 380px; background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink);
  padding: 20px 18px 18px; text-align: center; margin: auto;
}
.logo { margin: 0; font-size: 44px; line-height: 1.1; font-weight: 800; letter-spacing: .02em; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.logo span:nth-child(3n+1) { color: var(--red); } .logo span:nth-child(3n+2) { color: var(--yellow); } .logo span:nth-child(3n) { color: var(--blue); }
.lead { margin: 12px 0 14px; font-weight: 700; font-size: 15px; }
.best { margin: 12px 0 0; font-size: 13px; font-weight: 700; color: var(--muted); }
.best b { color: var(--ink); font-size: 17px; }
.btn {
  display: block; width: 100%; cursor: pointer; border: 3px solid var(--ink); border-radius: 16px; background: var(--red); color: #fff; font-weight: 800; font-size: 22px; padding: 12px 10px;
  box-shadow: 0 5px 0 var(--ink); text-shadow: 0 2px 0 rgba(0,0,0,.25); touch-action: manipulation; min-height: 58px;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn.sub { background: var(--paper); color: var(--ink); text-shadow: none; font-size: 15px; padding: 8px 6px; min-height: 46px; box-shadow: 0 4px 0 var(--ink); }
.btn.sub:active { box-shadow: 0 1px 0 var(--ink); }
.btn.x { background: var(--ink); color: #fff; text-shadow: none; }
.row { display: flex; gap: 10px; margin-top: 14px; }
.row > * { flex: 1; }
.scrollhint { margin: 14px 0 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.scrollhint a { color: var(--ink); }

#tutorial .card { padding-top: 16px; }
#tutorial h2 { margin: 0 0 6px; font-size: 22px; }
.rules { list-style: none; padding: 0; margin: 8px 0 12px; text-align: left; font-size: 14.5px; font-weight: 700; }
.rules li { padding: 5px 0 5px 30px; position: relative; border-bottom: 2px dotted #e2cf9b; }
.rules li:last-child { border-bottom: 0; }
.rules li i { position: absolute; left: 0; top: 7px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; font-style: normal; font-size: 12.5px; text-align: center; line-height: 22px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin: 0 0 14px; font-size: 12.5px; font-weight: 800; text-align: left; }
.legend div { display: flex; align-items: center; gap: 6px; background: var(--paper2); border-radius: 10px; padding: 3px 8px; line-height: 1.3; }
.legend i { flex: none; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.legend small { display: block; font-weight: 700; color: var(--muted); font-size: 11px; }

/* 結果 */
#result .card { padding-top: 16px; }
.rlabel { font-size: 13px; font-weight: 800; color: var(--muted); margin: 0; }
.rtotal { margin: 0; font-size: 62px; line-height: 1.1; font-weight: 800; color: var(--red); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.rtotal small { font-size: 24px; margin-left: 3px; }
.newrec { display: inline-block; background: var(--yellow); border: 2.5px solid var(--ink); border-radius: 999px; padding: 0 12px; font-weight: 800; font-size: 14px; transform: rotate(-3deg); margin-bottom: 4px; }
.chips { display: flex; justify-content: center; gap: 6px; margin: 10px 0 12px; }
.rchip { flex: 1; max-width: 64px; border: 2.5px solid var(--ink); border-radius: 12px; background: #fff; padding: 4px 0 5px; font-weight: 800; line-height: 1.2; }
.rchip i { display: block; width: 20px; height: 20px; margin: 0 auto 2px; border-radius: 50%; border: 2px solid var(--ink); }
.rchip b { display: block; font-size: 15px; }
.rchip small { font-size: 10.5px; color: var(--muted); }
.rchip.burst { background: #ffe1dd; }
.rchip.burst b { color: var(--red); font-size: 14px; }
.diag { background: var(--paper2); border: 2.5px solid var(--ink); border-radius: 16px; padding: 8px 10px 10px; margin-bottom: 14px; }
.diag small { font-size: 12px; font-weight: 800; color: var(--muted); }
.diag h3 { margin: 0; font-size: 26px; line-height: 1.3; }
.diag p { margin: 2px 0 0; font-size: 13px; font-weight: 700; line-height: 1.55; }
.diag .pct { font-size: 12.5px; color: var(--muted); }
#copyMsg { min-height: 1.4em; margin: 8px 0 0; font-size: 12.5px; font-weight: 800; color: var(--blue); }
#copyBox { width: 100%; margin-top: 6px; font-family: inherit; font-size: 13px; border: 2px solid var(--ink); border-radius: 10px; padding: 6px; background: #fff; color: var(--ink); resize: none; }

#fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 28px; text-align: center; font-weight: 800; line-height: 1.8; background: var(--sky); }

/* ---- 画面の下の本文 ---- */
.about, .doc main { max-width: 720px; margin: 0 auto; padding: 28px 18px 16px; }
.about { background: var(--paper); border-top: 4px solid var(--ink); max-width: none; padding: 0; }
.about-in { max-width: 720px; margin: 0 auto; padding: 28px 18px 8px; }
h1, h2, h3 { line-height: 1.4; }
.about h2, .doc h2 { font-size: 21px; margin: 28px 0 8px; padding-left: 12px; border-left: 8px solid var(--red); }
.about h2:first-child { margin-top: 0; }
.doc h1 { font-size: 28px; margin: 6px 0 14px; }
.doc h3 { font-size: 17px; margin: 18px 0 4px; }
.about p, .doc p, .about li, .doc li { font-size: 15.5px; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; padding: 0; list-style: none; }
.cols li { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 8px 12px; font-size: 14px; line-height: 1.55; }
.cols li b { display: block; font-size: 16px; }
.cols li i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); margin-right: 6px; vertical-align: -1px; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; padding: 0; list-style: none; }
.links a { display: inline-block; background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; padding: 6px 16px; font-weight: 800; font-size: 14px; color: var(--ink); text-decoration: none; box-shadow: 0 3px 0 var(--ink); }
.adbox { margin: 24px 0 8px; min-height: 20px; }
.site-foot { background: var(--ink); color: #fff; padding: 18px; font-size: 13px; text-align: center; }
.site-foot a { color: #fff; margin: 0 8px; }
.site-foot p { margin: 8px 0 0; color: #b9c2d8; }

/* 本文ページ（遊び方・プライバシー） */
.doc { background: var(--paper); }
.doc main { background: var(--paper); }
.doc table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 14px; }
.doc th, .doc td { border: 2px solid var(--ink); padding: 6px 8px; text-align: left; }
.doc th { background: var(--paper2); }
.doc nav ol { background: #fff; border: 2.5px solid var(--ink); border-radius: 14px; padding: 10px 10px 10px 36px; font-size: 14px; }
.doc a { color: var(--blue); }
.back { display: inline-block; margin: 12px 0; font-weight: 800; }

@media (min-width: 720px) { #stage { border-left: 4px solid var(--ink); border-right: 4px solid var(--ink); } }
@media (max-height: 560px) {
  .logo { font-size: 34px; } .lead { margin: 6px 0 8px; } .rtotal { font-size: 46px; } .diag h3 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { #hint { animation: none; } }

/* 本文ページのフッター */
.page-foot { margin-top: 24px; }
.foot-group { display: block; margin: 6px 0; }
.foot-title { display: block; font-size: 12px; color: #b9c2d8; }
.foot-copy { margin: 10px 0 0; }
.policy { max-width: 720px; }
.doc code { background: var(--paper2); padding: 0 5px; border-radius: 5px; font-size: 13px; }
/* ちょいゲー工房の「戻る」ボタン（上の中央に固定）と重ならないよう、狭い画面では上の表示を1段下げる */
@media (max-width: 540px) {
  #hud { padding-top: calc(50px + env(safe-area-inset-top)); }
  #chip { top: calc(100px + env(safe-area-inset-top)); }
}
