@font-face {
  font-family: "Bricolage Grotesque";
  src: url("/static/fonts/bricolage.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --page: #ffc629;
  --on-page: #17134a;
  --on-page-soft: #4a4679;
  --panel: #17134a;
  --on-panel: #fff4c9;
  --on-panel-soft: #cfc7a4;
  --accent: #ffc629;
  --paper: #fff4c9;
  --paper-shade: #f7e29a;
  --ink: #17134a;
  --ink-soft: #57537f;
  --mark: #e3126e;
  --on-mark: #ffffff;
  --cta: #17134a;
  --on-cta: #ffc629;
  --hot: #e3126e;
  --on-hot: #ffffff;
  --good: #0b6e41;
  --on-good: #ffffff;
  --shade: rgba(23, 19, 74, .55);
  --dab: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M50 6c13-2 27 3 35 14 8 10 11 23 8 35-3 13-11 26-24 32-13 7-30 7-42-2C15 77 6 63 7 48 8 34 15 20 27 12c7-4 15-5 23-6z'/%3E%3C/svg%3E");
}

[data-theme="night"] {
  --page: #151046;
  --on-page: #fff4c9;
  --on-page-soft: #bdb7e8;
  --panel: #2a2180;
  --on-panel: #fff4c9;
  --on-panel-soft: #cfc9f2;
  --cta: #ffc629;
  --on-cta: #151046;
  --shade: rgba(5, 3, 30, .7);
}

[data-theme="rani"] {
  --page: #c30f5f;
  --on-page: #ffffff;
  --on-page-soft: #ffd7e7;
  --cta: #17134a;
  --on-cta: #ffc629;
  --good: #0b6e41;
  --hot: #ffc629;
  --on-hot: #17134a;
}

[data-theme="brand"] {
  --page: #dcefeb;
  --on-page: #0e3a44;
  --on-page-soft: #41666f;
  --panel: #0e3a44;
  --on-panel: #f3fbf9;
  --on-panel-soft: #b5d3cf;
  --accent: #f7a823;
  --paper: #fffdf6;
  --paper-shade: #e7efe6;
  --ink: #0e3a44;
  --ink-soft: #4d6f76;
  --mark: #e4572e;
  --cta: #0e3a44;
  --on-cta: #f7a823;
  --hot: #e4572e;
  --shade: rgba(14, 58, 68, .55);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--page);
  touch-action: manipulation; /* no double-tap zoom on a fast thumb, pinch still works */
}

body {
  margin: 0;
  background: var(--page);
  color: var(--on-page);
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior: none;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--mark); outline-offset: 2px; }

.logo { display: block; height: 26px; width: auto; }
.logo.on-dark { display: none; }
[data-theme="night"] .logo.on-light, [data-theme="rani"] .logo.on-light { display: none; }
[data-theme="night"] .logo.on-dark, [data-theme="rani"] .logo.on-dark { display: block; }

.btn {
  display: inline-block;
  border: 2.5px solid var(--cta);
  border-radius: 10px;
  background: var(--cta);
  color: var(--on-cta);
  font-weight: 700;
  padding: 12px 18px;
  min-height: 46px;
  text-align: center;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn.plain { background: transparent; color: inherit; border-color: currentColor; }
.btn.hot { background: var(--hot); border-color: var(--hot); color: var(--on-hot); }

/* The ticket: printed paper, ink grid, pen marks. */
.ticket {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: 7px;
  box-shadow: 4px 5px 0 var(--ink);
}
[data-theme="night"] .ticket { box-shadow: 4px 5px 0 var(--mark); }
.ticket-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 6px 10px;
  font-weight: 700;
  border-bottom: 2.5px solid var(--ink);
}
.ticket-head span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.ticket-head span:last-child { font-weight: 500; white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); }
.cell {
  position: relative;
  appearance: none;
  -webkit-appearance: none;
  aspect-ratio: 1 / 1.08;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  border-right: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 700;
  font-size: var(--cell-font, 19px);
  font-variant-numeric: tabular-nums;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}
.cell:nth-child(9n) { border-right: 0; }
.cell:nth-last-child(-n+9) { border-bottom: 0; }
.cell.blank { background: var(--paper-shade); }

/* A pen mark. Every marked number on every screen uses this. */
.marked::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--mark-size, 86%);
  aspect-ratio: 1;
  background: var(--mark);
  -webkit-mask: var(--dab) center / contain no-repeat;
  mask: var(--dab) center / contain no-repeat;
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  z-index: -1;
}
.marked { color: var(--on-mark); }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

@media (prefers-reduced-motion: no-preference) {
  .pop { animation: pop .3s cubic-bezier(.2, 1.4, .4, 1); }
  @keyframes pop { from { scale: .55; } to { scale: 1; } }
  .marked.pop { animation: none; }
  .marked.pop::before { animation: stamp .24s cubic-bezier(.2, 1.5, .4, 1); }
  @keyframes stamp { from { width: 140%; opacity: .4; } }
  .nope { animation: nope .3s; }
  @keyframes nope { 25% { translate: -3px 0; } 75% { translate: 3px 0; } }
}

@media (prefers-reduced-motion: reduce) {
  .ticket.deal, .prize.ready, dialog.sheet[open], button.cell.current::after, .timer.run { animation: none !important; }
}
