/* Pour Perfect: 夜のカウンター。数字と液体が主役。外部フォントなし */
:root {
  color-scheme: dark;
  --bg: #14110f; --bg2: #241a16; --fg: #f3ece4; --dim: #b9aca0;
  --gold: #e8b64a; --warm: #ff8a5b; --cool: #6ec1ff; --red: #e0483e;
  --bar: 56px; --trap: 64px; --foot: 80px;
  --num: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif; font-size: 16px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }

/* 卓: スマホは全幅、PC は幅 420px の中央 */
#table { position: fixed; top: 0; bottom: 0; left: 50%; width: min(100vw, 420px); transform: translateX(-50%); z-index: 15; pointer-events: none; }
#bar { position: absolute; top: 0; left: 0; right: 0; height: var(--bar); display: flex; align-items: center; justify-content: space-between; padding: env(safe-area-inset-top, 0) 12px 0 16px; font-variant-numeric: tabular-nums; pointer-events: none; }
#counter { font-family: var(--num); font-size: 28px; font-weight: 800; letter-spacing: .02em; display: flex; align-items: baseline; gap: 6px; min-width: 96px; text-shadow: 0 2px 8px #0008; }
#counter b { font-weight: 800; }
#ctotal { font-size: 16px; color: var(--dim); font-weight: 600; }
#date { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
@media (max-width: 420px) { #date { font-size: 11px; letter-spacing: 0; } #tools { gap: 3px; } }
#langs { display: flex; gap: 4px; }
#langs button { width: 44px; height: 44px; border-radius: 14px; border: 1px solid #ffffff30; background: #0006; color: var(--fg); font-weight: 800; font-size: 14px; letter-spacing: .04em; cursor: pointer; }
#langs button[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* 罠の予告 */
#table { --top: calc(var(--bar) + var(--trap)); }
#traps { position: absolute; top: var(--bar); left: 0; right: 0; min-height: var(--trap); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 4px 12px 12px; pointer-events: none; }
.trap { width: 100%; max-width: 340px; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; border-radius: 28px; background: #14110fb0; border: 1px solid #ffffff22; backdrop-filter: blur(2px); animation: trapIn .5s cubic-bezier(.2,.8,.2,1) both; transform-origin: 50% 0; }
.trap .ic { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--gold); color: var(--gold); display: grid; place-items: center; background: #14110fa0; }
.trap .ic svg { width: 26px; height: 26px; }
.trap span.w { font-size: 15px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; min-width: 0; }
.trap span.w i { display: block; font-style: normal; font-size: 13px; font-weight: 600; color: #d3c8bc; margin-top: 1px; }
.trap.plain .ic { border-color: #ffffff50; color: #ffffffb0; }
.trap.plain { color: var(--dim); max-width: 220px; }
@keyframes trapIn { 0% { transform: scale(1.18); opacity: 0; } 40% { opacity: 1; } 100% { transform: none; } }

/* はじめのヒント */
#hint { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--top) + 56px); width: max-content; max-width: calc(100% - 32px); text-align: center; pointer-events: none; color: var(--fg); padding: 12px 20px 8px; border-radius: 22px; background: #14110fc0; border: 1px solid #ffffff26; box-shadow: 0 8px 30px #0008; animation: hintIn .4s ease-out both; }
#hint p { margin: 0 0 4px; font-size: 20px; font-weight: 800; text-shadow: 0 2px 10px #000a; }
#hint svg { display: block; margin: 0 auto; color: var(--gold); animation: press 1.6s ease-in-out infinite; }
@keyframes hintIn { from { opacity: 0; margin-top: 8px; } }
@keyframes press { 0%, 100% { transform: translateY(0); } 45% { transform: translateY(8px) scale(.92); } }
#tapnext { margin-top: 10px; font-size: 14px; font-weight: 700; color: var(--dim); letter-spacing: .04em; opacity: 0; animation: tapIn .4s ease-out .7s forwards; }
@keyframes tapIn { to { opacity: .9; } }
#mute { width: 44px; height: 44px; border-radius: 14px; border: 1px solid #ffffff30; background: #0006; color: var(--fg); display: grid; place-items: center; cursor: pointer; padding: 0; }
#mute svg { width: 22px; height: 22px; }
#mute .off { display: none; }
#mute[aria-pressed="true"] .on { display: none; }
#mute[aria-pressed="true"] .off { display: block; }
#vib { width: 44px; height: 44px; border-radius: 14px; border: 1px solid #ffffff30; background: #0006; color: var(--fg); display: grid; place-items: center; cursor: pointer; padding: 0; }
#vib svg { width: 22px; height: 22px; }
#vib .x { display: none; }
#vib[aria-pressed="true"] .x { display: block; }
#vib:focus-visible { outline: 3px solid var(--cool); outline-offset: 2px; }
#hint p { white-space: pre-line; }
#mute:focus-visible { outline: 3px solid var(--cool); outline-offset: 2px; }
#tools { display: flex; gap: 4px; pointer-events: auto; align-items: center; }
#ring { position: fixed; z-index: 14; width: 76px; height: 76px; margin: -38px 0 0 -38px; border-radius: 50%; border: 2px solid #ffffff55; background: radial-gradient(#ffffff12, #ffffff00 70%); pointer-events: none; animation: ringIn .15s ease-out; }
@keyframes ringIn { from { transform: scale(.5); opacity: 0; } }

/* 判定の重ね表示 */
#judge { position: absolute; left: 0; right: 0; top: calc(var(--top) + 52px); text-align: center; pointer-events: none; animation: judgeIn .18s ease-out; }
@keyframes judgeIn { from { transform: scale(.7); opacity: 0; } }
#jnum { display: inline-flex; align-items: center; gap: 6px; font-family: var(--num); font-size: 56px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 3px 18px #000c; }
#jnum small { font-size: 20px; font-weight: 700; color: var(--dim); margin-left: 2px; align-self: flex-end; padding-bottom: 6px; }
#judge.over #jnum { color: var(--warm); }
#judge.under #jnum { color: var(--cool); }
#judge.perfect #jnum { color: var(--gold); }
#judge.perfect #jarrow { display: none; }
#judge.spill #jnum, #judge.nonum #jnum { display: none; }
#judge.under #jarrow { transform: rotate(180deg); }
#jgrade { margin-top: 8px; font-size: 26px; font-weight: 800; letter-spacing: .06em; text-shadow: 0 2px 12px #000c; transition: opacity .3s; }
#judge.perfect #jgrade { color: var(--gold); font-size: 32px; }
#judge.spill #jgrade { font-size: 44px; }
#judge.poured #jgrade { font-size: 38px; color: var(--warm); }
#judge.gradeOff #jgrade { opacity: 0; }
#resume { position: absolute; left: 0; right: 0; top: 46%; text-align: center; font-size: 22px; font-weight: 800; text-shadow: 0 2px 14px #000; padding: 14px; background: #14110fb0; }
#sparepop { position: absolute; left: 0; right: 0; top: calc(var(--top) + 166px); text-align: center; font-family: var(--num); font-weight: 800; font-size: 22px; color: #ffd0cb; text-shadow: 0 2px 10px #000; animation: popUp 1.4s ease-out both; }
#sparepop b { display: block; font-size: 38px; color: #fff; }
@keyframes popUp { 0% { transform: scale(.7); opacity: 0; } 12% { transform: scale(1.12); opacity: 1; } 24% { transform: none; } 100% { opacity: 1; } }   /* タップで次へ進むまで残す */
#closed { flex-direction: column; gap: 18px; }
#closed em { font-style: normal; font-size: 16px; font-weight: 700; color: var(--dim); letter-spacing: .04em; opacity: 0; animation: tapIn .4s ease-out .6s forwards; }

/* 下の帯: 替えのグラスと合計 */
#spares { position: absolute; bottom: 0; left: 0; right: 0; height: var(--foot); display: flex; align-items: center; justify-content: space-between; padding: 0 20px env(safe-area-inset-bottom, 0); pointer-events: none; }
#glasses { display: flex; gap: 10px; }
#glasses svg { width: 30px; height: 40px; overflow: visible; }
#glasses .g { fill: #e8b64a55; stroke: #f3ece4; stroke-width: 2; stroke-linejoin: round; }
#glasses .lost .g { fill: none; stroke: #f3ece455; stroke-dasharray: 3 4; }
#glasses .crack { display: none; stroke: #f3ece4aa; stroke-width: 1.6; fill: none; }
#glasses .lost .crack { display: block; opacity: .55; }
#glasses .break { animation: shatter .5s ease-in forwards; transform-origin: 50% 100%; }
@keyframes shatter { 0% { transform: none; } 30% { transform: rotate(-8deg) scale(1.1); } 100% { transform: translateY(34px) rotate(24deg) scale(.4); opacity: 0; } }
#total { font-family: var(--num); font-size: 18px; font-weight: 700; color: var(--dim); font-variant-numeric: tabular-nums; }

#closed { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; background: #0a0807d8; animation: fadeIn .7s ease-out both; pointer-events: none; }
#closed span { font-size: 56px; font-weight: 800; letter-spacing: .2em; padding-left: .2em; }
@keyframes fadeIn { from { opacity: 0; } }

/* 結果のカードと順位表 */
#card, #sheet { position: fixed; inset: 0; background: #0a0807e6; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; touch-action: pan-y; padding: calc(var(--bar) + 8px) 0 24px; }
#card { z-index: 10; }
#sheet { z-index: 12; background: #0a0807; }
.col { width: min(342px, 100vw - 48px); margin: auto; }
.paper { position: relative; padding: 20px 20px 18px; border-radius: 18px; background: linear-gradient(170deg, #2a1f19, #17120f 70%); border: 1px solid #ffffff1c; box-shadow: 0 20px 50px #000a; overflow: hidden; user-select: text; -webkit-user-select: text; }
.paper.gold { box-shadow: 0 20px 50px #000a, 0 0 0 1px #e8b64a66, 0 0 36px #e8b64a40 inset; }
.ch { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; color: var(--dim); }
.ch b { color: var(--fg); font-size: 16px; letter-spacing: .02em; }
.ct { margin-top: 18px; font-size: 20px; font-weight: 800; }
.cn { font-family: var(--num); font-size: 64px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; color: var(--gold); }
.cn small { font-size: 20px; color: var(--dim); margin-left: 6px; font-weight: 700; }
.cs { margin-top: 2px; font-size: 16px; color: var(--dim); min-height: 1.4em; }
#marks { display: block; width: 100%; height: auto; margin-top: 14px; }
.cf { margin-top: 8px; font-size: 14px; color: var(--dim); }
.btns { display: flex; gap: 8px; margin-top: 14px; }
.btn { flex: 1 1 0; min-height: 52px; padding: 0 10px; border-radius: 14px; border: 1px solid #ffffff2c; background: #ffffff10; color: var(--fg); font-weight: 800; font-size: 16px; cursor: pointer; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--gold); color: #1a1208; border-color: var(--gold); }
.btn.small { flex: none; min-height: 44px; padding: 0 16px; }
.btn:focus-visible, #langs button:focus-visible, input:focus-visible { outline: 3px solid var(--cool); outline-offset: 2px; }
#sharebox { width: 100%; margin-top: 10px; border-radius: 12px; border: 1px solid #ffffff30; background: #0008; color: var(--fg); padding: 10px; font-size: 16px; user-select: text; -webkit-user-select: text; }
body.in-card #counter, body.in-card #traps, body.in-card #judge, body.in-card #hint, body.in-card #spares, body.in-card #sparepop, body.in-card #resume { display: none; }

.sheetcol { width: min(342px, 100vw - 32px); margin: 0 auto; }
.sh { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sh h2 { margin: 0; font-size: 22px; }
#rankline { margin: 14px 0 10px; padding: 14px; border-radius: 14px; background: #e8b64a1c; border: 1px solid #e8b64a55; font-size: 22px; font-weight: 800; line-height: 1.25; }
#rankline small { display: block; margin-top: 4px; font-size: 14px; font-weight: 600; color: var(--dim); }
#nameform { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
#nameform label { font-size: 14px; color: var(--dim); }
#nick { flex: 1 1 0; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid #ffffff38; background: #0007; color: var(--fg); padding: 0 12px; font-size: 16px; user-select: text; -webkit-user-select: text; }
#boardmsg { margin: 0 0 10px; padding: 12px; border-radius: 12px; background: #e0483e22; border: 1px solid #e0483e66; font-size: 15px; line-height: 1.4; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
#rows { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
#rows li { display: grid; grid-template-columns: 38px 1fr auto; gap: 8px; align-items: center; min-height: 40px; padding: 4px 10px; border-radius: 10px; font-size: 16px; }
#rows li:nth-child(odd) { background: #ffffff08; }
#rows li.mine { background: #e8b64a38; font-weight: 800; box-shadow: inset 0 0 0 1px #e8b64a88; }
#rows li .r { color: var(--dim); text-align: right; }
#rows li .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#rows li .v { text-align: right; white-space: nowrap; font-size: 15px; }
#rows li.gap { display: block; text-align: center; color: var(--dim); min-height: 20px; padding: 0; background: none; }
#rows li.sk { height: 40px; background: linear-gradient(90deg, #ffffff08, #ffffff18, #ffffff08); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

#toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 30; padding: 10px 18px; border-radius: 999px; background: #f3ece4; color: #14110f; font-weight: 800; opacity: 0; pointer-events: none; transition: opacity .2s; white-space: nowrap; }
#toast.on { opacity: 1; }

@media (max-height: 640px) {
  :root { --bar: 48px; --trap: 52px; --foot: 60px; }
  #counter { font-size: 24px; }
  .trap .ic { width: 34px; height: 34px; } .trap .ic svg { width: 22px; height: 22px; }
  #jnum { font-size: 44px; } #glasses svg { width: 24px; height: 32px; }
  #hint { top: calc(var(--top) + 44px); } #hint p { font-size: 16px; margin-bottom: 4px; } #hint svg { width: 32px; height: 44px; }
  #judge { top: calc(var(--top) + 46px); } #sparepop { top: calc(var(--top) + 158px); font-size: 18px; } #sparepop b { font-size: 28px; }
  .cn { font-size: 52px; } .paper { padding: 14px 16px; } .ct { margin-top: 10px; } .btn { min-height: 46px; }
}
@media (prefers-reduced-motion: reduce) {
  .trap, #judge, #ring, #sparepop, #closed { animation-duration: .01s; }
  #hint svg { animation: none; }
}

/* 失敗のときの「タップで次へ」は、替えの表示の中に出す（判定の文字と重ならない） */
#judge.fail #tapnext { display: none; }
#sparepop em { display: block; margin-top: 4px; font-style: normal; font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif; font-size: 14px; font-weight: 700; color: var(--dim); opacity: 0; animation: tapIn .3s ease-out .6s forwards; }

/* 横向きなど高さが低いとき: 案内はグラスの右に寄せて、グラスに重ねない */
@media (max-height: 420px) {
  #hint { left: auto; right: 8px; transform: none; top: calc(var(--top) + 14px); max-width: 130px; padding: 8px 10px 4px; }
  #hint p { font-size: 14px; } #hint svg { width: 24px; height: 32px; }
}

/* 周回2: 規則の1行、こぼした量、閉店の理由、凡例 */
#sparepop small.rule { display: block; margin: 6px auto 0; max-width: 300px; padding: 6px 12px; border-radius: 12px; background: #14110fcc; border: 1px solid #e8b64a66; font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif; font-size: 14px; font-weight: 700; line-height: 1.35; color: #ffe9b8; text-shadow: none; }
#jextra { margin-top: 4px; font-family: var(--num); font-size: 22px; font-weight: 800; color: #ffd0cb; text-shadow: 0 2px 10px #000c; font-variant-numeric: tabular-nums; }
#jextra:empty { display: none; }
.cr { margin-top: 6px; font-size: 14px; font-weight: 700; line-height: 1.4; color: #ffd0cb; }
.legend { list-style: none; margin: 8px 0 0; padding: 8px 0 0; border-top: 1px solid #ffffff14; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--dim); }
.legend li { display: inline-flex; align-items: center; gap: 5px; }
.legend svg { width: 16px; height: 16px; flex: none; }

/* 割れる替え: 大きく割れて破片が飛ぶ */
#glasses > span { position: relative; }
#glasses .break { animation: shatter2 .7s ease-in forwards; }
@keyframes shatter2 { 0% { transform: none; filter: none; } 12% { transform: scale(1.7) rotate(-10deg); filter: brightness(2); } 30% { transform: scale(1.5) rotate(8deg); } 100% { transform: translateY(44px) rotate(30deg) scale(.3); opacity: 0; } }
.shard { position: absolute; left: 50%; top: 50%; width: 7px; height: 11px; margin: -5px 0 0 -3px; background: #f3ece4; opacity: 0; clip-path: polygon(50% 0, 100% 100%, 0 80%); z-index: 3; animation: shard .75s cubic-bezier(.2,.7,.4,1) forwards; }
@keyframes shard { 0% { opacity: 1; transform: translate(0,0) rotate(0) scale(var(--s)); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) + 40px)) rotate(var(--r)) scale(var(--s)); } }

/* 画面の一瞬の揺れ（0.28秒）。#scene は transform、#table は translate（#table の transform を壊さない） */
#scene.shk { animation: shkS .28s linear; } #scene.shk2 { animation: shkS2 .2s linear; }
#table.shk { animation: shkT .28s linear; } #table.shk2 { animation: shkT2 .2s linear; }
@keyframes shkS { 0%,100% { transform: none; } 10% { transform: translate(-11px, 6px); } 25% { transform: translate(10px, -7px); } 40% { transform: translate(-8px, 5px); } 58% { transform: translate(6px, -4px); } 78% { transform: translate(-3px, 2px); } }
@keyframes shkS2 { 0%,100% { transform: none; } 20% { transform: translate(-5px, 3px); } 50% { transform: translate(4px, -2px); } 80% { transform: translate(-2px, 1px); } }
@keyframes shkT { 0%,100% { translate: 0 0; } 10% { translate: -11px 6px; } 25% { translate: 10px -7px; } 40% { translate: -8px 5px; } 58% { translate: 6px -4px; } 78% { translate: -3px 2px; } }
@keyframes shkT2 { 0%,100% { translate: 0 0; } 20% { translate: -5px 3px; } 50% { translate: 4px -2px; } 80% { translate: -2px 1px; } }

/* 完璧: 判定の数字が跳ねる（拡大して戻る）。続くほど大きく */
#judge.perfect #jnum { animation: jbounce .6s cubic-bezier(.2,1.6,.4,1) both; transform-origin: 50% 60%; }
#judge.perfect.s2 #jnum { animation-name: jbounce2; }
#judge.perfect.s3 #jnum { animation-name: jbounce3; }
@keyframes jbounce { 0% { transform: scale(.6); } 35% { transform: scale(1.5); } 100% { transform: scale(1); } }
@keyframes jbounce2 { 0% { transform: scale(.6); } 35% { transform: scale(1.75); } 70% { transform: scale(.95); } 100% { transform: scale(1); } }
@keyframes jbounce3 { 0% { transform: scale(.6) rotate(-4deg); } 35% { transform: scale(2); } 70% { transform: scale(.95) rotate(2deg); } 100% { transform: scale(1); } }
#judge.perfect #jgrade { animation: jglow 1s ease-out both; }
@keyframes jglow { 0% { text-shadow: 0 0 0 #ffcf6a; } 25% { text-shadow: 0 0 22px #ffcf6a, 0 0 6px #fff; } 100% { text-shadow: 0 2px 12px #000c; } }
#judge.spill #jgrade { animation: spillPop .4s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes spillPop { 0% { transform: scale(.5) rotate(-6deg); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  #scene.shk, #scene.shk2, #table.shk, #table.shk2, #judge.perfect #jnum, #judge.spill #jgrade { animation: none; }
  .shard { display: none; }
}
#sparepop { top: calc(var(--top) + 172px); }
@media (max-height: 640px) { #sparepop { top: calc(var(--top) + 140px); } }

/* 客（guest.js）。カウンターの向こうの席。グラスの横の余白に、顔が見える大きさで置く。判定には関係しない */
#guest { position: fixed; z-index: 6; pointer-events: none; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; --s: 1; }
#guest[hidden] { display: none; }
#guest svg { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 4px 8px #0008); }
#guest .bubble { position: relative; margin: 0 0 calc(7px * var(--s)); padding: calc(4px * var(--s)) calc(6px * var(--s)); border-radius: calc(10px * var(--s)); background: #f3ece4; color: #14110f; font-size: calc(11.5px * var(--s)); line-height: 1.25; font-weight: 800; text-align: center; overflow-wrap: anywhere; word-break: keep-all; text-wrap: balance; animation: bubbleIn .25s cubic-bezier(.2,1.6,.4,1) both; box-shadow: 0 3px 10px #0007; }
#guest .bubble[hidden] { display: none; }
#guest .bubble::after { content: ""; position: absolute; left: 50%; bottom: calc(-5px * var(--s)); width: calc(10px * var(--s)); height: calc(10px * var(--s)); margin-left: calc(-5px * var(--s)); background: #f3ece4; transform: rotate(45deg); border-radius: 2px; }
@keyframes bubbleIn { from { transform: scale(.6); opacity: 0; } }
#guest .f, #guest .wet, #guest .hands { display: none; }
#guest[data-face="calm"] .f-calm, #guest[data-face="watch"] .f-watch, #guest[data-face="hope"] .f-hope, #guest[data-face="worry"] .f-worry, #guest[data-face="happy"] .f-happy,
#guest[data-face="smile"] .f-smile, #guest[data-face="shock"] .f-shock, #guest[data-face="frozen"] .f-frozen, #guest[data-face="sad"] .f-sad { display: inline; }
#guest[data-state="spill"] .wet { display: inline; }
#guest[data-clap="1"] .hands { display: inline; }
#guest .br, #guest .mo { fill: none; stroke: #241a14; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
#guest .pu { transform: translate(var(--px, 0px), var(--py, 0px)); }
#guest[data-state="spill"] svg { filter: drop-shadow(0 4px 8px #0008) saturate(.8) brightness(.9); }

/* 動き（prefers-reduced-motion では止める。表情の切り替えだけ残る） */
#guest svg.go { transform-origin: 50% 100%; }
#guest[data-state="wait"] svg.go { animation: gIn .4s ease-out both; }
#guest[data-state="perfect"] svg.go { animation: gJump .55s cubic-bezier(.2,1.6,.4,1) both; }
#guest[data-state="nod"] svg.go .head { animation: gNod .7s ease-in-out both; transform-origin: 50% 80%; }
#guest[data-state="over"] svg.go { animation: gPop .4s cubic-bezier(.2,1.8,.4,1) both; }
#guest[data-state="spill"] svg.go .wet path:nth-child(2) { animation: gDrip 1.4s ease-in infinite; }
#guest[data-state="short"] svg.go { animation: gLean .6s ease-out both; }
#guest[data-state="leave"] svg.go { animation: gLeave .7s ease-in both; }
#guest[data-clap="1"] svg.go .hl { animation: gClapL .22s ease-in-out infinite alternate; }
#guest[data-clap="1"] svg.go .hr { animation: gClapR .22s ease-in-out infinite alternate; }
@keyframes gIn { from { opacity: 0; transform: translateY(14px); } }
@keyframes gJump { 0% { transform: scale(.94); } 40% { transform: translateY(-8%) scale(1.06); } 100% { transform: none; } }
@keyframes gNod { 0%,100% { transform: none; } 30% { transform: translateY(5%) rotate(2deg); } 60% { transform: translateY(1%); } }
@keyframes gPop { from { transform: scale(.85); } to { transform: none; } }
@keyframes gLean { from { transform: none; } to { transform: translateX(calc(var(--dir) * -6%)) rotate(calc(var(--dir) * -5deg)); } }
@keyframes gLeave { to { transform: translateX(calc(var(--dir) * 130%)); opacity: 0; } }
@keyframes gDrip { 0% { transform: translateY(-4px); opacity: 0; } 20% { opacity: 1; } 100% { transform: translateY(40px); opacity: 0; } }
@keyframes gClapL { to { transform: translateX(9px); } }
@keyframes gClapR { to { transform: translateX(-9px); } }
#guest[data-state="leave"] { opacity: 0; transition: opacity .7s ease-in; }
#guest.rm svg.go, #guest.rm svg.go .head, #guest.rm svg.go .hl, #guest.rm svg.go .hr, #guest.rm svg.go .wet path, #guest.rm .bubble { animation: none; }
#guest.rm[data-state="leave"] { transition: none; }
body.in-card #guest { display: none; }
@media (prefers-reduced-motion: reduce) { #guest, #guest * { animation: none !important; } }

/* 文の束の下に客と吹き出しを縦に積めないとき（360×640 で最初に替えを失うなど）は、吹き出しを客の外側の横へ出す（js/guest.js の fit） */
#guest[data-bub="side"] .bubble { position: absolute; bottom: 30%; margin: 0; width: max-content; max-width: var(--bw, 110px); }
#guest[data-bub="side"][data-side="r"] .bubble { left: calc(100% + 6px); }
#guest[data-bub="side"][data-side="l"] .bubble { right: calc(100% + 6px); }
#guest[data-bub="side"] .bubble::after { display: none; }
#guest[data-bub="none"] .bubble { display: none; }

/* 周回4: 最初の1行、練習の入口と画面、結果のカードの客の顔 */
#intro { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--top) + 4px); width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 6px 12px; border-radius: 14px; background: #14110fc0; border: 1px solid #ffffff26; text-align: center; font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--fg); pointer-events: none; text-wrap: balance; }
#intro.real { border-color: var(--gold); color: #ffe9b8; font-size: 16px; }
#pcmp { position: absolute; left: 50%; transform: translateX(-50%); top: calc(var(--top) + 44px); width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 5px 12px; border-radius: 14px; background: #14110fc0; border: 1px solid #ffffff26; text-align: center; font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--fg); pointer-events: none; text-wrap: balance; }
#table.has-pcmp #hint { top: var(--hy); }
#practice { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); max-width: calc(100% - 156px); min-height: 48px; padding: 6px 14px; border-radius: 14px; border: 1px solid #e8b64a99; background: #14110fcc; color: #ffe9b8; font-size: 14px; font-weight: 800; line-height: 1.25; cursor: pointer; pointer-events: auto; }
#practice[data-kind="skip"] { border-color: #ffffff40; color: var(--fg); }
#practice:focus-visible { outline: 3px solid var(--cool); outline-offset: 2px; }
#counter.practice #cnum { font-size: 20px; }
#counter.practice #ctotal { font-size: 20px; color: var(--gold); }
#jpractice { margin: 8px auto 0; max-width: 300px; padding: 4px 12px; border-radius: 12px; background: #14110fcc; border: 1px solid #e8b64a66; font-size: 14px; font-weight: 700; line-height: 1.3; color: #ffe9b8; }
.cmain { display: flex; align-items: center; gap: 8px; }
.cmain .cl { flex: 1 1 0; min-width: 0; }
.cmain .cn { font-size: 52px; }
.cg { flex: none; width: 80px; text-align: center; }
.cg[hidden] { display: none; }
#cface { display: block; width: 76px; height: auto; margin: 0 auto; filter: drop-shadow(0 3px 6px #0008); }
#cface .br, #cface .mo { fill: none; stroke: #241a14; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
#cline { margin-top: 2px; font-size: 12px; font-weight: 700; line-height: 1.25; color: var(--dim); overflow-wrap: anywhere; }
.legend { gap: 4px 10px; font-size: 12px; }
@media (max-width: 380px) { .cmain .cn { font-size: 42px; } .cn small { font-size: 16px; margin-left: 3px; } .cg { width: 68px; } #cface { width: 62px; } }
@media (max-height: 640px) {
  #intro { top: calc(var(--top) + 0px); font-size: 13px; padding: 4px 10px; }
  #intro.real { font-size: 14px; }
  #jpractice { font-size: 13px; margin-top: 4px; }
  #practice { min-height: 44px; }
}
#counter.practice #cnum, #counter.practice #ctotal { font-size: 16px; }
#table:has(#counter.practice) #date { visibility: hidden; }

/* 周回6: 客の段（惜しい＝身を乗り出す eager、ずれた＝首をかしげる puzzle）、カードの顔を大きく、凡例 7 つを 1 行に */
#guest[data-face="eager"] .f-eager, #guest[data-face="puzzle"] .f-puzzle { display: inline; }
@keyframes gEager { 0% { transform: none; } 60% { transform: translateX(calc(var(--dir) * -7%)) translateY(-3%) scale(1.1); } 100% { transform: translateX(calc(var(--dir) * -5%)) scale(1.07); } }
@keyframes gTilt { 0% { transform: none; } 50% { transform: rotate(-12deg) translateX(-4%); } 100% { transform: rotate(-9deg) translateX(-3%); } }
#guest[data-state="near"] svg.go { animation: gEager .5s cubic-bezier(.2,1.4,.4,1) both; }
#guest[data-state="skew"] svg.go .head { animation: gTilt .6s ease-out both; transform-origin: 50% 85%; }
#guest.rm svg.go, #guest.rm svg.go .head { animation: none; }
.cg { width: 118px; }
#cface { width: 112px; }
#cline { font-size: 13px; }
.legend { flex-wrap: nowrap; gap: 4px 6px; font-size: 11px; justify-content: space-between; }
.legend li { gap: 3px; white-space: nowrap; }
.legend svg { width: 13px; height: 13px; }
@media (max-width: 380px) { .cg { width: 96px; } #cface { width: 92px; } #cline { font-size: 12px; } .legend { font-size: 10px; gap: 4px 3px; } .legend svg { width: 11px; height: 11px; } .legend li { gap: 2px; } }
/* 凡例 7 つを 1 行に: 記号の下に語を置き、7 列に等分する */
.legend { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0 1px; font-size: 10px; text-align: center; line-height: 1.2; }
.legend li { flex-direction: column; justify-content: flex-start; gap: 2px; white-space: nowrap; min-width: 0; }
.legend svg { width: 16px; height: 16px; }
@media (max-width: 380px) { .legend { font-size: 9px; gap: 0 1px; } .legend svg { width: 14px; height: 14px; } }
#cline { text-wrap: balance; word-break: keep-all; overflow-wrap: anywhere; }
/* 周回7: 8杯目に入るときの1行。札の中の細い1行 */
.narrow-note { max-width: 340px; width: 100%; box-sizing: border-box; padding: 2px 12px; border-radius: 12px; background: #14110fb0; border: 1px solid #ff6a5a66; color: #ffb4aa; font-size: 12px; font-weight: 700; line-height: 1.3; text-align: center; text-wrap: balance; animation: trapIn .5s cubic-bezier(.2,.8,.2,1) both; }

/* 周回9: 幅 480px 以下の最初の画面（最初の押しの前）。罠の札・最初の1行・案内を1つの枠（#fbox）にまとめ、客を大きく置く（js/main.js layoutFirst）。PC（481px 以上）は変えない */
#fbox { display: none; }
@media (max-width: 480px) {
  #fbox { display: block; position: absolute; left: 10px; right: 10px; border-radius: 18px; background: #14110fc8; border: 1px solid #ffffff2a; box-shadow: 0 8px 30px #0008; pointer-events: none; }
  #fbox[hidden] { display: none; }
  #table.first .trap, #table.first .trap.plain { background: none; border: 0; backdrop-filter: none; padding: 2px 14px 2px 8px; max-width: 360px; }
  #table.first #intro, #table.first #intro.real, #table.first #pcmp { background: none; border: 0; box-shadow: none; padding: 0 16px; font-size: 13px; font-weight: 600; color: var(--dim); max-width: calc(100% - 40px); }
  #table.first #intro.real { color: #ffe9b8; }
  #table.first #hint { background: none; border: 0; box-shadow: none; animation: none; padding: 2px 16px 2px; display: flex; align-items: center; justify-content: center; gap: 10px; }
  #table.first #hint p { margin: 0; font-size: 17px; }
  #table.first #hint svg { margin: 0; width: 22px; height: 30px; }
}
