:root {
  --bg-a: #d9e9ff;
  --bg-b: #edf5ff;
  --bg-c: #f8fbff;
  --ink: #17233d;
  --ink-muted: #4f6285;
  --border: rgba(24, 70, 136, 0.18);
  --brand: #1461d2;
  --brand-deep: #0d4ba9;
  --brand-soft: #4ca6ff;
  --accent: #ffb21d;
  --ok: #1b9865;
  --danger: #b9445f;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 560px at -4% -15%, #b8deff 0%, transparent 60%),
    radial-gradient(950px 460px at 102% -12%, #d9e7ff 0%, transparent 56%),
    linear-gradient(165deg, var(--bg-a) 0%, var(--bg-b) 46%, var(--bg-c) 100%);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.24);
  background:
    linear-gradient(140deg, rgba(8, 49, 117, 0.95), rgba(20, 95, 194, 0.92));
  box-shadow: 0 12px 34px rgba(9, 41, 88, 0.35);
}

.site-header h1 {
  margin: 0;
  font-family: "Outfit", "Sora", sans-serif;
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  color: #f7fbff;
}

.site-header a {
  color: #eaf4ff;
  text-decoration: none;
  font-weight: 700;
}

.site-header a:hover {
  text-decoration: underline;
}

.header-right {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(239, 248, 255, 0.86));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    0 12px 30px rgba(13, 65, 122, 0.15);
  backdrop-filter: blur(8px);
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.grid.three {
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}

.grid.three > .card {
  min-width: 0;
}

.stack {
  display: grid;
  gap: 0.72rem;
  min-width: 0;
}

.stack > * {
  min-width: 0;
}

.row {
  display: flex;
  gap: 0.62rem;
  flex-wrap: wrap;
}

h2,
h3 {
  margin: 0 0 0.7rem;
  font-family: "Outfit", "Sora", sans-serif;
}

label {
  display: grid;
  gap: 0.27rem;
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.085em;
  color: #58709b;
  font-weight: 800;
  width: 100%;
  min-width: 0;
}

input,
select,
button {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.62rem 0.78rem;
  font-size: 0.95rem;
  font-family: inherit;
}

.stack input,
.stack select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.stack small {
  min-width: 0;
  overflow-wrap: anywhere;
}

input[type="file"] {
  width: 100%;
  max-width: 100%;
}

/* Remove number input spinners */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input,
select {
  background:
    linear-gradient(180deg, #ffffff, #f4f9ff);
  color: var(--ink);
}

input:focus,
select:focus,
button:focus {
  outline: none;
  border-color: #2b86f8;
  box-shadow: 0 0 0 3px rgba(43, 134, 248, 0.2);
}

button {
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(1.06);
}

button:active {
  transform: translateY(1px);
}

button.ghost {
  background: rgba(255, 255, 255, 0.84);
  color: var(--brand-deep);
  border-color: rgba(20, 97, 210, 0.24);
}

button.small,
.small {
  font-size: 0.84rem;
}

a {
  color: #145bc5;
}

a:hover {
  color: #0e46a2;
}

.muted {
  color: var(--ink-muted);
}

.mono {
  font-family: Menlo, Consolas, monospace;
}

#status {
  margin-top: 0.85rem;
  color: #154f9f;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.74);
}

th,
td {
  border-bottom: 1px solid rgba(28, 66, 124, 0.12);
  padding: 0.52rem;
  text-align: left;
  vertical-align: middle;
}

th {
  background: linear-gradient(180deg, #edf5ff, #e4efff);
  color: #355a8e;
}

.hidden {
  display: none !important;
}

.screen-reader-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Admin tabs */
.admin-shell {
  display: grid;
  gap: 0.85rem;
}

.admin-identity-line {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  align-items: center;
  font-size: 0.93rem;
}

.logout-link {
  text-decoration: underline;
  font-weight: 700;
}

.tab-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding: 0.35rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid var(--border);
}

.tab-button {
  background: linear-gradient(145deg, #fafdff, #e8f2ff);
  color: #2b4e80;
  border: 1px solid rgba(24, 90, 170, 0.2);
  border-radius: 11px;
  padding: 0.55rem 0.82rem;
}

.tab-button.active {
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  color: #fff;
  border-color: transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.inline-form {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  align-items: end;
}

.inline-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.mode-repeat-box {
  border: 1px solid rgba(20, 97, 210, 0.2);
  border-radius: 12px;
  padding: 0.55rem 0.7rem;
  background: rgba(245, 250, 255, 0.88);
  display: grid;
  gap: 0.35rem;
}

.mode-repeat-title {
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.085em;
  color: #58709b;
  font-weight: 800;
}

.mode-repeat-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: normal;
  color: var(--ink);
  font-weight: 600;
  flex-wrap: wrap;
  min-width: 0;
  overflow-wrap: anywhere;
}

.mode-repeat-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.qty-input {
  max-width: 110px;
}

#carton-form.inline-form {
  grid-template-columns: minmax(260px, 1fr) auto;
}

#carton-form .inline-actions {
  justify-self: end;
}

.generated-table-wrap {
  margin-top: 0.9rem;
  overflow: auto;
}

.tiny-qr {
  width: 160px;
  height: 160px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid rgba(24, 90, 170, 0.2);
  background: #fff;
}

/* Marketing studio */
.marketing-grid {
  align-items: start;
}

.marketing-image-list {
  border: 1px dashed rgba(32, 89, 166, 0.25);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  min-height: 40px;
  background: rgba(245, 251, 255, 0.82);
  font-size: 0.82rem;
}

.marketing-only-preview {
  position: relative;
  border-radius: 16px;
  border: 1px solid rgba(29, 96, 187, 0.24);
  overflow: hidden;
  min-height: 180px;
  background: linear-gradient(155deg, #102860, #1b4d9f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  --preview-transition-seconds: 0.8s;
  --preview-zoom-seconds: 5s;
}

.marketing-only-preview::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 18px rgba(255, 245, 214, 0.7);
  border-radius: inherit;
}

.marketing-only-preview img {
  width: 100%;
  height: 100%;
  min-height: 180px;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--preview-transition-seconds) ease-in-out;
}

.marketing-only-preview img.active {
  opacity: 1;
}

.marketing-only-preview img.zooming {
  animation: marketing-zoom var(--preview-zoom-seconds) ease-in-out infinite alternate;
}

/* Display page */
.display-only .site-header {
  display: none;
}

.display-only .container {
  max-width: 100%;
  height: 100vh;
  padding: 0.45rem;
  overflow: hidden;
}

.carton-only {
  overflow: hidden;
}

.carton-only .container {
  max-width: 100%;
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.carton-modal-shell {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  background:
    radial-gradient(1200px 560px at 10% -15%, rgba(110, 176, 255, 0.28), transparent 55%),
    radial-gradient(900px 460px at 102% -5%, rgba(253, 190, 95, 0.2), transparent 60%),
    linear-gradient(165deg, rgba(8, 24, 73, 0.82), rgba(17, 12, 61, 0.86));
}

.display-page {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.55rem;
  height: 100%;
  overflow: hidden;
}

.lively-display .display-top {
  background:
    radial-gradient(circle at 12% 22%, rgba(255, 255, 255, 0.5), transparent 36%),
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, 0.35), transparent 40%),
    linear-gradient(145deg, #0f66da, #2d8dff 55%, #0f72ec);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.25);
}

.display-title-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.display-title-row h2 {
  margin-bottom: 0.25rem;
  color: #fff;
}

.display-title-row p {
  margin: 0;
  color: rgba(240, 249, 255, 0.92);
  font-weight: 600;
}

.call-strip {
  margin-top: 0.8rem;
  display: grid;
  gap: 0.7rem;
  align-items: stretch;
}

.call-strip.has-qr {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.call-strip.no-qr {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.prestart-panel {
  margin-top: 0.7rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: linear-gradient(155deg, rgba(5, 36, 96, 0.92), rgba(8, 56, 128, 0.85));
  padding: 0.8rem 1rem 1rem;
  display: grid;
  justify-items: center;
  gap: 0.45rem;
}

.prestart-title {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: rgba(235, 247, 255, 0.92);
  font-weight: 700;
}

.prestart-game-name {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: clamp(1.35rem, 2.6vw, 2.1rem);
  font-weight: 800;
  color: #ffe9a4;
  text-align: center;
}

.prestart-qr-image {
  width: min(56vw, 360px);
  height: min(56vw, 360px);
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.58);
  background: #fff;
  object-fit: contain;
  box-shadow: 0 14px 28px rgba(3, 15, 49, 0.45);
}

.prestart-countdown {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  font-weight: 700;
  color: #f7fbff;
}

.prestart-countdown span {
  color: #ffcf4a;
  font-weight: 900;
  font-size: 1.2em;
}

.prestart-marketing-slot {
  margin-top: 0.4rem;
  width: min(96%, 1200px);
  min-height: clamp(220px, 34vh, 420px);
  border-radius: 18px;
  border: 1px solid rgba(255, 238, 196, 0.45);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 14px 26px rgba(4, 14, 48, 0.34);
}

.prestart-marketing-slot .marketing-slideshow {
  height: clamp(220px, 34vh, 420px);
}

.prestart-marketing-slot .marketing-slideshow::after {
  box-shadow:
    inset 0 0 26px rgba(255, 248, 227, 0.78),
    inset 0 0 60px rgba(255, 239, 191, 0.46);
}

.display-page.prestart-mode .call-strip {
  display: none;
}

.display-page.prestart-mode .numbers-and-winner {
  display: none;
}

.join-qr-panel {
  margin-top: 0;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.join-qr-media {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.join-qr-copy p {
  margin: 0;
  color: rgba(240, 249, 255, 0.92);
  font-weight: 700;
  font-size: 0.9rem;
}

.join-url-link {
  max-width: 220px;
  text-align: center;
  font-size: 0.75rem;
  color: #eef7ff;
  text-decoration: underline;
  word-break: break-all;
}

.join-qr-image {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: #fff;
  object-fit: contain;
}

.call-panel {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(7, 34, 92, 0.28);
  padding: 0.5rem 0.75rem;
  min-height: clamp(150px, 22vh, 210px);
  display: flex;
  flex-direction: column;
}

.call-panel.previous {
  background: rgba(5, 40, 85, 0.18);
}

.call-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.72rem;
  color: rgba(230, 244, 255, 0.9);
  margin-bottom: 0.18rem;
  font-weight: 700;
}

.call-value {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}

.call-letter {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  color: #ffcf4a;
}

.call-number {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: 5.25rem;
  font-weight: 900;
  line-height: 1;
  color: #fff;
}

.bingo-header {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.bingo-letter {
  text-align: center;
  font-family: "Outfit", "Sora", sans-serif;
  font-weight: 800;
  font-size: 1.45rem;
  letter-spacing: 0.2em;
  color: #0d4ba9;
  text-transform: uppercase;
}

.display-bingo-header .bingo-letter {
  font-size: 2rem;
  font-weight: 800;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.2rem 0.62rem;
  background: rgba(227, 243, 255, 0.88);
  border: 1px solid rgba(26, 111, 156, 0.24);
  color: #19587f;
  text-transform: lowercase;
}

.lively-display .display-top .pill {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
  font-weight: 700;
}

.numbers-and-winner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.85rem;
  align-items: start;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.numbers-column {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.winner-sidebar {
  border-radius: 14px;
  border: 1px solid rgba(22, 90, 170, 0.2);
  padding: 0.65rem 0.75rem;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(233, 244, 255, 0.86));
  min-width: 0;
}

.winner-sidebar h3 {
  margin-bottom: 0.45rem;
}

.winner-history-wrap {
  margin-top: 0.55rem;
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid rgba(22, 90, 170, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
}

.winner-history-wrap-top {
  margin-top: 0.25rem;
  max-height: min(15vh, 155px);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(3, 14, 44, 0.9);
}

.winner-history-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.9rem;
  color: #f5fbff;
}

.winner-history-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(6, 30, 86, 0.96);
  color: #ffffff;
  font-weight: 800;
}

.winner-history-table th,
.winner-history-table td {
  border-bottom: 1px solid rgba(202, 228, 255, 0.22);
  padding: 0.3rem 0.36rem;
  text-align: left;
  white-space: nowrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.winner-history-table td {
  color: #f5fbff;
  font-weight: 700;
  background: rgba(5, 20, 58, 0.55);
}

.winner-history-table th:nth-child(1),
.winner-history-table td:nth-child(1) {
  width: 110px;
}

.winner-history-table th:nth-child(2),
.winner-history-table td:nth-child(2) {
  width: 112px;
}

.winner-history-table th:nth-child(3),
.winner-history-table td:nth-child(3) {
  width: 96px;
}

.winner-history-table th:nth-child(4),
.winner-history-table td:nth-child(4) {
  width: 70px;
}

.winner-flash {
  animation: winner-flash 1.2s ease-in-out infinite;
}

@keyframes winner-flash {
  0% {
    background: rgba(255, 241, 163, 0.08);
  }
  50% {
    background: rgba(255, 198, 59, 0.28);
  }
  100% {
    background: rgba(255, 241, 163, 0.08);
  }
}

.board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.28rem;
  min-height: 0;
  align-content: space-between;
  overflow: hidden;
}

.board-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 0.45rem;
  align-items: center;
}

.row-letter {
  text-align: center;
  font-family: "Outfit", "Sora", sans-serif;
  font-weight: 900;
  font-size: 5.2rem;
  color: #0d4ba9;
}

.row-track {
  display: grid;
  grid-template-columns: repeat(var(--row-count, 15), minmax(0, 1fr));
  gap: 0.42rem;
  width: 100%;
}

.ball-cell {
  border: 1px solid rgba(42, 78, 119, 0.24);
  border-radius: 999px;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.35rem, 1.95vw, 2.15rem);
  font-weight: 700;
  color: #1f2f47;
  background: rgba(255, 255, 255, 0.92);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.ball-cell.called {
  background: linear-gradient(145deg, #20a276, #18855f);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 7px 15px rgba(11, 92, 64, 0.28);
}

.ball-cell.just-called {
  animation: called-pop 280ms ease-out;
}

@keyframes called-pop {
  0% {
    transform: scale(1);
  }
  55% {
    transform: scale(1.13);
  }
  100% {
    transform: scale(1);
  }
}

.marquee {
  min-height: 2.2rem;
  padding: 0.6rem;
  border: 1px dashed rgba(48, 91, 131, 0.25);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.74);
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.marquee img {
  max-height: 60px;
  width: auto;
  border-radius: 8px;
}

.ball-zoom-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

.ball-zoom-overlay.active {
  animation: zoom-overlay-fade 1600ms ease-out forwards;
}

.ball-zoom-chip {
  width: clamp(220px, 42vmin, 480px);
  height: clamp(220px, 42vmin, 480px);
  border-radius: 999px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  background:
    radial-gradient(circle at 28% 26%, rgba(255, 255, 255, 0.46), transparent 42%),
    linear-gradient(150deg, #26a97b 0%, #1b8b61 48%, #15704e 100%);
  box-shadow:
    0 30px 80px rgba(8, 31, 71, 0.48),
    inset 0 2px 8px rgba(255, 255, 255, 0.35);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  transform: scale(0.2);
}

.ball-zoom-letter {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: clamp(4rem, 8vmin, 8rem);
  font-weight: 900;
  line-height: 1;
  color: #ffe17e;
}

.ball-zoom-number {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: clamp(5.2rem, 12vmin, 11rem);
  font-weight: 900;
  line-height: 1;
}

@keyframes zoom-overlay-fade {
  0% {
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.ball-zoom-overlay.active .ball-zoom-chip {
  animation: zoom-ball-pop 1600ms cubic-bezier(0.18, 0.78, 0.26, 1) forwards;
}

@keyframes zoom-ball-pop {
  0% {
    transform: scale(0.16);
    filter: blur(2px);
  }
  24% {
    transform: scale(1.06);
    filter: blur(0);
  }
  52% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(0.88);
  }
}

.winner-bingo-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1115;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  background: radial-gradient(circle at center, rgba(7, 14, 48, 0.25), rgba(4, 9, 30, 0.45));
}

.winner-bingo-overlay.active {
  animation: winner-bingo-fade 3000ms ease-in-out forwards;
}

.winner-bingo-image {
  width: min(76vw, 760px);
  max-height: 78vh;
  object-fit: contain;
  filter: drop-shadow(0 18px 38px rgba(0, 0, 0, 0.48));
  transform-origin: center;
}

.winner-bingo-overlay.active .winner-bingo-image {
  animation: winner-bingo-pulse 560ms ease-in-out infinite;
}

@keyframes winner-bingo-fade {
  0% {
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  92% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes winner-bingo-pulse {
  0% {
    transform: scale(0.84);
  }
  48% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(0.89);
  }
}

/* Carton page */
.carton-page {
  --carton-accent: #2f74dc;
  --carton-accent-soft: #9bc8ff;
  --carton-bg-shade: 0.68;
  --carton-bg-image: none;
  --carton-inner-glow: rgba(255, 199, 84, 0.38);
  margin: 0 auto 1rem;
  width: min(100%, 460px);
  position: relative;
  overflow: hidden;
  border-radius: 28px;
  border: 2px solid rgba(255, 200, 98, 0.55);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 212, 92, 0.3), transparent 42%),
    linear-gradient(180deg, rgba(98, 24, 158, 0.9), rgba(12, 19, 105, 0.92));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.1),
    inset 0 0 42px var(--carton-inner-glow),
    0 26px 52px rgba(8, 18, 80, 0.42);
  padding: clamp(0.65rem, 1.8vw, 1rem);
  display: grid;
  gap: clamp(0.48rem, 1.4vw, 0.72rem);
}

.carton-only .carton-page {
  margin: 0;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  border-radius: 0;
  border-width: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 0 36px var(--carton-inner-glow);
  padding: clamp(0.55rem, 1.9vw, 1rem);
  overflow-x: hidden;
  overflow-y: auto;
}

.carton-only .carton-grid {
  min-height: 0;
}

.carton-only .carton-bingo-header,
.carton-only .carton-grid,
.carton-only .carton-slider-controls,
.carton-only #marketing-bottom,
.carton-only .carton-auto-daub {
  width: min(100%, 84vh);
  margin-left: auto;
  margin-right: auto;
}

.carton-only .carton-cell {
  font-size: clamp(1.2rem, 6.2vw, 3.2rem);
}

.carton-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--carton-bg-image);
  background-size: cover;
  background-position: center;
  opacity: calc(1 - var(--carton-bg-shade));
  pointer-events: none;
}

.carton-page::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(23, 8, 73, calc(var(--carton-bg-shade) * 0.72)) 0%,
    rgba(12, 6, 56, calc(var(--carton-bg-shade) * 0.74)) 100%
  );
  pointer-events: none;
}

.carton-page > * {
  position: relative;
  z-index: 1;
}

#marketing-bottom {
  margin-left: 0;
  margin-right: 0;
  width: 100%;
}

.carton-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.1rem 0.1rem 0.2rem;
}

.carton-header-row h2 {
  color: #fff6d6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.carton-header-row p {
  margin: 0.2rem 0 0;
  color: #ffe1ff;
}

.carton-slider-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin: 0.15rem 0;
  background: rgba(10, 16, 82, 0.44);
  border: 1px solid rgba(255, 235, 184, 0.34);
  border-radius: 12px;
  padding: 0.42rem 0.5rem;
}

.carton-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.45rem 0 0.75rem;
}

.carton-pill {
  border: 1px solid rgba(20, 97, 210, 0.24);
  background: rgba(255, 255, 255, 0.85);
  color: #1b4f9a;
  border-radius: 999px;
  padding: 0.36rem 0.68rem;
  font-size: 0.8rem;
  font-weight: 700;
}

.carton-pill.active {
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  border-color: transparent;
  color: #fff;
}

.toggle-line {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.93rem;
  color: #fff9de;
  letter-spacing: 0.01em;
  background: rgba(5, 11, 62, 0.42);
  border: 1px solid rgba(255, 235, 187, 0.32);
  border-radius: 10px;
  padding: 0.45rem 0.62rem;
}

.carton-auto-daub {
  margin-top: 0.12rem;
  justify-content: center;
  flex-wrap: wrap;
}

.carton-last-six {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  margin-left: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 232, 177, 0.45);
  background: rgba(15, 18, 70, 0.56);
  color: #ffe7b2;
  font-family: "Outfit", "Sora", sans-serif;
  font-weight: 800;
  font-size: 0.88rem;
  letter-spacing: 0.05em;
}

.carton-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: clamp(0.24rem, 1.05vw, 0.45rem);
}

.carton-bingo-header {
  margin-bottom: 0.16rem;
  background: linear-gradient(180deg, rgba(255, 153, 68, 0.85), rgba(255, 77, 153, 0.78));
  border: 1px solid rgba(255, 230, 170, 0.45);
  border-radius: 12px;
  padding: 0.26rem 0.32rem;
}

.carton-bingo-header .bingo-letter {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: clamp(1.3rem, 4.7vw, 2rem);
  font-weight: 900;
  color: #fff6d2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.carton-cell {
  min-height: 0;
  aspect-ratio: 1 / 1;
  font-weight: 900;
  font-size: clamp(0.95rem, 3.7vw, 1.7rem);
  line-height: 1;
  background: linear-gradient(180deg, #fffaf0 0%, #fff2da 100%);
  color: #1f2a42;
  border: 1px solid rgba(96, 67, 21, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 0 rgba(255, 225, 163, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.carton-cell.callable {
  border-color: var(--carton-accent);
  box-shadow: inset 0 0 0 1px rgba(20, 97, 210, 0.24);
}

.carton-cell.marked {
  background: linear-gradient(140deg, #24976c, #1b7f5c);
  color: #fff;
  border-color: transparent;
}

.carton-cell.free {
  opacity: 1;
  background: linear-gradient(145deg, #45a63f, #2f7f3a);
  color: #fffbe8;
  border-color: rgba(255, 243, 192, 0.68);
}

.carton-center-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  filter: none;
}

.carton-cell.winner-line-hit {
  position: relative;
  overflow: hidden;
}

.carton-cell.winner-line-hit::after {
  content: "";
  position: absolute;
  left: -12%;
  top: 50%;
  width: 124%;
  height: 4px;
  border-radius: 999px;
  background: #ef3c3c;
  box-shadow: 0 0 0 1px rgba(130, 7, 7, 0.22), 0 0 8px rgba(206, 35, 35, 0.35);
  transform-origin: center;
  transform: translateY(-50%) rotate(0deg);
}

.carton-cell.winner-line-col::after {
  transform: translateY(-50%) rotate(90deg);
}

.carton-cell.winner-line-diag-main::after {
  transform: translateY(-50%) rotate(45deg);
}

.carton-cell.winner-line-diag-anti::after {
  transform: translateY(-50%) rotate(-45deg);
}

.marketing-slot {
  margin: 0.1rem 0;
  border: 1px solid rgba(255, 227, 163, 0.54);
  border-radius: 14px;
  background:
    linear-gradient(130deg, rgba(255, 249, 230, 0.98), rgba(255, 236, 198, 0.95));
  padding: 0;
  text-align: center;
  min-height: clamp(90px, 21vw, 130px);
  display: block;
  overflow: hidden;
}

.marketing-slideshow {
  position: relative;
  width: 100%;
  height: clamp(90px, 21vw, 130px);
  --marketing-transition-seconds: 0.8s;
  --marketing-zoom-seconds: 5s;
}

.marketing-slideshow::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 16px rgba(255, 244, 213, 0.64);
}

.marketing-slide-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity var(--marketing-transition-seconds) ease-in-out;
}

.marketing-slide-image.active {
  opacity: 1;
}

.marketing-slide-image.zooming {
  animation: marketing-zoom var(--marketing-zoom-seconds) ease-in-out infinite alternate;
}

@keyframes marketing-zoom {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.08);
  }
}

.player-join-card {
  width: min(94vw, 430px);
  margin: 1.4rem auto 0;
}

.cashier-only .site-header {
  display: none;
}

.cashier-only .container {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 0.75rem;
}

.cashier-app {
  display: grid;
  gap: 0.72rem;
}

.cashier-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.cashier-topbar h2 {
  margin: 0;
  font-size: clamp(1.5rem, 4.8vw, 2rem);
}

.cashier-topbar p {
  margin: 0.2rem 0 0;
  font-size: 0.95rem;
}

.cashier-panel {
  padding: 0.85rem;
}

.cashier-form {
  display: grid;
  gap: 0.74rem;
}

.cashier-form label {
  font-size: 0.86rem;
}

.cashier-form input,
.cashier-form select,
.cashier-form button {
  font-size: clamp(1rem, 3.7vw, 1.25rem);
  min-height: 52px;
}

.cashier-qty-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 64px;
  gap: 0.45rem;
}

.cashier-qty-row input {
  text-align: center;
  font-weight: 800;
}

.cashier-price-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 0.45rem 0.7rem;
  padding: 0.68rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(19, 92, 181, 0.24);
  background: linear-gradient(160deg, rgba(225, 242, 255, 0.95), rgba(205, 228, 255, 0.92));
}

.cashier-price-strip p {
  margin: 0;
  font-size: 0.88rem;
  color: #345481;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.cashier-price-strip strong {
  font-family: "Outfit", "Sora", sans-serif;
  font-size: clamp(1.45rem, 6vw, 2.2rem);
  color: #103f86;
  line-height: 1;
}

.cashier-sell-button {
  min-height: 62px;
  font-size: clamp(1.1rem, 4.8vw, 1.45rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  background: linear-gradient(130deg, #0b8d5b, #16a86e);
}

.cashier-last-sale {
  text-align: center;
  background:
    radial-gradient(circle at 22% -5%, rgba(255, 246, 196, 0.7), transparent 44%),
    linear-gradient(155deg, rgba(255, 239, 194, 0.95), rgba(255, 223, 149, 0.93));
}

.cashier-sale-label {
  margin: 0;
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #784b09;
  font-weight: 800;
}

.cashier-sale-code {
  margin: 0.25rem 0;
  font-size: clamp(2.3rem, 13vw, 4rem);
  line-height: 1;
  letter-spacing: 0.08em;
  color: #7a2200;
  font-weight: 900;
}

.cashier-sale-meta {
  margin: 0;
  color: #5b3d09;
  font-weight: 700;
}

.cashier-sales-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.6rem;
}

.cashier-sales-header h3 {
  margin: 0;
  font-size: clamp(1.2rem, 4.8vw, 1.5rem);
}

.cashier-sales-list {
  display: grid;
  gap: 0.56rem;
}

.cashier-sale-card {
  border-radius: 14px;
  border: 1px solid rgba(27, 88, 168, 0.24);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.96), rgba(230, 241, 255, 0.92));
  padding: 0.65rem 0.7rem;
}

.cashier-sale-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  margin-bottom: 0.35rem;
}

.cashier-sale-head strong {
  font-size: 1.06rem;
  color: #163e77;
}

.cashier-sale-head span {
  font-size: 0.78rem;
  color: #4f678c;
}

.cashier-sale-code-chip {
  margin: 0;
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 66, 142, 0.28);
  background: rgba(239, 247, 255, 0.95);
  font-size: clamp(1.25rem, 6.2vw, 1.9rem);
  font-weight: 900;
  color: #0e3a7b;
  letter-spacing: 0.07em;
}

.cashier-sale-row {
  margin: 0.35rem 0 0;
  color: #34537d;
  font-weight: 700;
  font-size: 0.92rem;
}

#cashier-status {
  margin: 0.45rem 0 1rem;
  font-size: 0.98rem;
  color: #143f7a;
  font-weight: 700;
  text-align: center;
}

.join-error {
  margin: 0.35rem 0 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid rgba(196, 39, 39, 0.24);
  background: rgba(254, 243, 243, 0.9);
  color: #8a1f1f;
  font-weight: 600;
}

.game-bg-preview {
  border: 1px dashed rgba(40, 95, 151, 0.28);
  border-radius: 12px;
  padding: 0.6rem;
  background: rgba(247, 252, 255, 0.82);
}

.game-bg-preview img {
  width: 100%;
  max-height: 170px;
  object-fit: cover;
  border-radius: 10px;
  margin-top: 0.4rem;
}

@media (max-width: 900px) {
  .admin-identity-line {
    justify-content: flex-start;
  }

  .inline-actions {
    width: 100%;
  }

  #carton-form.inline-form {
    grid-template-columns: 1fr;
  }

  #carton-form .inline-actions {
    grid-column: auto;
    justify-self: stretch;
  }

  .carton-header-row {
    align-items: flex-start;
  }

  .call-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .join-qr-panel {
    flex-wrap: wrap;
  }

  .join-url-link {
    max-width: min(86vw, 300px);
  }

  .join-qr-image {
    width: min(86vw, 280px);
    height: min(86vw, 280px);
  }

  .call-letter {
    font-size: 2.5rem;
  }

  .call-number {
    font-size: 3.2rem;
  }

  .numbers-and-winner {
    grid-template-columns: 1fr;
  }

  .board-row {
    grid-template-columns: 74px 1fr;
  }

  .row-track {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: thin;
  }

  .row-letter {
    font-size: 4.2rem;
  }

  .ball-cell {
    width: 80px;
    height: 80px;
    min-height: 80px;
    font-size: 1.85rem;
  }

  .cashier-only .container {
    padding: 0.52rem;
  }
}

@media (max-width: 640px) {
  .call-strip {
    grid-template-columns: 1fr;
  }
}
