:root {
  --ink: #f7fbff;
  --muted: #9bb2c7;
  --line: rgba(255, 255, 255, 0.15);
  --gold: #ffd36c;
  --cyan: #57f2ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 211, 108, 0.16), transparent 24%),
    radial-gradient(circle at 86% 22%, rgba(87, 242, 255, 0.14), transparent 28%),
    radial-gradient(circle at 50% 100%, rgba(255, 79, 216, 0.11), transparent 36%),
    linear-gradient(135deg, #050a13 0%, #111827 52%, #06070d 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at center, black, transparent 78%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0);
  transition: background 3000ms ease;
}

body.is-dimmed::after {
  background: rgba(0, 0, 0, 0.42);
}

#sparkCanvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stage-shell {
  position: relative;
  z-index: 2;
  width: min(1160px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 0 64px;
}

.finish-order {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 4;
  display: grid;
  width: min(320px, calc(100% - 28px));
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}

.finish-order div {
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(6, 12, 22, 0.36);
}

.finish-order span {
  color: var(--muted);
  font-size: 9px;
}

.finish-order strong {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.reveal-zone {
  min-height: calc(100vh - 84px);
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 74px 0 50px;
}

.cinema-scene {
  min-height: 54vh;
  width: min(900px, 100%);
  display: grid;
  place-items: center;
  text-align: center;
  animation: slowBoom 3200ms cubic-bezier(.16, .84, .28, 1) both;
  will-change: opacity, transform;
}

.cinema-scene > div {
  display: grid;
  gap: 14px;
  filter: drop-shadow(0 0 28px rgba(255, 255, 255, 0.13));
}

.scene-mark {
  color: rgba(255, 211, 108, 0.78);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.28em;
}

.cinema-scene h2 {
  margin: 0;
  color: #f7fbff;
  font-size: clamp(46px, 8.5vw, 112px);
  line-height: 0.95;
  letter-spacing: 0;
}

.cinema-scene p {
  margin: 0;
  color: var(--gold);
  font-size: clamp(18px, 3vw, 34px);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.announce-button {
  position: relative;
  width: 240px;
  min-height: 76px;
  border: 0;
  color: #fff;
  font-size: 18px;
  font-weight: 950;
  letter-spacing: 0.04em;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
}

.announce-button::before,
.announce-button::after {
  content: "";
  position: absolute;
  inset: -60%;
  z-index: -1;
}

.announce-button::before {
  background: conic-gradient(from 90deg, transparent, rgba(255, 255, 255, 0.8), transparent 28%);
  animation: spin 2.8s linear infinite;
}

.announce-button::after {
  inset: 2px;
}

.style-blackout {
  border-radius: 8px;
  background: #05070c;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22), 0 0 38px rgba(255, 255, 255, 0.15);
}

.style-blackout::after {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.09), transparent 38%), #05070c;
}

.style-goldrush {
  border-radius: 6px;
  background: linear-gradient(135deg, #e6a93a, #ff4fd8);
  box-shadow: 0 0 34px rgba(255, 211, 108, 0.3);
}

.style-goldrush::after {
  background:
    radial-gradient(circle at 18% 25%, rgba(255, 255, 255, 0.28), transparent 24%),
    linear-gradient(135deg, rgba(104, 56, 4, 0.88), rgba(20, 10, 6, 0.88));
}

.ticket-card {
  position: relative;
  isolation: isolate;
  width: min(520px, 100%);
  aspect-ratio: 1.64 / 1;
  min-height: 316px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 132px 54px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
  overflow: hidden;
  padding: 14px 16px 13px;
  color: #191714;
  background:
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(78, 242, 224, 0.09) 12px 13px),
    #fff;
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.44), 0 0 28px rgba(255, 255, 255, 0.12);
  animation: ticketBang 900ms cubic-bezier(.17, .84, .32, 1.18) both;
  will-change: opacity, transform;
}

.ticket-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  z-index: -1;
  border: 1px solid rgba(45, 35, 24, 0.22);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.82), inset 0 0 22px rgba(88, 255, 235, 0.08);
}

.ticket-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: rgba(78, 242, 224, 0.12);
}

.ticket-frame {
  position: absolute;
  inset: 3px;
  z-index: -1;
  border: 2px solid rgba(58, 48, 36, 0.18);
  pointer-events: none;
}

.watermarks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: rgba(78, 242, 224, 0.15);
  font-weight: 950;
}

.watermarks span {
  position: absolute;
  font-size: clamp(25px, 4vw, 42px);
}

.watermarks span:nth-child(1) { top: 8%; left: 54%; }
.watermarks span:nth-child(2) { top: 31%; right: -4%; }
.watermarks span:nth-child(3) { top: 62%; left: 48%; }
.watermarks span:nth-child(4) { bottom: -10%; left: 30%; font-size: clamp(44px, 7vw, 78px); opacity: 0.42; }

.mint-strip {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 98px;
  width: 24px;
  background: rgba(78, 242, 224, 0.28);
}

.ticket-left {
  position: relative;
  z-index: 2;
  grid-row: 1 / 3;
  display: grid;
  align-content: start;
  gap: 4px;
  color: #070707;
}

.ticket-date {
  font-size: 17px;
}

.ticket-venue {
  font-size: 32px;
  font-weight: 900;
  line-height: 0.95;
}

.race-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 20px;
  font-weight: 500;
  color: #070707;
}

.race-chip strong {
  min-width: 50px;
  min-height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 3px 12px;
  background: linear-gradient(180deg, #333, #090909);
  color: white;
  font-weight: 950;
}

.memorial {
  align-self: end;
  margin-top: 62px;
  padding-bottom: 0;
  display: grid;
  min-height: 105px;
  gap: 0;
  align-content: end;
  color: #070707;
  text-align: center;
}

.memorial strong {
  display: grid;
  justify-items: center;
  font-size: 28px;
  line-height: 0.9;
  font-weight: 950;
}

.memorial strong span {
  margin: 0;
  text-align: center;
}

.memorial > span {
  margin-top: 18px;
  font-size: 11px;
  font-weight: 900;
  text-align: left;
}

.type-rail {
  position: relative;
  z-index: 2;
  grid-row: 1 / 2;
  justify-self: center;
  width: 42px;
  min-height: 156px;
  display: grid;
  place-items: center;
  align-content: space-between;
  padding: 6px 5px;
  border: 2px solid rgba(47, 38, 28, 0.68);
  background: rgba(255, 255, 255, 0.35);
  color: #4b4035;
}

.type-rail span {
  font-size: 9px;
  font-weight: 900;
}

.type-rail strong {
  writing-mode: vertical-rl;
  text-orientation: upright;
  color: #17140f;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0.08em;
  font-weight: 950;
}

.ticket-main {
  position: relative;
  z-index: 2;
  grid-column: 3;
  display: grid;
  align-content: start;
  gap: 5px;
  padding-left: 2px;
}

.ticket-card.horse-count-1 .ticket-main {
  padding-top: 38px;
}

.ticket-card.horse-count-2 .ticket-main {
  padding-top: 18px;
}

.ticket-owner {
  width: 100%;
  color: #030303;
  font-size: 41px;
  line-height: 0.95;
  font-weight: 950;
  white-space: nowrap;
  overflow: visible;
}

.ticket-owner.is-long {
  font-size: 30px;
  letter-spacing: 0;
}

.horse-list {
  display: grid;
  gap: 3px;
  margin: 3px 0 0;
  padding: 0;
  list-style: none;
}

.horse-list li {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.05;
}

.horse-no {
  min-width: 28px;
  height: 25px;
  font-size: 18px;
  display: inline-grid;
  place-items: center;
  border: 3px solid rgba(23, 105, 71, 0.78);
  background: rgba(255, 255, 255, 0.5);
}

.horse-name {
  overflow-wrap: anywhere;
}

.bet-amount {
  justify-self: end;
  margin-top: 2px;
  color: #433b31;
  font-size: 24px;
  font-weight: 950;
}

.bet-amount > span {
  margin-right: 6px;
  color: #426f62;
}

.money-number {
  font-variant-numeric: tabular-nums;
}

.money-yen {
  margin-left: 2px;
  font-size: 0.48em;
}

.payout-block {
  justify-self: end;
  display: grid;
  text-align: right;
  color: #0b0a08;
}

.payout-block > span {
  color: #795c19;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.18em;
}

.payout-block strong {
  position: relative;
  display: inline-block;
  padding: 1px 5px 2px;
  color: #070707;
  font-size: 44px;
  line-height: 0.92;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.65), 0 0 20px rgba(255, 211, 108, 0.44);
  overflow: hidden;
  isolation: isolate;
}

.payout-block strong::after {
  content: "";
  position: absolute;
  top: -42%;
  bottom: -42%;
  left: -58%;
  z-index: 2;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), rgba(255, 211, 108, 0.72), transparent);
  transform: skewX(-22deg);
  animation: payoutShine 1150ms ease-out 360ms both;
  pointer-events: none;
}

.ticket-bottom {
  position: relative;
  z-index: 2;
  grid-column: 2 / 4;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 6px;
  color: #15120d;
  font-size: 20px;
  font-weight: 950;
}

.ticket-bottom em {
  color: rgba(21, 18, 13, 0.48);
  font-size: 10px;
  font-style: normal;
}

.footer-stars {
  margin-right: 4px;
  color: #426f62;
}

.counter {
  color: #d7e6f4;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.08em;
  animation: fadeLift 400ms ease both;
}

.ticket-card.is-leaving,
.counter.is-leaving {
  animation: softLeave 1250ms ease both;
}

.final-result {
  width: min(900px, 100%);
  padding: clamp(24px, 5vw, 54px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent 34%),
    rgba(6, 12, 22, 0.78);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.48), inset 0 0 0 1px rgba(255, 211, 108, 0.18);
  animation: boomIn 900ms cubic-bezier(.17, .84, .32, 1.18) both;
}

.final-result > span {
  display: block;
  color: var(--gold);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.final-result h2 {
  margin: 6px 0 26px;
  font-size: clamp(42px, 7vw, 84px);
  line-height: 0.95;
}

.final-result ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.final-result li {
  display: grid;
  grid-template-columns: 42px minmax(120px, 1fr) minmax(160px, 1.5fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.055);
}

.final-result .rank {
  color: var(--gold);
  font-weight: 950;
}

.final-result strong {
  font-size: 22px;
}

.final-result em {
  color: #b9cadb;
  font-style: normal;
}

.final-result b {
  color: var(--gold);
  font-size: 24px;
}

.no-hit {
  margin: 0;
  color: #dce8f4;
  font-size: 24px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(12px);
}

.modal-backdrop.is-hidden {
  display: none;
}

.entry-card {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(180deg, rgba(13, 25, 42, 0.96), rgba(8, 12, 22, 0.96));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55), 0 0 60px rgba(87, 242, 255, 0.12);
  animation: boing 360ms ease-out both;
  will-change: opacity, transform;
}

.step-indicator {
  margin-bottom: 10px;
  color: var(--cyan);
  font-weight: 800;
}

.entry-picks {
  display: grid;
  gap: 7px;
  margin: 0 0 18px;
}

.entry-picks div {
  min-height: 38px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.055);
}

.entry-picks span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.entry-picks strong {
  min-width: 0;
  color: #eaf3ff;
  font-size: 15px;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-picks .is-preview {
  border-color: rgba(255, 211, 108, 0.45);
  background: rgba(255, 211, 108, 0.11);
}

.entry-picks .is-preview strong {
  color: var(--gold);
}

.entry-card h2 {
  margin: 0 0 20px;
  font-size: 25px;
  line-height: 1.35;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.number-pad button {
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.number-pad button.is-selected {
  background: linear-gradient(135deg, var(--gold), #ff7b4a);
  color: #140c05;
}

.number-pad button.is-used,
.number-pad button:disabled {
  background: rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.24);
  cursor: not-allowed;
  filter: grayscale(1);
}

.typed-number {
  min-height: 42px;
  margin: 14px 0;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
}

.entry-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.ghost-button,
.next-button {
  min-height: 50px;
  border: 0;
  font-weight: 900;
  cursor: pointer;
}

.ghost-button {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.next-button {
  width: 104px;
  background: linear-gradient(135deg, var(--cyan), var(--gold));
  color: #101723;
  font-size: 24px;
}

#nextLabel {
  display: inline-block;
  font-family: "Arial Black", Impact, "Noto Sans JP", sans-serif;
  font-size: 30px;
  font-weight: 950;
  line-height: 1;
  transform: translateY(-1px);
}

.next-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

@keyframes boing {
  0% { opacity: 0; transform: translateY(18px) scale(.96); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slowBoom {
  0% { opacity: 0; transform: scale(.72); filter: blur(18px); }
  34% { opacity: 1; transform: scale(1.03); filter: blur(0); }
  72% { opacity: 1; transform: scale(1); filter: blur(0); }
  100% { opacity: 0; transform: scale(1.08); filter: blur(8px); }
}

@keyframes boomIn {
  from { opacity: 0; transform: scale(.9); filter: blur(10px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes ticketBang {
  0% { opacity: 0; transform: scale(.9); }
  62% { opacity: 1; transform: scale(1.045); }
  82% { opacity: 1; transform: scale(.985); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes fadeLift {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes softLeave {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(.985); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes frameShift {
  to { filter: hue-rotate(20deg); transform: scale(1.02); }
}

@keyframes payoutShine {
  0% { left: -58%; opacity: 0; }
  12% { opacity: 1; }
  58% { opacity: 1; }
  100% { left: 125%; opacity: 0; }
}

@media (max-width: 820px) {
  .stage-shell {
    width: min(100% - 22px, 1160px);
  }

  .ticket-card {
    aspect-ratio: auto;
    width: min(520px, 100%);
    min-height: 360px;
    grid-template-columns: 118px 48px minmax(0, 1fr);
    padding: 14px;
  }

  .mint-strip {
    left: 88px;
    width: 22px;
  }

  .type-rail {
    width: 48px;
    min-height: 245px;
  }

  .horse-no {
    min-width: 38px;
    height: 34px;
  }

  .ticket-bottom {
    grid-column: 1 / 4;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .final-result li {
    grid-template-columns: 1fr;
  }
}
