:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "Hiragino Sans", "Yu Gothic", sans-serif;
  --ink: #1c231f;
  --muted: #667069;
  --paper: #f6f2e8;
  --card: #fffdf7;
  --lime: #c9f43b;
  --orange: #ff6b35;
  --line: #d8d5ca;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: #deddd6; color: var(--ink); }

body { overscroll-behavior: none; }

button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

.app {
  width: min(100%, 480px);
  min-height: 100vh;
  min-height: 100svh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom));
  background: var(--paper);
  display: grid;
  grid-template-rows: auto auto minmax(190px, 1fr) auto auto;
  gap: 12px;
  overflow: hidden;
}
.app > * { min-width: 0; }

.brand { min-width: 0; }
.eyebrow, .status-label, .control-label { margin: 0; font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.eyebrow { color: var(--orange); }
.title-row { display: flex; align-items: center; justify-content: space-between; }
.title-actions { display: flex; align-items: center; gap: 8px; }
h1 { margin: 0; font-size: clamp(38px, 12vw, 62px); line-height: .95; letter-spacing: -.075em; }

.icon-button, .stepper button {
  min-width: 44px; min-height: 44px; border: 1.5px solid var(--ink); background: transparent;
  border-radius: 50%; font-weight: 900; cursor: pointer;
}

.icon-button:active, .stepper button:active, .roll-button:active { transform: translateY(2px); }
.settings-icon { font-size: 20px; line-height: 1; }
.history-button {
  min-height: 44px; padding: 0 12px; border: 1.5px solid var(--ink); border-radius: 22px;
  background: var(--card); font-size: 11px; font-weight: 900; cursor: pointer;
}
.history-button span {
  display: inline-grid; min-width: 20px; height: 20px; padding-inline: 5px; place-items: center;
  border-radius: 10px; background: var(--ink); color: var(--card); font-variant-numeric: tabular-nums;
}
.history-button:active { transform: translateY(2px); }
.history-button:disabled { opacity: .45; }

.status-card {
  border: 1.5px solid var(--ink); border-radius: 14px; padding: 11px 13px;
  width: 100%; min-width: 0; min-height: 96px; background: var(--card); display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: 4px 10px; box-shadow: 3px 3px 0 var(--ink);
}
.status-label { color: var(--muted); }
.status-text { grid-column: 1 / -1; margin: 0; min-width: 0; display: grid; grid-template-rows: 18px 18px; font-size: 14px; font-weight: 800; line-height: 18px; overflow-wrap: anywhere; }
.status-round, .status-message { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-round { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats { grid-column: 2; min-width: 0; display: flex; align-items: center; gap: 5px; }
.stats span { width: 66px; min-width: 0; display: grid; text-align: center; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .02em; }
.stats strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; color: var(--ink); font-size: 18px; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap; }
.reset-button {
  width: 44px; height: 44px; padding: 0; border: 1.5px solid var(--ink); border-radius: 50%;
  background: var(--card); font-size: 22px; font-weight: 900; line-height: 1; cursor: pointer;
}
.reset-button:active { transform: rotate(-25deg); }
.reset-button:disabled { opacity: .4; }

.dice-stage {
  position: relative; min-height: 0; border: 1.5px solid var(--line); border-radius: 18px;
  background: radial-gradient(circle at 50% 35%, #fff 0, #f0ebdf 72%);
  overflow: hidden;
}
.dice-stage.anticipation-hot { animation: warning-pulse .7s ease-in-out infinite; }
.dice-stage.anticipation-iwakan { animation: iwakan-pulse .55s ease-in-out 2; }
.dice-stage.anticipation-freeze { animation: freeze-pulse .9s steps(2, end) both; }
.dice-stage.anticipation-premium { animation: premium-pulse .75s linear 2; }
.app.iwakan-pips .pip { background: #8c5cff; box-shadow: 0 0 7px #8c5cff; }
.app.iwakan-arrow #rollArrow { display: inline-block; color: #8c5cff; transform: rotate(180deg); }
.app.iwakan-mirror .control-label { display: inline-block; color: #8c5cff; transform: scaleX(-1); }
.app.iwakan-shadow .die { box-shadow: -5px 6px 0 #8c5cff; }
.app.iwakan-rainbow .status-label,
.app.iwakan-rainbow .status-round,
.app.iwakan-rainbow .status-message,
.app.iwakan-rainbow .stats span,
.app.iwakan-rainbow .stats strong {
  color: transparent; background: linear-gradient(90deg, #f33, #ff9d00, #7fbf00, #00aee8, #7655ff, #e744c4, #f33);
  background-size: 300% 100%; background-clip: text; -webkit-background-clip: text; animation: rainbow-text .7s linear infinite;
}
.app.iwakan-seven .die:first-child .pip,
.app.iwakan-kanji .die:first-child .pip { opacity: 0; }
.app.iwakan-seven .die:first-child::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; border-radius: 50%;
  background: #8c5cff; transform: translate(-50%, -50%);
  box-shadow: -20px -20px 0 #8c5cff, 20px -20px 0 #8c5cff, -20px 0 0 #8c5cff, 20px 0 0 #8c5cff, -20px 20px 0 #8c5cff, 20px 20px 0 #8c5cff;
}
.app.iwakan-kanji .die:first-child::after {
  content: attr(data-kanji); position: absolute; inset: 2px; display: grid; place-items: center;
  border-radius: 15%; background: #fff; color: #8c5cff; font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  font-size: clamp(34px, 11vw, 50px); font-weight: 900; line-height: 1;
}
.iwakan-challenge {
  position: fixed; z-index: 12; top: max(10px, env(safe-area-inset-top)); left: 50%;
  min-width: min(280px, calc(100vw - 24px)); min-height: 46px; padding: 8px 10px 8px 15px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 2px solid #8c5cff; border-radius: 999px; background: rgb(255 253 247 / .96);
  box-shadow: 0 4px 0 #8c5cff; color: #5a32c8; font-size: 13px; font-weight: 1000;
  opacity: 0; pointer-events: none; transform: translate(-50%, -16px); transition: opacity .16s ease, transform .16s ease;
}
.iwakan-challenge.show { opacity: 1; transform: translate(-50%, 0); }
.iwakan-challenge strong { min-width: 42px; font-size: 18px; font-variant-numeric: tabular-nums; text-align: right; }
.iwakan-challenge.miss { border-color: var(--orange); box-shadow: 0 4px 0 var(--orange); color: #b83d16; animation: challenge-shake .24s ease; }
.iwakan-challenge.success { border-color: var(--lime); background: var(--ink); box-shadow: 0 4px 0 var(--lime); color: var(--lime); }
.app.iwakan-hunt { cursor: crosshair; }
.gold-shutter {
  position: fixed; inset: 0; z-index: 80; overflow: hidden; visibility: hidden; pointer-events: none;
  background: rgb(18 12 3 / 0); perspective: 700px;
}
.gold-shutter-panel {
  position: absolute; top: 0; bottom: 0; width: 51%;
  border-color: #4b2b00; border-style: solid;
  background:
    radial-gradient(circle at 15px 15px, #fff2a3 0 2px, #6f3a00 3px 5px, transparent 6px),
    repeating-linear-gradient(0deg, transparent 0 34px, rgb(85 42 0 / .7) 35px 39px, rgb(255 235 135 / .65) 40px 42px),
    linear-gradient(115deg, #704000 0%, #d89409 13%, #fff0a0 27%, #b96c00 42%, #ffe67b 57%, #8c4b00 73%, #f6c744 88%, #603300 100%);
  background-size: 58px 58px, auto, auto;
  box-shadow: inset 0 0 0 5px #e6a917, inset 0 0 34px #3d2100, 0 0 32px rgb(255 196 38 / .65);
  will-change: transform;
}
.gold-shutter-left { left: 0; border-width: 3px 7px 3px 3px; transform: translateX(-105%); }
.gold-shutter-right { right: 0; border-width: 3px 3px 3px 7px; transform: translateX(105%); }
.gold-shutter-impact {
  position: absolute; left: 50%; top: 50%; z-index: 2; width: 134px; aspect-ratio: 1;
  display: grid; place-content: center; gap: 1px; border: 4px double #492800; border-radius: 50%;
  background: radial-gradient(circle, #fff7b8 0 8%, #ffd64f 9% 28%, #a85d00 58%, #3f2200 72%);
  box-shadow: 0 0 0 5px #ffd44d, 0 0 0 9px #633600, 0 0 38px 12px #fff1a1;
  color: #2c1700; text-align: center; opacity: 0; transform: translate(-50%, -50%) scale(1.7) rotate(-8deg);
}
.gold-shutter-impact span { font-size: 12px; font-weight: 1000; letter-spacing: .2em; }
.gold-shutter-impact strong { font-size: 34px; font-weight: 1000; line-height: 1; letter-spacing: .08em; }
.gold-shutter.show { visibility: visible; pointer-events: auto; animation: gold-shutter-backdrop 1.55s linear both; }
.gold-shutter.show .gold-shutter-left { animation: gold-shutter-close-left 1.55s cubic-bezier(.2, .84, .2, 1) both; }
.gold-shutter.show .gold-shutter-right { animation: gold-shutter-close-right 1.55s cubic-bezier(.2, .84, .2, 1) both; }
.gold-shutter.show .gold-shutter-impact { animation: gold-shutter-impact 1.55s ease-out both; }
.dice-grid {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  display: flex; flex-wrap: wrap; align-content: safe center; justify-content: center; gap: 12px;
  padding: 18px;
}
.die {
  position: relative; width: clamp(62px, 20vw, 88px); aspect-ratio: 1; flex: 0 0 auto;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 11px;
  border: 2px solid var(--ink); border-radius: 18%; background: #fff; box-shadow: 5px 6px 0 var(--ink);
  animation: settle .22s ease-out;
}
.pip { align-self: center; justify-self: center; width: 11px; height: 11px; border-radius: 50%; background: var(--ink); }
.p1 { grid-area: 1 / 1; } .p2 { grid-area: 1 / 2; } .p3 { grid-area: 1 / 3; }
.p4 { grid-area: 2 / 1; } .p5 { grid-area: 2 / 2; } .p6 { grid-area: 2 / 3; }
.p7 { grid-area: 3 / 1; } .p8 { grid-area: 3 / 2; } .p9 { grid-area: 3 / 3; }
.result-badge {
  position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%) rotate(-5deg) scale(.8);
  z-index: 2; padding: 10px 18px; background: var(--lime); border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink); font-size: clamp(28px, 10vw, 48px); font-weight: 1000;
  letter-spacing: -.05em; opacity: 0; pointer-events: none;
}
.result-badge.show { animation: pop .8s ease both; }
.lucky-overlay {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; overflow: hidden;
  background: rgb(201 244 59 / 0); opacity: 0; pointer-events: none;
}
.lucky-overlay.show { animation: lucky-flash 1.9s ease-out both; }
.lucky-overlay.hot .lucky-copy { background: var(--orange); }
.lucky-overlay.iwakan .lucky-copy { background: #fff; box-shadow: -8px 8px 0 #8c5cff; transform: rotate(1deg); }
.lucky-overlay.freeze { background: rgb(28 35 31 / .72); }
.lucky-overlay.freeze .lucky-copy { background: #fff; box-shadow: 8px 8px 0 var(--orange); }
.lucky-overlay.puchun { background: #050505; }
.lucky-overlay.puchun .lucky-copy { color: #fff; background: #050505; border-color: #fff; box-shadow: 0 0 28px #fff; }
.lucky-overlay.puchun .lucky-copy span { color: #fff; }
.lucky-overlay.premium { background: conic-gradient(from 0deg, #ff5555aa, #ffe94aaa, #5cff78aa, #4ddcffaa, #8c5cffaa, #ff55ddaa, #ff5555aa); }
.lucky-overlay.premium.show { animation: premium-overlay 2.4s linear both; }
.lucky-overlay.premium .lucky-copy { background: #ffe94a; box-shadow: 8px 8px 0 #ff55dd; }
.lucky-overlay.premium .lucky-copy strong { background: linear-gradient(90deg, #f33, #f90, #2a5, #28e, #b3e); color: transparent; background-clip: text; -webkit-background-clip: text; }
.crt-overlay {
  position: fixed; inset: 0; z-index: 100; overflow: hidden; background: #000; opacity: 0;
  pointer-events: none; visibility: hidden;
}
.crt-overlay::before, .crt-overlay::after { content: ""; position: absolute; left: 50%; top: 50%; opacity: 0; }
.crt-overlay::before {
  width: 100vw; height: 4px; transform: translate(-50%, -50%) scaleX(1);
  background: linear-gradient(90deg, #6f35ff 0%, #a98cff 24%, #d8caff 42%, #fff 50%, #d8caff 58%, #a98cff 76%, #6f35ff 100%);
  box-shadow: 0 0 5px #fff, 0 0 13px #9b70ff, 0 0 30px #6f35ff;
}
.crt-overlay::after {
  width: 130px; height: 130px; transform: translate(-50%, -50%) scale(0);
  background: radial-gradient(circle, #fff 0 9%, #eadfff 19%, #8d5cff 40%, transparent 68%);
  clip-path: polygon(50% 0, 57% 42%, 100% 50%, 57% 58%, 50% 100%, 43% 58%, 0 50%, 43% 42%);
  filter: drop-shadow(0 0 9px #fff) drop-shadow(0 0 18px #8d5cff);
}
.crt-overlay.show { visibility: visible; animation: crt-blackout 1s linear both; }
.crt-overlay.show::before { animation: crt-line-collapse 1s ease-in both; }
.crt-overlay.show::after { animation: crt-star-collapse 1s ease-out both; }
.freeze-overlay {
  position: fixed; inset: 0; z-index: 90; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  display: grid; place-items: center; background: #000; opacity: 0; visibility: hidden; pointer-events: none;
}
.freeze-overlay::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 100vw; height: 2px;
  background: #fff; box-shadow: 0 0 10px #fff; opacity: 0; transform: translate(-50%, -50%) scaleX(0);
}
.freeze-overlay.show { visibility: visible; opacity: 1; pointer-events: auto; animation: full-freeze .12s linear both; }
.freeze-prompt { display: grid; place-items: center; gap: 18px; opacity: 0; transform: scale(.96); transition: opacity .18s ease, transform .18s ease; }
.freeze-prompt p { margin: 0; color: #fff; font-size: clamp(16px, 5vw, 22px); font-weight: 900; letter-spacing: .08em; text-align: center; }
.freeze-prompt button {
  min-width: 132px; min-height: 58px; border: 2px solid #fff; border-radius: 999px; background: #fff;
  color: #000; box-shadow: 0 0 0 0 #fff; font-size: 18px; font-weight: 1000; letter-spacing: .14em; cursor: pointer;
}
.freeze-overlay.ready .freeze-prompt { opacity: 1; transform: scale(1); }
.freeze-overlay.ready .freeze-prompt button { animation: freeze-button-pulse 1s ease-in-out infinite; }
.freeze-prompt button:active { transform: scale(.94); }
.freeze-prompt button:focus-visible { outline: 3px solid var(--lime); outline-offset: 5px; }
.freeze-overlay.releasing { animation: freeze-release .28s ease-in both; }
.freeze-overlay.releasing::after { animation: freeze-release-line .28s ease-out both; }
.lucky-copy {
  position: relative; z-index: 2; width: min(86%, 320px); padding: 18px 12px;
  display: grid; place-items: center; gap: 3px; border: 3px solid var(--ink); border-radius: 18px;
  background: var(--lime); box-shadow: 8px 8px 0 var(--ink); text-align: center;
  transform: rotate(-3deg) scale(.5); opacity: 0;
}
.lucky-overlay.show .lucky-copy { animation: lucky-card 1.9s cubic-bezier(.2, .9, .2, 1) both; }
.lucky-copy span { color: var(--orange); font-size: 10px; font-weight: 1000; letter-spacing: .2em; }
.lucky-copy strong { font-size: clamp(30px, 10vw, 48px); line-height: 1; letter-spacing: -.06em; }
.lucky-copy small { font-size: 12px; font-weight: 900; }
.confetti { position: absolute; inset: 0; }
.confetti i {
  position: absolute; left: 50%; top: 50%; width: 9px; height: 18px; border: 1px solid var(--ink);
  background: var(--orange); opacity: 0;
}
.lucky-overlay.show .confetti i { animation: confetti-burst 1.3s ease-out both; animation-delay: var(--delay); }
.confetti i:nth-child(3n) { background: #5b61ff; }
.confetti i:nth-child(3n + 1) { background: var(--lime); }

.controls { display: grid; gap: 10px; }
.count-control { display: flex; justify-content: space-between; align-items: center; min-height: 50px; }
.count-control strong { display: block; font-size: 18px; }
.probability { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stepper { display: flex; gap: 8px; }
.stepper button:disabled { opacity: .35; }
.action-row { display: grid; grid-template-columns: minmax(96px, .38fr) minmax(0, 1fr); gap: 9px; align-items: stretch; }
.skip-button {
  min-height: 58px; padding: 5px 9px; border: 2px solid var(--ink); border-radius: 14px;
  background: var(--card); box-shadow: 0 5px 0 var(--ink); font-size: 12px; font-weight: 900;
  line-height: 1.25; cursor: pointer;
}
.roll-button {
  width: 100%; min-height: 58px; padding: 0 18px; display: flex; justify-content: space-between; align-items: center;
  border: 2px solid var(--ink); border-radius: 14px; background: var(--lime); box-shadow: 0 5px 0 var(--ink);
  font-weight: 950; font-size: 18px; cursor: pointer;
}
.roll-button[disabled], .skip-button[disabled] { opacity: .65; }
footer { text-align: center; color: var(--muted); font-size: 10px; min-height: 12px; }

.debug-toggle {
  position: fixed; z-index: 20; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom));
  min-width: 52px; min-height: 44px; border: 2px dashed #8c5cff; border-radius: 12px; background: #fff;
  color: #5a32c8; font-size: 10px; font-weight: 1000; letter-spacing: .08em; cursor: pointer;
}
.debug-panel {
  position: fixed; z-index: 19; right: max(10px, env(safe-area-inset-right)); bottom: max(62px, calc(env(safe-area-inset-bottom) + 62px));
  width: min(230px, calc(100vw - 20px)); padding: 10px; display: none; grid-template-columns: 1fr 1fr; gap: 7px;
  border: 2px dashed #8c5cff; border-radius: 14px; background: rgb(255 253 247 / .96); box-shadow: 5px 5px 0 var(--ink);
}
.debug-panel.open { display: grid; }
.debug-panel strong { grid-column: 1 / -1; font-size: 11px; color: #5a32c8; }
.debug-panel button { min-height: 44px; border: 1.5px solid var(--ink); border-radius: 9px; background: #fff; font-size: 11px; font-weight: 900; cursor: pointer; }
.debug-panel button[data-tier="hot"] { background: #ff9d7a; }
.debug-panel button[data-tier="iwakan"] { background: #eee8ff; }
.debug-panel button[data-tier="freeze"] { background: #dfe3ff; }
.debug-panel button[data-tier="puchun"] { color: #fff; background: #111; }
.debug-panel button[data-tier="premium"] { background: linear-gradient(90deg, #ff8d8d, #fff071, #7bff9c, #83d9ff, #d68cff); }

dialog { width: min(calc(100% - 36px), 420px); max-height: calc(100dvh - 36px); padding: 20px; border: 2px solid var(--ink); border-radius: 18px; background: var(--card); box-shadow: 7px 7px 0 var(--ink); }
dialog::backdrop { background: rgb(28 35 31 / .52); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 28px; }
dialog p { line-height: 1.75; }
.note { color: var(--muted); font-size: 13px; }
.settings-section { margin-top: 18px; }
.settings-section + .settings-section { padding-top: 14px; border-top: 1px solid var(--line); }
.settings-section h3 { margin: 0 0 8px; font-size: 16px; }
.sound-heading { display: flex; align-items: center; justify-content: space-between; }
.sound-heading output { font-size: 14px; font-weight: 1000; font-variant-numeric: tabular-nums; }
.sound-slider { width: 100%; min-height: 44px; accent-color: var(--orange); cursor: pointer; }
.sound-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.sound-actions button {
  min-height: 44px; border: 1.5px solid var(--ink); border-radius: 10px; background: var(--card); font-size: 12px; font-weight: 900; cursor: pointer;
}
.sound-actions button[aria-pressed="true"] { color: #fff; background: var(--ink); }
.credits { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.credits h3 { margin: 0 0 6px; font-size: 16px; }
.credits p { margin: 4px 0; font-size: 13px; }
.dialog-kicker { color: var(--orange); font-size: 9px; font-weight: 1000; letter-spacing: .16em; }
.history-list { max-height: min(52dvh, 420px); overflow-y: auto; overscroll-behavior: contain; display: grid; gap: 9px; margin: 14px 0; }
.history-entry { padding: 11px 12px; border: 1.5px solid var(--ink); border-radius: 12px; background: var(--paper); }
.history-entry header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.history-entry strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.history-entry small { color: var(--orange); font-size: 10px; font-weight: 1000; }
.history-entry p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.history-empty { margin: 18px 0; padding: 20px 12px; border: 1.5px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; font-size: 13px; }
.history-empty[hidden] { display: none; }

@keyframes settle { from { transform: rotate(8deg) scale(.88); opacity: .5; } }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-5deg) scale(.7); } 25%, 70% { opacity: 1; transform: translate(-50%, -50%) rotate(-5deg) scale(1); } 100% { opacity: 0; transform: translate(-50%, -65%) rotate(-5deg) scale(1); } }
@keyframes lucky-flash { 0% { opacity: 0; background: rgb(201 244 59 / 0); } 8%, 72% { opacity: 1; background: rgb(201 244 59 / .3); } 100% { opacity: 0; } }
@keyframes lucky-card { 0% { opacity: 0; transform: rotate(-8deg) scale(.45); } 16% { opacity: 1; transform: rotate(3deg) scale(1.08); } 27%, 72% { opacity: 1; transform: rotate(-3deg) scale(1); } 100% { opacity: 0; transform: rotate(-3deg) scale(1.12); } }
@keyframes confetti-burst { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(0) scale(.4); } 75% { opacity: 1; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--fall))) rotate(var(--r)) scale(.8); } }
@keyframes warning-pulse { 0%, 100% { border-color: var(--line); box-shadow: none; } 50% { border-color: #f22; box-shadow: inset 0 0 0 5px rgb(255 34 34 / .45), 0 0 20px #f22; } }
@keyframes iwakan-pulse { 0%, 100% { transform: none; } 45% { transform: translateX(0); } 46% { transform: translateX(3px) rotate(.4deg); filter: hue-rotate(80deg); } 52% { transform: translateX(-2px); } }
@keyframes rainbow-text { to { background-position: -300% 0; } }
@keyframes challenge-shake { 30% { transform: translate(calc(-50% - 5px), 0); } 65% { transform: translate(calc(-50% + 5px), 0); } }
@keyframes gold-shutter-backdrop { 0% { background: rgb(18 12 3 / 0); } 20%, 72% { background: rgb(18 12 3 / .5); } 100% { background: rgb(18 12 3 / 0); } }
@keyframes gold-shutter-close-left { 0%, 5% { transform: translateX(-105%) rotateY(8deg); } 30%, 69% { transform: translateX(0) rotateY(0); } 100% { transform: translateX(-105%) rotateY(8deg); } }
@keyframes gold-shutter-close-right { 0%, 5% { transform: translateX(105%) rotateY(-8deg); } 30%, 69% { transform: translateX(0) rotateY(0); } 100% { transform: translateX(105%) rotateY(-8deg); } }
@keyframes gold-shutter-impact { 0%, 25% { opacity: 0; transform: translate(-50%, -50%) scale(1.7) rotate(-8deg); } 32% { opacity: 1; transform: translate(-50%, -50%) scale(.88) rotate(2deg); } 40%, 63% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); } 72%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.12); } }
@keyframes freeze-pulse { 0%, 45% { filter: none; } 46%, 100% { filter: grayscale(1) contrast(1.7); background: #1c231f; } }
@keyframes crt-blackout { 0%, 8% { opacity: 0; } 12%, 88% { opacity: 1; } 100% { opacity: 0; } }
@keyframes crt-line-collapse { 0%, 14% { opacity: 0; transform: translate(-50%, -50%) scaleX(1); } 20%, 58% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); } 76% { opacity: 1; transform: translate(-50%, -50%) scaleX(.12); } 90% { opacity: .9; transform: translate(-50%, -50%) scaleX(.015); } 100% { opacity: 0; transform: translate(-50%, -50%) scaleX(0); } }
@keyframes crt-star-collapse { 0%, 52% { opacity: 0; transform: translate(-50%, -50%) scale(0); } 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 86% { opacity: .85; transform: translate(-50%, -50%) scale(.48); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.05); } }
@keyframes full-freeze { from { opacity: 0; } to { opacity: 1; } }
@keyframes freeze-button-pulse { 50% { box-shadow: 0 0 0 7px rgb(255 255 255 / .18), 0 0 24px #fff; } }
@keyframes freeze-release { 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes freeze-release-line { 0% { opacity: 0; transform: translate(-50%, -50%) scaleX(0); } 45% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scaleX(1); } }
@keyframes premium-pulse { to { filter: hue-rotate(360deg); box-shadow: inset 0 0 25px #fff, 0 0 24px #ff55dd; } }
@keyframes premium-overlay { 0% { opacity: 0; filter: hue-rotate(0); } 10%, 78% { opacity: 1; } 100% { opacity: 0; filter: hue-rotate(360deg); } }

@media (orientation: landscape) {
  .app { width: min(100%, 720px); grid-template-columns: minmax(220px, .8fr) minmax(300px, 1.2fr); grid-template-rows: auto auto 1fr auto; gap: 8px 14px; padding-block: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-bottom)); }
  .brand, .status-card, footer { grid-column: 1; }
  .dice-stage { grid-column: 2; grid-row: 1 / 4; min-height: 180px; }
  .controls { grid-column: 1; }
  footer { font-size: 9px; }
  h1 { font-size: clamp(34px, 8vw, 48px); }
  .status-card { min-height: 96px; }
}

@media (orientation: portrait) and (max-height: 620px) {
  .app { gap: 7px; padding-block: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-bottom)); grid-template-rows: auto auto minmax(150px, 1fr) auto auto; }
  h1 { font-size: 36px; }
  .status-card { min-height: 88px; padding-block: 7px; }
  .dice-grid { padding: 12px; gap: 9px; }
  .count-control { min-height: 44px; }
  .roll-button, .skip-button { min-height: 52px; }
  footer { font-size: 9px; }
}

@media (max-width: 340px) {
  .app { padding-inline: 12px; gap: 9px; }
  .status-card { padding: 9px 10px; }
  .stats { gap: 3px; }
  .stats span { width: 66px; }
  .stats strong { font-size: 14px; }
  .die { width: 62px; }
  .action-row { grid-template-columns: 96px minmax(0, 1fr); gap: 7px; }
  .roll-button { padding-inline: 12px; font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .lucky-overlay.show { opacity: 1; background: rgb(201 244 59 / .3); }
  .lucky-overlay.show .lucky-copy { opacity: 1; transform: none; }
  .confetti { display: none; }
  .gold-shutter.show { visibility: visible; background: rgb(18 12 3 / .5); }
  .gold-shutter.show .gold-shutter-left,
  .gold-shutter.show .gold-shutter-right { transform: translateX(0); }
  .gold-shutter.show .gold-shutter-impact { opacity: 1; transform: translate(-50%, -50%); }
}
