:root {
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color-scheme: dark;
  --bg: var(--tg-theme-bg-color, #10201c);
  --panel: var(--tg-theme-secondary-bg-color, #182b25);
  --text: var(--tg-theme-text-color, #f2f5e9);
  --muted: var(--tg-theme-hint-color, #a2b6ab);
  --accent: #d7ed9a;
  --ink: #17271c;
  --line: #ffffff2a;
  background: var(--bg);
  color: var(--text);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
}
button,
select {
  font: inherit;
}
button {
  touch-action: manipulation;
  cursor: pointer;
}
button:disabled {
  opacity: 0.3;
  cursor: default;
}
button:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
main {
  max-width: 560px;
  margin: auto;
  padding: 12px 16px max(8px, env(safe-area-inset-bottom));
  padding-top: max(12px, var(--tg-content-safe-area-inset-top, 0px));
}
header,
.brand,
.hand-heading,
.hero-row,
.dialog-heading,
.config-row,
.stepper,
.opponent-edit-row,
.picker-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
header {
  height: 44px;
  margin-bottom: 8px;
}
.brand {
  justify-content: flex-start;
  gap: 8px;
}
.mark {
  font-size: 29px;
  color: var(--accent);
}
h1 {
  font-size: 20px;
  letter-spacing: -0.8px;
  margin: 0;
}
h1 span {
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}
h2 {
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}
.quiet {
  border: 0;
  background: none;
  color: var(--muted);
  padding: 8px 0;
  font-size: 12px;
  min-height: 44px;
  white-space: nowrap;
}
.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}
.chip {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  color: var(--text);
  background: var(--panel);
  font-size: 12px;
  white-space: nowrap;
}
/* Setup occupies its own screen. The live table has no configuration form. */
#setup {
  margin: 48px 0 24px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  padding: 24px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--accent);
  margin: 0 0 12px;
}
#setup h2 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.6px;
}
.setup-note {
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 32px;
}
#setup label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
select {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin: 8px 0 24px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
}
.config-row {
  font-size: 13px;
}
.stepper {
  gap: 14px;
}
.stepper button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 24px;
}
.stepper output {
  font-size: 20px;
  min-width: 16px;
  text-align: center;
}
.primary {
  width: 100%;
  min-height: 56px;
  margin: 32px 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
}
#play-screen {
  display: flex;
  flex-direction: column;
  min-height: calc(100svh - 76px - env(safe-area-inset-bottom));
}
/* Four small metrics, one status line. Card entry gets the remaining space. */
.result {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  padding: 9px 12px 0;
  margin-bottom: 10px;
}
.metrics {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 8px;
  align-items: end;
}
.metrics > div {
  display: grid;
  gap: 4px;
}
.metrics span {
  font-size: 10px;
  color: var(--muted);
}
.metrics b {
  font-size: 17px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.main-metric b {
  font-size: 25px;
  color: var(--accent);
  font-weight: 600;
}
.result-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--muted);
  min-height: 28px;
}
#result-note {
  flex: 1;
}
#badge {
  font-size: 9px;
  white-space: nowrap;
}
#info {
  border: 0;
  background: none;
  color: var(--muted);
  min-width: 32px;
  min-height: 28px;
  font-size: 15px;
}
#streets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: var(--panel);
  margin-bottom: 8px;
}
#streets button {
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
#streets button[aria-current="step"] {
  background: var(--accent);
  color: var(--ink);
  font-weight: 600;
}
.hero-row {
  min-height: 65px;
  margin-bottom: 6px;
}
.hero-row h2 {
  white-space: nowrap;
}
.cards {
  display: flex;
  gap: 8px;
  margin: 0;
}
.card {
  min-width: 44px;
  width: 50px;
  height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  padding: 0;
}
.card small {
  font-size: 17px;
  line-height: 1.1;
}
.card.filled {
  border: 1px solid #f6f4e9;
  background: #f6f4e9;
  color: #25372e;
  font-weight: 600;
}
.card.red {
  color: #bd484a;
}
.card.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-style: solid;
}
.hero {
  margin-right: auto;
}
.hero-row h2 {
  font-size: 12px;
}
.hero-row .chip {
  font-size: 11px;
  padding: 8px;
}
.hand-heading {
  min-height: 28px;
}
.hand-heading > span {
  font-size: 10px;
  color: var(--muted);
}
.board {
  margin: 4px 0 10px;
}
.board .card {
  flex: 1;
  width: auto;
  height: 52px;
}
.picker {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 280px;
  border-top: 1px solid var(--line);
}
.picker .hand-heading {
  min-height: 40px;
}
.ranks {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(3, minmax(64px, 1fr));
  gap: 8px;
  flex: 1;
}
.rank {
  min-width: 0;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--panel);
  color: var(--text);
  font-size: 28px;
  font-weight: 500;
}
.rank:active {
  background: var(--accent);
  color: var(--ink);
}
.rank.clear {
  color: var(--muted);
  font-size: 25px;
}
.picker-footer {
  min-height: 44px;
}
.picker-footer .quiet {
  font-size: 11px;
}
#opponent-editor {
  min-height: 170px;
  padding: 4px 0 12px;
}
.opponent-edit-row {
  margin: 8px 0 10px;
}
#opponent-cards .card {
  width: 64px;
  height: 68px;
}
/* Large suit targets stay close to the rank keypad. */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 16px 20px;
  width: min(360px, calc(100vw - 24px));
  box-shadow: 0 18px 80px #0008;
  max-height: calc(100svh - 32px);
  overflow: auto;
}
dialog::backdrop {
  background: #06110bbd;
  backdrop-filter: blur(4px);
}
.dialog-heading {
  margin-bottom: 6px;
}
.dialog-heading h2 {
  font-size: 15px;
}
.suit-cross {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 68px);
  gap: 8px;
  margin: 4px 0 14px;
}
.suit-cross button {
  border: 0;
  border-radius: 14px;
  background: #f6f4e9;
  color: #25372e;
  font-size: 36px;
  line-height: 1;
}
.suit-cross small {
  display: block;
  font-size: 10px;
  margin-top: 4px;
}
.suit-cross .diamonds,
.suit-cross .hearts {
  color: #bd484a;
}
.clubs {
  grid-area: 1/2;
}
.diamonds {
  grid-area: 2/1;
}
.hearts {
  grid-area: 2/3;
}
.spades {
  grid-area: 3/2;
}
#selected-rank {
  grid-area: 2/2;
  align-self: center;
  text-align: center;
  font-size: 30px;
  color: var(--accent);
}
#suit-dialog .hint {
  text-align: center;
}
.seat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.seat > span {
  font-size: 12px;
  white-space: nowrap;
}
.seat .card {
  width: 44px;
  height: 50px;
}
.seat .cards {
  gap: 6px;
}
.seat.folded > span {
  color: var(--muted);
}
.seat.folded .chip {
  color: var(--muted);
}
#info-dialog p {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
:root[data-theme="light"] {
  --accent: #466529;
  --ink: #fff;
  --line: #183c2526;
}
@media (max-width: 370px) {
  main {
    padding-inline: 12px;
  }
  .rank {
    font-size: 25px;
  }
  .ranks {
    gap: 6px;
  }
  .hero-row {
    gap: 7px;
  }
  .hero .card {
    width: 44px;
  }
  .hero-row .chip {
    padding: 6px;
  }
  .metrics b {
    font-size: 15px;
  }
  .main-metric b {
    font-size: 23px;
  }
  #setup {
    padding: 18px;
  }
  #setup h2 {
    font-size: 23px;
  }
}
@media (max-height: 740px) {
  .picker {
    min-height: 250px;
  }
  .rank {
    min-height: 56px;
  }
  .ranks {
    grid-template-rows: repeat(3, minmax(56px, 1fr));
  }
  .result {
    margin-bottom: 7px;
  }
  .hero-row {
    min-height: 60px;
  }
  .board .card {
    height: 48px;
  }
}
@media (max-width: 600px) {
  #suit-dialog {
    inset: auto 0 max(12px, env(safe-area-inset-bottom)) 0;
    margin: 0 auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
