:root {
  color-scheme: light;
  --bg: #f3f9fd;
  --surface: #ffffff;
  --text: #15344d;
  --muted: #5f7d93;
  --line: #d3e6f2;
  --accent: #1e9be8;
  --accent-deep: #137ac0;
  --accent-soft: #e3f3fd;
  --felt: #5ab7e6;
  --felt-light: #9bd6f3;
  --felt-deep: #2f97d2;
  --rail: #ffffff;
  --red: #e5484d;
  --black: #1f2a37;
  --win: #10b981;
  --lose: #ef4444;
  --shade: rgba(21, 52, 77, .14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 17px;
  line-height: 1.6;
}
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
b { font-weight: 700; }

/* 上端の細い水色のライン */
.marquee { height: 4px; flex: none; background: linear-gradient(90deg, var(--felt-light), var(--accent), var(--felt-light)); }

/* ホーム */
.hero { padding: 0 0 24px; text-align: center; }
.hero .marquee { margin-bottom: 28px; }
.hero h1 { margin: 0 16px 8px; font-size: 30px; line-height: 1.3; font-weight: 800; color: var(--text); letter-spacing: .02em; }
.hero h1::first-line { color: var(--accent); }
.hero p { margin: 0 16px; color: var(--muted); }
.menu { padding: 0 16px 16px; display: grid; gap: 12px; }
.menu-item {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  box-shadow: 0 4px 14px var(--shade);
}
.menu-mark {
  --c: var(--accent);
  width: 52px; height: 52px; border-radius: 50%; background: var(--c); color: #fff;
  display: grid; place-items: center; font-size: 26px; line-height: 1; border: 3px dashed rgba(255, 255, 255, .85);
}
.menu-item:nth-child(2) .menu-mark { --c: var(--felt-deep); }
.menu-item:nth-child(3) .menu-mark { --c: var(--felt); }
.menu-item:nth-child(4) .menu-mark { --c: var(--text); }
.menu-name { font-size: 18px; font-weight: 700; line-height: 1.3; }
.menu-catch { font-size: 14px; color: var(--muted); line-height: 1.4; }
.menu-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.menu-state.done { color: var(--win); font-weight: 700; }
.note { padding: 4px 16px 24px; font-size: 14px; color: var(--muted); }

/* 共通の枠 */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); color: var(--text); padding: 10px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 35; /* 説明カードの上でもスキップを押せる */
}
.bar a { font-size: 15px; padding: 4px 0; color: var(--accent); }
.bar strong { font-size: 17px; font-weight: 700; }
.page { padding: 20px 16px 16px; flex: 1; }
.page h2 { margin: 0 0 14px; font-size: 24px; line-height: 1.35; }
.actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px; background: rgba(255, 255, 255, .96);
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
}
.btn {
  flex: 1; min-height: 54px; padding: 8px 12px; border-radius: 14px; font-weight: 700; font-size: 18px; line-height: 1.25;
  background: var(--accent); color: #fff; text-align: center; display: grid; place-items: center;
  box-shadow: 0 4px 0 var(--accent-deep); transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-deep); }
.btn small { display: block; font-size: 12px; font-weight: 500; opacity: .85; }
.btn.alt { background: var(--surface); color: var(--accent); border: 2px solid var(--accent); box-shadow: 0 4px 0 var(--line); }
.btn:disabled { background: #e3edf4; color: #9fb4c3; box-shadow: 0 4px 0 #d3e1ea; cursor: default; }

/* 早見表の中身 */
.points { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.points li { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.points b, .table-list th { color: var(--accent-deep); }
.section-title { margin: 22px 0 8px; font-size: 15px; font-weight: 700; color: var(--accent); }
.examples { display: grid; gap: 8px; }
.example { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; font-size: 15px; }
.table-list th, .table-list td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-list th { font-weight: 700; white-space: nowrap; }
.flow { list-style: none; margin: 0; padding: 0; counter-reset: s; }
.flow li { counter-increment: s; position: relative; padding: 0 0 18px 46px; }
.flow li::before {
  content: counter(s); position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center;
}
.flow b.t { display: block; font-size: 18px; }

/* カード・サイコロ */
.card {
  display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 64px; flex: none;
  border-radius: 8px; background: #fff; color: var(--black); border: 1px solid #e3edf4;
  font-size: 17px; font-weight: 700; line-height: 1; box-shadow: 0 3px 8px rgba(21, 52, 77, .2);
}
.card.red { color: var(--red); }
.card.back { background: repeating-linear-gradient(45deg, var(--accent) 0 6px, var(--felt-light) 6px 12px); border: 2px solid #fff; }
.cards { display: flex; gap: 6px; flex-wrap: wrap; min-height: 64px; }
.die {
  width: 58px; height: 58px; border-radius: 12px; background: #fff; display: grid; padding: 8px; flex: none;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr); box-shadow: 0 3px 8px rgba(21, 52, 77, .2);
}
.die i { border-radius: 50%; margin: 1px; }
.die i.on { background: var(--black); }
.die.one i.on { background: var(--red); }
.die.rolling { animation: shake .18s linear infinite; }
@keyframes shake { 50% { transform: rotate(8deg) translateY(-3px); } }
.dice { display: flex; gap: 10px; min-height: 58px; }

/* 卓（疑似3D）: 奥にディーラー、手前に向かって卓が広がる */
#play { flex: 1; display: flex; flex-direction: column; }
#play.demo { pointer-events: none; }
.scene {
  flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 0 0 14px; overflow: hidden; color: var(--text);
  background: linear-gradient(#ffffff 0%, #eef7fd 45%, #e2f0f9 100%);
}
.status { display: flex; align-items: center; gap: 12px; padding: 0 16px; font-size: 14px; color: var(--muted); }
.status > span:first-child { flex: 1; }
.status b { color: var(--accent); font-size: 19px; }
.help {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  border: 1.5px solid var(--accent); font-weight: 700; font-size: 18px; pointer-events: auto;
}
.dealer-row { display: flex; align-items: flex-start; gap: 10px; padding: 0 16px; }
.dealer-svg { width: 72px; height: 66px; flex: none; margin-top: 6px; position: relative; z-index: 1; }
.dealer-svg .body { fill: var(--text); }
.dealer-svg .shirt { fill: #fff; }
.dealer-svg .tie { fill: var(--accent); }
.bubble {
  position: relative; z-index: 3; flex: 1; min-height: 52px; background: #fff; color: var(--text); border-radius: 14px;
  padding: 8px 12px; font-size: 15px; line-height: 1.5; border: 1.5px solid #bfe2f6;
  box-shadow: 0 4px 14px var(--shade); transition: border-color .2s;
}
.bubble::before {
  content: ""; position: absolute; left: -9px; top: 18px; border-style: solid;
  border-width: 8px 9px 8px 0; border-color: transparent #bfe2f6 transparent transparent;
}
.bubble b { color: var(--accent-deep); }
.bubble.win { border-color: var(--win); }
.bubble.win::before { border-right-color: var(--win); }
.bubble.lose { border-color: var(--lose); }
.bubble.lose::before { border-right-color: var(--lose); }
.table { position: relative; z-index: 2; margin-top: -26px; padding: 0 6px; perspective: 760px; perspective-origin: 50% 0%; }
.surface {
  position: relative; transform: rotateX(20deg); transform-origin: 50% 100%; color: #fff;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 14px 14px 26px;
  background: radial-gradient(90% 70% at 50% 25%, var(--felt-light) 0%, var(--felt) 50%, var(--felt-deep) 100%);
  border: 11px solid var(--rail); border-top-width: 8px; border-radius: 22px 22px 50% 50% / 22px 22px 18% 18%;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6), inset 0 12px 30px rgba(21, 52, 77, .15), 0 0 0 1px var(--line), 0 16px 30px rgba(21, 52, 77, .22);
}
.shoe {
  position: absolute; right: 16px; top: 12px; width: 38px; height: 52px; border-radius: 6px; transform: rotate(10deg);
  background: repeating-linear-gradient(45deg, var(--accent) 0 6px, var(--felt-light) 6px 12px); border: 3px solid #fff; box-shadow: 2px 3px 6px rgba(21, 52, 77, .25);
}
.hand { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 64px; }
.hands .hand { flex-direction: column; gap: 4px; }
.surface .die { width: 46px; height: 46px; padding: 6px; border-radius: 10px; }
.surface .dice { gap: 8px; min-height: 46px; }
.hand .cards, .hand .dice { justify-content: center; }
.val {
  min-width: 46px; min-height: 28px; padding: 0 10px; border-radius: 14px; background: #fff;
  color: var(--accent-deep); font-weight: 700; text-align: center; font-size: 17px; line-height: 28px; box-shadow: 0 2px 6px rgba(21, 52, 77, .2);
}
.val:empty { visibility: hidden; }
.who { font-size: 12px; font-weight: 700; color: #fff; letter-spacing: .08em; }
.felt-print {
  margin: 0; padding: 3px 14px; color: #fff; border: 1.5px solid rgba(255, 255, 255, .8); border-radius: 12px;
  font-size: 12px; font-weight: 700; text-align: center;
}
.spot {
  position: relative; width: 64px; height: 64px; border-radius: 50%; border: 2px dashed rgba(255, 255, 255, .9);
  display: flex; align-items: center; justify-content: center;
}
.spot small { font-size: 11px; font-weight: 700; color: #fff; letter-spacing: .08em; }
.spot b { position: absolute; bottom: -12px; background: #fff; color: var(--accent-deep); font-size: 13px; padding: 0 8px; border-radius: 10px; }
.stack { position: relative; width: 40px; height: 40px; }
.stack:empty { display: none; }
.stack i, .chip-mini {
  --c: var(--accent);
  position: absolute; left: 0; bottom: calc(var(--i, 0) * 4px); width: 40px; height: 40px; border-radius: 50%;
  background: var(--c); border: 4px dashed #fff; box-shadow: 0 0 0 2px var(--c), 0 2px 4px rgba(21, 52, 77, .3);
}
.stack i.c1 { --c: var(--text); }
.stack i.c2 { --c: var(--felt-deep); }
.chip-mini { position: static; width: 24px; height: 24px; border-width: 3px; }
.bowl {
  width: 100px; height: 26px; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, #fff, #e3f3fd 60%, #a9d8f2); box-shadow: 0 4px 8px rgba(21, 52, 77, .2);
}
.tray {
  margin: 0 16px; padding: 10px 12px; display: grid; gap: 10px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 4px 14px var(--shade);
}
.placed { font-size: 15px; }
.placed b { color: var(--accent); font-size: 19px; }
.betbar { display: flex; align-items: center; gap: 8px; }
.betbar .amount { flex: 1 1 auto; min-width: 0; font-size: 14px; line-height: 1.2; color: var(--muted); }
.betbar .amount b { color: var(--accent); font-size: 24px; }
.chip-btn {
  --c: var(--accent);
  width: 56px; height: 56px; border-radius: 50%; background: var(--c); color: #fff; font-weight: 700; padding: 0; font-size: 15px;
  border: 4px dashed #fff; box-shadow: 0 0 0 3px var(--c), 0 4px 8px rgba(21, 52, 77, .25);
}
.chip-btn:nth-of-type(2) { --c: var(--text); }
.chip-btn.clear {
  --c: transparent;
  width: auto; height: 44px; border: 1.5px solid var(--line); border-radius: 22px; background: transparent; color: var(--muted);
  padding: 0 12px; font-size: 14px; box-shadow: none;
}
.sides { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.side { min-height: 52px; border-radius: 12px; background: var(--surface); color: var(--text); border: 1.5px solid var(--line); font-weight: 700; line-height: 1.2; font-size: 15px; }
.side.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.hands { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; padding-top: 26px; }
.hands .card { width: 36px; height: 52px; font-size: 14px; }
.zones { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; width: 100%; }
.zone {
  min-height: 70px; border-radius: 14px; background: rgba(255, 255, 255, .15); border: 2px solid rgba(255, 255, 255, .85); color: #fff;
  font-weight: 700; font-size: 14px; line-height: 1.2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.zone small { font-weight: 500; font-size: 11px; color: #fff; opacity: .9; }
.zone.on { background: #fff; border-color: #fff; color: var(--accent-deep); }
.zone.on small { color: var(--accent-deep); }

/* 演出 */
.card.deal { animation: deal .4s ease-out both; }
.card.flip { animation: flip .4s ease-out both; }
@keyframes deal { from { transform: translate(120px, -110px) rotate(-30deg) scale(.7); opacity: 0; } }
@keyframes flip { from { transform: rotateY(90deg); } }
/* チュートリアルで押してほしいボタン */
#play.demo [data-act]:not(.guide):not(.focus) { filter: grayscale(.6) opacity(.55); }
.guide { position: relative; z-index: 4; pointer-events: auto; animation: glow 1s ease-in-out infinite; }
.guide::after {
  content: ""; position: absolute; left: 50%; bottom: 100%; margin-left: -11px; pointer-events: none; z-index: 5;
  border: 11px solid transparent; border-top: 14px solid var(--accent); border-bottom: 0;
  filter: drop-shadow(0 0 2px #fff); animation: poke .8s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { outline: 3px solid rgba(30, 155, 232, 1); outline-offset: 2px; }
  50% { outline: 3px solid rgba(30, 155, 232, .15); outline-offset: 7px; }
}
@keyframes poke { 0%, 100% { transform: translateY(-10px); } 50% { transform: translateY(-2px); } }

/* 説明カード */
#layer { position: fixed; inset: 0; z-index: 30; display: none; align-items: flex-end; justify-content: center; background: rgba(21, 52, 77, .28); }
#layer.show { display: flex; }
.modal {
  width: 100%; max-width: 480px; background: #fff; color: var(--text); border-radius: 22px 22px 0 0; border-top: 4px solid var(--accent);
  padding: 18px 16px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 24px rgba(21, 52, 77, .18); animation: up .3s cubic-bezier(.3, 1.3, .5, 1);
}
.modal h3 { margin: 0 0 6px; font-size: 20px; font-weight: 700; color: var(--accent); }
.modal p { margin: 0 0 14px; }
.modal p b { color: var(--accent-deep); }
.modal .btn { width: 100%; }
@keyframes up { from { transform: translateY(60px); opacity: 0; } }

/* 早見表 */
#sheet { position: fixed; inset: 0; z-index: 40; display: none; overflow-y: auto; background: var(--bg); }
#sheet.show { display: block; }
#sheet .bar, #sheet .page { max-width: 480px; margin: 0 auto; }
.bar-tools { display: flex; gap: 8px; }
.bar-btn { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); border-radius: 16px; padding: 2px 12px; font-size: 14px; font-weight: 700; }

/* 役一覧 */
.ranks { display: grid; font-size: 14px; line-height: 1.35; }
.rk { display: grid; grid-template-columns: 4.6em 1fr auto; gap: 8px; padding: 2px 6px; border-bottom: 1px solid var(--line); }
.rk:last-child { border-bottom: 0; }
.rk b { font-weight: 500; }
.rk > span:last-child { white-space: nowrap; }
.rk.on { background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; border-radius: 6px; }
.rk.on b { font-weight: 700; }

/* 完了 */
.clear-card {
  background: linear-gradient(135deg, var(--accent), var(--felt-light)); color: #fff; border-radius: 20px; padding: 24px 18px; text-align: center;
  box-shadow: 0 8px 24px rgba(30, 155, 232, .3);
}
.clear-card .label { font-weight: 700; letter-spacing: .1em; opacity: .9; }
.clear-card h2 { margin: 2px 0 14px; font-size: 28px; font-weight: 800; }
.clear-card ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.bonus {
  margin-top: 14px; background: var(--accent-soft); color: var(--accent-deep); font-weight: 700; border: 1.5px solid var(--accent);
  border-radius: 14px; padding: 12px; text-align: center;
}
.bonus.off { background: var(--surface); color: var(--muted); border-color: var(--line); font-weight: 500; }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); max-width: 320px; width: calc(100% - 32px);
  background: var(--text); color: #fff; font-weight: 700; border-radius: 12px; padding: 10px 14px; text-align: center; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20;
}
#toast.show { opacity: 1; }

/* チンチロ: 卓の斜め視点からお椀の真上へズームし、お椀の中でサイコロを転がす */
.table[class*="cam-"] .surface { transform-origin: 50% 45%; }
.table.cam-in .surface { animation: camera .6s ease-in both; }
.table.cam-bowl .surface { visibility: hidden; }
.table.cam-out .surface { animation: camera .5s ease-out reverse both; }
@keyframes camera { to { transform: rotateX(0deg) scale(2.4); opacity: 0; } }
.bowl-view {
  position: absolute; inset: 0 6px; z-index: 3; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 11px solid var(--rail); border-radius: 22px; color: #fff;
  background: radial-gradient(circle at 50% 45%, var(--felt-light) 0%, var(--felt) 55%, var(--felt-deep) 100%);
  box-shadow: 0 0 0 1px var(--line), 0 16px 30px rgba(21, 52, 77, .22);
}
.cam-in .bowl-view { animation: bowl-in .6s ease-in both; }
.cam-out .bowl-view { animation: bowl-in .5s ease-out reverse both; }
@keyframes bowl-in { from { transform: translateY(-20px) scale(.35) rotateX(65deg); opacity: 0; } }
.bowl-who { font-size: 13px; font-weight: 700; letter-spacing: .1em; }
.bowl-top {
  position: relative; width: min(210px, 62vw); aspect-ratio: 1; border-radius: 50%; flex: none;
  background: radial-gradient(circle, #fff 0 36%, #f2f9fe 52%, #d6ecf9 64%, #a9d8f2 69%, #fff 71%, #e3f3fd 75%, #fff 77%);
  box-shadow: 0 10px 18px rgba(21, 52, 77, .25), inset 0 0 24px rgba(30, 155, 232, .2);
}
.bowl-top .die {
  position: absolute; left: 50%; top: 50%; margin: -24px; width: 48px; height: 48px; padding: 7px;
  transform: translate(var(--x), var(--y)) rotate(var(--r)); box-shadow: 0 4px 8px rgba(21, 52, 77, .3);
}
.bowl-top .bdie {
  position: absolute; left: 50%; top: 50%; margin: -24px; width: 48px; height: 48px;
  transform: translate(var(--x), var(--y)) rotate(var(--r));
  animation: tumble 1.45s cubic-bezier(.15, .6, .3, 1) var(--d) both;
}
.bowl-top .bdie > * { position: absolute; inset: 0; margin: 0; transform: none; }
.bowl-top .bdie .alt { animation: face-alt 1.45s linear var(--d) both; }
.bowl-top .bdie .final { animation: face-final 1.45s linear var(--d) both; }
.bowl-top .bdie .cube { width: 56px; height: 56px; inset: -4px; animation: face-cube 1.45s linear var(--d) both; filter: drop-shadow(0 4px 4px rgba(21, 52, 77, .3)); }
.cube path { stroke: #c4d5e1; stroke-width: 1; stroke-linejoin: round; }
.cube .top { fill: #fff; }
.cube .left { fill: #e8f0f6; }
.cube .right { fill: #d3e1eb; }
.cube circle { fill: var(--black); }
.cube circle.one { fill: var(--red); }
/* 移動と回転: 手前から投げ込まれ、壁で跳ね返りながら3回転以上して止まる */
@keyframes tumble {
  0% { transform: translate(calc(var(--x) * -1.5), 170px) rotate(calc(var(--r) - 1500deg)) scale(1.35); }
  25% { transform: translate(calc(var(--x) * -.8), calc(var(--y) * -1.4)) rotate(calc(var(--r) - 900deg)) scale(1.18); }
  50% { transform: translate(calc(var(--x) * 1.35), calc(var(--y) * .4)) rotate(calc(var(--r) - 420deg)) scale(1.08); }
  72% { transform: translate(calc(var(--x) * .8), calc(var(--y) * 1.2)) rotate(calc(var(--r) - 120deg)) scale(1.02); }
  88% { transform: translate(calc(var(--x) * 1.04), calc(var(--y) * .97)) rotate(calc(var(--r) - 20deg)); }
  100% { transform: translate(var(--x), var(--y)) rotate(var(--r)); }
}
/* 面 → 角が上 → 面… を切り替える。面に戻る瞬間はつぶして、辺を越えて倒れる感じを出す */
@keyframes face-cube {
  0%, 9% { opacity: 1; } 10%, 19% { opacity: 0; } 20%, 29% { opacity: 1; } 30%, 41% { opacity: 0; }
  42%, 51% { opacity: 1; } 52%, 66% { opacity: 0; } 67%, 74% { opacity: 1; } 75%, 100% { opacity: 0; }
}
@keyframes face-alt {
  0%, 9% { opacity: 0; } 10% { opacity: 1; transform: scaleY(.35); } 14% { transform: none; } 19% { opacity: 1; transform: scaleX(.5); }
  20%, 41% { opacity: 0; } 42%, 100% { opacity: 0; }
}
@keyframes face-final {
  0%, 29% { opacity: 0; } 30% { opacity: 1; transform: scaleX(.35); } 35% { transform: none; } 41% { opacity: 1; transform: scaleY(.5); }
  42%, 51% { opacity: 0; } 52% { opacity: 1; transform: scaleY(.35); } 57% { transform: none; } 66% { opacity: 1; }
  67%, 74% { opacity: 0; } 75% { opacity: 1; transform: scaleX(.4); } 82%, 100% { opacity: 1; transform: none; }
}
.bowl-top .die.pair { opacity: .5; }
.bowl-top .die.eye { box-shadow: 0 0 0 3px var(--accent), 0 4px 8px rgba(21, 52, 77, .3); }
.bowl-view .val:not(:empty) { animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both; }

/* 説明カードが指している場所: 卓を暗くして、そこだけ光らせる */
.card, .hand, .hands, .val, .felt-print, .zone { position: relative; }
#play.explain .surface::after {
  content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; background: rgba(21, 52, 77, .5); pointer-events: none;
}
.focus { z-index: 2; animation: spotlight 1.2s ease-in-out infinite; }
@keyframes spotlight {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255, 255, 255, .9)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 255, 255, 1)) brightness(1.08); }
}
.felt-print.lit { animation: spotlight .8s ease-in-out infinite; }
/* count: カードの上に数え方を順に出す */
#play.count .focus .card[data-n]::after {
  content: attr(data-n); position: absolute; left: 50%; top: -16px; translate: -50% 0; z-index: 3;
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700; line-height: 1; padding: 3px 7px; border-radius: 10px;
  animation: pop .35s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: calc(var(--k) * .45s);
}
#play.count .focus .val[data-raw]::before { content: attr(data-raw) " → "; opacity: .6; }
#play.count .focus .val { animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) 1s both; }
/* eyes: そろった2個を薄く、目の1個を跳ねさせる */
#play.eyes .focus .die.pair { opacity: .4; }
#play.eyes .focus .die.eye { box-shadow: 0 0 0 3px var(--accent), 0 3px 8px rgba(21, 52, 77, .2); animation: hop .5s ease-in-out infinite alternate; }
@keyframes hop { to { translate: 0 -6px; } }
@keyframes pop { from { scale: 0; opacity: 0; } }

/* 決着: スタンプと、チップの行き来 */
.stamp {
  position: absolute; right: 10px; top: 40%; z-index: 3; padding: 2px 12px; border: 2px solid #fff; border-radius: 10px;
  font-size: 22px; font-weight: 800; letter-spacing: .04em; rotate: -8deg; box-shadow: 0 4px 12px rgba(21, 52, 77, .25);
  animation: stamp .4s cubic-bezier(.3, 1.6, .5, 1) .5s both;
}
@keyframes stamp { from { scale: 2.4; opacity: 0; } }
.stamp.win { background: var(--accent); color: #fff; }
.stamp.lose { background: #8aa1b3; color: #fff; }
.stamp.push { background: #fff; color: var(--text); }
.surface.bj .stamp, .surface.chi .stamp { top: auto; bottom: 30px; right: 22px; }
.surface.bac .stamp { top: 128px; left: 50%; right: auto; translate: -50% 0; font-size: 18px; }
.spot .payout { position: absolute; left: 30px; top: 6px; animation: payin .6s ease-out .7s both; }
.spot.lose .stack { animation: takeaway .6s ease-in .7s both; }
.minis { display: flex; gap: 2px; }
.zone.win .chip-mini.payout { animation: payin .6s ease-out .7s both; }
.zone.lose .chip-mini { animation: takeaway .6s ease-in .7s both; }
@keyframes payin { from { translate: 0 -180px; scale: .6; opacity: 0; } }
@keyframes takeaway { to { translate: 0 -180px; scale: .6; opacity: 0; } }

/* 説明カードが光らせた場所を隠すときは上に出す */
#layer.top { align-items: flex-start; padding-top: 52px; }
#layer.top .modal { border-radius: 0 0 22px 22px; border-top: 0; border-bottom: 4px solid var(--accent); }

/* ===== レスポンシブ ===== */
/* 縦が短い画面（SE・小型Android・ブラウザのバーが出ている状態）: 卓・賭け・ボタンが1画面に収まるよう詰める */
@media (max-height: 720px) {
  .bar { padding: 6px 16px; }
  .scene { gap: 6px; padding-bottom: 8px; }
  .status { font-size: 13px; }
  .status b { font-size: 17px; }
  .help { width: 32px; height: 32px; font-size: 16px; }
  .dealer-svg { width: 58px; height: 54px; margin-top: 2px; }
  .bubble { min-height: 44px; font-size: 14px; line-height: 1.45; padding: 6px 10px; }
  .bubble::before { top: 14px; }
  .table { margin-top: -20px; }
  .surface { gap: 6px; padding: 10px 12px 18px; }
  .card { width: 42px; height: 58px; font-size: 16px; }
  .cards, .hand { min-height: 58px; }
  .spot { width: 56px; height: 56px; }
  .hands { padding-top: 20px; }
  .zone { min-height: 60px; }
  .tray { padding: 8px 10px; gap: 8px; }
  .chip-btn { width: 50px; height: 50px; font-size: 14px; }
  .actions { padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
  .btn { min-height: 50px; font-size: 17px; }
  .hero .marquee { margin-bottom: 20px; }
  .menu-item { padding: 12px; }
}
/* さらに短い画面: チンチロの役一覧を2列にし、例は「?」の早見表に任せる */
@media (max-height: 620px) {
  .dealer-svg { width: 48px; height: 44px; }
  .bubble { min-height: 0; font-size: 13.5px; }
  .surface { padding: 8px 12px 14px; }
  .card { width: 38px; height: 54px; font-size: 15px; }
  .cards, .hand { min-height: 54px; }
  .hands .card { width: 32px; height: 46px; font-size: 13px; }
  .surface .die { width: 40px; height: 40px; padding: 5px; }
  .surface .dice { min-height: 40px; }
  .spot { width: 50px; height: 50px; }
  .stack { width: 34px; height: 34px; }
  .stack i { width: 34px; height: 34px; border-width: 3px; }
  .bowl { height: 20px; }
  .zone { min-height: 54px; }
  .chip-btn { width: 46px; height: 46px; }
  .btn { min-height: 46px; }
  .ranks { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(3, auto); grid-auto-flow: column; column-gap: 8px; font-size: 13px; }
  .rk { grid-template-columns: 1fr auto; }
  .rk .ex { display: none; }
  .rk:nth-child(3) { border-bottom: 0; }
  .bowl-top { width: min(180px, 52vw); }
  .hero h1 { font-size: 26px; }
}
/* 4インチ級（iPhone SE 初代のブラウザ表示など）: ディーラーの絵を外して吹き出しだけにする */
@media (max-height: 520px) {
  .bar { padding-top: 4px; padding-bottom: 4px; }
  .scene { gap: 5px; padding-bottom: 6px; }
  .status { font-size: 12px; }
  .status b { font-size: 16px; }
  .help { width: 28px; height: 28px; font-size: 15px; }
  .dealer-svg { display: none; }
  .bubble::before { display: none; }
  .bubble { padding: 4px 10px; font-size: 13px; line-height: 1.4; }
  .table { margin-top: 0; }
  .surface { gap: 4px; padding: 6px 10px 10px; }
  .card { width: 34px; height: 48px; font-size: 14px; }
  .cards, .hand { min-height: 48px; }
  .hands { padding-top: 14px; }
  .hands .card { width: 28px; height: 40px; font-size: 12px; }
  .spot { width: 44px; height: 44px; }
  .stack, .stack i { width: 30px; height: 30px; }
  .spot b { font-size: 12px; bottom: -10px; }
  .felt-print { font-size: 11px; padding: 1px 10px; }
  .zone { min-height: 46px; }
  .tray { padding: 6px 10px; }
  .chip-btn { width: 42px; height: 42px; font-size: 13px; }
  .chip-btn.clear { height: 34px; }
  .betbar .amount b { font-size: 18px; }
  .ranks { font-size: 12px; line-height: 1.3; }
  .actions { padding-top: 6px; padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .btn { min-height: 42px; font-size: 16px; }
  .btn small { font-size: 11px; }
  .bowl-top { width: min(150px, 46vw); }
}
/* 幅の狭い画面（iPhone SE 初代・Galaxy Fold の外画面など） */
@media (max-width: 359px) {
  body { font-size: 16px; }
  .bar { padding-left: 12px; padding-right: 12px; gap: 6px; }
  .bar > * { white-space: nowrap; }
  .bar a { font-size: 13px; }
  .bar strong { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .bar-btn { font-size: 13px; padding: 2px 8px; }
  .page { padding-left: 12px; padding-right: 12px; }
  .status, .dealer-row { padding: 0 12px; }
  .status > span:first-child { flex: 1 1 auto; min-width: 0; }
  .status > span { white-space: nowrap; }
  .tray { margin: 0 12px; }
  .actions { padding-left: 12px; padding-right: 12px; }
  .table { padding: 0 4px; }
  .surface { border-width: 8px; border-top-width: 6px; padding-left: 8px; padding-right: 8px; }
  .shoe { width: 30px; height: 42px; right: 10px; top: 8px; }
  .card { width: 36px; height: 52px; font-size: 14px; border-radius: 6px; }
  .cards { gap: 4px; }
  .hands { gap: 6px; }
  .hands .card { width: 28px; height: 42px; font-size: 12px; border-radius: 5px; }
  .hands .cards { gap: 3px; flex-wrap: nowrap; }
  .who { font-size: 11px; letter-spacing: 0; }
  .zones { gap: 4px; }
  .zone { font-size: 12.5px; padding: 0 2px; word-break: keep-all; }
  .zone small { font-size: 10px; }
  .betbar { gap: 6px; }
  .betbar .amount { font-size: 12px; white-space: nowrap; }
  .betbar .amount b { font-size: 20px; }
  .chip-btn { width: 46px; height: 46px; font-size: 13px; border-width: 3px; }
  .chip-btn.clear { height: 38px; padding: 0 8px; font-size: 13px; white-space: nowrap; }
  .btn { font-size: 16px; padding: 6px 8px; }
  .actions { gap: 8px; }
  .menu { padding: 0 12px 12px; }
  .menu-item { grid-template-columns: 44px 1fr auto; gap: 10px; padding: 12px 10px; }
  .menu-mark { width: 44px; height: 44px; font-size: 22px; }
  .menu-name { font-size: 17px; }
  .hero h1 { font-size: 25px; }
  .table-list { font-size: 14px; }
  .table-list th, .table-list td { padding: 8px 7px; }
  .rk { gap: 4px; padding: 2px 4px; }
}
/* バカラ: 狭い画面ではシューを2つの手札の間へ（「バンカー」の文字に重ならないように） */
@media (max-width: 400px) {
  .surface.bac .shoe { right: auto; left: 50%; margin-left: -15px; top: 6px; width: 30px; height: 42px; }
}
/* 横向き: 縦が足りないのでスクロールで見せる。ボタンだけは常に下に固定 */
@media (orientation: landscape) and (max-height: 500px) {
  .dealer-svg { width: 44px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .die.rolling, .bowl-top .bdie, .bowl-top .bdie > *, .table[class*="cam-"] .surface, .bowl-view, .card.deal, .card.flip, .modal { animation: none; }
  .guide, .guide::after { animation-duration: 3s; }
}
