:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #142033;
  --muted: #667085;
  --line: #e4e7ec;
  --red: #ef332b;
  --green: #009b55;
  --blue: #174f99;
  --soft-red: #ffd3c9;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 14px 12px 40px;
}

.hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.hero > div:first-child,
.balance-card,
.panel,
.status-strip {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero > div:first-child {
  flex: 1;
  padding: 16px;
}

.eyebrow {
  display: block;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-line,
.lang-switch,
.app-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.lang-switch {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lang-btn {
  width: auto;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.lang-btn.active {
  background: var(--green);
  color: #fff;
}

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

h1 { font-size: 28px; line-height: 1.1; }
h3 { font-size: 17px; }
p { color: var(--muted); line-height: 1.45; margin-top: 6px; }

.balance-card {
  min-width: 132px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.balance-card span,
.status-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.balance-card strong {
  margin-top: 5px;
  font-size: 22px;
}

.status-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  margin-bottom: 12px;
}

.status-strip div {
  padding: 12px;
  background: #fff;
}

.status-strip strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.app-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(10px);
}

.app-tab {
  padding: 10px 8px;
  background: transparent;
  color: var(--muted);
}

.app-tab.active {
  background: var(--green);
  color: #fff;
}

.tab-page { display: none; }
.tab-page.active { display: block; }

.ticket-stage {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.ticket-blank {
  width: min(100%, 500px);
  background: #fff;
  border: 1px solid #1f1f1f;
  padding: 24px 28px;
  --accent: var(--red);
  color: var(--accent);
  box-shadow: 0 20px 45px rgba(15, 23, 42, .12);
}

.ticket-blank.rav { --accent: var(--blue); }
.ticket-blank.system { --accent: var(--green); }

.ticket-brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 28px;
  color: var(--green);
}

.ticket-brand h2 {
  font-size: 34px;
  line-height: 1;
}

.ticket-brand span {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.star {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-size: 44px;
}

.red-band {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  text-align: center;
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
  padding: 8px 10px;
  margin: 12px 0 8px;
}

.game-numbers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-bottom: 2px solid rgba(239, 51, 43, .65);
}

.game-option {
  min-height: 88px;
  border-right: 2px solid rgba(239, 51, 43, .7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.game-option:last-child { border-right: 0; }
.game-option span { font-size: 13px; font-weight: 900; color: var(--green); }
.game-option strong {
  font-size: 58px;
  line-height: .9;
  color: var(--accent);
  -webkit-text-stroke: .8px var(--accent);
}
.game-option.active {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.game-option small,
.choice small {
  width: 22px;
  height: 8px;
  border: 1.5px solid var(--red);
  border-radius: 999px;
}
.game-option.active small,
.choice.active small { background: var(--red); }

.tg-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.tg-gate > div {
  width: min(460px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.stake-row,
.draw-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  font-weight: 900;
}

.choice {
  min-width: 38px;
  display: grid;
  justify-items: center;
  gap: 2px;
  cursor: pointer;
}

.choice b { font-size: 17px; }
.choice em { font-size: 12px; font-style: normal; }

.card-grid {
  border: 6px solid var(--soft-red);
  border-radius: 28px;
  overflow: hidden;
}

.suit-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr) 48px;
  align-items: center;
  border-bottom: 4px solid var(--soft-red);
  min-height: 70px;
}

.suit-row:last-child { border-bottom: 0; }
.suit-row.disabled { opacity: .4; }

.rank-cell {
  display: grid;
  justify-items: center;
  gap: 3px;
  cursor: pointer;
  font-weight: 900;
  color: var(--red);
}

.rank-cell small {
  width: 22px;
  height: 8px;
  border: 1.5px solid var(--red);
  border-radius: 999px;
}

.rank-cell.active small { background: var(--red); }
.suit-symbol { font-size: 44px; text-align: center; color: var(--red); }

.auto-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--soft-red);
  color: var(--red);
  padding: 10px 18px;
  margin-top: 12px;
  font-weight: 900;
}

.switch {
  width: 52px;
  height: 30px;
  margin: 0 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch span {
  display: block;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid rgba(239, 51, 43, .7);
  position: relative;
  transition: background .18s ease, border-color .18s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--red);
  transition: transform .18s ease, background .18s ease;
}

.switch input:checked + span {
  background: var(--green);
  border-color: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(22px);
  background: #fff;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}

.panel {
  padding: 16px;
  margin-bottom: 12px;
}

label {
  display: block;
  margin: 12px 0 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

select, button, input {
  width: 100%;
  border: 1px solid #cfd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  font: inherit;
}

button {
  border: 0;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

button.secondary {
  background: #eef2ff;
  color: var(--blue);
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.button-grid.three { grid-template-columns: repeat(3, 1fr); }

.hint {
  font-size: 13px;
}

pre {
  min-height: 110px;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
  border-radius: 8px;
  background: #0f172a;
  color: #d7e3ff;
  padding: 12px;
  font-size: 12px;
}

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

canvas {
  width: 100%;
  display: block;
  border-radius: 8px;
  background: #101828;
}

.tickets-list {
  display: grid;
  gap: 10px;
}

.ticket-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fafafa;
}

.ticket-item strong { display: block; }
.ticket-item span { color: var(--muted); font-size: 13px; }

.win-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.win-summary > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.win-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.win-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.win-item button {
  margin-top: 10px;
}

.status {
  display: inline-flex;
  margin-top: 10px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
}

.status.paid {
  background: #dcfae6;
  color: #067647;
}

@media (max-width: 720px) {
  .hero, .controls, .status-strip, .two { grid-template-columns: 1fr; flex-direction: column; }
  .controls { display: block; }
  .ticket-blank { padding: 18px 14px; }
  .ticket-brand h2 { font-size: 30px; }
  .game-option strong { font-size: 46px; }
  .suit-row { grid-template-columns: repeat(8, 1fr) 36px; min-height: 58px; }
  .suit-symbol { font-size: 34px; }
  .rank-cell b { font-size: 15px; }
}
