:root {
  --bg: #f5f5f7;
  --line: #d1d1d1;
  --blue: #0092dd;
  --red: #f1010a;
  --self: #c7edcc;
  --stake: #f1f1fd;
  --win: #fcfaf2;
}

* { box-sizing: border-box; }
html {
  overflow: clip;
  overscroll-behavior-y: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  height: 100dvh;
  min-height: 100svh;
  margin: 0;
  overflow: clip;
  overscroll-behavior-y: none;
  touch-action: manipulation;
  background: var(--bg);
  color: #111;
  font-family: "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
}
button,
textarea {
  -webkit-appearance: none;
  appearance: none;
  font-family: inherit;
  font-size: inherit;
}

.hidden { display: none !important; }
.app-shell {
  height: 100dvh;
  min-height: 100svh;
}

.error-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.error-card {
  width: min(360px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  text-align: center;
}

.chat-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  background: var(--bg);
  height: 100dvh;
  min-height: 100svh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  background: var(--bg);
}
.round-table {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin: 4px auto;
  padding: 0 6px;
}
.stage-label,
.countdown-label {
  min-width: 38px;
  padding-top: 7px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.stage-label { color: #111; }
.balance-label {
  width: fit-content;
  margin: 0 auto 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fff;
  color: #3273dc;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.draw-balls {
  display: grid;
  grid-template-columns: repeat(8, 24px);
  gap: 5px;
}
.ball {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 4px solid var(--blue);
  border-radius: 50%;
  background: var(--blue);
  color: #fafafa;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}
.ball.hot {
  border-color: var(--red);
  background: var(--red);
  color: #fafafa;
}
.topbar::after {
  content: "";
  display: block;
  height: 1px;
  width: 100%;
  background: #6464d3;
}

.chat-list {
  height: 100%;
  overflow-x: clip;
  overflow-y: auto;
  padding: 8px 0 12px 4px;
  overscroll-behavior-y: none;
}

.tip-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .42);
}
.tip-modal-card {
  position: relative;
  width: min(420px, 96vw);
  max-height: 88dvh;
  overflow: auto;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
}
.tip-modal-card img {
  display: block;
  width: 100%;
  height: auto;
}
.tip-close {
  position: sticky;
  top: 8px;
  left: calc(100% - 40px);
  z-index: 1;
  width: 30px;
  height: 30px;
  margin: 8px 8px -38px auto;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .72);
  color: #fff;
  font-size: 24px;
  line-height: 1;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  margin: 0 0 4px;
  padding: 0 8px 0 2px;
}
.message-row.self {
  justify-content: flex-end;
  padding-right: 6px;
}
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex: 0 0 auto;
  object-fit: cover;
}
.bubble-wrap {
  max-width: 330px;
}
.message-row.self .bubble-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.name-tag {
  display: inline-block;
  margin: 0 0 3px;
  padding: 2px 8px;
  border-radius: 4px;
  background: transparent;
  color: #f14668;
  font-size: 12px;
  font-weight: 700;
}
.message-row.self .name-tag {
  margin-right: 16px;
  color: #3273dc;
}

.bubble {
  position: relative;
  width: fit-content;
  max-width: 288px;
  min-height: 20px;
  margin: 0 0 22px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  word-break: break-all;
  word-wrap: break-word;
  line-height: 1.35;
  font-size: 17px;
}
.bubble::before,
.bubble::after {
  position: absolute;
  top: 6px;
  display: block;
  width: 0;
  height: 0;
  border: 10px solid transparent;
  content: "";
}
.message-row.other .bubble::before {
  left: -20px;
  border-right-color: var(--line);
}
.message-row.other .bubble::after {
  left: -18px;
  border-right-color: #fff;
}
.message-row.self .bubble {
  margin-right: 8px;
  background: var(--self);
}
.message-row.self .bubble::before {
  right: -20px;
  border-left-color: var(--line);
}
.message-row.self .bubble::after {
  right: -18px;
  border-left-color: var(--self);
}
.bubble.stakes,
.bubble.guests {
  background: var(--stake);
}
.bubble.stakes::after,
.bubble.guests::after {
  border-right-color: var(--stake);
}
.bubble.wins,
.bubble.refer {
  background: var(--win);
}
.bubble.wins::after,
.bubble.refer::after {
  border-right-color: var(--win);
}
.bubble div {
  margin-bottom: 4px;
}
.system-tag {
  display: inline-block;
  margin: 8px auto 16px;
  padding: 4px 8px;
  border-radius: 5px;
  background: #cecece;
  color: #fafafa;
  font-size: 12px;
  font-weight: 700;
}
.message-row:has(.system-tag) {
  justify-content: center;
}

.bubble:has(.result-panel) {
  width: min(312px, calc(100vw - 78px));
  max-width: min(312px, calc(100vw - 78px));
  padding: 4px;
}
.result-panel {
  width: 100%;
  margin: 0;
  padding: 8px 6px 7px;
  border-radius: 4px;
  background: #fff;
  color: #111;
  font-size: 12px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.result-head,
.result-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.result-head {
  margin-bottom: 5px;
}
.result-head span:first-child {
  color: #ff3f3f;
  font-size: 21px;
  font-weight: 800;
}
.result-head span:last-child,
.result-meta span {
  color: #3273dc;
  font-weight: 700;
}
.result-head span:last-child {
  font-size: 13px;
}
.result-meta {
  margin-bottom: 6px;
}
.result-meta span {
  font-size: 12px;
}
.result-meta strong {
  justify-self: center;
  min-width: 44px;
  padding: 3px 7px;
  background: #f00;
  color: #fff;
  font-size: 18px;
  line-height: 1;
}
.result-balls {
  display: grid;
  grid-template-columns: repeat(8, 23px);
  justify-content: center;
  gap: 3px;
  margin-bottom: 7px;
}
.result-ball,
.history-ball {
  display: inline-grid;
  place-items: center;
  border: 1px solid #3cb6e6;
  border-radius: 50%;
  background: #fff;
  color: #111;
  font-weight: 700;
  line-height: 1;
}
.result-ball {
  width: 23px;
  height: 23px;
  font-size: 11px;
}
.result-ball.hot,
.history-ball.hot {
  border-color: #f00;
}
.result-history-scroll {
  width: 100%;
  border: 1px solid #3cb6e6;
}
.result-history {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10px;
  line-height: 1;
  text-align: center;
}
.result-history col.history-period { width: 21px; }
.result-history col.history-time { width: 46px; }
.result-history col.history-number { width: 20px; }
.result-history col.history-scope { width: 19px; }
.result-history col.history-odd-even,
.result-history col.history-big-small { width: 20px; }
.result-history th,
.result-history td {
  height: 22px;
  padding: 0;
  border: 0;
  font-weight: 700;
  white-space: nowrap;
}
.result-history thead {
  background: #3cb6e6;
  color: #fff;
}
.result-history thead th {
  height: 22px;
  border-bottom: 1px solid #f00;
}
.history-ball {
  width: 19px;
  height: 19px;
  font-size: 9px;
}
.result-history tbody tr.latest > * {
  border-top: 1px solid #f00;
  border-bottom: 1px solid #f00;
}
.result-history tbody tr.latest > *:first-child {
  border-left: 1px solid #f00;
}
.result-history tbody tr.latest > *:last-child {
  border-right: 1px solid #f00;
}
.scope-badge {
  display: inline-grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border: 1px solid #111;
  color: #fff;
  font-weight: 800;
}
.scope-1 { background: #5d96ff; }
.scope-2 { background: #3ec67c; }
.scope-3 { background: #f7d400; color: #111; }
.scope-4 { background: #ff3e41; }

.roadmap-panel {
  margin-top: 7px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.roadmap-label {
  margin-bottom: 3px;
  color: #3273dc;
  font-size: 12px;
  font-weight: 800;
}
.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(12, 21px);
  gap: 0;
  width: max-content;
  border-left: 1px solid #111;
  border-top: 1px solid #111;
}
.roadmap-grid > span {
  width: 21px;
  height: 21px;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
}
.road-dot {
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.road-dot.blue { background: #5d96ff; }
.road-dot.green { background: #3ec67c; }
.road-dot.gold { background: #f7d400; color: #111; }
.road-dot.red { background: #ff3e41; }

.new-msg-btn {
  position: fixed;
  right: 2%;
  bottom: 112px;
  z-index: 20;
  border: 0;
  background: transparent;
  color: #257953;
  font-size: 12px;
  font-weight: 700;
}

.composer {
  display: grid;
  grid-template-columns: 40px 1fr auto 42px;
  gap: 6px;
  align-items: center;
  padding: 8px 8px 12px;
  border-top: 1px solid #dadadc;
  background: #dadadc;
}
.icon-btn {
  width: 40px;
  height: 40px;
  margin-top: 4px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: #444;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
#toggle-voice {
  display: none;
}
.composer textarea {
  min-height: 36px;
  max-height: 120px;
  padding: 8px 10px;
  border: 1px solid #c8c8c8;
  border-radius: 5px;
  outline: none;
  resize: none;
  background: #fff;
  color: #111;
  font: inherit;
  font-size: 16px;
  line-height: 1.25;
  -webkit-text-size-adjust: 100%;
}
.send-btn {
  min-width: 56px;
  height: 42px;
  border: 0;
  border-radius: 13px;
  background: #12b51f;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.add-btn {
  width: 42px;
  height: 42px;
  border: 2px solid #a2a2a2;
  border-radius: 50%;
  background: #fff;
  color: #8f8f8f;
  font-size: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 300;
}
.keypad {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 42px;
  padding: 0 12px 10px;
  background: #dadadc;
}
.keypad-left,
.keypad-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-content: start;
}
.key-row {
  display: grid;
  gap: 6px 8px;
  align-items: center;
}
.key-row-bottom button {
  height: 30px;
}
.key-row-9 {
  grid-template-columns: repeat(9, minmax(0, 1fr));
}
.key-row-8 {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
.key-row-7 {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.key-row-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.key-row-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.keypad button {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid #b8b8b8;
  border-radius: 999px;
  background: #edffff;
  color: #111;
  font-size: clamp(14px, 3.8vw, 16px);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.keypad-left button {
  background: #f1ffff;
}
.keypad-left .key-single {
  width: 39px;
  height: 30px;
  justify-self: center;
}
.keypad-left .key-flow {
  height: 30px;
}
.keypad .music-key {
  min-width: 36px;
  background: #28c983;
}
.keypad .swap-key {
  min-width: 36px;
  background: #ff426d;
}

.keypad.keypad-stacked {
  grid-template-columns: 1fr;
  gap: 8px;
}
.keypad.keypad-split {
  grid-template-columns: max-content max-content;
  justify-content: center;
  gap: 42px;
}
.keypad.keypad-split .keypad-left {
  width: max-content;
}
.keypad.keypad-split .keypad-right {
  width: max-content;
}
.keypad.keypad-split .key-row-4 {
  grid-template-columns: repeat(4, 34px);
}
.keypad.keypad-split .keypad-left .key-row-4 {
  grid-template-columns: repeat(4, 39px);
}
.keypad.keypad-split .key-row-3 {
  grid-template-columns: 64px 64px 39px;
}
.keypad.keypad-split .key-row-3 button:first-child,
.keypad.keypad-split .key-row-3 button:nth-child(2) {
  width: 64px;
}
.keypad.keypad-split .key-row-3 button {
  height: 30px;
}
.keypad.keypad-split .key-single {
  width: 34px;
}

@media (max-width: 420px) {
  .round-table {
    gap: 2px;
    padding: 0 2px;
  }
  .draw-balls {
    grid-template-columns: repeat(8, 22px);
    gap: 3px;
  }
  .ball {
    width: 22px;
    height: 22px;
    border-width: 4px;
    font-size: 11px;
  }
  .bubble-wrap { max-width: calc(100vw - 70px); }
  .bubble { max-width: 288px; }
  .composer {
    grid-template-columns: 40px minmax(0, 1fr) 56px 42px;
    gap: 6px;
    padding: 7px 8px 8px;
  }
  .composer textarea {
    min-width: 0;
    min-height: 40px;
    padding: 8px;
  }
  .send-btn {
    min-width: 56px;
    height: 40px;
    font-size: 18px;
  }
  .keypad {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0 12px calc(8px + env(safe-area-inset-bottom));
  }
  .keypad.keypad-split {
    grid-template-columns: max-content max-content;
    gap: 18px;
  }
  .key-row {
    gap: 5px 7px;
  }
}

@media (min-width: 760px) {
  .chat-screen {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
  }
  .topbar {
    height: auto;
    overflow: visible;
  }
  .topbar::after {
    display: block;
  }
  .chat-list {
    padding: 2px 0 6px;
    background: #f1f1f3;
  }
  .message-row {
    gap: 6px;
    margin-bottom: 3px;
    padding-left: 8px;
  }
  .avatar {
    width: 43px;
    height: 43px;
  }
  .bubble-wrap {
    max-width: 760px;
  }
  .name-tag {
    margin: 0 0 1px;
    padding: 0;
    background: transparent;
    border: 0;
    color: #ff3366;
    font-size: 12px;
    line-height: 16px;
  }
  .bubble {
    max-width: 720px;
    margin-bottom: 7px;
    padding: 4px 8px;
    border-radius: 7px;
    font-size: 16px;
    line-height: 1.35;
    box-shadow: none;
  }
  .bubble::before,
  .bubble::after {
    top: 9px;
    border-width: 8px;
  }
  .message-row.other .bubble::before {
    left: -16px;
  }
  .message-row.other .bubble::after {
    left: -14px;
  }
  .bubble div {
    margin-bottom: 0;
  }
  .bubble.stakes,
  .bubble.guests,
  .bubble.wins,
  .bubble.refer {
    background: #fff;
  }
  .bubble.stakes::after,
  .bubble.guests::after,
  .bubble.wins::after,
  .bubble.refer::after {
    border-right-color: #fff;
  }
  .composer {
    grid-template-columns: 28px minmax(0, 1fr) 50px 28px;
    gap: 8px;
    align-items: center;
    padding: 7px 8px 4px;
    border-top: 1px solid #c6c6c6;
  }
  .icon-btn {
    width: 28px;
    height: 28px;
    margin: 0;
    border: 2px solid #ff8b18;
    color: #ff8b18;
    font-size: 14px;
  }
  .composer textarea {
    min-height: 31px;
    height: 31px !important;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 15px;
  }
  .send-btn {
    min-width: 50px;
    height: 30px;
    border-radius: 10px;
    font-size: 16px;
  }
  .add-btn {
    width: 28px;
    height: 28px;
    font-size: 28px;
    line-height: 22px;
  }
  .keypad {
    min-height: 112px;
    padding: 0 14px 7px;
  }
  .keypad.keypad-stacked {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .keypad.keypad-split {
    grid-template-columns: max-content max-content;
    gap: 42px;
  }
  .keypad button {
    min-width: 37px;
    min-height: 27px;
    padding: 0 11px;
    font-size: 16px;
  }
  .key-row {
    gap: 6px 8px;
  }
}
