:root {
  --bg: #07040f;
  --gold: #ffd34d;
  --red: #ff3b5c;
  --paper: #fbf6e7;
  --ink: #2a1d3b;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%; position: fixed; inset: 0; background: var(--bg); color: var(--paper); touch-action: none;
  font-family: var(--font); overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#stage { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #fff; z-index: 3; }
#vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 2;
  background: radial-gradient(ellipse at center, rgba(120,0,30,0) 35%, rgba(140,0,40,0.75) 100%); transition: opacity .3s; }
#pop-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }

/* ---- HUD ---- */
#hud { position: absolute; left: 0; right: 0; top: calc(12px + env(safe-area-inset-top)); z-index: 4; pointer-events: none; text-align: center; }
.amount {
  display: inline-block; padding: 8px 22px; border-radius: 999px; font-weight: 900; font-size: min(30px, 6.2vw); line-height: 1.1; max-width: 80vw;
  color: #fff3c4; background: rgba(10,6,24,0.55); border: 2px solid rgba(255,211,77,0.8);
  text-shadow: 0 0 12px rgba(255,211,77,0.9), 0 2px 0 rgba(0,0,0,0.6); letter-spacing: .02em; font-variant-numeric: tabular-nums;
  transition: transform .08s;
}
.amount .u { font-size: .62em; color: var(--gold); margin: 0 1px; }
.amount.neg { color: #ffb3bd; border-color: rgba(255,59,92,0.9); text-shadow: 0 0 12px rgba(255,59,92,0.9), 0 2px 0 rgba(0,0,0,0.6); }
.amount.neg .u { color: #ff6b7a; }
.amount.bump { animation: bump .28s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }
.combo { height: 22px; margin-top: 4px; font-weight: 900; font-size: min(18px, 4.6vw); color: #7fe8ff; text-shadow: 0 0 10px #39c6ff; letter-spacing: .1em; }
.progress { width: 160px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: rgba(255,255,255,0.15); overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: linear-gradient(90deg, #ffd34d, #ff9b3d); }

/* ---- ポップアップ文字 ---- */
.pop {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 56px; line-height: 1; white-space: nowrap; letter-spacing: .02em;
  color: #fff; -webkit-text-stroke: 2px rgba(0,0,0,0.55); paint-order: stroke fill;
  text-shadow: 0 0 18px currentColor, 0 4px 0 rgba(0,0,0,0.5);
  animation: popIn .7s cubic-bezier(.2,1.5,.4,1) both;
}
.pop.gold { color: #ffd34d; }
.pop.red { color: #ff4d6d; }
.pop.blue { color: #7fd3ff; }
.pop.white { color: #fff; }
.pop.huge { font-size: 92px; animation: popHuge 1.4s cubic-bezier(.2,1.4,.3,1) both; }
.pop.banner { font-size: 64px; top: 30%; letter-spacing: 0; animation: banner 1.8s cubic-bezier(.2,1.2,.3,1) both; }
.pop.sub { font-size: 24px; top: 52%; animation: popIn 1.2s ease-out both; }
.pop.small { font-size: 30px; }
@keyframes popIn { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 70% { opacity: 1; transform: translate(-50%, -60%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -90%) scale(.95); } }
@keyframes popHuge { 0% { opacity: 0; transform: translate(-50%, -50%) scale(3) rotate(-8deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(2deg); } 30% { transform: translate(-50%, -50%) scale(1.08) rotate(-1deg); } 80% { opacity: 1; transform: translate(-50%, -52%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -70%) scale(1.2); } }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scaleX(1.5) scaleY(.2); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); } 25% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); } }
.shake-screen { animation: screenShake .35s linear; }
@keyframes screenShake { 0%,100% { transform: none; } 20% { transform: translate(-8px, 5px); } 40% { transform: translate(7px, -6px); } 60% { transform: translate(-5px, 4px); } 80% { transform: translate(4px, -3px); } }

/* ---- タイトル ---- */
.overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between; padding: calc(12vh + env(safe-area-inset-top)) 20px calc(10vh + env(safe-area-inset-bottom)); text-align: center; }
.title-wrap .t1 { font-size: min(36px, 9vw); font-weight: 900; color: #fff3c4; text-shadow: 0 0 16px rgba(255,211,77,0.7), 0 3px 0 #5a2a00; letter-spacing: .2em; }
.title-wrap .t2 { font-size: min(76px, 19vw); font-weight: 900; color: #ffd34d; line-height: 1; text-shadow: 0 0 30px rgba(255,180,40,0.9), 0 5px 0 #6a2a00, 0 8px 18px rgba(0,0,0,0.6); letter-spacing: .05em; animation: titleFloat 2.4s ease-in-out infinite; }
@keyframes titleFloat { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-8px) } }
.title-wrap .t3 { margin-top: 14px; font-size: 14px; color: #e8dcc0; text-shadow: 0 1px 2px #000; }
.title-bottom .hint { font-size: min(20px, 5.2vw); font-weight: 800; text-shadow: 0 0 10px rgba(255,255,255,0.6), 0 2px 2px #000; animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .45 } }
.title-bottom .hint2 { font-size: 13px; color: #cfc6e0; margin-top: 4px; text-shadow: 0 1px 2px #000; }
.title-bottom .best { font-size: 13px; color: var(--gold); margin-top: 18px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.site-links { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px 16px; margin-top: 16px; font-size: 12px; }
.site-links a { color: #e8dcc0; pointer-events: auto; padding: 8px 0; text-underline-offset: 3px; }
.site-links a:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

/* ---- おみくじ紙 ---- */
.paper {
  position: absolute; left: 50%; top: 40%; width: 58vw; max-width: 260px; height: calc(min(58vw, 260px) * 1.333); z-index: 4; pointer-events: none;
  background: linear-gradient(180deg, #fffaf0, #f3e9d0); color: #9a1414; border: 3px solid #c9b27a; outline: 4px solid #fbf6e7;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6); transform: translate(-50%, -50%); transform-origin: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--serif);
}
.paper.drop { animation: paperDrop .55s cubic-bezier(.2,1.1,.3,1) both; }
@keyframes paperDrop { 0% { transform: translate(-50%, -160%) rotate(-6deg); } 60% { transform: translate(-50%, -48%) rotate(2deg); } 100% { transform: translate(-50%, -50%) rotate(0); } }
.paper.corner { animation: paperCorner .4s ease-in-out both; }
@keyframes paperCorner { 0% { transform: translate(-50%, -50%) scale(1); left: 50%; top: 40%; } 100% { transform: translate(-50%, -50%) scale(.34); left: calc(100% - 46px); top: calc(74px + env(safe-area-inset-top)); } }
.paper-head { position: absolute; top: 10px; font-size: 13px; letter-spacing: .4em; color: #8a6a1e; }
.paper-fortune { font-size: 64px; font-weight: 700; letter-spacing: .06em; opacity: 0; writing-mode: vertical-rl; text-orientation: upright; line-height: 1; max-height: 86%; }
.paper-fortune.stamp { animation: stamp .5s cubic-bezier(.2,1.4,.4,1) both; }
.paper-fortune.neg { color: #2a1040; }
@keyframes stamp { 0% { opacity: 0; transform: scale(3) rotate(-10deg); } 60% { opacity: 1; transform: scale(.92) rotate(2deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
.paper-stamp { position: absolute; right: 14px; top: 34px; padding: 2px 8px; border: 3px solid #c2233a; color: #c2233a; font-family: var(--font); font-weight: 900; font-size: 18px; letter-spacing: .1em; transform: rotate(-14deg); animation: stamp .4s .25s both; }

/* ---- 賽銭確定→縁起ボーナス加算 ---- */
.tally { position: absolute; left: 50%; top: calc(96px + env(safe-area-inset-top)); transform: translateX(-50%); width: 94vw; max-width: 430px; z-index: 4; pointer-events: none;
  padding: 10px 10px 8px; border-radius: 16px; background: rgba(10,6,24,0.74); border: 2px solid rgba(255,211,77,0.75); box-shadow: 0 10px 30px rgba(0,0,0,.5); text-align: center;
  animation: tallyIn .4s cubic-bezier(.2,1.4,.4,1) both; }
.tally.out { animation: tallyOut .35s ease-in both; }
@keyframes tallyIn { from { opacity: 0; transform: translateX(-50%) scale(.6); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes tallyOut { to { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(.8); } }
.tally-title { font-size: 13px; font-weight: 900; letter-spacing: .2em; color: #ffd34d; text-shadow: 0 0 8px rgba(255,211,77,.8); }
.tally-title.neg { color: #ff6b7a; text-shadow: 0 0 8px rgba(255,59,92,.8); }
.digits { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 10px; margin: 8px 0 6px; }
.dgroup { display: inline-flex; align-items: flex-end; gap: 3px; }
.dgroup .unit { font-size: 13px; font-weight: 900; color: #ffd34d; margin-left: 2px; padding-bottom: 4px; }
.tile { width: var(--tile, 30px); height: calc(var(--tile, 30px) * 1.2); border-radius: 6px; background: #fbf6e7; color: #2a1d3b; font-weight: 900; font-size: calc(var(--tile, 30px) * .72);
  display: flex; align-items: center; justify-content: center; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); animation: tileIn .35s cubic-bezier(.2,1.5,.4,1) both; }
.tile.neg { background: #3a1a2a; color: #ffb3bd; }
.tile.sign { background: transparent; box-shadow: none; color: #ff6b7a; }
@keyframes tileIn { from { opacity: 0; transform: translateY(-16px) scale(.6); } to { opacity: 1; transform: none; } }
.tile.hit { background: linear-gradient(180deg, #ffe79a, #ffb52e); color: #3a2000; box-shadow: 0 0 14px #ffd34d, inset 0 -3px 0 rgba(0,0,0,.15); animation: tileHit .5s cubic-bezier(.2,1.6,.4,1); }
.tile.hit.bad { background: linear-gradient(180deg, #ff6b7a, #c2233a); color: #fff; box-shadow: 0 0 14px #ff3b5c; }
@keyframes tileHit { 0% { transform: scale(1); } 40% { transform: scale(1.35) rotate(-6deg); } 100% { transform: scale(1); } }
.tbonus { display: flex; flex-direction: column; gap: 4px; }
.tchip { display: flex; justify-content: space-between; gap: 8px; padding: 3px 10px; border-radius: 999px; background: rgba(255,211,77,.15); border: 1px solid rgba(255,211,77,.6); color: #fff3c4; font-weight: 800; font-size: 14px; animation: chipIn .4s cubic-bezier(.2,1.4,.4,1) both; }
.tchip.bad { background: rgba(255,59,92,.15); border-color: rgba(255,59,92,.6); color: #ffb3bd; }
.tchip .v { color: #ffd34d; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tchip.bad .v { color: #ff6b7a; }
.tchip.none { justify-content: center; color: #cfc6e0; border-style: dashed; }
@keyframes chipIn { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
.tally-score { margin-top: 8px; display: flex; justify-content: space-between; align-items: baseline; padding: 0 6px; }
.tally-score .lbl { font-size: 12px; color: #cfc6e0; letter-spacing: .2em; }
.tally-score .val { font-size: 24px; font-weight: 900; color: #ffd34d; text-shadow: 0 0 10px rgba(255,211,77,.8); font-variant-numeric: tabular-nums; transition: font-size .3s; }
.tally-score .val.neg { color: #ff6b7a; text-shadow: 0 0 10px rgba(255,59,92,.8); }
.tally-score .val.bump { animation: bump .3s cubic-bezier(.2,1.6,.4,1); }
.tally.final .tally-score .val { font-size: 30px; }
.tally.final .tally-score .lbl { color: #ffd34d; }

/* ---- ボタン・パネル ---- */
.icon-btn {
  position: absolute; bottom: calc(12px + env(safe-area-inset-bottom)); right: 12px; z-index: 6;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.25);
  background: rgba(20,11,46,0.6); color: #fff; font-size: 18px; cursor: pointer;
}
.skip-btn {
  position: absolute; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6;
  padding: 9px 20px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.35); background: rgba(20,11,46,0.7);
  color: #fff; font-family: inherit; font-size: 14px; font-weight: 800; letter-spacing: .08em; cursor: pointer; touch-action: manipulation;
}
.panel { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: center; pointer-events: none; animation: slideUp .45s cubic-bezier(.2,.9,.3,1.1) both; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel-inner {
  pointer-events: auto; width: min(100vw, 430px); margin: 0 8px;
  background: linear-gradient(180deg, #fbf6e7, #f3e8cd); color: var(--ink); border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,0.45);
  border: 2px solid var(--gold); border-bottom: none; max-height: 62vh; overflow-y: auto;
}
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 4px; }
.row .label { flex: none; font-size: 11px; color: #6b5a3e; letter-spacing: .1em; }
.row .value { font-size: clamp(16px, 5.4vw, 22px); font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.15; text-align: right; word-break: break-all; min-width: 0; }
.row .value.big { font-size: clamp(20px, 6.8vw, 28px); color: #8a4a00; }
.value.neg { color: #c2233a !important; }
.bonus { margin: 6px 0 0; display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 12px; }
.bonus .b { padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.7); border: 1px solid #e0cf9a; color: #5a3a00; white-space: nowrap; }
.bonus .b .v { font-weight: 800; color: #b0761a; margin-left: 4px; font-variant-numeric: tabular-nums; }
.bonus .b .v.neg { color: #c2233a; }
.bonus .none { color: #8a7a5e; font-size: 12px; }
.fortune-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0 2px; flex-wrap: wrap; }
.fortune { font-family: var(--serif); font-size: 34px; font-weight: 700; letter-spacing: .06em; color: #7a1414; line-height: 1.1; text-align: center; max-width: 100%; }
.fortune.neg { color: #2a1040; }
.fortune .stamp-tag { display: inline-block; font-size: 13px; vertical-align: middle; margin-left: 6px; padding: 1px 6px; border: 2px solid #c2233a; color: #c2233a; border-radius: 4px; transform: rotate(-6deg); font-family: var(--font); letter-spacing: .1em; }
.rank { font-size: 14px; font-weight: 900; color: #fff; background: linear-gradient(90deg, #b0761a, #e8a92a); padding: 3px 10px; border-radius: 999px; }
.rank.neg { background: linear-gradient(90deg, #5a1a26, #c2233a); }
.god-line { text-align: center; font-size: 13px; color: #5a3a7a; font-weight: 700; margin-top: 6px; }
.buttons { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn { flex: 1 1 45%; padding: 12px 10px; border-radius: 12px; border: 2px solid #b0761a; background: #fff8e8; color: #5a3a00; font-weight: 800; font-size: 15px; cursor: pointer; text-align: center; text-decoration: none; font-family: inherit; }
.btn.primary { background: linear-gradient(180deg, #ffd978, #e8a92a); color: #3a2400; }
.btn.ghost { background: transparent; }
.btn:active { transform: translateY(1px); filter: brightness(.95); }
.detail-toggle { display: block; width: 100%; margin-top: 8px; background: none; border: none; color: #8a6a1e; font-size: 12px; font-family: inherit; cursor: pointer; padding: 4px; }
.lines { font-family: var(--serif); font-size: 14px; line-height: 1.6; text-align: center; color: #3a2a1a; }
.exact { text-align: center; font-size: 11px; color: #6b5a3e; margin-top: 6px; word-break: break-all; font-variant-numeric: tabular-nums; }
.best-line { text-align: center; font-size: 12px; color: #8a7a5e; margin-top: 4px; }
.note { text-align: center; font-size: 12px; color: #6b5a3e; margin-top: 6px; min-height: 1em; }
