:root {
  --bg: #F0F7FF;
  --bg-2: #FFFFFF;
  --panel: #FFFFFF;
  --panel-2: #E5F1FF;
  --header-bg: #FFFFFF;
  --stat-bg: #FFFFFF;
  --purple: #1555B8;
  --purple-deep: #172B4D;
  --heading: #123B78;
  --ink: #172B4D;
  --muted: #64748B;
  --gold: #F5A623;
  --gold-bright: #F59E0B;
  --gold-grad: linear-gradient(135deg, #F5A623, #FF9500);
  --blue-grad: linear-gradient(135deg, #2478D4, #1555B8);
  --bright-blue: #38A5F5;
  --navy: #102A5E;
  --active-nav: #D5E9FF;
  --b-green: #1555B8;
  --i-orange: #2478D4;
  --n-blue: #102A5E;
  --g-red: #F5A623;
  --o-purple: #16A34A;
  --called-bg: #1555B8;
  --current-bg: #2478D4;
  --cell-bg: #FFFFFF;
  --cell-ink: #172B4D;
  --refresh-bg: var(--blue-grad);
  --glass: rgba(229, 241, 255, 0.8);
  --line: #C3DAF5;
  --green: #16A34A;
  --success: #16A34A;
  --warning: #F59E0B;
  --error: #EF4444;
}

* { box-sizing: border-box; }

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

body {
  font-family: system-ui, "Segoe UI", -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.boot-loader.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-spinner {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: conic-gradient(
    #EF4444 0deg 120deg,
    #F5A623 120deg 240deg,
    #16A34A 240deg 360deg
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #000 calc(100% - 7px));
  animation: boot-spin 0.9s linear infinite;
  box-shadow: 0 0 24px rgba(21, 85, 184, 0.2);
}

@keyframes boot-spin {
  to { transform: rotate(360deg); }
}

.boot-text {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--heading);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.boot-dots { display: inline-flex; gap: 4px; }

.boot-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  animation: boot-bounce 1s ease-in-out infinite;
}

.boot-dots span:nth-child(1) { background: #EF4444; }
.boot-dots span:nth-child(2) { background: #F5A623; animation-delay: 0.15s; }
.boot-dots span:nth-child(3) { background: #16A34A; animation-delay: 0.3s; }

@keyframes boot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40% { transform: translateY(-6px); opacity: 1; }
}

button { font-family: inherit; touch-action: manipulation; }

[hidden] { display: none !important; }

.app {
  height: 100vh;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.appbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 22px;
  height: auto;
  padding: var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 0px)) 4px 0;
  background-color: #078930;
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 40%, rgba(0, 0, 0, 0.1) 100%),
    linear-gradient(180deg,
      #078930 0%,
      #078930 33.34%,
      #FCDD09 33.34%,
      #FCDD09 66.67%,
      #DA121A 66.67%,
      #DA121A 100%);
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 0;
  box-shadow: 0 4px 18px rgba(16, 42, 94, 0.22);
}

.appbar-horse {
  position: absolute;
  left: 20%;
  top: 50%;
  height: 18px;
  width: auto;
  transform: translate(-50%, -50%);
  color: var(--error);
  stroke-width: 7;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.95)) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.appbar-star {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  opacity: 0.65;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));
}

.appbar-icon,
.appbar-title,
.appbar-right {
  position: relative;
  z-index: 1;
}

.appbar-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: linear-gradient(180deg, #FFFFFF 0%, #EEF4FF 100%);
  color: #102A5E;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28), inset 0 1px 0 #FFFFFF;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.appbar-icon:active {
  transform: scale(0.92);
  background: #FFFFFF;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), inset 0 1px 0 #FFFFFF;
}

#menuBtn {
  display: flex;
  align-items: center;
  width: auto;
  height: 20px;
  padding: 0 9px;
  gap: 4px;
  border: 1.5px solid var(--purple);
  border-radius: 999px;
  background: linear-gradient(180deg, #FFFFFF 0%, #EEF4FF 100%);
  color: var(--purple);
  font-size: 9px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28), 0 0 10px rgba(21, 85, 184, 0.45), inset 0 1px 0 #FFFFFF;
}

#menuBtn:active {
  background: linear-gradient(180deg, #EEF4FF, #DCE9FF);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25), inset 0 1px 0 #FFFFFF;
}

#menuBtn .menu-dots {
  font-size: 12px;
  line-height: 1;
}

#menuBtn .menu-text {
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--purple);
  text-shadow: none;
}

#menuBtn { animation: menu-glow 1.6s ease-in-out infinite; }

#menuBtn::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 999px;
  border: 2px solid rgba(21, 85, 184, 0.85);
  animation: menu-ring 1.6s ease-out infinite;
  pointer-events: none;
}

@keyframes menu-glow {
  0%, 100% {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28), 0 0 10px rgba(21, 85, 184, 0.45), inset 0 1px 0 #FFFFFF;
  }
  50% {
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.3), 0 0 22px rgba(21, 85, 184, 0.85), 0 0 34px rgba(21, 85, 184, 0.4), inset 0 1px 0 #FFFFFF;
  }
}

@keyframes menu-ring {
  0% { transform: scale(0.9); opacity: 0.9; }
  70%, 100% { transform: scale(1.4); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #menuBtn, #menuBtn::after { animation: none; }
}

#closeBtn {
  position: relative;
  font-size: 0;
  color: transparent;
}

#closeBtn::before,
#closeBtn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 2px;
  border-radius: 2px;
  background: #0B1F45;
}

#closeBtn::before { transform: translate(-50%, -50%) rotate(45deg); }
#closeBtn::after { transform: translate(-50%, -50%) rotate(-45deg); }

.appbar-title {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.appbar-title h1 {
  margin: 0;
  color: #0B1F45;
  font-family: Impact, "Haettenschweiler", "Arial Narrow Bold", "Arial Black", sans-serif;
  font-size: clamp(10px, 3vw, 13px);
  font-style: italic;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow:
    1px 1px 0 rgba(255, 255, 255, 0.9),
    -1px 1px 0 rgba(255, 255, 255, 0.9),
    1px -1px 0 rgba(255, 255, 255, 0.9),
    -1px -1px 0 rgba(255, 255, 255, 0.9),
    0 0 6px rgba(255, 255, 255, 0.65),
    0 2px 5px rgba(0, 0, 0, 0.3);
  animation: header-float 3.2s ease-in-out infinite;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar-title h1 .hw {
  display: inline-block;
}

.appbar-title h1 .hw-1,
.appbar-title h1 .hw-2,
.appbar-title h1 .hw-3 {
  color: inherit;
}

@keyframes header-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .appbar-title h1 { animation: none; }
}

.appbar-caret {
  border: 0;
  padding: 2px;
  border-radius: 4px;
  background: transparent;
  color: #FFFFFF;
  font-size: 10px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

.appbar-right { position: relative; display: flex; justify-content: flex-end; }

.dropdown {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: min(86vw, 320px);
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 32px rgba(21, 85, 184, 0.18), 0 2px 8px rgba(21, 85, 184, 0.08);
  z-index: 40;
}

.dropdown-right { left: auto; right: 0; transform: none; }

.dropdown-title { color: var(--heading); font-size: 13px; font-weight: 800; }
.dropdown-title.small { margin-bottom: 4px; }
.dropdown-sub { margin-top: 3px; color: var(--muted); font-size: 12px; font-weight: 700; }
.dropdown-sep { height: 1px; margin: 8px 0; background: var(--line); }

.menu-item {
  display: block;
  padding: 6px 2px;
  color: var(--purple-deep);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.dropdown-winners {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.winner-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border-radius: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}

.winner-name { font-weight: 800; color: var(--ink); }
.winner-line { color: var(--gold); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.winner-prize { margin-left: auto; color: var(--gold-bright); font-weight: 800; }

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 0 10px 0;
}

.stat:nth-child(1) { --accent: #1555B8; --accent-soft: #E7F0FF; }
.stat:nth-child(2) { --accent: #16A34A; --accent-soft: #E9FBF0; }
.stat:nth-child(3) { --accent: #2478D4; --accent-soft: #E8F3FF; }
.stat:nth-child(4) { --accent: #B45309; --accent-soft: #FFF4E0; }
.stat:nth-child(5) { --accent: #102A5E; --accent-soft: #EAF0FB; }

.stat {
  --accent: var(--purple);
  --accent-soft: #E7F0FF;
  padding: 7px 2px 6px;
  border-radius: 12px;
  background: linear-gradient(180deg, #FFFFFF 0%, var(--accent-soft) 100%);
  text-align: center;
  color: var(--accent);
  border: 1px solid var(--line);
  box-shadow: inset 0 3px 0 var(--accent), 0 2px 6px rgba(21, 85, 184, 0.12);
}

.stat-label {
  display: block;
  color: var(--accent);
  opacity: 0.85;
  font-size: clamp(9px, 2.6vw, 12px);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.stat-value {
  display: block;
  margin-top: 1px;
  font-size: clamp(15px, 4.4vw, 22px);
  font-weight: 800;
  line-height: 1.1;
}

.layout {
  display: grid;
  grid-template-columns: 38fr 62fr;
  gap: 8px;
  min-height: 0;
  padding: 10px;
}

.board-panel { min-height: 0; display: flex; }

.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.board-col {
  min-height: 0;
  display: grid;
  grid-template-rows: auto repeat(15, minmax(0, 1fr));
  gap: 3px;
}

.board-head {
  display: grid;
  place-items: center;
  min-height: clamp(20px, 3.4vh, 30px);
  border-radius: clamp(5px, 1.2vw, 8px);
  color: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  font-size: clamp(12px, 3.4vw, 16px);
  font-weight: 800;
}

.board-cell {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: clamp(4px, 1vw, 7px);
  background: var(--cell-bg);
  color: var(--cell-ink);
  font-size: clamp(8px, 1.7vh, 16px);
  font-weight: 800;
  transition: background 0.2s ease;
}

.board-cell.called { background: var(--called-bg); color: #FFFFFF; border-color: var(--purple); }
.board-cell.last { background: var(--current-bg); color: #FFFFFF; border-color: var(--current-bg); }

.letter-b { background: var(--b-green); }
.letter-i { background: var(--i-orange); }
.letter-n { background: var(--n-blue); }
.letter-g { background: var(--g-red); }
.letter-o { background: var(--o-purple); }

.side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.current-call {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 12px;
  background: linear-gradient(120deg, #FFFFFF, var(--panel-2));
  border: 1px solid var(--line);
  color: var(--heading);
  box-shadow: 0 3px 10px rgba(21, 85, 184, 0.1);
}

.call-label { color: var(--purple); font-size: clamp(12px, 3.8vw, 15px); font-weight: 800; }

.call-ball {
  flex: 0 0 auto;
  width: clamp(30px, 8vw, 38px);
  height: clamp(30px, 8vw, 38px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-grad);
  color: #FFFFFF;
  font-size: clamp(12px, 3.4vw, 15px);
  font-weight: 900;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.45), 0 3px 10px rgba(21, 85, 184, 0.3);
}

.call-ball.pop { animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.3); }

@keyframes pop {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.recent-calls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vw, 10px);
  min-height: clamp(34px, 6vh, 42px);
  padding: 4px 8px;
  border-radius: 12px;
  background: var(--glass);
  border: 1px solid var(--line);
}

.recent-ball {
  flex: 0 0 auto;
  width: clamp(28px, 8vw, 34px);
  height: clamp(28px, 8vw, 34px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #FFFFFF;
  border: 1px solid var(--purple);
  font-size: clamp(9px, 2.6vw, 11px);
  font-weight: 800;
}

.recent-ball.placeholder { background: var(--panel-2); color: var(--muted); border-color: var(--line); }

.call-side { display: flex; align-items: center; gap: 8px; }

.auto-inline { display: flex; align-items: center; gap: 5px; cursor: pointer; }

.auto-label { color: var(--heading); font-size: clamp(11px, 3.2vw, 13px); font-weight: 800; }

.switch { position: relative; display: inline-block; width: 34px; height: 20px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #CBD5E1;
  cursor: pointer;
  transition: background 0.2s ease;
}

.slider::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(14px); }

.message-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 8px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 3px 12px rgba(21, 85, 184, 0.1);
}

.message-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.message-inner.message-only { justify-content: center; }

.message-text {
  margin: 0;
  color: var(--purple-deep);
  text-align: center;
  font-size: clamp(14px, 4.2vw, 19px);
  font-weight: 800;
  line-height: 1.5;
  white-space: pre-line;
}

.live-badge {
  align-self: center;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--success);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.3);
}

.live-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  border-radius: 50%;
  background: #FFFFFF;
  animation: live-pulse 1.2s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.cards { display: flex; flex-direction: column; gap: 8px; }

.card {
  padding: 8px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(21, 85, 184, 0.06);
}

.card.bingo { box-shadow: 0 0 0 2px var(--success), 0 0 18px rgba(22, 163, 74, 0.3); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--purple-deep);
  font-size: 11px;
  font-weight: 800;
}

.card-head b { color: var(--ink); font-size: 12px; }

.badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--gold-grad);
  color: var(--cell-ink);
  font-size: 9px;
  font-weight: 800;
}

.letters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-top: 6px;
}

.letters span {
  padding: 2px 0;
  border-radius: 6px;
  color: #FFFFFF;
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.board-head.letter-g,
.recent-ball.letter-g,
.letters span.letter-g { color: var(--navy); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  margin-top: 4px;
}

.ccell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--cell-bg);
  color: var(--cell-ink);
  font-size: clamp(10px, 2.6vw, 15px);
  font-weight: 800;
}

.ccell.marked { background: var(--called-bg); color: #FFFFFF; border-color: var(--called-bg); }
.ccell.free { background: var(--gold-grad); color: #FFFFFF; border-color: var(--gold); }
.ccell.win { background: var(--success); color: #FFFFFF; border-color: var(--success); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35), 0 0 12px rgba(22, 163, 74, 0.35); }

.message-inner.fit-cards { overflow: hidden; }

.message-inner.fit-cards .message-text { font-size: clamp(12px, 3.6vw, 16px); line-height: 1.35; }

.cards-two { flex: 1 1 auto; gap: 6px; min-height: 0; }

.cards-two .card {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 6px;
}

.cards-two .card-head,
.cards-two .letters { flex: 0 0 auto; }

.cards-two .letters span { padding: 1px 0; font-size: 9px; }

.cards-two .card-grid {
  flex: 1 1 auto;
  min-height: 0;
  gap: 3px;
  grid-template-rows: repeat(5, minmax(0, 1fr));
}

.cards-two .ccell {
  aspect-ratio: auto;
  min-height: 0;
  overflow: hidden;
  font-size: clamp(9px, 2.2vw, 13px);
  line-height: 1;
}

.winner-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(10px + var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 0px))) 10px 10px;
  background: rgba(16, 42, 94, 0.62);
}

.winner-box {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(16, 42, 94, 0.35);
}

.winner-head {
  text-align: center;
  font-family: Impact, "Haettenschweiler", "Arial Narrow Bold", "Arial Black", sans-serif;
  font-size: 28px;
  font-style: italic;
  letter-spacing: 0.05em;
  color: var(--gold-bright);
  text-shadow: 0 2px 0 rgba(247, 250, 255, 0.9), 0 3px 8px rgba(21, 85, 184, 0.25);
}

.winner-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 10px;
}

.winner-cards .card { width: min(260px, 100%); }
.winner-cards .card-head b { font-size: 13px; }

.winner-foot {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

body.winner-open { overflow: hidden; }

.empty {
  padding: 14px 8px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.actions { display: flex; flex-wrap: nowrap; justify-content: center; gap: 4px; }

.bet-control {
  position: relative;
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}

.bet-control select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  background: transparent;
  opacity: 0;
  appearance: none;
  cursor: pointer;
  font-size: 16px;
}

.bet-caret {
  font-size: 14px;
  line-height: 1;
  opacity: 0.8;
}

#buyBtn, #pickBtn {
  flex: 1 1 0;
  min-width: 0;
  padding: 4px 6px;
  border: 1.5px solid #FFFFFF;
  border-radius: 999px;
  background: var(--gold-grad);
  color: var(--navy);
  font-size: clamp(8px, 2.4vw, 10px);
  font-weight: 800;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2), 0 0 10px rgba(245, 166, 35, 0.55);
  cursor: pointer;
  animation: menu-glow 1.6s ease-in-out infinite;
}

#buyBtn:disabled, #pickBtn:disabled { opacity: 0.55; animation: none; }

@media (prefers-reduced-motion: reduce) {
  #buyBtn, #pickBtn { animation: none; }
}

.bottombar {
  display: flex;
  justify-content: center;
  padding: 0 10px env(safe-area-inset-bottom);
  background-color: #102A5E;
  background-image:
    radial-gradient(120% 180% at 50% 0%, rgba(56, 165, 245, 0.35) 0%, rgba(16, 42, 94, 0) 60%),
    linear-gradient(180deg, #123B78 0%, #102A5E 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0;
  box-shadow: 0 -4px 18px rgba(16, 42, 94, 0.22);
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 3px 0 0;
  border: 0;
  background: transparent;
  color: #FFFFFF;
  cursor: pointer;
}

.refresh-star {
  position: relative;
  display: block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0) 60%),
    #2478D4;
  border: 1px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.12s ease;
}

.refresh-star::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  transform: translate(-50%, -50%);
  background: #FFFFFF;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.refresh-caption {
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.refresh-btn:active .refresh-star { transform: scale(0.9); }
.refresh-btn:disabled { opacity: 0.75; cursor: default; }
.refresh-btn.is-busy .refresh-star { animation: star-pulse 0.9s ease-in-out infinite; }

@keyframes star-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.82); }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(
      8px + var(--tg-content-safe-area-inset-top, env(safe-area-inset-top, 0px))
    )
    8px 8px;
  background: rgba(16, 42, 94, 0.45);
}

.sheet {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 -20px 50px rgba(21, 85, 184, 0.18);
}

body.picker-open { overflow: hidden; }

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sheet-head h2 { margin: 0; font-size: 18px; color: var(--heading); }
.sheet-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }

.ghost {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #FFFFFF;
  color: var(--purple);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.primary {
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--blue-grad);
  color: #FFFFFF;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(21, 85, 184, 0.25);
  cursor: pointer;
}

.pick-timebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--accent-soft, #E7F0FF);
  color: var(--purple);
  font-size: 12px;
  font-weight: 800;
}

.pick-timebar.urgent { background: #FDE7E7; color: #C62828; }

.pick-time-label { display: inline-flex; align-items: center; gap: 5px; }

.pick-timer {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.lucky-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.legend-item { display: inline-flex; align-items: center; gap: 5px; }

.legend-item .dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--cell-bg);
}

.legend-item .dot.taken { background: var(--panel-2); border-color: var(--line); }
.legend-item .dot.mine { background: var(--purple); border-color: var(--purple); }

.lucky-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 5px;
  margin-top: 10px;
}

.lucky-num {
  position: relative;
  min-height: 32px;
  padding: 4px 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--cell-bg);
  color: var(--cell-ink);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.lucky-num.taken {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.9;
}

.lucky-num.mine {
  border-color: var(--purple);
  background: var(--purple);
  color: #FFFFFF;
  box-shadow: 0 0 10px rgba(21, 85, 184, 0.3);
  cursor: default;
}

.lucky-num.mine::after {
  content: "\2713";
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: 9px;
  line-height: 1;
  font-weight: 900;
  color: #FFFFFF;
}

.lucky-num:disabled:not(.taken):not(.mine) { opacity: 0.4; }

.pick-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.menu-sheet { max-width: 460px; }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.menu-action {
  min-height: 46px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.menu-action:active {
  transform: scale(0.98);
  background: var(--active-nav);
  border-color: var(--purple);
  color: var(--purple);
}

.menu-action.play {
  grid-column: 1 / -1;
  background: var(--blue-grad);
  border-color: var(--purple);
  color: #FFFFFF;
  box-shadow: 0 8px 20px rgba(21, 85, 184, 0.25);
}

.menu-action[data-mm="deposit"] {
  background: var(--purple);
  border-color: var(--purple);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(21, 85, 184, 0.25);
}

.menu-action[data-mm="withdraw"] {
  background: var(--gold-bright);
  border-color: var(--gold);
  color: var(--navy);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.25);
}

.menu-action[data-mm="transfer"] {
  background: var(--green);
  border-color: var(--green);
  color: #FFFFFF;
  box-shadow: 0 6px 16px rgba(22, 163, 74, 0.25);
}

.menu-foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

#wallet, #menuWallet {
  color: var(--gold-bright);
  font-weight: 800;
}

#balance {
  color: var(--accent);
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  z-index: 50;
  max-width: 82vw;
  padding: 10px 14px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  color: var(--heading);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(21, 85, 184, 0.2);
  transform: translateX(-50%);
}

@media (max-width: 380px) {
  .stats { gap: 4px; padding: 0 6px 0; }
  .layout { gap: 5px; padding: 8px 6px; }
  .board { gap: 3px; }
  .board-col { gap: 2px; }
  .side { gap: 6px; }
  .recent-calls { gap: 6px; padding: 5px 8px; }
}

@media (max-height: 520px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .board-col { grid-template-rows: auto repeat(15, minmax(24px, 1fr)); }
  .message-panel { min-height: 160px; }
}
