:root {
  color-scheme: dark;
  --ink: #f7f8ff;
  --muted: #a4abc3;
  --panel: rgba(17, 22, 47, 0.72);
  --panel-strong: rgba(12, 16, 36, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --blue: #62dcff;
  --violet: #8c7dff;
  --lime: #cbff68;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-right: max(20px, env(safe-area-inset-right));
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  --safe-left: max(20px, env(safe-area-inset-left));
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #070a16;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(7, 10, 22, 0.9), rgba(7, 10, 22, 0.96)),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(255, 255, 255, 0.018) 80px),
    repeating-linear-gradient(0deg, transparent 0 79px, rgba(255, 255, 255, 0.018) 80px),
    #070a16;
  color: var(--ink);
  font-family: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 560px;
  height: 560px;
  border-radius: 50%;
  filter: blur(110px);
  opacity: 0.16;
  pointer-events: none;
}

.ambient-one {
  top: -240px;
  left: -180px;
  background: #4a54ff;
}

.ambient-two {
  right: -240px;
  bottom: -240px;
  background: #00d8ff;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1560px, 100%);
  min-height: 72px;
  margin: 0 auto;
  padding: var(--safe-top) var(--safe-right) 14px var(--safe-left);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: white;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand b {
  color: var(--blue);
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(98, 220, 255, 0.26), rgba(140, 125, 255, 0.16));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.25), 0 8px 24px rgba(0, 0, 0, 0.24);
  color: var(--lime);
  font-size: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.static-badge,
.home-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  color: #dfe3f3;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-decoration: none;
}

.static-badge i {
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 14px var(--lime);
}

.home-link {
  letter-spacing: 0;
}

.ad-zone {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.018);
  color: rgba(255, 255, 255, 0.25);
  text-align: center;
}

.ad-zone > span {
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.ad-zone > div {
  font-size: 11px;
}

.ad-zone-top,
.ad-zone-bottom {
  width: min(970px, calc(100% - 40px));
  min-height: 96px;
  margin: 18px auto 0;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(360px, 510px) minmax(540px, 780px) 180px;
  gap: clamp(22px, 3vw, 48px);
  align-items: center;
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: clamp(28px, 4.8vw, 76px) var(--safe-right) clamp(42px, 6vw, 90px) var(--safe-left);
}

.intro {
  position: relative;
  z-index: 5;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.eyebrow span {
  width: 31px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--blue));
}

h1 {
  margin: 0;
  color: #f7f8ff;
  font-size: clamp(44px, 5vw, 76px);
  font-weight: 850;
  letter-spacing: -0.065em;
  line-height: 1.04;
  word-break: keep-all;
}

h1 em {
  background: linear-gradient(92deg, #80ebff 0%, #b7a7ff 48%, #d9ff78 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-style: normal;
}

.description {
  max-width: 480px;
  margin: 25px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.85;
  word-break: keep-all;
}

.draw-actions {
  display: flex;
  gap: 10px;
  margin-top: 32px;
}

.draw-button {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 14px;
  min-height: 74px;
  padding: 12px 18px;
  overflow: hidden;
  border: 1px solid rgba(203, 255, 104, 0.58);
  border-radius: 19px;
  background: linear-gradient(115deg, #d8ff75, #8ff3bf 50%, #66e6ff);
  box-shadow: 0 18px 50px rgba(120, 233, 190, 0.18), inset 0 1px rgba(255, 255, 255, 0.8);
  color: #06131a;
  cursor: pointer;
  transition: transform 0.22s ease, filter 0.22s ease, opacity 0.22s ease;
  touch-action: manipulation;
}

.draw-button::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.7) 50%, transparent 80%);
  content: "";
  transform: translateX(-120%);
}

.draw-button:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-2px);
}

.draw-button:hover:not(:disabled)::before {
  animation: buttonShine 0.8s ease;
}

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

.draw-button:disabled {
  cursor: wait;
  filter: saturate(0.55);
  opacity: 0.58;
}

.draw-button-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 50%;
  background: #0d1721;
  box-shadow: inset -6px -8px 12px rgba(0, 0, 0, 0.35), inset 5px 4px 10px rgba(255, 255, 255, 0.15);
  color: var(--lime);
  font-size: 14px;
}

.draw-button-copy {
  display: grid;
  flex: 1;
  gap: 2px;
  text-align: left;
}

.draw-button-copy small {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.14em;
  opacity: 0.6;
}

.draw-button-copy strong {
  font-size: 17px;
  letter-spacing: -0.03em;
}

.draw-button-arrow {
  font-size: 22px;
}

.sound-button {
  width: 74px;
  min-width: 74px;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--panel);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
  color: white;
  cursor: pointer;
  font-size: 20px;
  touch-action: manipulation;
}

.status-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.status-light {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffbd5b;
  box-shadow: 0 0 15px #ffbd5b;
  transition: background 0.25s, box-shadow 0.25s;
}

.status-light.ready {
  background: var(--lime);
  box-shadow: 0 0 15px var(--lime);
}

.status-light.drawing {
  background: #6ee7ff;
  box-shadow: 0 0 18px #6ee7ff;
  animation: statusBlink 0.65s ease-in-out infinite alternate;
}

.status-card small,
.result-heading small {
  display: block;
  margin-bottom: 3px;
  color: #68718f;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.status-card strong {
  display: block;
  color: #e6e9f6;
  font-size: 12px;
  font-weight: 750;
}

.rpm {
  min-width: 66px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.rpm strong {
  color: var(--blue);
  font-size: 11px;
}

.result-card {
  margin-top: 18px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(25, 31, 66, 0.82), rgba(11, 15, 34, 0.9));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24), inset 0 1px rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px);
}

.result-card.complete {
  border-color: rgba(98, 220, 255, 0.34);
  box-shadow: 0 20px 70px rgba(36, 183, 255, 0.12), inset 0 1px rgba(255, 255, 255, 0.09);
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.result-heading h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.04em;
}

.result-heading > span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #8d96b4;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.result-balls {
  display: grid;
  grid-template-columns: repeat(6, minmax(40px, 1fr));
  gap: 8px;
  margin-top: 17px;
}

.result-ball {
  position: relative;
  display: grid;
  width: 100%;
  max-width: 58px;
  aspect-ratio: 1;
  place-items: center;
  justify-self: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background:
    radial-gradient(circle at 31% 24%, rgba(255, 255, 255, 0.98) 0 6%, rgba(255, 255, 255, 0.34) 7% 12%, transparent 13%),
    radial-gradient(circle at 66% 72%, rgba(0, 0, 0, 0.48), transparent 44%),
    var(--ball, #252b47);
  box-shadow: inset -8px -10px 14px rgba(0, 0, 0, 0.38), inset 7px 6px 12px rgba(255, 255, 255, 0.26), 0 10px 22px rgba(0, 0, 0, 0.34);
  color: var(--ball-text, white);
  font-size: clamp(15px, 2vw, 20px);
  font-weight: 950;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  transform: perspective(160px) rotateX(-7deg) rotateY(9deg);
}

.result-ball::after {
  position: absolute;
  inset: 23%;
  z-index: -1;
  border-radius: 50%;
  background: rgba(8, 10, 22, 0.45);
  content: "";
}

.result-ball.empty {
  --ball: #202640;
  border-style: dashed;
  color: #626c8a;
  box-shadow: inset -8px -10px 14px rgba(0, 0, 0, 0.28), inset 7px 6px 12px rgba(255, 255, 255, 0.06);
}

.result-ball.revealed {
  animation: resultReveal 0.58s cubic-bezier(0.2, 0.82, 0.2, 1.15) both;
}

.result-card > p {
  margin: 14px 0 0;
  color: #78819d;
  font-size: 11px;
  line-height: 1.55;
}

.machine-column {
  min-width: 0;
}

.machine-stage {
  position: relative;
  height: clamp(620px, 72vw, 790px);
  max-height: 790px;
  overflow: hidden;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 42px;
  background:
    radial-gradient(circle at 50% 36%, rgba(80, 176, 255, 0.11), transparent 44%),
    linear-gradient(160deg, #0d132b, #070a16 68%);
  box-shadow: 0 46px 100px rgba(0, 0, 0, 0.4), inset 0 1px rgba(255, 255, 255, 0.08);
  isolation: isolate;
}

#lottoCanvas {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: pan-y;
  -webkit-touch-callout: none;
  user-select: none;
}

.stage-grid {
  position: absolute;
  z-index: 1;
  inset: 0;
  background:
    linear-gradient(rgba(98, 220, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 220, 255, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, transparent, black 20%, black 76%, transparent);
  pointer-events: none;
}

.stage-label {
  position: absolute;
  z-index: 6;
  top: 22px;
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(7, 10, 22, 0.48);
  color: #727c99;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.1em;
  backdrop-filter: blur(10px);
  pointer-events: none;
}

.stage-label span {
  color: #e9ecf7;
  font-size: 13px;
  letter-spacing: 0;
}

.stage-label-left {
  left: 22px;
}

.stage-label-right {
  right: 22px;
}

.stage-vignette {
  position: absolute;
  z-index: 5;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 110px rgba(0, 0, 0, 0.42), inset 0 -80px 100px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.loading-panel {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  background: #090d1e;
  text-align: center;
  transition: opacity 0.55s ease, visibility 0.55s;
}

.loading-panel.hidden {
  visibility: hidden;
  opacity: 0;
}

.loading-panel strong {
  margin-top: 9px;
  font-size: 15px;
}

.loading-panel small {
  color: #747d98;
  font-size: 11px;
}

.loading-orbit {
  position: relative;
  width: 54px;
  height: 54px;
  border: 1px solid rgba(98, 220, 255, 0.34);
  border-radius: 50%;
  animation: orbitSpin 1.2s linear infinite;
}

.loading-orbit::before {
  position: absolute;
  top: -5px;
  left: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 20px var(--lime);
  content: "";
}

.interaction-hint {
  margin: 13px 0 0;
  color: #646d89;
  font-size: 10px;
  text-align: center;
}

.interaction-hint span {
  display: inline-block;
  margin-right: 5px;
  color: var(--blue);
}

.ad-zone-side {
  align-self: stretch;
  min-height: 600px;
}

.ad-zone-bottom {
  min-height: 112px;
  margin-top: 0;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: min(1560px, 100%);
  margin: 44px auto 0;
  padding: 24px var(--safe-right) var(--safe-bottom) var(--safe-left);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  color: #555e78;
  font-size: 10px;
}

footer p {
  margin: 0;
}

.noscript-message {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  padding: 15px 18px;
  border: 1px solid #ff8298;
  border-radius: 14px;
  background: #22111b;
  color: white;
}

@keyframes buttonShine {
  to { transform: translateX(120%); }
}

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

@keyframes statusBlink {
  to { opacity: 0.4; }
}

@keyframes resultReveal {
  0% { opacity: 0; transform: perspective(160px) translateY(18px) rotateX(-40deg) scale(0.45); }
  65% { opacity: 1; transform: perspective(160px) translateY(-4px) rotateX(5deg) scale(1.08); }
  100% { opacity: 1; transform: perspective(160px) rotateX(-7deg) rotateY(9deg) scale(1); }
}

@media (max-width: 1320px) {
  .page-shell {
    grid-template-columns: minmax(340px, 0.82fr) minmax(520px, 1.18fr);
    max-width: 1240px;
  }

  .ad-zone-side {
    display: none;
  }
}

@media (max-width: 900px) {
  .ad-zone-top {
    min-height: 78px;
  }

  .page-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 34px;
    max-width: 720px;
    padding-top: 42px;
  }

  .intro {
    display: contents;
  }

  .eyebrow,
  h1,
  .description,
  .draw-actions,
  .status-card {
    grid-column: 1;
  }

  .machine-column {
    grid-row: 6;
  }

  .result-card {
    grid-row: 7;
    margin-top: 0;
  }

  .machine-stage {
    height: min(740px, 112vw);
    min-height: 570px;
  }

  h1 {
    font-size: clamp(46px, 9vw, 70px);
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 62px;
  }

  .static-badge {
    display: none;
  }

  .home-link {
    min-height: 34px;
    padding-inline: 11px;
  }

  .ad-zone-top,
  .ad-zone-bottom {
    width: calc(100% - 28px);
    min-height: 72px;
    border-radius: 14px;
  }

  .page-shell {
    gap: 27px;
    padding: 36px 14px 50px;
  }

  .eyebrow {
    margin-bottom: 13px;
    font-size: 9px;
  }

  h1 {
    font-size: clamp(39px, 12.5vw, 56px);
  }

  .description {
    margin-top: 18px;
    font-size: 13px;
    line-height: 1.72;
  }

  .draw-actions {
    margin-top: 25px;
  }

  .draw-button,
  .sound-button {
    min-height: 66px;
    border-radius: 17px;
  }

  .sound-button {
    width: 66px;
    min-width: 66px;
  }

  .draw-button-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .draw-button-copy strong {
    font-size: 15px;
  }

  .draw-button-arrow {
    display: none;
  }

  .status-card {
    grid-template-columns: auto 1fr;
  }

  .rpm {
    display: none;
  }

  .machine-stage {
    height: 128vw;
    min-height: 500px;
    max-height: 640px;
    border-radius: 28px;
  }

  .stage-label {
    top: 15px;
  }

  .stage-label-left {
    left: 15px;
  }

  .stage-label-right {
    right: 15px;
  }

  .result-card {
    padding: 16px 13px;
  }

  .result-balls {
    gap: 5px;
  }

  .result-ball {
    font-size: clamp(13px, 4vw, 18px);
  }

  footer {
    display: grid;
    gap: 8px;
    margin-top: 30px;
    padding-inline: 16px;
    line-height: 1.5;
  }
}

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