:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: rgba(13, 28, 47, 0.72);
  --surface-strong: #101f34;
  --line: rgba(170, 204, 230, 0.14);
  --muted: #8fa4ba;
  --text: #f7fbff;
  --gold: #f6c85f;
  --gold-deep: #e9a93a;
  --cyan: #62d9e8;
  --green: #69d7ae;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -10%, rgba(37, 107, 139, 0.18), transparent 40%),
    linear-gradient(180deg, #081523 0%, var(--bg) 55%, #050d18 100%);
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.ambient { position: fixed; border-radius: 50%; filter: blur(90px); pointer-events: none; opacity: .22; z-index: -1; }
.ambient-one { width: 360px; height: 360px; background: #0ea5b7; top: 22%; left: -220px; }
.ambient-two { width: 420px; height: 420px; background: #ae7d2a; top: 48%; right: -300px; }

.topbar {
  width: min(1180px, calc(100% - 40px));
  height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-size: 19px; font-weight: 850; letter-spacing: -.045em; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; position: relative; }
.brand-mark span { position: absolute; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset -2px -3px 5px rgba(0,0,0,.24); }
.brand-mark span:nth-child(1) { background: #f2c85e; left: 2px; top: 8px; }
.brand-mark span:nth-child(2) { background: #5bcbdc; right: 1px; top: 2px; }
.brand-mark span:nth-child(3) { background: #ef7185; right: 3px; bottom: 1px; }
.sound-button { width: 42px; height: 42px; display: grid; place-items: center; color: #a7b8c9; background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 13px; cursor: pointer; transition: .2s ease; }
.sound-button:hover { color: white; background: rgba(255,255,255,.08); }
.sound-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-button .sound-on { display: none; }
.sound-button[aria-pressed="true"] .sound-on { display: block; }
.sound-button[aria-pressed="true"] .sound-off { display: none; }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.intro { padding: 68px 0 52px; text-align: center; }
.intro h1 { margin: 0; font-size: clamp(48px, 6.5vw, 78px); line-height: 1.08; letter-spacing: -.06em; font-weight: 900; }
.intro h1 em { color: var(--gold); font-style: normal; }
.jackpot-break { display: none; }

.draw-layout { display: grid; grid-template-columns: minmax(0, 1.07fr) minmax(390px, .93fr); gap: 22px; align-items: stretch; }
.machine-card, .control-card, .history-section { position: relative; border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(145deg, rgba(19,40,64,.78), rgba(7,20,35,.78)); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.machine-card { min-height: 640px; padding: 26px; overflow: hidden; }
.machine-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 35%, rgba(71, 180, 201, .09), transparent 47%); pointer-events: none; }
.machine-head, .control-head, .history-head { position: relative; display: flex; justify-content: space-between; align-items: center; }
.section-kicker, .step { color: #7291a9; font-size: 10px; line-height: 1; font-weight: 800; letter-spacing: .18em; }
.machine-head h2, .control-head h2, .history-head h2 { margin: 7px 0 0; font-size: 20px; letter-spacing: -.03em; }
.live-chip { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid rgba(101,216,175,.19); border-radius: 20px; color: #8bdec0; background: rgba(50,153,119,.07); font-size: 11px; font-weight: 700; }
.live-chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.live-chip.active i { animation: livePulse 1s infinite; }

.machine-wrap { width: min(420px, 91%); aspect-ratio: 1 / 1.1; margin: 18px auto -1px; position: relative; }
#lottoMachine { position: absolute; width: 88%; aspect-ratio: 1; left: 6%; top: 0; border-radius: 50%; z-index: 2; }
.machine-rim { position: absolute; width: 91%; aspect-ratio: 1; left: 4.5%; top: -1.4%; border: 8px solid rgba(174,217,230,.17); border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255,255,255,.22), 0 0 28px rgba(67,204,227,.08); z-index: 3; pointer-events: none; }
.machine-highlight { position: absolute; width: 31%; height: 10%; left: 20%; top: 8%; border-radius: 50%; border-top: 2px solid rgba(255,255,255,.58); transform: rotate(-20deg); z-index: 4; opacity: .6; }
.machine-glow { position: absolute; inset: 9% 10% 14%; border-radius: 50%; background: rgba(69,197,215,.18); filter: blur(36px); }
.machine-chute { position: absolute; width: 27%; height: 22%; right: 5%; bottom: 4%; transform: rotate(-26deg); z-index: 4; background: linear-gradient(90deg, #12283a, #31506a 48%, #102435); border: 2px solid rgba(191,225,235,.23); border-radius: 15px 15px 26px 26px; box-shadow: inset 8px 0 15px rgba(255,255,255,.05), 4px 10px 20px rgba(0,0,0,.3); }
.machine-chute span { position: absolute; width: 122%; height: 28%; left: -11%; bottom: -5%; background: linear-gradient(#29465e, #0b1928); border: 2px solid rgba(191,225,235,.2); border-radius: 50%; }
.machine-base { position: absolute; left: 18%; right: 18%; bottom: 0; height: 20%; display: grid; place-items: center; background: linear-gradient(160deg, #1d3850, #0b1828 68%); border: 1px solid rgba(174,217,230,.2); clip-path: polygon(12% 0,88% 0,100% 100%,0 100%); box-shadow: inset 0 2px 0 rgba(255,255,255,.08); z-index: 1; }
.machine-base span { margin-top: 38px; color: rgba(164,195,215,.4); font-size: 9px; font-weight: 800; letter-spacing: .25em; }

.result-stage { position: relative; padding-top: 17px; border-top: 1px solid rgba(255,255,255,.07); text-align: center; z-index: 5; }
.result-label { margin: 0 0 12px; color: #8096aa; font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.result-balls { display: flex; min-height: 52px; justify-content: center; align-items: center; gap: clamp(6px, 1.4vw, 11px); }
.empty-ball, .lotto-ball { width: clamp(40px, 5.6vw, 50px); height: clamp(40px, 5.6vw, 50px); flex: 0 0 auto; border-radius: 50%; }
.empty-ball { border: 1px dashed rgba(154,183,203,.22); background: rgba(255,255,255,.018); }
.lotto-ball { position: relative; display: grid; place-items: center; color: #fff; font-size: 18px; font-weight: 850; text-shadow: 0 1px 3px rgba(0,0,0,.38); box-shadow: inset -5px -7px 10px rgba(0,0,0,.19), inset 4px 4px 7px rgba(255,255,255,.3), 0 8px 16px rgba(0,0,0,.23); animation: ballArrive .48s cubic-bezier(.2,1.8,.4,1) both; }
.lotto-ball::before { content: ""; position: absolute; width: 32%; height: 19%; left: 20%; top: 12%; border-radius: 50%; background: rgba(255,255,255,.48); filter: blur(1px); transform: rotate(-25deg); }
.lotto-ball.pinned::after { content: "✓"; position: absolute; width: 15px; height: 15px; right: -2px; top: -2px; display: grid; place-items: center; border-radius: 50%; color: #07111f; background: #fff; border: 2px solid #13263c; font-size: 9px; text-shadow: none; }
.result-hint { min-height: 18px; margin: 11px 0 0; color: #71879b; font-size: 11px; }
.result-balls.multi { width: min(430px, 100%); min-height: 0; margin: 0 auto; display: grid; gap: 7px; }
.game-row { display: grid; grid-template-columns: 25px repeat(6, 1fr); align-items: center; gap: 4px; min-height: 46px; padding: 4px 7px 4px 5px; border-radius: 13px; background: rgba(255,255,255,.025); opacity: .5; transition: opacity .2s ease, background .2s ease; }
.game-row.revealed { opacity: 1; background: rgba(255,255,255,.045); }
.game-index { display: grid; place-items: center; width: 25px; height: 25px; color: #7790a6; border-radius: 8px; background: rgba(255,255,255,.045); font-size: 11px; font-weight: 850; }
.game-row.revealed .game-index { color: #121722; background: var(--gold); }
.game-row .empty-ball, .game-row .lotto-ball { width: min(9.5vw, 40px); height: min(9.5vw, 40px); justify-self: center; }
.game-row .lotto-ball { font-size: 13px; }
.game-row .lotto-ball.pinned::after { width: 11px; height: 11px; font-size: 7px; border-width: 1px; }

.control-card { padding: 28px; }
.step { color: var(--gold); }
.selection-count { display: flex; align-items: baseline; gap: 3px; color: #668097; }
.selection-count strong { color: #fff; font-size: 25px; }
.selection-count span { font-size: 13px; }
.control-copy { margin: 14px 0 18px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.selected-slots { height: 54px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; padding: 8px; border: 1px solid rgba(255,255,255,.07); border-radius: 16px; background: rgba(0,0,0,.12); }
.selected-slots span { display: grid; place-items: center; min-width: 0; border-radius: 10px; color: #07111f; background: rgba(255,255,255,.035); font-size: 13px; font-weight: 850; transition: .22s ease; }
.selected-slots span.filled { background: var(--gold); box-shadow: inset -3px -4px 7px rgba(152,91,14,.22), 0 4px 12px rgba(242,194,81,.15); transform: scale(1.03); }
.picker-toolbar { margin: 19px 2px 10px; display: flex; justify-content: space-between; align-items: center; }
.picker-toolbar span { color: #6f879d; font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.picker-toolbar button, .history-head button { padding: 0; border: 0; color: #8297aa; background: none; font-size: 11px; cursor: pointer; }
.picker-toolbar button:hover, .history-head button:hover { color: #fff; }
.number-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.number-button { aspect-ratio: 1; min-width: 0; border: 1px solid rgba(153,184,205,.11); border-radius: 50%; color: #b7c7d4; background: rgba(255,255,255,.025); font-size: 12px; font-weight: 700; cursor: pointer; transition: transform .14s ease, color .14s ease, background .14s ease, border-color .14s ease; }
.number-button:hover { color: white; border-color: rgba(246,200,95,.5); background: rgba(246,200,95,.07); }
.number-button:active { transform: scale(.9); }
.number-button.selected { color: #07111f; border-color: var(--gold); background: var(--gold); font-weight: 850; box-shadow: 0 3px 12px rgba(246,200,95,.22); transform: scale(1.04); }
.number-button:disabled { cursor: not-allowed; opacity: .38; }
.number-button.selected:disabled { opacity: 1; }
.game-count-setting { margin-top: 19px; padding: 11px 12px 11px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid rgba(255,255,255,.07); border-radius: 15px; background: rgba(0,0,0,.1); }
.game-count-copy { display: grid; gap: 3px; }
.game-count-copy strong { color: #dce8f1; font-size: 12px; }
.game-count-copy span { color: #71879b; font-size: 9px; }
.game-count-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px; border-radius: 11px; background: rgba(255,255,255,.04); }
.game-count-toggle button { min-width: 58px; padding: 8px 10px; border: 0; border-radius: 8px; color: #8197aa; background: transparent; font-size: 10px; font-weight: 750; cursor: pointer; transition: .18s ease; }
.game-count-toggle button.active { color: #111722; background: var(--gold); box-shadow: 0 3px 10px rgba(236,177,54,.19); }
.game-count-toggle button:disabled { cursor: wait; }
.draw-summary { margin: 20px 0 14px; padding: 12px 15px; display: flex; justify-content: space-around; align-items: center; border-radius: 14px; background: rgba(255,255,255,.025); }
.draw-summary div { display: flex; align-items: baseline; gap: 7px; }
.draw-summary span { color: #7f95a8; font-size: 11px; }
.draw-summary strong { color: #dce8f1; font-size: 12px; }
.draw-summary i { width: 1px; height: 20px; background: rgba(255,255,255,.08); }
.draw-button { width: 100%; min-height: 68px; display: flex; align-items: center; padding: 10px 16px; color: #10131a; border: 0; border-radius: 18px; background: linear-gradient(135deg, #ffe294, var(--gold) 46%, var(--gold-deep)); box-shadow: 0 12px 28px rgba(221,161,42,.22), inset 0 1px 0 rgba(255,255,255,.64); cursor: pointer; transition: transform .18s ease, box-shadow .18s ease, filter .18s ease; }
.draw-button:hover { transform: translateY(-2px); filter: brightness(1.04); box-shadow: 0 16px 35px rgba(221,161,42,.3), inset 0 1px 0 rgba(255,255,255,.64); }
.draw-button:active { transform: translateY(1px) scale(.99); }
.draw-button:disabled { cursor: wait; filter: saturate(.55); transform: none; }
.button-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: rgba(255,255,255,.34); }
.button-icon svg, .button-arrow { width: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button-icon svg.spinning { animation: spin .8s linear infinite; }
.button-copy { display: grid; gap: 3px; margin-left: 13px; text-align: left; }
.button-copy strong { font-size: 15px; letter-spacing: -.02em; }
.button-copy small { color: rgba(16,19,26,.62); font-size: 10px; }
.button-arrow { margin-left: auto; }
.draw-note { margin: 13px 0 0; display: flex; justify-content: center; align-items: center; gap: 5px; color: #64798c; font-size: 9px; }
.draw-note svg { width: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.history-section { margin-top: 22px; padding: 25px 28px 28px; }
.history-list { margin-top: 18px; display: grid; gap: 9px; }
.history-item { display: flex; align-items: center; padding: 12px 14px; border: 1px solid rgba(255,255,255,.06); border-radius: 15px; background: rgba(255,255,255,.025); }
.history-time { width: 94px; color: #74899d; font-size: 10px; }
.history-game-label { width: 23px; height: 23px; margin-right: 9px; display: grid; place-items: center; flex: 0 0 auto; color: #111722; border-radius: 7px; background: var(--gold); font-size: 9px; font-weight: 850; }
.history-balls { display: flex; gap: 7px; }
.history-ball { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; color: white; font-size: 12px; font-weight: 850; text-shadow: 0 1px 2px rgba(0,0,0,.3); box-shadow: inset -3px -4px 6px rgba(0,0,0,.18); }
.history-ball.pinned { outline: 1px solid rgba(255,255,255,.6); outline-offset: 2px; }
.copy-button { margin-left: auto; width: 34px; height: 34px; display: grid; place-items: center; color: #788fa3; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.copy-button:hover { color: #fff; background: rgba(255,255,255,.06); }
.copy-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; }

footer { width: min(1180px, calc(100% - 40px)); margin: 48px auto 0; padding: 24px 0 calc(32px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.06); color: #566c80; font-size: 10px; }
footer p { margin: 0; }
.footer-logo { color: var(--gold); margin-right: 5px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 20; padding: 11px 16px; color: #0a1522; background: #eff8ff; border-radius: 12px; box-shadow: 0 12px 35px rgba(0,0,0,.35); font-size: 12px; font-weight: 750; transform: translate(-50%, 25px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@keyframes livePulse { 50% { opacity: .35; transform: scale(.7); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ballArrive { from { opacity: 0; transform: translateY(-18px) scale(.55) rotate(-30deg); } to { opacity: 1; transform: translateY(0) scale(1) rotate(0); } }

@media (max-width: 860px) {
  .draw-layout { grid-template-columns: 1fr; }
  .machine-card { min-height: auto; }
  .machine-wrap { max-width: 430px; }
  .control-card { padding: 27px; }
}

@media (max-width: 520px) {
  .topbar, main, footer { width: min(100% - 24px, 1180px); }
  .topbar { height: 64px; }
  .brand { gap: 9px; font-size: 18px; }
  .brand-mark { width: 30px; height: 30px; }
  .sound-button { width: 38px; height: 38px; border-radius: 12px; }
  .intro { padding: 52px 6px 42px; }
  .intro h1 { font-size: clamp(43px, 12.2vw, 52px); line-height: 1.12; }
  .jackpot-break { display: initial; }
  .machine-card, .control-card, .history-section { border-radius: 23px; }
  .machine-card { padding: 21px 16px 23px; }
  .machine-head { padding: 0 4px; }
  .machine-wrap { width: 100%; margin-top: 16px; }
  .machine-rim { border-width: 6px; }
  .machine-base span { margin-top: 28px; }
  .result-balls { gap: 7px; }
  .empty-ball, .lotto-ball { width: min(12.4vw, 46px); height: min(12.4vw, 46px); }
  .lotto-ball { font-size: 17px; }
  .control-card { padding: 24px 18px 20px; }
  .control-copy { font-size: 12px; }
  .selected-slots { gap: 6px; }
  .number-grid { gap: 6px; }
  .number-button { font-size: 11px; }
  .draw-button { min-height: 66px; }
  .history-section { padding: 22px 16px; }
  .history-item { padding: 11px 9px; }
  .history-time { display: none; }
  .history-game-label { margin-right: 7px; }
  .history-balls { gap: 5px; }
  .history-ball { width: min(8.7vw, 34px); height: min(8.7vw, 34px); font-size: 11px; }
  footer { margin-top: 32px; }
}

@media (max-width: 350px) {
  .number-grid { gap: 4px; }
  .history-ball { width: 27px; height: 27px; }
  .copy-button { width: 29px; }
}

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