/* 202 ぐるぐるソフト：ソフトクリーム専門店の札と紙。ミルクの白・焦げ茶の線・ネオンのピンク・水色のタイル。色はここだけに書く。 */
@font-face { font-family: "GuruMaru"; src: url("zenmaru.woff2") format("woff2"); font-display: block; }
:root {
  --milk: #FFF7E8; --milk-2: #F3D9AA; --ink: #3A2418; --ink-2: #6B4A36; --pink: #FF5E9C; --pink-d: #D9467F; --tile: #A6DEDA; --cone: #E3A55A; --white: #FFFFFF;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --line: 3px; --r: 22px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--tile); font-family: "GuruMaru", system-ui, sans-serif; color: var(--ink); -webkit-user-select: none; user-select: none; touch-action: manipulation; overscroll-behavior: none; }
#lg-canvas { touch-action: none; position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; outline: none; }
[hidden] { display: none !important; }
button, a { font-family: inherit; color: inherit; }

/* ボタン：押すと沈む（下の影が縮む）。アイコンは使わず、文字だけ */
.big, .sub, .chip, .link, .snd-t { cursor: pointer; border: var(--line) solid var(--ink); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; line-height: 1; transition: transform .06s ease-out, box-shadow .06s ease-out; }
.big { background: var(--pink); color: var(--white); font-size: 26px; letter-spacing: .12em; min-width: 220px; min-height: 64px; padding: 0 28px; border-radius: 999px; box-shadow: 0 6px 0 var(--ink); text-shadow: 0 2px 0 var(--pink-d); }
.sub { background: var(--milk); font-size: 15px; min-height: 46px; padding: 0 16px; border-radius: 999px; box-shadow: 0 4px 0 var(--ink); }
.sub.warn { background: var(--pink); color: var(--white); }
.chip { background: var(--milk); font-size: 14px; min-height: 40px; padding: 0 14px; border-radius: 999px; box-shadow: 0 3px 0 var(--ink); }
.link { border: 0; background: none; font-size: 14px; min-height: 44px; padding: 0 8px; text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.big:active, .big.is-down { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.sub:active, .sub.is-down, .chip:active, .chip.is-down { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.big:focus-visible, .sub:focus-visible, .chip:focus-visible, .link:focus-visible, .snd-t:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
.row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* 音：ON/OFF と音量（端末に保存） */
.snd { display: inline-flex; align-items: center; gap: 8px; }
.snd-t { background: var(--milk); font-size: 14px; min-width: 52px; min-height: 40px; border-radius: 999px; box-shadow: 0 3px 0 var(--ink); padding: 0 10px; }
.snd-t[aria-pressed="false"] { background: var(--ink); color: var(--milk); }
.snd-t[aria-pressed="false"]::after { content: " 切"; }
.snd-v { -webkit-appearance: none; appearance: none; width: 96px; height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--pink) var(--v, 80%), var(--milk-2) var(--v, 80%)); border: 2px solid var(--ink); }
.snd-v::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--milk); border: 3px solid var(--ink); }
.snd-v::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--milk); border: 3px solid var(--ink); }
.snd.wide .snd-v { width: 150px; }

/* 題名：店の看板（上）と足もと（下） */
.panel { position: fixed; z-index: 5; }
#title { inset: 0; display: flex; flex-direction: column; justify-content: space-between; align-items: center; padding: calc(18px + var(--safe-t)) 16px calc(18px + var(--safe-b)); pointer-events: none; }
#title > * { pointer-events: auto; }
.sign { background: var(--milk); border: var(--line) solid var(--ink); border-radius: 28px; padding: 12px 22px 14px; box-shadow: 0 6px 0 var(--ink); text-align: center; transform: rotate(-1.5deg); }
.sign .kicker { margin: 0 0 2px; font-size: 13px; letter-spacing: .3em; color: var(--pink-d); }
.sign h1 { margin: 0; font-size: clamp(34px, 10.5vw, 52px); letter-spacing: .02em; line-height: 1.1; white-space: nowrap; }
.sign h1 span { display: inline-block; }
.sign h1 span:nth-child(odd) { transform: translateY(-3px) rotate(-5deg); }
.sign h1 span:nth-child(even) { transform: translateY(2px) rotate(4deg); }
.sign h1 span:nth-child(-n+4) { color: var(--pink-d); }
.foot { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 440px; }
.how { margin: 0; background: var(--milk); border: 2px solid var(--ink); border-radius: 999px; padding: 8px 16px; font-size: 14px; text-align: center; }
.best { margin: 0; font-size: 14px; background: var(--ink); color: var(--milk); border-radius: 999px; padding: 6px 14px; }
#title .row { gap: 6px 12px; background: var(--milk); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 10px; }

/* 遊ぶ画面：左上に高さの札・右上にひとやすみ・下に短い手引き */
#hud { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
#meter { position: absolute; left: calc(12px + var(--safe-l)); top: calc(12px + var(--safe-t)); background: var(--milk); border: var(--line) solid var(--ink); border-radius: 18px; padding: 6px 14px 8px; box-shadow: 0 4px 0 var(--ink); min-width: 118px; }
#meter p { margin: 0; }
#meter .h b { font-size: 34px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
#meter .h small { font-size: 14px; margin-left: 3px; }
#meter .lean { font-size: 13px; color: var(--ink-2); }
#meter .lean b { font-variant-numeric: tabular-nums; }
#meter.tilt .lean { color: var(--pink-d); }
#pause-btn { position: absolute; right: calc(12px + var(--safe-r)); top: calc(14px + var(--safe-t)); pointer-events: auto; }
#hint { position: absolute; left: 50%; bottom: calc(26px + var(--safe-b)); transform: translateX(-50%); margin: 0; background: var(--milk); border: var(--line) solid var(--ink); border-radius: 999px; padding: 10px 18px; font-size: 16px; width: max-content; max-width: calc(100% - 24px); text-align: center; line-height: 1.5; white-space: normal; box-shadow: 0 4px 0 var(--ink); }
#ghost { position: absolute; left: 50%; bottom: calc(86px + var(--safe-b)); width: 120px; height: 120px; transform: translateX(-50%); }
#ghost svg { width: 100%; height: 100%; overflow: visible; }
#ghost .path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 6 8; opacity: .7; }
#ghost .center { fill: var(--ink); opacity: .5; }
#ghost .tip { fill: var(--milk); stroke: var(--ink); stroke-width: 3; transform-origin: 60px 60px; animation: orbit 1.1s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #ghost .tip { animation-duration: 3s; } }

/* 指を置いた所（真ん中）と、いまの指 */
#touch { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
#touch-ring, #touch-dot { position: absolute; display: none; border-radius: 50%; transform: translate(-50%, -50%); }
#touch-ring { width: 26px; height: 26px; border: 3px solid var(--ink); background: rgba(255, 247, 232, .55); }
#touch-dot { width: 16px; height: 16px; background: var(--pink); border: 2px solid var(--ink); }
#touch.on #touch-ring, #touch.on #touch-dot { display: block; }

/* 下から出る紙（ひとやすみ・結果・シェア・きろく） */
.sheet { touch-action: pan-y; overscroll-behavior: contain; left: 50%; bottom: 0; transform: translateX(-50%); width: min(100%, 460px); max-height: 100%; overflow-y: auto; background: var(--milk); border: var(--line) solid var(--ink); border-bottom: 0; border-radius: 30px 30px 0 0; padding: 18px 18px calc(18px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: 0 -4px 0 rgba(58, 36, 24, .15); }
.ptitle { margin: 0; font-size: 20px; letter-spacing: .1em; }
.line { margin: 0; font-size: 15px; text-align: center; line-height: 1.6; }
.mini { margin: 0; font-size: 12px; color: var(--ink-2); text-align: center; }
#confirm { display: flex; flex-direction: column; gap: 10px; align-items: center; border-top: 2px dashed var(--ink-2); padding-top: 12px; width: 100%; }

#result { gap: 8px; }
.say { position: relative; margin: 0 0 6px; background: var(--white); border: 2px solid var(--ink); border-radius: 18px; padding: 8px 16px; font-size: 15px; line-height: 1.5; text-align: center; }
.say::after { content: ""; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; background: var(--white); border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: translateX(-50%) rotate(45deg); }
.say small { display: block; font-size: 11px; color: var(--ink-2); }
.new { margin: 0; background: var(--pink); color: var(--white); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 12px; font-size: 13px; letter-spacing: .06em; }
#r-name { margin: 0; font-size: clamp(30px, 9vw, 40px); letter-spacing: .04em; line-height: 1.15; text-align: center; }
.stats { margin: 0; display: flex; gap: 8px; justify-content: center; width: 100%; }
.stats > div { flex: 1; min-width: 0; background: var(--white); border: 2px solid var(--ink); border-radius: 14px; padding: 6px 4px; text-align: center; }
.stats dt { font-size: 12px; color: var(--ink-2); }
.stats dd { margin: 0; font-size: 13px; }
.stats dd b { font-size: 24px; font-variant-numeric: tabular-nums; margin-right: 2px; }
.note { margin: 0; font-size: 13px; color: var(--ink-2); text-align: center; line-height: 1.5; }
#retry { margin-top: 4px; }

#share-img { width: 100%; height: auto; border: 2px solid var(--ink); border-radius: 12px; background: var(--white); }
#rec-list { margin: 0; padding: 0; list-style: none; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#rec-list li { background: var(--white); border: 2px solid var(--ink); border-radius: 12px; padding: 6px 10px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
#rec-list li span:last-child { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rec-stats dd b { font-size: 22px; }
.close { margin-top: 4px; }

#flash { position: fixed; inset: 0; z-index: 9; background: var(--white); opacity: 0; pointer-events: none; }
#flash.on { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .9; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #flash.on { animation-duration: .2s; } }

#load { position: fixed; inset: 0; z-index: 20; background: var(--tile); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; transition: opacity .3s; }
#load.done { opacity: 0; }
#load p { margin: 0; font-size: 28px; background: var(--milk); border: var(--line) solid var(--ink); border-radius: 22px; padding: 8px 20px; box-shadow: 0 5px 0 var(--ink); }
#bar { width: 200px; height: 14px; border: var(--line) solid var(--ink); border-radius: 99px; background: var(--milk); overflow: hidden; }
#fill { width: 4%; height: 100%; background: var(--pink); }
#err { font-size: 13px !important; max-width: 80vw; }

/* 横長（PC）：紙は右下、看板は左上 */
@media (min-aspect-ratio: 4/3) and (min-width: 820px) {
  #title { align-items: flex-start; padding-left: calc(40px + var(--safe-l)); }
  .foot { align-items: flex-start; }
  .sheet { touch-action: pan-y; overscroll-behavior: contain; left: auto; right: 24px; bottom: 24px; transform: none; border-bottom: var(--line) solid var(--ink); border-radius: 30px; width: 420px; max-height: calc(100% - 48px); }
}

/* 低い縦画面は作品を主役に残す。数値と再挑戦/写真は省かず、一枚の小さな結果札へ。 */
@media (max-width: 430px) and (max-height: 700px) and (orientation: portrait) {
  #result { padding: 10px 12px calc(12px + var(--safe-b)); gap: 6px; border-radius: 24px 24px 0 0; max-height: calc(100dvh - 230px); }
  #result #r-say, #result #r-note { display: none; }
  #result #r-new { font-size: 11px; padding: 2px 10px; }
  #result #r-name { font-size: 26px; line-height: 1.12; }
  #result .stats { gap: 4px; border-top: 1px solid var(--milk-2); border-bottom: 1px solid var(--milk-2); }
  #result .stats > div { display: flex; align-items: baseline; justify-content: center; gap: 3px; border: 0; border-radius: 0; background: transparent; padding: 4px 0; white-space: nowrap; }
  #result .stats dt { font-size: 10px; }
  #result .stats dd { font-size: 11px; }
  #result .stats dd b { font-size: 18px; margin-right: 1px; }
  #result #retry { margin-top: 1px; min-width: 0; width: 100%; min-height: 48px; font-size: 22px; box-shadow: 0 4px 0 var(--ink); }
  #result .row { gap: 6px; width: 100%; }
  #result .row .sub { min-height: 44px; padding: 0 9px; font-size: 13px; box-shadow: 0 3px 0 var(--ink); }
}
