:root {
  --bg: #0b0713;
  --panel: #160f26;
  --panel-2: #211438;
  --card: rgba(255, 255, 255, 0.075);
  --card-strong: rgba(255, 255, 255, 0.11);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f6f0ff;
  --muted: #b7a8ce;
  --accent: #9146ff;
  --accent-2: #c5a3ff;
  --good: #38d991;
  --warn: #ffce6b;
  --danger: #ff5c7c;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  --radius-sm: 14px;
  font-family: "SN Pro", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(145, 70, 255, 0.32), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(56, 217, 145, 0.12), transparent 28rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 330px) 1fr;
  min-height: 100vh;
}

.side-panel {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  background: linear-gradient(180deg, rgba(22, 15, 38, 0.96), rgba(11, 7, 19, 0.97));
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.brand-block {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.logo-only {
  padding: 6px 2px 2px;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 265px;
  height: auto;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.32));
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 1.55rem;
  letter-spacing: -0.05em;
}

h2 {
  font-size: clamp(1.9rem, 3vw, 3.4rem);
  letter-spacing: -0.06em;
}

h3 {
  font-size: 1.25rem;
}

.eyebrow,
.section-label {
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: blur(16px);
}

.live-card {
  text-align: center;
  background: linear-gradient(160deg, rgba(145, 70, 255, 0.18), rgba(255, 255, 255, 0.07));
}

.current-ball {
  display: grid;
  place-items: center;
  width: 142px;
  height: 142px;
  margin: 14px auto 10px;
  border-radius: 50%;
  color: #170d29;
  background: radial-gradient(circle at 33% 25%, #ffffff 0, #efe6ff 42%, #cdb3ff 100%);
  border: 10px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset -14px -18px 26px rgba(23, 13, 41, 0.18), 0 20px 42px rgba(145, 70, 255, 0.35);
  font-size: 3.6rem;
  font-weight: 950;
  letter-spacing: -0.08em;
}

.muted,
.form-message {
  color: var(--muted);
  font-size: 0.88rem;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.prize-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.prize-row:first-of-type {
  border-top: 0;
}

.prize-row span {
  font-weight: 800;
}

.prize-row strong {
  color: var(--good);
  font-size: 1.15rem;
}

.prize-row small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.house-row strong {
  color: var(--warn);
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: rgba(5, 3, 10, 0.45);
}

input:focus {
  border-color: rgba(197, 163, 255, 0.9);
  box-shadow: 0 0 0 4px rgba(145, 70, 255, 0.16);
}

.money-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 12px;
  border-radius: 14px;
  background: rgba(5, 3, 10, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.money-input span {
  color: var(--muted);
  font-weight: 900;
}

.money-input input {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.ticket-form {
  display: grid;
  gap: 10px;
}

.primary-btn,
.secondary-btn,
.danger-btn {
  min-height: 42px;
  padding: 11px 13px;
  border-radius: 14px;
  color: white;
  font-weight: 900;
  transition: transform 160ms ease, filter 160ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), #6320d7);
  box-shadow: 0 12px 24px rgba(145, 70, 255, 0.25);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.11);
  color: var(--text);
}

.danger-btn {
  background: rgba(255, 92, 124, 0.18);
  color: #ffdce4;
}

.primary-btn:hover,
.secondary-btn:hover,
.danger-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.button-grid {
  display: grid;
  gap: 9px;
}

.text-btn {
  color: var(--accent-2);
  background: transparent;
  font-weight: 900;
}

.called-balls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.called-balls.empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.called-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 31px;
  height: 31px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
}

.tickets-panel {
  padding: 36px;
}

.tickets-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.stats-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stats-strip span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
}

.stats-strip strong {
  color: var(--text);
}

.tickets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.ticket-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.06));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

.ticket-card.house-winner {
  border-color: rgba(255, 206, 107, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 206, 107, 0.3), 0 18px 48px rgba(0, 0, 0, 0.24);
}

.ticket-card.line-winner {
  border-color: rgba(56, 217, 145, 0.75);
}

.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.player-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-weight: 950;
}

.player-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: rgba(145, 70, 255, 0.22);
  color: #e8d9ff;
}

.ticket-status {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.ticket-status.won-line {
  color: #dfffee;
  background: rgba(56, 217, 145, 0.18);
}

.ticket-status.won-house {
  color: #fff2cf;
  background: rgba(255, 206, 107, 0.18);
}

.ticket-shell {
  padding: 14px;
}

.ticket-card {
  min-width: 0;
}

.bingo-ticket {
  display: grid;
  gap: 0;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(71, 47, 110, 0.22);
  background: linear-gradient(180deg, #fffefe, #f7f4fb);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.95), 0 10px 24px rgba(9, 5, 18, 0.08);
}

.ticket-row {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

.ticket-row + .ticket-row {
  border-top: 1px solid #d9d3e5;
}

.ticket-cell {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  min-height: 0;
  padding: 2px;
  overflow: hidden;
  background: #ffffff;
  color: #181125;
  font-size: clamp(0.95rem, 0.35vw + 0.8rem, 1.25rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.cell-number {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.ticket-cell + .ticket-cell {
  border-left: 1px solid #d9d3e5;
}

.ticket-cell.blank {
  color: transparent;
  background: #fbf9fe;
}

.ticket-cell.called::after {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 72%;
  height: 72%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(145, 70, 255, 0.28);
  box-shadow: inset 0 0 0 3px rgba(145, 70, 255, 0.62);
  z-index: 1;
}

.ticket-row-win .ticket-cell:not(.blank) {
  background: linear-gradient(180deg, #daf9ea, #c8f0dd);
  color: #11462d;
}

.ticket-row-win .ticket-cell.called::after {
  background: rgba(31, 174, 111, 0.26);
  box-shadow: inset 0 0 0 3px rgba(31, 174, 111, 0.68);
}

.ticket-meta {

  display: flex;
  justify-content: space-between;
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  min-height: 380px;
  padding: 38px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
}

.empty-icon {
  margin-bottom: 12px;
  font-size: 3rem;
}

.empty-state p {
  max-width: 460px;
  margin-top: 8px;
  color: var(--muted);
}

.winner-notice {
  margin-top: 12px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(56, 217, 145, 0.13);
  color: #dfffee;
  font-weight: 800;
  font-size: 0.86rem;
}

.hidden {
  display: none;
}

@media (max-width: 1400px) {
  .tickets-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

@media (max-width: 950px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tickets-panel {
    padding: 24px;
  }

  .tickets-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .side-panel,
  .tickets-panel {
    padding: 16px;
  }

  .tickets-grid {
    grid-template-columns: 1fr;
  }

  .current-ball {
    width: 120px;
    height: 120px;
    font-size: 3rem;
  }
}


@media (max-width: 720px) {
  .brand-logo {
    max-width: 220px;
  }
}

/* Minimal ticket cards and animated winner focus */
body.winner-open {
  overflow: hidden;
}

.minimal-ticket-card {
  padding: 14px;
  transition: opacity 260ms ease, transform 320ms ease, filter 320ms ease, box-shadow 320ms ease, border-color 320ms ease;
}

.winner-focus-active .minimal-ticket-card.is-dimmed {
  opacity: 0.16;
  transform: scale(0.96);
  filter: blur(1px) saturate(0.65);
}

.winner-focus-active .minimal-ticket-card.active-winner-in-grid {
  opacity: 1;
  transform: scale(1.025);
  z-index: 2;
}

.minimal-ticket-top,
.winner-ticket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.twitch-username {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.minimal-winner-label {
  flex: 0 0 auto;
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.minimal-ticket-card .ticket-shell,
.winner-ticket-card .ticket-shell {
  padding: 0;
}

.minimal-ticket-card .bingo-ticket,
.winner-ticket-card .bingo-ticket {
  padding: 0;
  overflow: hidden;
  border-radius: 12px;
}

.winner-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: clamp(18px, 4vw, 48px);
}

.winner-overlay.hidden {
  display: none;
}

.winner-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 2, 12, 0.82);
  backdrop-filter: blur(10px);
  animation: winnerBackdropIn 360ms ease both;
}

.winner-stage {
  position: relative;
  display: grid;
  gap: 20px;
  width: min(1180px, 100%);
  max-height: min(86vh, 900px);
  padding: clamp(18px, 3vw, 32px);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 30px;
  background: rgba(15, 10, 27, 0.94);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.52);
  animation: winnerStageIn 430ms cubic-bezier(0.2, 0.9, 0.2, 1.05) both;
}

.winner-stage-top {
  text-align: center;
}

.winner-stage-top h2 {
  margin-top: 4px;
  font-size: clamp(2rem, 5vw, 4.5rem);
}

.winner-prize-text {
  margin-top: 8px;
  color: var(--warn);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 900;
}

.winner-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 18px;
  align-items: center;
}

.winner-cards-grid.single-winner {
  grid-template-columns: minmax(280px, 620px);
  justify-content: center;
}

.winner-ticket-card {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.34);
  animation: winnerCardIn 460ms cubic-bezier(0.2, 0.9, 0.2, 1.08) both;
  animation-delay: var(--delay, 0ms);
}

.winner-ticket-card.line-winner-card {
  border-color: rgba(56, 217, 145, 0.55);
}

.winner-ticket-card.house-winner-card {
  border-color: rgba(255, 206, 107, 0.62);
}

.winner-ticket-top .twitch-username {
  font-size: clamp(1.05rem, 2vw, 1.45rem);
}

.winner-ticket-top strong {
  flex: 0 0 auto;
  color: var(--warn);
  font-size: clamp(1rem, 2vw, 1.35rem);
}

.winner-ticket-card .ticket-cell {
  font-size: clamp(1rem, 1.3vw, 1.7rem);
}

.play-on-btn {
  justify-self: center;
  min-width: 180px;
  padding: 15px 26px;
  font-size: 1rem;
}

.winner-overlay.is-closing .winner-backdrop {
  animation: winnerBackdropOut 360ms ease both;
}

.winner-overlay.is-closing .winner-stage {
  animation: winnerStageOut 380ms cubic-bezier(0.5, 0, 0.75, 0) both;
}

@keyframes winnerBackdropIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes winnerBackdropOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes winnerStageIn {
  from { opacity: 0; transform: translateY(28px) scale(0.82); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes winnerStageOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(22px) scale(0.86); }
}

@keyframes winnerCardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.88); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 520px) {
  .winner-stage {
    border-radius: 22px;
  }

  .winner-ticket-card {
    padding: 12px;
  }
}

/* Twitch chat connection and ticket sales controls */
.twitch-card .muted strong {
  color: var(--text);
}

.twitch-buttons {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.twitch-command-help {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.twitch-command-help strong {
  color: var(--text);
  font-weight: 900;
}

.twitch-status-pill.offline {
  color: #ffc5d1;
  background: rgba(255, 92, 124, 0.14);
}

.twitch-status-pill.connecting {
  color: #fff0c4;
  background: rgba(255, 206, 107, 0.14);
}

.twitch-status-pill.online {
  color: #dfffee;
  background: rgba(56, 217, 145, 0.16);
}

.ticket-sales-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.075), rgba(145, 70, 255, 0.09));
}

.ticket-sales-status.open {
  color: #dfffee;
  background: rgba(56, 217, 145, 0.16);
}

.ticket-sales-status.closed {
  color: #fff0c4;
  background: rgba(255, 206, 107, 0.16);
}

.full-btn {
  width: 100%;
}
