:root {
  --bg: #f1edff;
  --card: #ffffff;
  --text: #1d1730;
  --muted: #6d6590;
  --line: #e4defa;
  --accent: #7c56e2;
  --accent-dark: #623ec4;
  --accent-soft: #ebe5ff;
  --orange: #ff7a2c;
  --orange-light: #ffaa68;
  --ok: #1f9d55;
  --ok-soft: #e3f6ea;
  --bad: #d93a3a;
  --bad-soft: #fde8e8;
  --warn: #b7791f;
  --warn-soft: #fdf3dc;
  --ray: #d6cdfc;
  --ray-base: #c4b8f6;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(80, 50, 160, .10);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
.dark {
  --bg: #15111f;
  --card: #211a33;
  --text: #f1edff;
  --muted: #a59cc6;
  --line: #31284b;
  --accent: #9a7bff;
  --accent-dark: #7c56e2;
  --accent-soft: #2c2347;
  --ok-soft: #173326;
  --bad-soft: #3a1c22;
  --warn-soft: #3a2f17;
  --ray: #2e2450;
  --ray-base: #241c40;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100vh;
  overscroll-behavior: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

/* ---------- каркас ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px;
  background: var(--bg);
}
.brand { font-weight: 900; font-style: italic; font-size: 22px; letter-spacing: .3px; text-transform: uppercase; }
.chip {
  font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent);
}
main { padding: 4px 16px calc(96px + var(--safe-bottom)); max-width: 560px; margin: 0 auto; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 6px 2px; border-radius: 12px;
  color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer;
}
.tab .ico { font-size: 22px; line-height: 1; filter: grayscale(.6); opacity: .8; }
.tab.on { color: var(--accent); background: var(--accent-soft); }
.tab.on .ico { filter: none; opacity: 1; }

h1 { font-size: 26px; font-weight: 900; font-style: italic; text-transform: uppercase; margin: 6px 0 4px; line-height: 1.05; }
h2 { font-size: 19px; margin: 18px 0 10px; }
.sub { color: var(--muted); margin: 0 0 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.stack > * + * { margin-top: 10px; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* ---------- кнопки и поля ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 52px; padding: 12px 18px; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 17px;
  transition: transform .08s, opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.orange { background: linear-gradient(180deg, var(--orange-light), var(--orange)); box-shadow: 0 6px 18px rgba(255, 122, 44, .35); }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.sm { min-height: 40px; font-size: 15px; padding: 8px 12px; border-radius: 12px; width: auto; }
.input, .textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 14px;
  padding: 13px 14px; outline: none;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.input.code { text-transform: uppercase; letter-spacing: 2px; font-weight: 700; text-align: center; font-size: 20px; }
.textarea { min-height: 150px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px; }
label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; }

/* ---------- афиша ---------- */
.event { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; }
.date {
  flex: 0 0 62px; text-align: center; border-radius: 14px; padding: 8px 0 6px;
  background: linear-gradient(160deg, #9a7bff, #6b45d8); color: #fff;
}
.date .d { font-size: 26px; font-weight: 900; line-height: 1; }
.date .m { font-size: 12px; opacity: .9; text-transform: uppercase; font-weight: 700; }
.event .title { font-weight: 800; font-size: 17px; line-height: 1.25; }
.event .when { color: var(--muted); font-size: 14px; margin-top: 2px; }
.badge {
  display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700;
  padding: 4px 9px; border-radius: 99px; background: var(--ok-soft); color: var(--ok);
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.poster { border-radius: 14px; margin-top: 12px; width: 100%; }
.desc { white-space: pre-wrap; margin-top: 10px; }

/* ---------- колесо ---------- */
.wheel-page {
  margin: -4px -16px 0; padding: 4px 16px 18px; text-align: center; overflow: hidden;
  background:
    radial-gradient(circle at 50% 58%, rgba(255,255,255,.55), transparent 62%),
    repeating-conic-gradient(from 0deg at 50% 58%, var(--ray) 0deg 9deg, var(--ray-base) 9deg 20deg);
  border-radius: 0 0 28px 28px;
}
.dark .wheel-page { background:
    radial-gradient(circle at 50% 58%, rgba(124,86,226,.25), transparent 62%),
    repeating-conic-gradient(from 0deg at 50% 58%, var(--ray) 0deg 9deg, var(--ray-base) 9deg 20deg); }
.wheel-page h1 { font-size: 34px; margin-top: 8px; color: #16102a; }
.dark .wheel-page h1 { color: #fff; }
.wheel-page .sub { color: #4f4675; font-weight: 500; }
.dark .wheel-page .sub { color: var(--muted); }
.wheel-wrap { position: relative; width: min(88vw, 400px); aspect-ratio: 1; margin: 6px auto 18px; }
.wheel-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#wheel-disk { will-change: transform; }
.spin-note { margin-top: 10px; color: #4f4675; font-weight: 600; }
.dark .spin-note { color: var(--muted); }

/* ---------- QR и коды ---------- */
.qr { background: #fff; border-radius: 16px; padding: 10px; width: min(70vw, 260px); margin: 6px auto 10px; }
.qr img { width: 100%; image-rendering: pixelated; }
.code-big { font-size: 24px; font-weight: 900; letter-spacing: 2px; text-align: center; margin: 4px 0; user-select: all; }
.pass { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.pass .mini { width: 64px; height: 64px; flex: 0 0 64px; background: #fff; border-radius: 10px; padding: 4px; }
.pass .mini img { width: 100%; height: 100%; image-rendering: pixelated; }
.pass .t { font-weight: 800; }
.pass .s { color: var(--muted); font-size: 14px; }

.result { text-align: center; }
.result .emoji { font-size: 54px; line-height: 1; margin: 6px 0 4px; }
.result h2 { margin: 6px 0; font-size: 24px; }

/* ---------- проверка кодов ---------- */
.check-card { border-left: 6px solid var(--line); }
.check-card.ok { border-left-color: var(--ok); }
.check-card.used { border-left-color: var(--warn); }
.check-card.bad { border-left-color: var(--bad); }
.check-card .line { margin: 3px 0; }
.scan-btn { min-height: 120px; font-size: 20px; flex-direction: column; border-radius: 22px; }
.scan-btn .ico { font-size: 40px; }

/* ---------- админка ---------- */
.seg { display: flex; gap: 6px; background: var(--card); padding: 5px; border-radius: 14px; margin: 4px 0 14px; overflow-x: auto; }
.seg button {
  flex: 1; border: 0; background: none; padding: 9px 8px; border-radius: 10px; font-weight: 700;
  font-size: 14px; color: var(--muted); white-space: nowrap; cursor: pointer;
}
.seg button.on { background: var(--accent); color: #fff; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tile { background: var(--card); border-radius: 14px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.tile .n { font-size: 26px; font-weight: 900; color: var(--accent); }
.tile .l { font-size: 12px; color: var(--muted); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 4px; }
table.t td { padding: 8px 4px; border-top: 1px solid var(--line); }
table.t td.n, table.t th.n { text-align: right; }
.sum { font-weight: 700; }
.sum.good { color: var(--ok); }
.sum.badsum { color: var(--bad); }
.link-box { word-break: break-all; background: var(--accent-soft); color: var(--accent); padding: 10px 12px; border-radius: 12px; font-size: 14px; margin: 8px 0; }

/* ---------- всплывашки ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(86px + var(--safe-bottom)); z-index: 30;
  background: #1d1730; color: #fff; padding: 13px 16px; border-radius: 14px; text-align: center;
  font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.25); animation: pop .2s ease-out;
}
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

.sheet-back {
  position: fixed; inset: 0; z-index: 20; background: rgba(20, 12, 40, .45);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .2s;
}
.sheet {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-radius: 26px 26px 0 0; padding: 22px 18px calc(22px + var(--safe-bottom));
  animation: up .25s ease-out;
}
.sheet-close {
  position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--accent-soft); color: var(--accent); font-size: 24px; line-height: 1; cursor: pointer;
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }

.loading { display: flex; justify-content: center; padding: 60px 0; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 25; }
