@font-face {
  font-family: "SF Pro Display";
  src: url("asset/fonts/sfprodisplay_regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
}
@font-face {
  font-family: "SF Pro Display";
  src: url("asset/fonts/sfprodisplay_bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
}
@font-face {
  font-family: "SF Pro Display";
  src: url("asset/fonts/sfprodisplay_heavyitalic.woff2") format("woff2");
  font-weight: 800;
  font-style: italic;
}
@font-face {
  font-family: "DS-Digital";
  src: url("asset/fonts/ds_digital_bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
}

:root {
  --green: #51b579;
  --green-hi: #5fdb94;
  --panel: #1b1e1f;
  --cell: linear-gradient(180deg, #333f46 0%, #242b31 100%);
  --cell-sel: linear-gradient(180deg, #254632 0%, #4c8b65 100%);
  --muted: #789588;
  --text: #e2e2e2;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #191b31;
  color: var(--text);
  font-family: "SF Pro Display", "Segoe UI", sans-serif;
  overflow: hidden;
}

.desktop-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #191b31 url("asset/bg.jpg") center / cover no-repeat;
}

.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(#000, transparent);
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  display: grid;
  place-items: center;
  text-decoration: none;
  cursor: pointer;
}
.icon-btn img { width: 16px; height: auto; }

.credit {
  margin-left: auto;
  background: #111;
  border: 1px solid #2c3a36;
  border-radius: 8px;
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
}
.credit strong { font-size: 0.95rem; color: #e6b529; }
.credit span { color: #9aa3af; font-size: 0.72rem; margin-left: 4px; }

.fair-id {
  color: #71ce96;
  font-size: 0.78rem;
  padding-right: 22px;
  background: url("asset/icon_fairness.png") right center / 16px no-repeat;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-tabs { display: none; }

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr) minmax(220px, 280px);
  gap: 8px;
  padding: 0 8px 8px;
}

.side {
  background: rgba(20, 24, 26, 0.86);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.side-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 10px 6px;
  flex-shrink: 0;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #71ce96;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 4px 0 8px 20px;
  position: relative;
  opacity: 0.7;
}
.tab.on { opacity: 1; }
.tab.on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: #71ce96;
}
.icn {
  position: absolute;
  left: 0;
  top: 4px;
  width: 16px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
}
.tab-game { background-image: url("asset/tab1.svg"); }
.tab-hist { background-image: url("asset/tab2.svg"); }
.tab-res { background-image: url("asset/tab3.svg"); }
.tab-stat { background-image: url("asset/tab4.svg"); }
.tab-lead { background-image: url("asset/tab5.svg"); }

.sub-tabs {
  display: flex;
  gap: 8px;
  padding: 0 10px 8px;
  font-size: 0.72rem;
}
.sub {
  appearance: none;
  border: 0;
  background: transparent;
  color: #9aa8a0;
  cursor: pointer;
}
.sub.on { color: #fff; }
.sub em { color: var(--green); font-style: normal; margin-left: 2px; }

.side-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 8px 10px;
  scrollbar-width: thin;
  scrollbar-color: #8b8e8f rgba(255, 255, 255, 0.1);
}

.ticket-row {
  background: #283134;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 4px;
  font-size: 0.75rem;
}
.ticket-row .who { color: #d7d9db; margin-bottom: 4px; display: flex; justify-content: space-between; }
.ticket-row .nums { display: flex; gap: 3px; flex-wrap: wrap; }
.ticket-row .n {
  background: #35434b;
  border-radius: 3px;
  padding: 6px 0;
  min-width: 22px;
  text-align: center;
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
}
.ticket-row .n.hit { background: #51b579; color: #fff; }
.ticket-row .st { color: #ffe833; }
.ticket-row .st.win { color: #51b579; }
.ticket-row.mine { background: rgba(163, 85, 39, 0.74); }

.result-row {
  background: #283134;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 4px;
}
.result-row .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.72rem; margin-bottom: 4px; }
.result-row .combo { color: #51b579; font-size: 0.72rem; line-height: 1.35; word-spacing: 4px; }
.result-row.wait .combo { color: #ffde39; }

.stat-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 0.75rem; }
.stat-row .num {
  width: 28px;
  text-align: center;
  background: #475259;
  border-radius: 3px;
  padding: 6px 0;
  color: #d7d9db;
}
.stat-row .bar { flex: 1; height: 2px; background: #2a3336; }
.stat-row .bar i { display: block; height: 100%; background: #51b579; }
.stat-row .val { width: 28px; color: #fff; }

.stage {
  background: rgba(27, 30, 31, 0.92);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 6px 10px 10px;
}

.keno-logo {
  display: block;
  height: 28px;
  width: auto;
  margin: 4px auto 0;
  mix-blend-mode: screen;
}

.timer {
  width: min(320px, 70%);
  margin: 4px auto 8px;
  text-align: center;
  font-family: "DS-Digital", monospace;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: #fff;
  padding: 8px 0 10px;
  background: url("asset/timer_bg.svg") center / contain no-repeat;
  text-shadow: 0 0 12px rgba(95, 219, 148, 0.45);
}

.ticket {
  position: relative;
  height: 132px;
  border-radius: 6px;
  background: #283134 url("asset/ticket_bg.svg") left center / cover no-repeat;
  margin-bottom: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.ticket::after {
  content: "";
  position: absolute;
  left: -2%;
  top: -8%;
  width: 18%;
  height: 120%;
  background: url("asset/balls.png") left top / contain no-repeat;
  pointer-events: none;
}
.ticket.has-picks::after,
.ticket.is-draw::after { display: none; }
.ticket.has-picks,
.ticket.is-draw { background-image: none; }

.ticket-empty {
  position: relative;
  z-index: 1;
  padding: 28px 18% 16px 22%;
}
.ticket-empty p {
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
}
.ticket-empty span { color: #5fdb94; font-family: "Roboto Condensed", sans-serif; font-weight: 700; }
.help-q {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #35434b;
  color: #51b579;
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 2;
}

.ticket-sel { position: relative; z-index: 1; padding: 8px 10px; height: 100%; }
.ticket-sel.hidden, .ticket-empty.hidden, .draw-stage.hidden { display: none; }
.sel-head { display: flex; align-items: baseline; gap: 6px; margin-bottom: 4px; }
.sel-head strong { font-size: 1.05rem; }
.sel-head em { opacity: 0.6; font-style: normal; font-size: 0.85rem; }
.possible { margin-left: auto; color: #51b579; font-family: "Roboto Condensed", sans-serif; font-weight: 700; }

.pay-row {
  display: grid;
  grid-template-columns: 52px repeat(11, 1fr);
  gap: 2px;
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  opacity: 0.45;
  margin-bottom: 3px;
}
.pay-row span { text-align: center; }
.pay-row span:first-child { text-align: left; opacity: 1; }
.pay-row .hi { color: #51b579; opacity: 1; }
.picked-row { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin-top: 4px; }
.picked-row b {
  background: #20282b;
  border-radius: 3px;
  text-align: center;
  padding: 8px 0;
  font-family: "Roboto Condensed", sans-serif;
  font-size: 0.95rem;
}
.picked-row b.on { background: #35434b; }
.picked-row b.hit { background: #51b579; color: #fff; }

.draw-stage {
  position: relative;
  z-index: 1;
  height: 100%;
  background: url("asset/gameplay_bg.svg") center / contain no-repeat;
}
.draw-stage::before {
  content: "";
  position: absolute;
  inset: -80% 0 auto;
  height: 220%;
  background: url("asset/gameplay_bg_anim.svg") center / contain no-repeat;
  animation: spin 20s linear infinite;
  pointer-events: none;
}
.draw-count {
  position: relative;
  z-index: 2;
  text-align: center;
  padding-top: 8px;
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  color: #5fdb94;
  font-size: 1.1rem;
}
.draw-balls {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px 0;
}
.kball {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  color: #e2e2e2;
  background: radial-gradient(circle, #0d3b69 0%, #061c33 36%, #4c6e6e 84%);
  box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.4);
  animation: pop 0.45s ease;
}
.kball.hit {
  color: #70f7a6;
  background: radial-gradient(circle, #087b67 0%, #03493f 59%, #6be2a8 78%);
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop {
  0% { transform: scale(0.2); opacity: 0; }
  55% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

.board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 3px;
}

.cell {
  appearance: none;
  border: 0;
  border-radius: 3px;
  background: var(--cell);
  color: #a0a0a0;
  font-family: "Roboto Condensed", sans-serif;
  font-weight: 700;
  font-size: clamp(0.85rem, 1.6vw, 1.35rem);
  cursor: pointer;
  position: relative;
}
.cell:hover { background: linear-gradient(180deg, #435057 0%, #333f46 100%); }
.cell.sel { color: #fff; background: var(--cell-sel); }
.cell.drawn { outline: 1px solid #5fdb94; }
.cell.hit { color: #fff; background: var(--cell-sel); box-shadow: inset 0 0 0 2px #70f7a6; }
.cell.hot::before,
.cell.cold::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.cell.hot::before { background: #e23b3b; }
.cell.cold::before { background: #3b82f6; }
.cell:disabled { cursor: default; }

.bet-bar {
  display: grid;
  grid-template-columns: 1.4fr 0.45fr 0.45fr 1.3fr;
  gap: 6px;
  margin-top: 8px;
  flex-shrink: 0;
}
.stake {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #242b31 0%, #333f46 100%);
  border-radius: 3px;
}
.step {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.step img { width: 22px; height: auto; }
#bet-amt {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #fff;
  text-align: center;
  font-family: "SF Pro Display", sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
}
.quick, .bet-btn {
  border: 0;
  border-radius: 3px;
  height: 44px;
  cursor: pointer;
}
.quick {
  background: linear-gradient(180deg, #333f46 0%, #242b31 100%);
  color: #51b579;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.bet-btn {
  background: linear-gradient(180deg, #4c8b65 0%, #254632 100%);
  color: #fff;
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  opacity: 0.55;
}
.bet-btn.on { opacity: 1; }
.bet-btn .lab-wait, .bet-btn .lab-ok { display: none; }
.bet-btn.wait .lab-bet, .bet-btn.ok .lab-bet { display: none; }
.bet-btn.wait .lab-wait { display: inline; }
.bet-btn.ok .lab-ok { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; }
.bet-btn.ok img { width: 16px; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
}
.overlay.hidden, .menu.hidden { display: none; }
.result-card {
  background: #1b1e1f;
  border: 1px solid #4c8b65;
  border-radius: 10px;
  padding: 28px 36px;
  text-align: center;
  min-width: 240px;
}
.result-card h2 {
  font-family: "Roboto Condensed", sans-serif;
  font-size: 2.4rem;
  color: #5fdb94;
}
.result-card.lose h2 { color: #e2e2e2; }
.result-card p { margin: 8px 0 16px; color: #9aa8a0; }
.again {
  border: 0;
  border-radius: 4px;
  background: linear-gradient(180deg, #4c8b65 0%, #254632 100%);
  color: #fff;
  font-weight: 800;
  padding: 10px 28px;
  cursor: pointer;
}

.menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(10, 12, 14, 0.96);
  padding: 48px 24px 24px;
  overflow: auto;
  color: #d7d9db;
}
.menu h3 { margin-bottom: 10px; color: #5fdb94; }
.menu p { max-width: 720px; line-height: 1.45; margin-bottom: 14px; }
.menu-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.pay-wrap { overflow-x: auto; }
.pay-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 640px;
}
.pay-table th, .pay-table td {
  border: 1px solid #2c3a36;
  padding: 6px 8px;
  text-align: center;
}
.pay-table th { color: #51b579; }
.rtp { color: #71ce96; margin-top: 16px; }

@media (max-width: 980px) {
  .mobile-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    background: #111827;
    border-bottom: 1px solid #2c3a36;
  }
  .m-tab {
    appearance: none;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-weight: 700;
    padding: 10px 6px;
    cursor: pointer;
  }
  .m-tab.active { color: #fff; border-bottom: 3px solid #51b579; background: #1b1e1f; }
  .layout {
    grid-template-columns: 1fr;
    padding: 0;
  }
  .left-side, .right-side { display: none; }
  .app.show-live .left-side,
  .app.show-results .right-side {
    display: flex;
    position: absolute;
    inset: 88px 0 0;
    z-index: 5;
    border-radius: 0;
  }
  .app.show-live .stage,
  .app.show-results .stage { visibility: hidden; }
  .ticket { height: 110px; }
  .bet-bar { grid-template-columns: 1.2fr 0.4fr 0.4fr 1.1fr; }
}
