:root {
  color-scheme: dark;
  --bg: #120d20; --line: #40334c; --text: #fff7fb; --muted: #cbbfd3;
  --accent: #ffb18c; --accent-light: #ffd9b9; --pink: #ff8dc1; --gold: #ffdd87;
  --display: 'Tektur', 'Montserrat', system-ui, sans-serif; --body: 'Montserrat', system-ui, sans-serif;
  --wheel-size: min(100%, 358px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); -webkit-tap-highlight-color: transparent; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; font: 400 16px/1.55 var(--body); color: var(--text); background: var(--bg); overflow-x: hidden;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: inherit; }
button, a, summary { touch-action: manipulation; }
button { font-family: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; }
.tabs, .stage, .cta, .chip, .ghost { -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.skip { position: fixed; z-index: 20; top: 8px; left: 8px; padding: 10px 14px; border-radius: 8px; background: #151520; }
.skip:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; padding: 0; }

.backdrop { position: absolute; z-index: 0; inset: 0 0 auto; height: min(790px, 75vw); pointer-events: none; }
.backdrop img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.backdrop::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #110b1b3b 0%, #120d2033 40%, var(--bg) 100%), linear-gradient(90deg, #120d20bb 0%, #120d2000 68%); }

.top, .layout, .foot { position: relative; z-index: 1; width: min(1180px, calc(100% - 2 * clamp(14px, 4.5vw, 64px))); margin-inline: auto; }
.top { height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #ffffff1a; }
.brand { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; text-decoration: none; font: 700 clamp(.82rem, 2.4vw, 1rem)/1 var(--display); letter-spacing: .06em; white-space: nowrap; }
.brand b { color: var(--accent); font-weight: 700; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 4px; background: var(--accent); color: #000; font: 700 .68rem/1 var(--display); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.chip { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: #ffffff08; color: var(--muted); font: 600 .78rem/1 var(--body); text-decoration: none; transition: color .2s, border-color .2s, background .2s; }
@media (hover: hover) { .chip:hover { color: #fff; border-color: #3c3c52; background: #ffffff10; } }
.chip svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#sound .wave, #sound .mute { display: none; }
#sound[aria-pressed=true] .wave { display: inline; }
#sound[aria-pressed=false] .mute { display: inline; }
#sound[aria-pressed=true] { color: var(--accent-light); border-color: #ff9d8f66; }

.layout { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); grid-template-areas: "head machine" "side machine" "rules rules"; gap: 22px clamp(24px, 4.5vw, 64px); align-items: start; padding-block: clamp(28px, 4.4vw, 64px) 44px; }
.head { grid-area: head; min-width: 0; } .machine { grid-area: machine; } .side { grid-area: side; min-width: 0; } .rules { grid-area: rules; }
.eyebrow { margin: 0; color: var(--accent); font: 700 .74rem/1.4 var(--display); letter-spacing: .2em; text-transform: uppercase; }
.head h1 { margin: 10px 0 16px; font: 800 clamp(3.2rem, 6.1vw, 6rem)/.92 var(--display); letter-spacing: -.045em; text-transform: uppercase; text-wrap: balance; }
.head h1 span { display: block; background: linear-gradient(100deg, var(--accent) 10%, #ff9ac9 45%, #dcc2ff 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 6px 36px #ff9d8f33; }
.lead { max-width: 40ch; margin: 0; color: var(--muted); font-size: 1.02rem; }
.side h2 { margin: 0 0 12px; font: 700 1.18rem/1.2 var(--display); }
.prizes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.prizes li { display: grid; place-items: center; grid-template-rows: minmax(0, 1fr) auto; gap: 4px; padding: 8px 4px 12px; min-width: 0; text-align: center; border: 1px solid #efd5ff24; border-radius: 13px; background: radial-gradient(ellipse at 50% 40%, #68385d88, transparent 72%), #1a1429eb; }
.prizes li:nth-child(even) { background: radial-gradient(ellipse at 50% 40%, #523b8a88, transparent 72%), #1a1429eb; }
.prizes img { display: block; width: min(100%, 86px); height: auto; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 6px 7px #0c061bb0); }
.prizes b { font: 700 clamp(.73rem, 1.25vw, .9rem)/1.2 var(--display); }
.mode-note { margin: 0 0 12px; padding: 9px 12px; border: 1px solid #ffd36b55; border-radius: 10px; background: #ffd36b12; color: #ffe3a0; font-size: .8rem; line-height: 1.4; }
.notice { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; border: 1px solid #ffffff2a; background: #ffffff0d; color: #e6e9f0; font-size: .86rem; line-height: 1.4; text-align: center; }
.soldout { margin: 14px 0 0; padding: 16px; border-radius: 14px; border: 1px solid #ffd36b66; background: linear-gradient(160deg, #ffd36b1c, #8a2cff14); }
.soldout h2 { margin: 4px 0 8px; font: 800 1.25rem/1.15 var(--display); text-transform: uppercase; }
.soldout p { margin: 0 0 12px; color: #e6e9f0; font-size: .88rem; line-height: 1.5; }
.soldout .eyebrow { color: #ffd36b; margin-bottom: 0; }
.soldout .actions { margin-top: 4px; }
.soldout .soldout-note { margin: 10px 0 0; min-height: 1.2em; color: var(--muted); font-size: .8rem; }
.foot small { color: #7d8392; font-size: .72rem; line-height: 1.6; }

.machine { position: relative; min-width: 0; padding: clamp(14px, 3vw, 26px); border-radius: 22px; border: 1px solid #ad83a956; background: radial-gradient(ellipse at 75% 8%, #44234c77, transparent 68%), linear-gradient(160deg, #231831 0%, #141022 68%); box-shadow: 0 28px 80px #0c031cb0, inset 0 1px 0 #ffffff18; }
.machine::before { content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: 23px; background: linear-gradient(135deg, #8a2cff88, transparent 38%, transparent 62%, #ff9d8f88); filter: blur(14px); opacity: .5; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 12px; background: #120d20; border: 1px solid var(--line); }
.tab { white-space: nowrap; min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: 700 .86rem/1 var(--display); letter-spacing: .04em; text-transform: uppercase; transition: color .2s, background .2s; }
@media (hover: hover) { .tab:hover { color: #fff; } }
.tab[aria-selected=true] { background: #36243e; color: #fff; box-shadow: inset 0 0 0 1px #65436a; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; padding: 0 5px; border-radius: 10px; background: var(--accent); color: #281329; font: 700 .7rem/1 var(--body); }

.stage { position: relative; display: grid; place-items: center; padding: 10px; isolation: isolate; border-radius: 16px; border: 1px solid #c494bc23; background: radial-gradient(ellipse at 50% 53%, #472341cc 0%, #221834 54%, #151021 83%); }
.wheel-frame { position: relative; display: grid; place-items: center; width: var(--wheel-size); aspect-ratio: 1; padding: 7px; border-radius: 50%; border: 1px solid #ffd5b873; background: linear-gradient(145deg, #ffe2a8, #ac5a90 25%, #33204c 57%, #f29d9f 80%, #ffcda1); box-shadow: 0 0 30px #ff7ca435, 0 12px 24px #0a0613a8; }
.wheel { position: absolute; inset: 7px; aspect-ratio: 1; border-radius: 50%; border: 2px solid #201029; background:
  radial-gradient(circle, #160c29 0% 15%, transparent 16% 84%, #ffd3ad66 85%, #1c112b 86%),
  repeating-conic-gradient(from -20deg, #ffdfbd77 0 1.2deg, transparent 1.2deg 40deg),
  conic-gradient(from -20deg, #573e7b 0 40deg, #794366 40deg 80deg, #652c65 80deg 120deg, #733780 120deg 160deg, #793a68 160deg 200deg, #4c336f 200deg 240deg, #6c376f 240deg 280deg, #4c3b81 280deg 320deg, #775049 320deg); }
.tile { position: absolute; left: var(--x); top: var(--y); display: grid; justify-items: center; gap: 1px; min-width: 30px; padding: 3px; transform: translate(-50%, -50%) rotate(var(--counter, 0deg)); text-align: center; color: #fff5f9; text-shadow: 0 2px 6px #150c21; }
.tile svg { width: clamp(21px, 5.9vw, 30px); height: clamp(21px, 5.9vw, 30px); fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile b { font: 800 clamp(.68rem, 2.3vw, .96rem)/1 var(--display); }
.tile[data-rarity=epic] { color: var(--gold); }
.tile.win { color: #fff1c7; text-shadow: 0 0 10px #ffe090; outline: 1px solid #fedfa2; border-radius: 8px; background: #341c4ad9; box-shadow: 0 0 16px #ffd5977a; }
.hub { position: absolute; z-index: 1; display: grid; place-items: center; width: 21%; aspect-ratio: 1; border-radius: 50%; border: 1px solid #ffd4ae9e; color: #fff0da; font: 800 clamp(.8rem, 4vw, 1.48rem)/1 var(--display); background: radial-gradient(circle at 36% 20%, #a66883, #402648 55%, #241834); box-shadow: 0 2px 16px #170d25, inset 0 0 0 4px #301b43; }
.needle { position: absolute; z-index: 2; top: -6px; left: 50%; width: 28px; height: 26px; transform: translateX(-50%); background: linear-gradient(160deg, #fff1be 12%, #ffbd87 75%); clip-path: polygon(0 0, 100% 0, 50% 100%); }
.stage.charging .needle { background: #fff0b9; }
.stage.charging .hub { box-shadow: 0 0 20px #ffba827a, inset 0 0 0 4px #301b43; }
.cta { position: relative; display: block; width: 100%; min-height: 58px; margin-top: 16px; padding: 10px 20px; overflow: hidden; border: 0; border-radius: 12px; background: linear-gradient(105deg, #ffd8a1, #ffa991 52%, #fb84bd); color: #281329; font: 800 clamp(.98rem, 3vw, 1.18rem)/1.2 var(--display); letter-spacing: .05em; text-transform: uppercase; box-shadow: 0 0 34px #ff9d8f55, inset 0 -3px 0 #00000026; transition: transform .15s, box-shadow .2s, background .2s; }
.cta::after { content: ""; position: absolute; inset: 0; transform: translateX(-120%) skewX(-18deg); background: linear-gradient(90deg, transparent, #ffffff66, transparent); animation: sweep 3.2s ease-in-out infinite; }
@media (hover: hover) { .cta:hover:not(:disabled) { background: linear-gradient(105deg, #ffe5b9, #ffbfaa 52%, #ffa1cf); box-shadow: 0 0 46px #ff9d8f88, inset 0 -3px 0 #00000026; } }
.cta:active:not(:disabled) { transform: translateY(1px) scale(.995); }
.cta:disabled { cursor: default; background: #171722; color: #b8bdca; box-shadow: inset 0 0 0 1px #2e2e42; }
.cta:disabled::after { display: none; }
@keyframes sweep { 0%, 55% { transform: translateX(-120%) skewX(-18deg); } 100% { transform: translateX(120%) skewX(-18deg); } }
.status { min-height: 1.5em; margin: 10px 0 0; text-align: center; color: var(--muted); font-size: .85rem; }
.status.err { color: #ffb3a8; }

.result { margin-top: 16px; padding: clamp(16px, 3vw, 22px); border-radius: 16px; border: 1px solid #ff9d8f66; background: linear-gradient(145deg, #462641, #21162f 68%); animation: pop .5s cubic-bezier(.2, .9, .3, 1.2); }
.result[data-rarity=rare] { border-color: #8a2cff88; background: linear-gradient(150deg, #20103f, #130d20 60%); }
.result[data-rarity=epic] { border-color: #ff5ec888; background: linear-gradient(150deg, #3a1230, #1c0f18 60%); }
.result[data-rarity=none] { border-color: #34344a; background: #101018; }
.result-head { display: flex; align-items: center; gap: clamp(8px, 3vw, 20px); }
.result-head > div { min-width: 0; }
.result-art { flex: none; width: clamp(68px, 22vw, 120px); height: auto; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 6px 9px #10091eaf); }
.result h2 { margin: 6px 0 2px; font: 800 clamp(1.6rem, 5vw, 2.2rem)/1.05 var(--display); text-transform: uppercase; letter-spacing: -.01em; }
.result h2:focus { outline: none; }
.caption { margin: 0; color: var(--muted); font-size: .9rem; }
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding: 12px 14px; border-radius: 12px; border: 1px dashed #ffffff3d; background: #00000040; }
.label { display: block; color: var(--muted); font: 600 .68rem/1 var(--body); letter-spacing: .14em; text-transform: uppercase; margin-bottom: 6px; }
code { -webkit-user-select: all; user-select: all; font: 700 clamp(1.15rem, 4.6vw, 1.55rem)/1.1 ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; letter-spacing: .06em; color: #fff; overflow-wrap: anywhere; }
.ghost { min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #ffffff3a; background: #ffffff10; color: #fff; font: 700 .82rem/1 var(--body); transition: background .2s; }
@media (hover: hover) { .ghost:hover { background: #ffffff20; } }
.left { margin: 10px 0 0; color: #d6dae3; font-size: .86rem; }
.hint { margin: 4px 0 12px; color: var(--muted); font-size: .84rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ghost.wide { padding: 0 16px; }
.tg { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #26a5e480; color: #6fcdf7; font: 700 .84rem/1 var(--body); text-decoration: none; transition: background .2s, color .2s; }
@media (hover: hover) { .tg:hover { background: #26a5e4; color: #00131c; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

.bag { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.bag li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line); background: #0a0a10; }
.bag li[data-state=active] { border-color: #ff9d8f66; background: #251932; }
.bag .name { font: 700 1.02rem/1.2 var(--display); text-transform: uppercase; }
.bag code { grid-column: 1; font-size: 1.02rem; }
.bag .meta { grid-column: 1; color: var(--muted); font-size: .8rem; }
.bag .pill { grid-row: 1 / span 2; grid-column: 2; align-self: center; padding: 5px 10px; border-radius: 999px; font: 700 .7rem/1 var(--body); letter-spacing: .05em; text-transform: uppercase; background: #ffffff10; color: var(--muted); }
.bag li[data-state=active] .pill { background: #ff9d8f22; color: var(--accent-light); }
.bag-empty { margin: 0; padding: 22px 8px; text-align: center; color: var(--muted); font-size: .9rem; }

.rules { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.rules details { border: 1px solid var(--line); border-radius: 12px; background: #1a1327; padding: 0 16px; align-self: start; }
.rules summary { min-height: 52px; display: flex; align-items: center; cursor: pointer; font-weight: 700; font-size: .92rem; }
.rules p { margin: 0 0 16px; color: var(--muted); font-size: .88rem; }
.foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 20px 0 30px; border-top: 1px solid #ffffff14; color: var(--muted); font-size: .78rem; }
.foot a { text-decoration: none; }
.foot a:hover { color: #fff; }
#confetti { position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%; pointer-events: none; }

@media (min-width: 881px) and (min-height: 521px) {
  /* Keep the intro at its own height when a result adds height to the wheel column. */
  .layout { grid-template-rows: max-content 1fr auto; }
}
@media (max-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "machine" "side" "rules"; max-width: 620px; gap: 16px; padding-top: 14px; padding-bottom: 28px; }
  .head h1 { margin: 6px 0 8px; font-size: clamp(2.1rem, 9.4vw, 3.4rem); line-height: .96; }
  .head h1 span { display: inline; }
  .lead { max-width: none; font-size: .92rem; line-height: 1.45; }
  .eyebrow { font-size: .7rem; }
  .machine { padding: 12px; border-radius: 18px; }
  .tabs { margin-bottom: 10px; }
  .stage { margin-top: 0; }
  .cta { margin-top: 12px; min-height: 56px; }
  :root { --wheel-size: min(100%, 310px); }
  .backdrop { height: 580px; }
  .backdrop img { object-position: 70% 50%; }
  .rules { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .code-box { flex-direction: column; align-items: stretch; }
  .code-box .ghost { width: 100%; }
  .actions { flex-direction: column; }
  .actions > * { width: 100%; }
  .top { height: 56px; }
}
@media (max-width: 420px) {
  #sound-label { display: none; }
  #sound { padding: 0 12px; }
  .cta:disabled { font-size: clamp(.82rem, 3.6vw, 1rem); letter-spacing: .03em; }
}
@media (max-width: 380px) {
  .top-actions { gap: 6px; }
  .top-actions .chip { padding: 0 10px; font-size: .72rem; }
  .top-actions .chip > span[aria-hidden] { display: none; }
  .brand { font-size: .78rem; gap: 6px; }
  .tab { font-size: .76rem; letter-spacing: .02em; }
}
/* низкий телефон стоя: описание прячем, чтобы колесо и кнопка остались на первом экране */
@media (max-width: 880px) and (max-height: 720px) and (orientation: portrait) {
  :root { --wheel-size: min(100%, 280px, max(175px, calc(100dvh - 355px))); }
  .head .lead { display: none; }
  .head h1 { margin-bottom: 0; }
  .layout { gap: 12px; }
  .mode-note { margin-bottom: 8px; padding: 7px 10px; font-size: .74rem; }
  .mode-note span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
}
/* телефон лёжа: заголовок слева, колесо справа — всё без прокрутки */
@media (max-height: 520px) and (orientation: landscape) {
  :root { --wheel-size: min(100%, 210px, calc(100dvh - 256px)); }
  .top { height: 46px; }
  .layout { grid-template-columns: minmax(0, .62fr) minmax(0, 1.38fr); grid-template-areas: "head machine" "side side" "rules rules"; max-width: none; gap: 12px 22px; padding-top: 10px; align-items: start; }
  .head h1 { font-size: 1.9rem; margin: 4px 0 6px; }
  .head .lead { display: block; font-size: .82rem; }
  .machine { padding: 10px; }
  .mode-note { margin-bottom: 8px; padding: 6px 10px; font-size: .74rem; }
  .mode-note span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; }
  .tabs { margin-bottom: 8px; }
  .stage { padding: 8px; }
  .tab { min-height: 44px; }
  .tile svg { width: 19px; height: 19px; }
  .cta { min-height: 48px; margin-top: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .cta::after, .stage.charging, .result { animation: none; }
}
