/* Digital Tambola — theme on top of Bootstrap 5 */
:root {
  --tb-ink: #1E1B2E;
  --tb-cream: #FBF6EC;
  --tb-paper: #F6F1E7;
  --tb-muted: #5E5870;
  --tb-line: #E4D9C4;
  --tb-soft-line: #F0E9DC;
  --tb-gold: #F2A007;
  --tb-gold-light: #FFC23D;
  --tb-gold-wash: #FFF4D6;
  --tb-gold-text: #7A4E00;
  --tb-green: #17773F;
  --tb-green-dark: #0F5A2F;
  --tb-red: #B42318;
  --tb-red-wash: #FDECEA;
  --tb-blank: #F1E8D6;
  --tb-on-ink-muted: #D9D4E6;
  --tb-display: 'Bricolage Grotesque', 'DM Sans', system-ui, sans-serif;

  --bs-body-font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bs-body-bg: var(--tb-cream);
  --bs-body-color: var(--tb-ink);
  --bs-secondary-color: var(--tb-muted);
  --bs-border-color: var(--tb-line);
  --bs-link-color-rgb: 30, 27, 46;
  --bs-link-hover-color-rgb: 94, 88, 112;
  --bs-success-rgb: 23, 119, 63;
  --bs-danger-rgb: 180, 35, 24;
  --bs-focus-ring-color: rgba(242, 160, 7, .45);
  --bs-heading-color: inherit;
  --bs-link-color: var(--tb-ink);
  --bs-link-hover-color: var(--tb-muted);
}

html, body { background: var(--tb-cream); }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { color: inherit; }
.btn-link { --bs-btn-color: var(--tb-ink); --bs-btn-hover-color: var(--tb-muted); --bs-btn-active-color: var(--tb-ink); }
body { -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain; }
.font-display { font-family: var(--tb-display); }
.text-muted-tb { color: var(--tb-muted) !important; }
.text-green { color: var(--tb-green) !important; }
.text-red { color: var(--tb-red) !important; }
.text-gold-light { color: var(--tb-gold-light) !important; }
.text-on-ink-muted { color: var(--tb-on-ink-muted) !important; }
.eyebrow { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 600; }
:focus-visible { outline: 3px solid var(--tb-gold); outline-offset: 2px; }

/* App shell: phone-width column, centred on larger screens */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative; }
.screen { flex: 1 0 auto; display: flex; flex-direction: column; }
.screen.d-none { display: none !important; }
.topbar { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 8px; }
.bottom-actions { margin-top: auto; padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }

/* Buttons */
.btn { font-weight: 600; }
.btn-tb { --bs-btn-padding-y: 0; height: 56px; border-radius: 14px; font-family: var(--tb-display); font-weight: 700; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-gold { --bs-btn-bg: var(--tb-gold); --bs-btn-color: var(--tb-ink); --bs-btn-border-color: var(--tb-gold); --bs-btn-hover-bg: #E29500; --bs-btn-hover-border-color: #E29500; --bs-btn-hover-color: var(--tb-ink); --bs-btn-active-bg: #D08900; --bs-btn-active-border-color: #D08900; --bs-btn-active-color: var(--tb-ink); --bs-btn-disabled-bg: var(--tb-gold); --bs-btn-disabled-border-color: var(--tb-gold); --bs-btn-disabled-color: var(--tb-ink); }
.btn-ink { --bs-btn-bg: var(--tb-ink); --bs-btn-color: #fff; --bs-btn-border-color: var(--tb-ink); --bs-btn-hover-bg: #2E2A43; --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: #2E2A43; --bs-btn-active-bg: #111; --bs-btn-active-color: #fff; }
.btn-outline-ink { --bs-btn-color: var(--tb-ink); --bs-btn-border-color: var(--tb-ink); --bs-btn-hover-bg: var(--tb-ink); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--tb-ink); --bs-btn-active-bg: var(--tb-ink); --bs-btn-active-color: #fff; border-width: 2px; }
.btn-outline-ink.btn-tb { background: transparent; }
.btn-icon { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--tb-line); background: #fff; color: var(--tb-ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; flex-shrink: 0; }
.btn-icon:hover { background: var(--tb-paper); }
.btn-icon.on-ink { background: rgba(255,255,255,.12); border: 0; color: #fff; }
.btn-icon.on-ink:hover { background: rgba(255,255,255,.2); }
.btn-icon svg, .icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }

/* Cards */
.tb-card { background: #fff; border: 1px solid var(--tb-line); border-radius: 20px; padding: 14px 16px; }
.tb-card-ink { background: var(--tb-ink); color: #fff; border-radius: 22px; }
.tb-card h2 { font-family: var(--tb-display); font-size: 18px; font-weight: 700; margin: 0; }

/* Home */
.hero { background: var(--tb-ink); border-radius: 0 0 36px 36px; height: 380px; position: relative; overflow: hidden; flex-shrink: 0; }
.hero .ball { position: absolute; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--tb-display); font-weight: 800; }
.hero h1 { font-family: var(--tb-display); font-weight: 800; font-size: 60px; line-height: 1; color: #fff; letter-spacing: -1.5px; margin: 0; }
.step-dot { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--tb-line); background: #fff; display: inline-flex; align-items: center; justify-content: center; font-family: var(--tb-display); font-weight: 700; flex-shrink: 0; }
@media (prefers-reduced-motion: no-preference) {
  .hero .ball { animation: float 6s ease-in-out infinite; }
  .hero .ball:nth-child(2n) { animation-delay: -2s; animation-duration: 7s; }
  .hero .ball:nth-child(3n) { animation-delay: -4s; animation-duration: 8s; }
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Forms */
.form-control.tb-input { height: 56px; border-radius: 14px; font-size: 18px; padding: 0 16px; border-color: var(--tb-line); }
.form-control.tb-input:focus, .code-box:focus { border-color: var(--tb-gold); box-shadow: 0 0 0 .25rem rgba(242,160,7,.25); }
.code-box { height: 72px; border-radius: 14px; border: 1px solid var(--tb-line); background: #fff; text-align: center; font-family: var(--tb-display); font-weight: 800; font-size: 34px; text-transform: uppercase; width: 100%; padding: 0; color: var(--tb-ink); caret-color: var(--tb-gold); }
.code-box:focus { outline: none; border: 2px solid var(--tb-gold); }
.form-label { font-weight: 600; font-size: 14px; }

/* Lobby */
.room-code { font-family: var(--tb-display); font-weight: 800; font-size: 44px; line-height: 1.05; letter-spacing: 8px; color: var(--tb-gold-light); }
.pchip { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px 0 4px; border-radius: 18px; background: var(--tb-paper); font-size: 14px; font-weight: 600; max-width: 100%; }
.pchip.offline { opacity: .5; }
.avatar { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--tb-display); font-weight: 700; flex-shrink: 0; color: #fff; }
.avatar-28 { width: 28px; height: 28px; font-size: 12px; }
.avatar-40 { width: 40px; height: 40px; font-size: 17px; }
.speed-card { border: 2px solid var(--tb-gold); }
.badge-host { font-size: 12px; font-weight: 700; color: var(--tb-gold-text); background: var(--tb-gold-wash); padding: 3px 8px; border-radius: 999px; }
.stepper-btn { width: 48px; height: 48px; border-radius: 12px; }
.speed-value { font-family: var(--tb-display); font-weight: 800; font-size: 30px; line-height: 1.1; }
.preset-grid { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr)); gap: 6px; }
.btn-preset { height: 44px; border-radius: 10px; font-family: var(--tb-display); font-weight: 700; font-size: 15px; padding: 0; border: 1px solid var(--tb-line); background: #fff; color: var(--tb-ink); }
.btn-preset[aria-pressed="true"] { background: var(--tb-ink); color: #fff; border-color: var(--tb-ink); }
.form-switch .form-check-input { width: 3em; height: 1.6em; cursor: pointer; }
.form-check-input:checked { background-color: var(--tb-green); border-color: var(--tb-green); }
.form-check-input:focus { border-color: var(--tb-gold); box-shadow: 0 0 0 .25rem rgba(242,160,7,.25); }

/* Ticket */
.ticket { display: flex; flex-direction: column; gap: 4px; }
.ticket-row { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.ticket-cell { height: 48px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-family: var(--tb-display); font-weight: 700; font-size: 17px; padding: 0; border: 1px solid var(--tb-line); background: #fff; color: var(--tb-ink); position: relative; transition: background .15s, transform .1s; touch-action: manipulation; user-select: none; }
.ticket-cell.blank { background: var(--tb-blank); border: 0; }
.ticket-cell.marked { background: var(--tb-green); color: #fff; border: 0; box-shadow: inset 0 0 0 2px var(--tb-green-dark); }
.ticket-cell.live { background: var(--tb-gold-wash); border: 2px solid var(--tb-gold); }
.ticket-cell.called-unmarked { border: 2px dashed var(--tb-gold); }
.ticket-cell:active:not(.blank) { transform: scale(.94); }
.ticket-cell.shake { animation: shake .35s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.ticket.mini .ticket-cell { height: 26px; font-size: 12px; border-radius: 6px; }
.ticket.mini, .ticket.mini .ticket-row { gap: 3px; }
.ticket.sheet .ticket-cell { height: 42px; font-size: 16px; }
.ticket-cell.dim { opacity: .35; }
.ticket-cell.req-miss { background: var(--tb-red-wash); color: var(--tb-red); border: 2px dashed var(--tb-red); box-shadow: none; }
.ticket-cell.req-unmarked { background: var(--tb-gold-wash); color: var(--tb-ink); border: 2px dashed var(--tb-gold); box-shadow: none; }
@media (max-width: 360px) { .ticket-cell { font-size: 15px; height: 44px; } }

/* Game */
.caller { background: var(--tb-ink); border-radius: 24px; padding: 16px 20px 18px; color: #fff; display: flex; flex-direction: column; align-items: center; text-align: center; }
.caller-number { font-family: var(--tb-display); font-weight: 800; font-size: 120px; line-height: 1; color: var(--tb-gold-light); letter-spacing: -3px; min-height: 120px; }
.caller-number.small { font-size: 44px; letter-spacing: 0; min-height: 120px; display: flex; align-items: center; }
.caller-number.flash { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.6); opacity: .2; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
.caller-progress { flex-grow: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.18); overflow: hidden; }
.caller-progress > div { height: 100%; width: 0; background: var(--tb-gold-light); }
.paused-pill { background: var(--tb-gold); color: var(--tb-ink); font-weight: 700; font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.history { display: flex; align-items: center; gap: 8px; }
.history-label { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--tb-muted); width: 40px; line-height: 1.2; }
.chip-num { width: 44px; height: 44px; border-radius: 50%; background: #fff; border: 1px solid var(--tb-line); display: flex; align-items: center; justify-content: center; font-family: var(--tb-display); font-weight: 700; font-size: 17px; flex-shrink: 0; }
.pill { height: 32px; padding: 0 12px; border-radius: 16px; background: #fff; border: 1px solid var(--tb-line); display: inline-flex; align-items: center; font-size: 14px; font-weight: 700; letter-spacing: 1px; }
.claims { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.btn-claim { height: 52px; border-radius: 12px; border: 2px solid var(--tb-ink); background: #fff; color: var(--tb-ink); font-family: var(--tb-display); font-weight: 700; font-size: 16px; padding: 0 6px; line-height: 1.1; }
.btn-claim:hover { background: var(--tb-paper); }
.btn-claim.full { grid-column: span 2; height: 56px; border: 0; background: var(--tb-gold); font-weight: 800; font-size: 18px; }
.btn-claim.full:hover { background: #E29500; }
.btn-claim.span-2 { grid-column: span 2; }
.btn-claim.locked { border: 1px dashed #BDB1C9; background: #F3EEE4; color: var(--tb-muted); font-family: inherit; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.btn-claim.locked.mine { border: 2px solid var(--tb-green); background: #E3F2E8; color: var(--tb-green); }
.btn-claim.locked .t { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.btn-claim.locked .s { font-size: 12px; }
.sound-banner { background: var(--tb-gold-wash); border: 1px solid var(--tb-gold); border-radius: 14px; padding: 10px 12px; display: flex; align-items: center; gap: 10px; font-size: 14px; }

/* Board modal */
.board-grid { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
.board-cell { aspect-ratio: 1; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-family: var(--tb-display); font-weight: 700; font-size: 14px; background: #fff; color: #8C8599; border: 1px solid var(--tb-line); }
.board-cell.called { background: var(--tb-ink); color: #fff; border-color: var(--tb-ink); }
.board-cell.current { background: var(--tb-gold); color: var(--tb-ink); border-color: var(--tb-gold); }

/* Claim sheet */
.offcanvas.claim-sheet { --bs-offcanvas-height: auto; background: var(--tb-cream); border-radius: 28px 28px 0 0; max-width: 480px; margin: 0 auto; border: 0; }
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: #D5C9B3; margin: 12px auto 0; }
.result-icon { width: 56px; height: 56px; border-radius: 16px; color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.result-icon svg { width: 30px; height: 30px; }
.bg-green { background: var(--tb-green); }
.bg-red { background: var(--tb-red); }

/* Results */
.prize-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: #fff; border: 1px solid var(--tb-line); }
.prize-row.you { background: var(--tb-gold-wash); border: 2px solid var(--tb-gold); }
.trophy { width: 64px; height: 64px; border-radius: 20px; background: var(--tb-gold); color: var(--tb-ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.trophy svg { width: 34px; height: 34px; }

/* Toasts */
.toast-container { z-index: 1090; }
.toast { border-radius: 14px; border: 0; background: var(--tb-ink); color: #fff; box-shadow: 0 8px 24px rgba(30,27,46,.25); }
.toast.toast-win { background: var(--tb-green); }
.toast.toast-error { background: var(--tb-red); }

/* Connection banner */
.conn-banner { position: fixed; left: 50%; transform: translateX(-50%); top: 8px; z-index: 1100; background: var(--tb-ink); color: #fff; font-size: 13px; padding: 6px 14px; border-radius: 999px; display: flex; align-items: center; gap: 8px; }
.conn-banner .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tb-gold-light); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
