:root {
  --paper: #fbf6ee;
  --paper-2: #f3ebdd;
  --card: #fffdf8;
  --ink: #3a3147;
  --ink-2: #7a7086;
  --line: #e4d9c7;
  --c0: #ef6f6c;
  --c1: #f39a4b;
  --c2: #eebd3b;
  --c3: #6cbf6a;
  --c4: #3aa7a3;
  --c5: #4c8fe0;
  --c6: #7f6bd6;
  --c7: #c56cc4;
  --c8: #e0708f;
  --ok: #3f9b5b;
  --bad: #d65252;
  --radius: 18px;
  --tabbar: 64px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  background-image:
    radial-gradient(circle at 12% 8%, rgba(239, 111, 108, .10) 0 90px, transparent 91px),
    radial-gradient(circle at 92% 18%, rgba(76, 143, 224, .10) 0 70px, transparent 71px),
    radial-gradient(circle at 80% 96%, rgba(108, 191, 106, .10) 0 110px, transparent 111px);
  background-attachment: fixed;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }

#app { max-width: 540px; margin: 0 auto; padding: 12px 14px calc(var(--tabbar) + 96px + env(safe-area-inset-bottom)); min-height: 100vh; }

.splash { display: grid; place-items: center; min-height: 70vh; gap: 10px; color: var(--ink-2); }
.splash .blob { width: 46px; height: 46px; position: absolute; animation: wobble 1.6s ease-in-out infinite; }
.splash .b1 { background: var(--c0); transform: translateX(-56px); }
.splash .b2 { background: var(--c2); animation-delay: .2s; }
.splash .b3 { background: var(--c5); transform: translateX(56px); animation-delay: .4s; }
.splash p { margin-top: 110px; }

.blob { border-radius: 58% 42% 55% 45% / 47% 56% 44% 53%; }

@keyframes wobble { 0%, 100% { border-radius: 58% 42% 55% 45% / 47% 56% 44% 53%; } 50% { border-radius: 44% 56% 46% 54% / 56% 44% 56% 44%; } }
@keyframes pop { 0% { transform: scale(.2) rotate(-25deg); opacity: 0; } 60% { transform: scale(1.12) rotate(4deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
@keyframes splat { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 6px 0 #b1373a, 0 0 0 0 rgba(239, 111, 108, .5); } 50% { box-shadow: 0 6px 0 #b1373a, 0 0 0 12px rgba(239, 111, 108, 0); } }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 2px 12px; }
.top h1 { font-size: 21px; margin: 0; letter-spacing: -.2px; }
.top .sub { color: var(--ink-2); font-size: 13px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--paper-2); color: var(--ink); white-space: nowrap; }
.pill.lobby { background: #fdebc8; }
.pill.running { background: #d8f0d6; }
.pill.paused { background: #e7e1f7; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.running .dot { background: var(--ok); animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.panel { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 0 var(--line); }
.panel h2 { font-size: 16px; margin: 0 0 10px; }
.panel h3 { font-size: 14px; margin: 14px 0 8px; color: var(--ink-2); font-weight: 600; }
.muted { color: var(--ink-2); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.note { background: #fff6e2; border: 1.5px dashed #ecc678; border-radius: 14px; padding: 10px 12px; white-space: pre-wrap; word-break: break-word; }
.hash { font: 11px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; color: var(--ink-2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border-radius: 14px; font-weight: 650; background: var(--ink); color: #fff; box-shadow: 0 3px 0 #1d1726; transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #1d1726; }
.btn.light { background: var(--paper-2); color: var(--ink); box-shadow: 0 3px 0 var(--line); }
.btn.green { background: var(--ok); box-shadow: 0 3px 0 #2a6d3f; }
.btn.red { background: var(--bad); box-shadow: 0 3px 0 #973434; }
.btn.small { padding: 7px 11px; font-size: 13px; border-radius: 11px; }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }

.stepper { display: inline-flex; align-items: center; background: var(--paper-2); border-radius: 14px; overflow: hidden; }
.stepper button { width: 42px; height: 42px; font-size: 22px; font-weight: 700; }
.stepper span { min-width: 34px; text-align: center; font-weight: 700; font-size: 18px; }

.ticket { background: var(--card); border: 1.5px solid var(--line); border-radius: 16px; padding: 8px; margin-bottom: 12px; position: relative; }
.ticket.sel { border-color: var(--c5); box-shadow: 0 0 0 3px rgba(76, 143, 224, .25); }
.ticket.dim { opacity: .55; }
.ticket.win { border-color: var(--c2); box-shadow: 0 0 0 3px rgba(238, 189, 59, .35); }
.ticket .meta { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--ink-2); margin: 0 2px 6px; }
.ticket .meta b { color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; }
.cell { aspect-ratio: 1 / 1.08; border-radius: 9px; display: grid; place-items: center; font-weight: 700; font-size: clamp(13px, 4.2vw, 19px); position: relative; user-select: none; }
.cell.empty { background: repeating-linear-gradient(135deg, var(--paper-2) 0 4px, transparent 4px 8px); opacity: .7; }
.cell.num { background: #fff; border: 1.5px dashed #cfc3ae; color: var(--ink); }
.cell.num.hint { border: 2px solid var(--c5); border-style: solid; }
.cell.num.on { border: 0; color: #fff; text-shadow: 0 1px 1px rgba(0, 0, 0, .25); animation: splat .25s ease-out; }
.cell.num.on::before { content: ""; position: absolute; inset: -2px; background: var(--paint); border-radius: 46% 54% 52% 48% / 55% 45% 55% 45%; z-index: 0; }
.cell.num.on span { position: relative; z-index: 1; }
.cell.num.wrong::after { content: ""; position: absolute; right: 2px; top: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--bad); }
.mini .cell { font-size: 11px; border-radius: 6px; aspect-ratio: 1 / 1.15; }
.mini .grid { gap: 2px; }

.stage { text-align: center; padding: 16px 10px 12px; }
.barrels { display: flex; justify-content: center; align-items: center; gap: 14px; min-height: 112px; }
.barrel { width: 92px; height: 92px; display: grid; place-items: center; color: #fff; font-size: 38px; font-weight: 800; text-shadow: 0 2px 2px rgba(0, 0, 0, .2); box-shadow: inset -6px -8px 0 rgba(0, 0, 0, .10), inset 6px 6px 0 rgba(255, 255, 255, .18); }
.barrel.sm { width: 74px; height: 74px; font-size: 30px; }
.barrel.anim { animation: pop .55s cubic-bezier(.2, .9, .3, 1.3) both; }
.barrel.anim:nth-child(2) { animation-delay: .12s; }
.barrel.anim:nth-child(3) { animation-delay: .24s; }
.counter { margin-top: 10px; font-weight: 650; }
.banner { margin: 10px auto 0; padding: 8px 12px; border-radius: 12px; font-weight: 650; display: inline-block; }
.banner.k { background: #fde2c4; }
.banner.p { background: #e7e1f7; }
.banner.x { background: #ffe0e0; }
.banner.c { background: #dcecff; }

.history { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.chip { min-width: 30px; height: 30px; padding: 0 4px; display: grid; place-items: center; border-radius: 50%; font-size: 13px; font-weight: 700; color: #fff; }
.chip.old { opacity: .85; }
.board90 { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.board90 div { aspect-ratio: 1; display: grid; place-items: center; font-size: 11.5px; border-radius: 6px; background: var(--paper-2); color: var(--ink-2); }
.board90 div.on { color: #fff; font-weight: 700; }

.bingo-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding: 10px 14px; background: linear-gradient(to top, var(--paper) 70%, rgba(251, 246, 238, 0)); z-index: 5; }
.bingo { display: block; width: 100%; max-width: 512px; margin: 0 auto; padding: 16px; border-radius: 20px; font-size: 22px; font-weight: 850; letter-spacing: .5px; color: #fff; background: var(--c0); box-shadow: 0 6px 0 #b1373a; }
.bingo:active { transform: translateY(4px); box-shadow: 0 2px 0 #b1373a; }
.bingo.ready { animation: pulse 1.6s infinite; }
.bingo[disabled] { background: #c9bfb2; box-shadow: 0 6px 0 #a39889; }
.bingo.shake { animation: shake .3s 2; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1.5px solid var(--line); display: flex; justify-content: center; z-index: 6; }
.tabs button { flex: 1; max-width: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--ink-2); position: relative; }
.tabs button .ic { font-size: 21px; line-height: 1; filter: grayscale(.6); }
.tabs button.on { color: var(--ink); font-weight: 700; }
.tabs button.on .ic { filter: none; }
.badge { position: absolute; top: 7px; left: calc(50% + 6px); background: var(--c0); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 6px; }

.seg { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { padding: 8px 12px; border-radius: 12px; background: var(--paper-2); font-weight: 600; font-size: 13.5px; white-space: nowrap; position: relative; }
.seg button.on { background: var(--ink); color: #fff; }
.seg .badge { position: static; margin-left: 4px; }

.list { display: flex; flex-direction: column; gap: 8px; }
.item { border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; background: #fff; }
.item.pending { border-color: #ecc678; background: #fffaf0; }
.item .t { font-weight: 650; }
.item .s { font-size: 12.5px; color: var(--ink-2); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--paper-2); }
.tag.pending { background: #fdebc8; }
.tag.paid, .tag.active { background: #d8f0d6; }
.tag.rejected, .tag.cancelled, .tag.excluded { background: #f6d6d6; }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form input[type=number], .form input[type=text], .form select, .form textarea { width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
.form textarea { min-height: 74px; resize: vertical; }
.check { display: flex !important; grid-template-columns: none; align-items: center; gap: 10px; color: var(--ink) !important; }
.check input { width: 22px; height: 22px; accent-color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--paper-2); border-radius: 14px; padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 12px; color: var(--ink-2); }

table.rt { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rt td, table.rt th { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: left; }
table.rt th { font-size: 12px; color: var(--ink-2); font-weight: 600; }
table.rt td.n { text-align: right; font-weight: 700; }

.log .e { display: flex; gap: 8px; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.log .e time { color: var(--ink-2); font-variant-numeric: tabular-nums; flex: none; }

.toast { position: fixed; left: 50%; top: 14px; transform: translate(-50%, -150%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 14px; font-weight: 600; z-index: 20; transition: transform .25s; max-width: 90vw; text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }
.toast.good { background: var(--ok); }

.overlay { position: fixed; inset: 0; background: rgba(58, 49, 71, .55); display: grid; place-items: center; z-index: 15; padding: 20px; }
.overlay.hidden { display: none; }
.modal { background: var(--card); border-radius: 24px; padding: 22px 18px; max-width: 420px; width: 100%; text-align: center; animation: pop .5s both; }
.modal .big { font-size: 54px; line-height: 1; }
.modal h2 { margin: 10px 0 6px; font-size: 24px; }

.empty-state { text-align: center; padding: 26px 10px; }
.empty-state .art { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.empty-state .art div { width: 34px; height: 34px; animation: wobble 2.4s ease-in-out infinite; }

details summary { cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: 13.5px; }
.sep { height: 1px; background: var(--line); margin: 12px 0; }

.panel.gift { background: linear-gradient(135deg, #fff6e2, #fde7ef); border-color: #ecc678; }
.progress { display: flex; gap: 6px; margin: 6px 0; }
.progress span { flex: 1; height: 12px; border-radius: 999px; background: var(--paper-2); }
.progress span.on { background: var(--c2); }
