:root {
  color-scheme: light;
  --ink: #171717;
  --muted: #6d7179;
  --panel: rgba(255, 255, 255, 0.86);
  --line: rgba(26, 26, 26, 0.16);
  --accent: #e85d2a;
  --accent-dark: #b93c18;
  --blue: #286aa8;
  --green: #287a62;
  --shadow: 0 18px 48px rgba(18, 28, 45, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 15%, rgba(232, 93, 42, 0.18), transparent 28%),
    radial-gradient(circle at 82% 22%, rgba(40, 106, 168, 0.16), transparent 26%),
    linear-gradient(135deg, #f8f5ee 0%, #edf4f7 45%, #faf7f1 100%);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  width: min(100vw, 1120px);
  height: 100vh;
  margin: 0 auto;
  padding: 14px clamp(10px, 2vw, 24px) max(14px, env(safe-area-inset-bottom));
}

.stage-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.58)),
    repeating-linear-gradient(
      -15deg,
      transparent 0 82px,
      rgba(0, 0, 0, 0.025) 83px 85px
    );
  box-shadow: var(--shadow);
}

#lotteryCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.control-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(136px, auto) 46px;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(18, 28, 45, 0.12);
  backdrop-filter: blur(14px);
}

.result-strip {
  display: flex;
  min-width: 0;
  min-height: 46px;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px;
  scrollbar-width: thin;
}

.result-ball {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffbf4a, #ec5d18 64%, #b93614);
  box-shadow:
    inset -6px -8px 12px rgba(112, 35, 4, 0.28),
    inset 5px 5px 9px rgba(255, 255, 255, 0.38),
    0 4px 10px rgba(112, 35, 4, 0.22);
  color: #17110c;
  font-size: 14px;
  font-weight: 800;
}

.result-ball.is-new {
  animation: settle-result 360ms cubic-bezier(0.2, 0.9, 0.28, 1.18);
}

@keyframes settle-result {
  0% {
    opacity: 0;
    transform: translateY(-14px) scale(0.7) rotate(-18deg);
  }

  72% {
    opacity: 1;
    transform: translateY(2px) scale(1.08) rotate(5deg);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

.draw-button,
.icon-button {
  cursor: pointer;
  user-select: none;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.draw-button {
  display: grid;
  min-width: 136px;
  min-height: 48px;
  place-items: center;
  padding: 8px 18px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), var(--accent-dark));
  box-shadow: 0 9px 20px rgba(185, 60, 24, 0.32);
  color: white;
}

.button-main {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.button-sub {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  line-height: 1.1;
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--blue);
  font-size: 24px;
  font-weight: 700;
}

.draw-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.draw-button:active,
.icon-button:active {
  transform: translateY(1px) scale(0.99);
}

.draw-button:disabled {
  cursor: default;
  opacity: 0.64;
  transform: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 620px) {
  .app-shell {
    gap: 10px;
    padding: 10px;
  }

  .control-bar {
    grid-template-columns: minmax(0, 1fr) 116px 42px;
    gap: 8px;
    padding: 8px;
  }

  .draw-button {
    min-width: 116px;
    min-height: 44px;
    padding: 7px 12px;
  }

  .button-main {
    font-size: 14px;
  }

  .button-sub {
    font-size: 11px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .result-ball {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }
}
