:root {
  color-scheme: dark;
  --ink: #f8f0df;
  --muted: #b9aa91;
  --paper: #f4dfad;
  --red: #ef4a32;
  --red-dark: #a72222;
  --gold: #ffc84c;
  --night: #191510;
  --panel: #272019;
  --line: rgba(255, 239, 205, 0.14);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 8%, rgba(239, 74, 50, 0.16), transparent 28rem),
    radial-gradient(circle at 85% 80%, rgba(255, 200, 76, 0.08), transparent 24rem),
    var(--night);
  overscroll-behavior: none;
}

button { font: inherit; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 4px; }

.game-shell {
  width: min(100%, 1240px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 44px; height: 44px; display: grid; place-items: center;
  background: var(--red); color: white; border-radius: 14px 14px 14px 4px;
  font-size: 24px; font-weight: 950; transform: rotate(-4deg); box-shadow: 0 8px 24px rgba(239, 74, 50, .25);
}
.eyebrow, .chapter { margin: 0 0 3px; color: var(--gold); font-size: .75rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: .04em; }
.sound-toggle, .text-button {
  border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--muted);
  border-radius: 999px; padding: 9px 13px; cursor: pointer; font-size: .82rem;
}

.scene { display: none; flex: 1; animation: scene-in .36s ease both; }
.scene.active { display: block; }
@keyframes scene-in { from { opacity: 0; transform: translateY(10px); } }

.road-scene {
  height: min(46vh, 360px); min-height: 280px; position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(#24223d 0 58%, #28231e 58%);
  box-shadow: inset 0 -60px 80px rgba(0,0,0,.35);
}
.moon { position: absolute; width: 60px; height: 60px; border-radius: 50%; background: #ffeec4; right: 12%; top: 12%; box-shadow: 0 0 40px rgba(255,238,196,.28); }
.city { position: absolute; left: 0; right: 0; bottom: 42%; background: repeating-linear-gradient(90deg, #171827 0 42px, transparent 42px 48px, #1b1c2e 48px 92px); }
.city-back { height: 35%; opacity: .7; }
.city-front { height: 25%; bottom: 36%; background: repeating-linear-gradient(90deg, #11131e 0 58px, transparent 58px 64px, #171827 64px 110px); }
.street-light { position: absolute; left: 22%; bottom: 18%; width: 6px; height: 54%; background: #5d5143; }
.street-light::before { content: ""; position: absolute; width: 80px; height: 5px; background: #5d5143; top: 0; left: 0; }
.street-light i { position: absolute; width: 34px; height: 18px; border-radius: 4px 4px 15px 15px; background: #ffe299; top: 2px; left: 52px; box-shadow: 0 10px 45px 15px rgba(255,205,96,.25); }
.character { position: absolute; left: 48%; bottom: 16%; width: 64px; height: 125px; filter: drop-shadow(8px 10px 7px rgba(0,0,0,.4)); }
.character span { position: absolute; background: #11100f; display: block; }
.character .head { width: 34px; height: 34px; border-radius: 50%; left: 14px; top: 0; }
.character .body { width: 50px; height: 64px; border-radius: 20px 20px 9px 9px; left: 6px; top: 29px; transform: rotate(4deg); }
.character .leg { width: 15px; height: 48px; top: 85px; border-radius: 8px; transform-origin: top; }
.character .leg.left { left: 13px; transform: rotate(9deg); }
.character .leg.right { left: 37px; transform: rotate(-9deg); }
.found-ticket {
  position: absolute; right: 25%; bottom: 13%; width: 68px; height: 38px; border: 0;
  background: linear-gradient(135deg, var(--gold), #ff7d3a); color: #4a1f13; font-weight: 950; font-size: 1.2rem;
  border-radius: 5px; transform: rotate(-8deg); cursor: pointer; box-shadow: 0 0 0 3px rgba(255,255,255,.2), 0 0 28px rgba(255,200,76,.45);
  animation: ticket-pulse 1.6s ease-in-out infinite;
}
@keyframes ticket-pulse { 50% { transform: rotate(-5deg) translateY(-6px); box-shadow: 0 0 0 5px rgba(255,255,255,.15), 0 0 42px rgba(255,200,76,.65); } }

.story-card { margin: -34px 14px 0; padding: 24px; position: relative; background: rgba(39,32,25,.96); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.story-card h2, .dashboard h2, .ending-card h2 { font-size: clamp(1.65rem, 6vw, 2.35rem); line-height: 1.15; margin: 8px 0 10px; }
.story-card p:not(.chapter), .ending-card > p { color: var(--muted); line-height: 1.75; margin: 0 0 20px; }

.primary-button {
  width: 100%; border: 0; border-radius: 15px; padding: 15px 18px; cursor: pointer;
  background: linear-gradient(135deg, var(--red), #ff7650); color: white; font-weight: 900; letter-spacing: .03em;
  box-shadow: 0 10px 28px rgba(239, 74, 50, .24); transition: transform .18s ease, filter .18s ease;
}
.primary-button:hover { filter: brightness(1.08); transform: translateY(-2px); }
.primary-button:active { transform: translateY(1px) scale(.99); }
.hidden { display: none !important; }

.status-row, .dashboard { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.wallet, .balance-card { text-align: right; }
.wallet span, .balance-card span { display: block; color: var(--muted); font-size: .76rem; }
.wallet strong, .balance-card strong { color: var(--gold); font-size: 1.45rem; }
.scratch-stage { padding: 22px 0; }

.ticket {
  position: relative; overflow: hidden; padding: 22px; color: #401c12;
  background: var(--ticket-bg, linear-gradient(135deg, #ffd668, #ff995e 52%, #ee513b)); border-radius: 24px;
  border: 3px solid rgba(255,255,255,.55); box-shadow: 0 24px 70px rgba(0,0,0,.34); transform: rotate(-1deg);
}
.ticket::before, .ticket::after { content: ""; position: absolute; top: 0; bottom: 0; width: 18px; background: radial-gradient(circle, var(--night) 7px, transparent 8px) center/18px 24px repeat-y; }
.ticket::before { left: -11px; } .ticket::after { right: -11px; }
.ticket-topline, .ticket-footer { display: flex; justify-content: space-between; gap: 14px; font-size: .72rem; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.ticket-title { text-align: center; margin: 26px 0 18px; }
.ticket-title small { letter-spacing: .35em; font-weight: 900; }
.ticket-title h2 { margin: 7px 0; font-size: clamp(1.5rem, 6vw, 2.25rem); }
.ticket-title p { margin: 0; font-size: .86rem; opacity: .72; }
.scratch-area { position: relative; min-height: 270px; border-radius: 11px; overflow: hidden; background: #bfc3c4; box-shadow: inset 0 0 0 3px rgba(69,62,56,.22), 0 0 0 5px rgba(255,219,92,.32); touch-action: none; user-select: none; -webkit-user-select: none; }
.scratch-area.number-ticket-mode { min-height: 620px; }
.scratch-area.large-ticket-mode { min-height: 570px; }
.scratch-area.million-ticket-mode { min-height: 600px; }
.scratch-area.batch-ticket-mode { min-height: 520px; }
.prize-result { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; text-align: center; padding: 18px; background-color: #c4c7c6; background-image: repeating-radial-gradient(ellipse at 15% 20%, transparent 0 8px, rgba(72,78,78,.08) 9px 10px, transparent 11px 19px); color: #1f2323; }
.result-kicker, .result-note { font-size: .82rem; color: #343838; font-weight: 850; }
.result-note { max-width: 260px; line-height: 1.5; }
.prize-result strong { font-size: clamp(2.8rem, 14vw, 5rem); line-height: 1; color: #a50e16; letter-spacing: -.05em; }
.prize-result.game-mode { align-content: center; gap: 8px; padding: 14px; }
.prize-result.game-mode > strong { font-size: 1.15rem; letter-spacing: 0; padding: 5px 13px; border-radius: 5px; background: #a20d16; color: #ffe26b; box-shadow: 0 2px 0 rgba(67,10,13,.35); }
.game-result { width: 100%; max-width: 390px; }
.real-ticket-panel { display: grid; gap: 6px; }
.panel-label { justify-self: start; padding: 3px 8px; background: #252929; color: white; font-size: .66rem; font-weight: 900; letter-spacing: .08em; transform: skew(-5deg); }
.symbol-grid, .amount-grid, .key-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.symbol-cell, .amount-cell, .key-cell { min-height: 48px; display: grid; place-items: center; border: 1px dashed rgba(31,35,35,.34); background: rgba(231,234,233,.45); border-radius: 3px; font-weight: 950; color: #181b1b; position: relative; }
.symbol-cell, .key-cell { font-size: 1.45rem; }
.amount-cell { color: #181b1b; font-size: .9rem; }
.number-game { display: grid; grid-template-columns: 76px 1fr; gap: 10px; align-items: stretch; }
.lucky-number { display: grid; place-items: center; padding: 8px; border-radius: 3px; background: #9f1018; color: #ffe46b; border: 2px solid #f1b923; }
.lucky-number span { font-size: .66rem; opacity: .8; }
.lucky-number b { font-size: 2rem; }
.your-numbers { display: grid; grid-template-columns: repeat(2,1fr); gap: 6px; }
.number-cell { padding: 6px; display: grid; grid-template-columns: 30px 1fr; align-items: center; background: rgba(231,234,233,.45); border: 1px dashed rgba(31,35,35,.34); border-radius: 3px; color: #171919; position: relative; }
.number-cell b { font-size: 1.05rem; }
.number-cell small { font-size: .66rem; }
.dice-game { display: grid; gap: 8px; }
.dice-row { display: flex; justify-content: center; gap: 10px; }
.die { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 4px; background: rgba(239,241,240,.7); color: #1b1e1e; border: 2px solid #363b3b; box-shadow: 0 3px 0 rgba(35,40,40,.2); font-size: 1.45rem; font-weight: 950; }
.dice-total { color: #191c1c; font-weight: 950; font-size: .85rem; position: relative; justify-self: center; padding: 3px 9px; }
.ladder { display: grid; grid-template-columns: repeat(5,1fr); align-items: end; gap: 5px; min-height: 105px; }
.ladder-step { display: grid; place-items: center; gap: 2px; padding: 6px 2px; height: var(--step-height); background: rgba(231,234,233,.5); border: 1px dashed rgba(31,35,35,.4); border-radius: 3px; font-size: 1.15rem; position: relative; }
.ladder-step small { font-size: .56rem; color: #78402e; }
.physical-number-game { width: 100%; display: grid; gap: 11px; color: #171919; }
.winning-zone, .my-number-zone { display: grid; gap: 6px; }
.paper-zone-label { justify-self: start; padding: 3px 9px; background: #252929; color: #fff; font-size: .72rem; font-weight: 950; letter-spacing: .08em; transform: skew(-5deg); }
.winning-number-strip { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 6px; padding: 7px; border: 2px solid #a50e16; background: rgba(255,235,156,.36); }
.winning-number-strip span { min-height: 37px; display: grid; place-items: center; border: 1px dashed rgba(36,39,39,.42); font-size: 1.08rem; font-weight: 950; }
.number-prize-rows { display: grid; border-top: 1px solid rgba(31,35,35,.45); }
.number-prize-row { display: grid; grid-template-columns: minmax(0,1fr) 86px; align-items: stretch; border-bottom: 1px solid rgba(31,35,35,.45); }
.paper-number-row { display: grid; grid-template-columns: repeat(var(--paper-cells, 4), minmax(0,1fr)); border-left: 1px solid rgba(31,35,35,.45); }
.paper-number { min-height: 40px; display: grid; place-items: center; border-right: 1px dashed rgba(31,35,35,.36); font-size: 1rem; font-weight: 950; position: relative; }
.paper-row-prize { min-height: 40px; display: grid; place-items: center; padding: 2px 6px; background: rgba(233,236,235,.52); border-right: 1px solid rgba(31,35,35,.45); font-size: .76rem; font-weight: 950; position: relative; }
.tenfold-symbol { color: #a50e16; font-size: .8rem; letter-spacing: -.04em; }
.number-ticket-mode .prize-result.game-mode { justify-content: stretch; align-content: center; gap: 8px; padding: 12px 16px; }
.number-ticket-mode .game-result { max-width: 430px; }
.number-ticket-mode .result-note { max-width: 390px; font-size: .72rem; line-height: 1.35; }
.number-ticket-mode .prize-result.game-mode > strong { font-size: 1rem; padding: 4px 12px; }
.direct-prize-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 7px; }
.direct-prize-cell { min-height: 43px; display: grid; place-items: center; padding: 4px; border: 1px dashed rgba(31,35,35,.4); background: rgba(231,234,233,.45); border-radius: 3px; color: #171919; font-size: .82rem; font-weight: 950; position: relative; }
.snake-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.lucky20-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 5px; }
.lucky20-grid .number-cell { min-height: 50px; grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 4px; }
.million-road-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 5px; }
.million-road-grid .number-cell { min-height: 50px; grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 4px; }
.million-road-grid .million-symbol { background: linear-gradient(145deg,rgba(255,218,100,.88),rgba(255,245,191,.8)); color: #7b1010; }
.snake50-board { display: grid; gap: 6px; padding: 7px; border: 1px solid rgba(31,35,35,.45); background: rgba(238,239,236,.22); }
.bundle-label { justify-self: start; color: #8f0d15; font-size: .76rem; }
.winning-number-strip.compact { grid-template-columns: repeat(4, minmax(0,1fr)); padding: 4px; }
.winning-number-strip.compact span { min-height: 31px; font-size: .92rem; }
.snake-number-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 4px; }
.snake-number-grid .number-cell { min-height: 42px; grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 3px; }
.snake-number-grid .number-cell b { font-size: .92rem; }
.quick-prize-row { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 4px; }
.quick-prize-row .direct-prize-cell { min-height: 35px; font-size: .67rem; }
.bundle-two-tickets { width: 100%; display: grid; gap: 10px; }
.million-ticket-mode .prize-result.game-mode { justify-content: stretch; align-content: center; padding: 10px 13px; }
.million-ticket-mode .game-result { max-width: 430px; }
.million-ticket-mode .result-note { max-width: 400px; font-size: .69rem; line-height: 1.3; }
.million-ticket-mode .prize-result.game-mode > strong { font-size: .96rem; padding: 4px 10px; }
.large-ticket-mode .prize-result.game-mode { justify-content: stretch; padding: 12px 14px; }
.large-ticket-mode .game-result { max-width: 420px; }
.large-ticket-mode .result-note { max-width: 390px; font-size: .72rem; }
.batch-ticket-mode .prize-result.game-mode { justify-content: stretch; align-content: center; padding: 14px; }
.batch-ticket-mode .game-result { max-width: 470px; }
.batch-result { display: grid; gap: 10px; }
.batch-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 7px; }
.batch-cell { min-height: 55px; display: grid; place-items: center; align-content: center; gap: 2px; padding: 6px; border: 1px dashed rgba(31,35,35,.42); background: rgba(238,239,236,.42); color: #171919; position: relative; }
.batch-cell small { font-size: .66rem; color: #555b59; }
.batch-cell b { font-size: .82rem; }
.batch-summary { display: flex; justify-content: center; gap: 16px; color: #8f0d15; font-size: .78rem; }
.batch-ticket-mode .result-note { max-width: 410px; font-size: .72rem; }
.win-mark { position: relative; z-index: 0; }
.win-mark::after, .win-mark::before { content: ""; position: absolute; inset: -7px -5px; border: 3px solid #e3151d; border-radius: 50%; opacity: 0; pointer-events: none; transform: rotate(-7deg) scale(.6); z-index: 3; }
.win-mark::before { inset: -5px -8px; border-width: 2px; transform: rotate(8deg) scale(.6); opacity: 0; }
.scratch-area.revealed .win-mark::after { animation: ring-draw .42s cubic-bezier(.2,.8,.2,1) .15s forwards; }
.scratch-area.revealed .win-mark::before { animation: ring-draw-soft .38s ease .35s forwards; }
@keyframes ring-draw { to { opacity: 1; transform: rotate(-7deg) scale(1); } }
@keyframes ring-draw-soft { to { opacity: .62; transform: rotate(8deg) scale(1); } }
#scratchCanvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; transition: opacity .5s ease; }
#scratchCanvas.revealed { opacity: 0; pointer-events: none; }
.ticket-footer { margin-top: 18px; opacity: .76; }
.scratch-hint { text-align: center; color: var(--muted); font-size: .88rem; margin: 18px 0; }

.dashboard { margin-bottom: 18px; }
.dashboard h2 { margin: 4px 0 0; }
.balance-card { min-width: 122px; padding: 13px 16px; border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 16px; }
.player-ip { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -8px 0 12px; padding: 8px 12px; border: 1px solid rgba(255,200,76,.2); border-radius: 10px; background: rgba(255,200,76,.055); }
.player-ip span { color: var(--muted); font-size: .7rem; }
.player-ip strong { color: var(--gold); font-size: .82rem; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .03em; }
.narrator { padding: 14px 16px; color: #decfb5; background: rgba(255,255,255,.035); border-left: 3px solid var(--red); border-radius: 4px 13px 13px 4px; line-height: 1.55; font-size: .9rem; margin-bottom: 18px; }
.lucky-day-banner { display: flex; align-items: center; gap: 10px; margin: -7px 0 12px; padding: 10px 13px; border: 1px solid rgba(255,200,76,.55); border-radius: 13px; color: #291706; background: linear-gradient(135deg,#ffe38e,#ffb936); box-shadow: 0 8px 24px rgba(255,174,35,.16); }
.lucky-day-banner > span { font-size: 1.45rem; }
.lucky-day-banner b, .lucky-day-banner small { display: block; }
.lucky-day-banner b { font-size: .85rem; }
.lucky-day-banner small { margin-top: 2px; font-size: .7rem; font-weight: 800; }
.lucky-day-banner.hidden { display: none; }
.life-status { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; margin-bottom: 12px; }
.life-status div { padding: 12px 14px; border: 1px solid var(--line); background: rgba(255,255,255,.025); border-radius: 14px; }
.life-status span { display: block; color: var(--muted); font-size: .72rem; margin-bottom: 4px; }
.life-status strong { font-size: .87rem; color: #f0dfbe; }
#luckStatus { color: var(--gold); }
#debtStatus.forced { color: #ff786f; }
.life-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
.life-actions button { min-height: 92px; padding: 13px; display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; column-gap: 7px; text-align: left; color: var(--ink); cursor: pointer; background: #2a231c; border: 1px solid var(--line); border-radius: 15px; transition: .18s ease; }
.life-actions button:hover:not(:disabled) { border-color: rgba(255,200,76,.5); transform: translateY(-2px); }
.life-actions button:disabled { opacity: .42; cursor: not-allowed; }
.life-actions button > span { grid-row: 1 / 3; font-size: 1.35rem; align-self: center; }
.life-actions b { align-self: end; font-size: .9rem; }
.life-actions small { color: var(--muted); font-size: .68rem; line-height: 1.35; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 8px 0 12px; }
.section-heading h3 { margin: 2px 0 0; font-size: 1.15rem; }
.ticket-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.tier-card {
  min-height: 170px; padding: 16px; text-align: left; color: white; position: relative; overflow: hidden; display: flex; flex-direction: column;
  background: var(--tier-bg, linear-gradient(135deg,#3c3026,#241d18)); border: 1px solid rgba(255,255,255,.13); border-radius: 18px;
  box-shadow: 0 12px 35px rgba(0,0,0,.18); transition: transform .18s ease, filter .18s ease, opacity .18s ease;
}
.tier-card::after { content: "刮"; position: absolute; right: -8px; bottom: -29px; font-size: 6rem; font-weight: 950; opacity: .08; transform: rotate(-8deg); }
.tier-card:hover { transform: translateY(-3px); filter: brightness(1.05); }
.tier-card .tier-name { display: block; font-size: .76rem; opacity: .78; margin-bottom: 4px; }
.tier-card strong { display: block; font-size: 2rem; color: var(--gold); }
.tier-card em { display: block; margin-top: 8px; font-size: .67rem; font-style: normal; opacity: .88; }
.tier-card small { display: block; margin-top: 8px; opacity: .72; }
.tier-actions { position: relative; z-index: 2; display: grid; grid-template-columns: .8fr 1.2fr; gap: 6px; margin-top: auto; padding-top: 11px; }
.tier-actions button { min-height: 34px; padding: 7px 6px; border: 1px solid rgba(255,255,255,.24); border-radius: 9px; color: white; background: rgba(20,15,12,.34); cursor: pointer; font-size: .67rem; font-weight: 900; transition: .16s ease; }
.tier-actions button:hover:not(:disabled) { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.42); }
.tier-actions .tier-buy-ten { color: #2b180b; background: var(--gold); border-color: rgba(255,232,160,.8); }
.tier-actions .tier-buy-ten:hover:not(:disabled) { background: #ffdc76; }
.tier-actions button:disabled { opacity: .32; cursor: not-allowed; filter: grayscale(.7); }
.stats-panel { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding-top: 18px; }
.stats-panel div { padding: 12px 8px; text-align: center; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.stats-panel span { display: block; color: var(--muted); font-size: .7rem; margin-bottom: 5px; }
.stats-panel strong { font-size: .86rem; }
.shop-layout { width: 100%; }
.shop-sidebar, .shop-counter { min-width: 0; }

.ending-card { margin-top: 8vh; padding: 34px 26px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 28px; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.ending-icon { font-size: 4rem; margin-bottom: 12px; }
.ending-stats { margin: 20px 0; display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.ending-stats div { padding: 13px; background: rgba(255,255,255,.04); border-radius: 13px; }
.ending-stats span { display: block; color: var(--muted); font-size: .72rem; }
.ending-stats strong { display: block; margin-top: 4px; color: var(--gold); }
.disclaimer { margin-top: auto; padding: 22px 8px 0; color: #756a5b; font-size: .7rem; line-height: 1.6; text-align: center; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #fff0c4; color: #4b261a; padding: 11px 17px; border-radius: 999px; font-weight: 800; opacity: 0; pointer-events: none; transition: .25s ease; z-index: 20; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: max(20px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom)); background: rgba(10,8,6,.78); backdrop-filter: blur(9px); }
.modal-card { width: min(100%, 520px); max-height: 86dvh; overflow: auto; padding: 28px; background: #2b241d; border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 30px 100px rgba(0,0,0,.55); animation: modal-in .25s ease both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.97); } }
.modal-icon { font-size: 3.3rem; margin-bottom: 12px; }
.event-card { text-align: center; }
.event-card h2 { margin: 7px 0 10px; font-size: 1.8rem; }
.event-card p:not(.chapter) { color: var(--muted); line-height: 1.7; }
.event-amount { display: block; color: var(--gold); font-size: 1.65rem; margin: 17px 0 23px; }
.event-amount.negative { color: #ff8068; }
.modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-heading h2 { margin: 3px 0 0; }
.close-button { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: transparent; color: var(--muted); cursor: pointer; }
.achievement-list { display: grid; gap: 9px; }
.achievement-item { display: grid; grid-template-columns: 46px 1fr; gap: 12px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); }
.achievement-item.locked { filter: grayscale(1); opacity: .42; }
.achievement-item .achievement-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: rgba(255,200,76,.12); font-size: 1.5rem; }
.achievement-item b { display: block; font-size: .9rem; }
.achievement-item small { display: block; color: var(--muted); font-size: .72rem; line-height: 1.4; margin-top: 3px; }
.leaderboard-card { width: min(100%, 650px); }
.leaderboard-note { margin: -4px 0 16px; color: var(--muted); font-size: .78rem; line-height: 1.6; }
.leaderboard-list { display: grid; gap: 8px; }
.leaderboard-row { display: grid; grid-template-columns: 36px minmax(0,1fr) auto; align-items: center; gap: 11px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.025); }
.leaderboard-row.current-player { border-color: rgba(255,200,76,.55); background: rgba(255,200,76,.08); }
.leaderboard-rank { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,200,76,.12); color: var(--gold); font-weight: 950; }
.finance-card { width: min(100%, 620px); }
.finance-note { margin: -2px 0 16px; color: var(--muted); font-size: .78rem; line-height: 1.65; }
.finance-note strong { color: var(--gold); }
.finance-status { margin-bottom: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.028); }
.finance-status.empty { color: var(--muted); text-align: center; }
.finance-position { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.finance-position div { padding: 11px; border-radius: 12px; background: rgba(255,200,76,.07); }
.finance-position span { display: block; margin-bottom: 4px; color: var(--muted); font-size: .68rem; }
.finance-position strong { color: #f0dfbe; font-size: .9rem; }
.finance-maturity { margin: 12px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.finance-maturity.ready { color: #79e3bd; font-weight: 800; }
.finance-options { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.finance-options button { min-height: 64px; padding: 11px 13px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink); background: #342b22; border: 1px solid var(--line); border-radius: 13px; cursor: pointer; transition: .18s ease; }
.finance-options button:hover:not(:disabled) { border-color: rgba(255,200,76,.55); transform: translateY(-1px); }
.finance-options button:disabled { opacity: .35; cursor: not-allowed; }
.finance-options span { color: var(--muted); font-size: .72rem; }
.finance-options b { color: var(--gold); font-size: .9rem; }
.finance-options .all-in { grid-column: 1 / -1; }
.finance-claim { width: 100%; margin-top: 14px; }
.leaderboard-row b { display: block; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .86rem; }
.leaderboard-row small { display: block; margin-top: 3px; color: var(--muted); font-size: .7rem; }
.leaderboard-row > strong { color: var(--gold); font-size: .9rem; }
.leaderboard-empty { padding: 30px 18px; display: grid; justify-items: center; gap: 7px; text-align: center; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); }
.leaderboard-empty span { font-size: 2rem; }
.leaderboard-empty b { color: var(--ink); }
.leaderboard-empty small { font-size: .72rem; }
.confetti { position: fixed; width: 9px; height: 14px; top: -20px; z-index: 30; pointer-events: none; animation: confetti-fall var(--duration) ease-in forwards; }
@keyframes confetti-fall { to { transform: translate(var(--drift), 110vh) rotate(760deg); } }

@media (min-width: 560px) {
  .ticket-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ticket { padding: 28px 34px; }
  .stats-panel { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 820px) {
  body { min-height: 100dvh; }
  .game-shell { min-height: 100dvh; padding: 14px 24px 12px; }
  .topbar { margin-bottom: 12px; }
  .brand-mark { width: 40px; height: 40px; font-size: 21px; }

  #introScene.active {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, .72fr);
    align-items: center;
    gap: 28px;
    min-height: 0;
  }
  .road-scene { height: min(70dvh, 620px); min-height: 460px; }
  .story-card { margin: 0; padding: 32px; }
  .story-card h2 { font-size: clamp(2rem, 3.2vw, 3.15rem); }

  #scratchScene.active {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
  }
  #scratchScene .status-row { min-height: 44px; }
  .scratch-stage {
    min-height: 0;
    padding: 4px 0 0;
    display: grid;
    grid-template-columns: minmax(600px, 850px) minmax(220px, 270px);
    grid-template-rows: 1fr auto;
    justify-content: center;
    align-items: center;
    gap: 18px 30px;
  }
  .scratch-stage > .ticket { grid-row: 1 / span 2; }
  .scratch-stage > .scratch-hint {
    align-self: end;
    margin: 0;
    padding: 22px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255,255,255,.035);
    font-size: 1rem;
    line-height: 1.55;
  }
  .scratch-stage > .primary-button { grid-column: 2; align-self: start; }
  .ticket { padding: 17px 25px; transform: rotate(-.35deg); }
  .ticket-title { margin: 8px 0 11px; }
  .ticket-title h2 { margin: 3px 0; font-size: clamp(1.45rem, 2.3vw, 2rem); }
  .ticket-title p { font-size: .8rem; }
  .ticket-footer { margin-top: 10px; }
  .scratch-area { min-height: 270px; }
  .scratch-area.number-ticket-mode { min-height: 370px; }
  .scratch-area.large-ticket-mode { min-height: 345px; }
  .scratch-area.million-ticket-mode { min-height: 365px; }
  .scratch-area.batch-ticket-mode { min-height: 365px; }
  .number-ticket-mode .physical-number-game { gap: 7px; }
  .number-ticket-mode .number-prize-rows { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 9px; }
  .number-ticket-mode .number-prize-row { grid-template-columns: minmax(0,1fr) 72px; }
  .number-ticket-mode .paper-number { min-height: 29px; font-size: .82rem; }
  .number-ticket-mode .paper-row-prize { min-height: 29px; font-size: .67rem; }
  .number-ticket-mode .winning-number-strip span { min-height: 31px; }
  .number-ticket-mode .result-note { font-size: .68rem; }
  .large-ticket-mode .lucky20-grid { grid-template-columns: repeat(5, minmax(0,1fr)); }
  .large-ticket-mode .lucky20-grid .number-cell { min-height: 41px; }
  .large-ticket-mode .snake-number-grid { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .large-ticket-mode .snake-number-grid .number-cell { min-height: 38px; }
  .million-ticket-mode .million-road-grid { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .million-ticket-mode .million-road-grid .number-cell { min-height: 38px; }
  .bundle-two-tickets { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
  .million-ticket-mode .result-note { font-size: .67rem; }
  .batch-grid { grid-template-columns: repeat(5, minmax(0,1fr)); gap: 6px; }
  .batch-cell { min-height: 56px; }
  .batch-ticket-mode .game-result { max-width: 650px; }
  .batch-ticket-mode .result-note { font-size: .68rem; }

  #shopScene.active { display: block; min-height: 0; }
  .shop-layout {
    display: grid;
    grid-template-columns: minmax(320px, 370px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }
  .shop-sidebar {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255,255,255,.025);
  }
  .dashboard { margin-bottom: 12px; }
  .dashboard h2 { font-size: 1.85rem; }
  .balance-card { padding: 10px 12px; }
  .player-ip { margin: -5px 0 9px; padding: 7px 10px; }
  .narrator { margin-bottom: 11px; padding: 10px 12px; font-size: .82rem; }
  .life-status { grid-template-columns: repeat(4, minmax(0,1fr)); margin-bottom: 10px; gap: 6px; }
  .life-status div { padding: 9px 8px; }
  .life-status span { font-size: .66rem; }
  .life-status strong { font-size: .75rem; }
  .life-actions { gap: 7px; margin-bottom: 10px; }
  .life-actions button { min-height: 70px; padding: 9px; grid-template-columns: 26px 1fr; }
  .life-actions button > span { font-size: 1.15rem; }
  .life-actions b { font-size: .78rem; }
  .life-actions small { font-size: .62rem; }
  .stats-panel { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 6px; padding-top: 3px; }
  .stats-panel div { padding: 8px 4px; }
  .stats-panel span { font-size: .62rem; }
  .stats-panel strong { font-size: .72rem; }
  .shop-counter {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: rgba(255,255,255,.018);
  }
  .shop-counter .section-heading { margin: 0 0 13px; }
  .shop-counter .section-heading h3 { font-size: 1.45rem; }
  .ticket-grid { grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
  .tier-card { min-height: 205px; padding: 17px; }
  .tier-card .tier-name { font-size: .8rem; }
  .tier-card strong { font-size: 2.25rem; }
  .tier-card em { font-size: .72rem; line-height: 1.5; }
  .tier-card small { font-size: .72rem; line-height: 1.45; }
  .tier-actions button { font-size: .68rem; }

  #endingScene.active { display: grid; place-items: center; }
  .ending-card { width: min(100%, 760px); margin: 0; padding: 34px 48px; }
  .ending-stats { grid-template-columns: repeat(4,1fr); }
  .disclaimer { padding-top: 10px; }
}

@media (max-width: 380px) {
  .game-shell { padding-left: 13px; padding-right: 13px; }
  .story-card { margin-left: 8px; margin-right: 8px; }
  .tier-card { min-height: 128px; padding: 13px; }
  .stats-panel { grid-template-columns: 1fr; }
  .life-status { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
