:root {
  color-scheme: light;
  --ink: #18332c;
  --muted: #6c7d76;
  --paper: #f5f0e6;
  --paper-deep: #e9e0cf;
  --white: #fffdf8;
  --green: #12382d;
  --green-2: #1e5947;
  --mint: #b9d8c6;
  --gold: #e7b64e;
  --red: #c64b45;
  --black-suit: #18332c;
  --red-suit: #ca3e42;
  --shadow: 0 12px 36px rgb(18 56 45 / 14%);
  --radius: 22px;
  font-family:
    Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% 8%, rgb(231 182 78 / 20%), transparent 26rem),
    linear-gradient(135deg, #f8f4eb 0%, #efe7d8 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(231 182 78 / 65%);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.menu-fab {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 15;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--green);
  color: white;
  font-size: 22px;
  box-shadow: 0 6px 16px rgb(18 56 45 / 22%);
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgb(255 255 255 / 11%);
  color: white;
  font-size: 23px;
}

.main {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) clamp(16px, 3vw, 30px)
    max(16px, env(safe-area-inset-bottom));
  flex: 1;
  display: flex;
  flex-direction: column;
}

.main.has-menu {
  padding-top: max(64px, calc(env(safe-area-inset-top) + 56px));
}

.screen-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green-2);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

h1,
h2 {
  font-family: Georgia, "Times New Roman", serif;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.screen-title {
  margin: 0 0 12px;
  font-size: clamp(22px, 3.5vw, 30px);
  letter-spacing: -0.02em;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(25px, 3.2vw, 38px);
  line-height: 1.05;
}

h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.lede,
.muted {
  color: var(--muted);
}

.lede {
  max-width: 670px;
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.55;
}

.card {
  border: 1px solid rgb(24 51 44 / 8%);
  border-radius: var(--radius);
  background: rgb(255 253 248 / 88%);
  box-shadow: var(--shadow);
}

.setup {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setup-head {
  margin-bottom: 2px;
}

.setup-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

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

.player-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 40px 34px;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 8px;
  border-radius: 14px;
  background: rgb(255 253 248 / 70%);
}

.player-row.dragging {
  opacity: 0.9;
  box-shadow: var(--shadow);
  background: var(--white);
}

.drag-handle {
  width: 30px;
  height: 48px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.order-number,
.bid-order {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--paper-deep);
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.order-number.is-dealer,
.bid-order.is-dealer {
  background: var(--gold);
  color: var(--green);
}

.text-input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid #d9d0c1;
  border-radius: 13px;
  background: var(--white);
  color: var(--ink);
  padding: 0 14px;
}

.remove-player {
  width: 40px;
  height: 44px;
  border-radius: 12px;
  background: transparent;
  color: #9d554e;
  font-size: 22px;
}

.remove-player:disabled {
  cursor: not-allowed;
  opacity: 0.25;
}

.setup-foot {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.setup-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.button {
  min-height: 48px;
  padding: 0 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 14px;
  background: var(--green);
  color: white;
  font-weight: 850;
  box-shadow: 0 7px 18px rgb(18 56 45 / 16%);
}

.button:hover {
  background: var(--green-2);
}

.button.secondary {
  border: 1px solid #d2c7b5;
  background: transparent;
  color: var(--green);
  box-shadow: none;
}

.button.secondary:hover {
  background: var(--paper-deep);
}

.button.danger {
  background: #9e3635;
}

.button.gold {
  background: var(--gold);
  color: var(--green);
}

.button:disabled,
.stepper button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.full-width {
  width: 100%;
}

.round-banner {
  margin-bottom: 16px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: auto auto auto 1fr;
  align-items: center;
  gap: clamp(12px, 4vw, 32px);
  overflow: hidden;
}

.round-stat > span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.round-stat > strong {
  font-size: clamp(18px, 3vw, 22px);
}

.round-stat-trump {
  justify-self: end;
  text-align: right;
}

.trump-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.suit-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  font-family: "Apple Symbols", "Arial Unicode MS", "Times New Roman", serif;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  transform: translateY(3px);
}

.suit-badge.red {
  color: var(--red-suit);
}

.suit-badge.black {
  color: var(--black-suit);
}

.suit-badge.no-trump {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 900;
  color: var(--green-2);
  transform: translateY(1px);
}

.suit {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.suit.red {
  color: var(--red-suit);
}

.suit.black {
  color: var(--black-suit);
}

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

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bid-card,
.result-card {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: 38px minmax(100px, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.bid-card.is-dealer {
  border-width: 2px;
  border-color: rgb(231 182 78 / 65%);
}

.player-name {
  overflow: hidden;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dealer-tag {
  display: inline-block;
  margin-left: 6px;
  color: #9c6c14;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
}

.stepper {
  display: grid;
  grid-template-columns: 42px 50px 42px;
  align-items: center;
  border: 1px solid #d7cebf;
  border-radius: 13px;
  overflow: hidden;
  background: var(--white);
}

.stepper button {
  height: 44px;
  background: var(--paper);
  color: var(--green);
  font-size: 22px;
  font-weight: 700;
}

.stepper output {
  display: block;
  text-align: center;
  font-size: 19px;
  font-weight: 900;
}

.restriction {
  margin: 16px 0 0;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-radius: 13px;
  background: #fff2cf;
  color: #745213;
  font-size: 13px;
  font-weight: 700;
}

.bid-total {
  white-space: nowrap;
}

.restriction.overbid {
  background: #e2f1e8;
  color: #246048;
}

.action-row {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.play-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.trump-hero {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 1;
  min-height: 150px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--green);
  box-shadow: var(--shadow);
  text-align: center;
}

.play-menu-fab {
  position: absolute;
  top: 12px;
  right: 12px;
}

.trump-hero .suit-symbol {
  font-family: Georgia, "Times New Roman", serif;
  font-size: min(42vh, 52vw);
  line-height: 0.85;
  filter: drop-shadow(0 12px 18px rgb(0 0 0 / 16%));
}

.trump-hero.red .suit-symbol {
  color: #ef706a;
}

.trump-hero.black .suit-symbol {
  color: var(--green);
}

.trump-hero .suit-symbol.no-trump {
  width: min(26vh, 34vw);
  height: min(26vh, 34vw);
  display: grid;
  place-items: center;
  border: 8px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: min(9vh, 12vw);
}

.trump-title {
  margin-top: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 6vw, 44px);
  line-height: 1;
}

.trump-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: clamp(13px, 3vw, 16px);
  font-weight: 700;
}

.play-bids {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bid-reminder-list {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--bid-columns, 2), minmax(0, 1fr));
  gap: 8px;
  overflow-y: auto;
}

.bid-reminder {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: 12px;
  background: rgb(255 253 248 / 82%);
  border: 1px solid rgb(24 51 44 / 8%);
}

.bid-reminder .player-name {
  font-size: clamp(14px, 3.4vw, 17px);
}

.bid-bubble {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-size: 16px;
  font-weight: 900;
}

.play-bids .button {
  flex: 0 0 auto;
}

.result-card {
  grid-template-columns: minmax(110px, 1fr) auto;
}

.bid-note {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.result-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 13px;
  background: var(--paper-deep);
}

.result-toggle button {
  min-width: 76px;
  min-height: 40px;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.result-toggle button.active-made {
  background: var(--green);
  color: white;
}

.result-toggle button.active-set {
  background: var(--red);
  color: white;
}

.points-preview {
  color: var(--green-2);
  font-size: 13px;
  font-weight: 900;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgb(9 26 21 / 52%);
  backdrop-filter: blur(3px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(390px, 88vw);
  padding: max(22px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right))
    max(22px, env(safe-area-inset-bottom)) 22px;
  display: flex;
  flex-direction: column;
  background: var(--white);
  box-shadow: -15px 0 45px rgb(0 0 0 / 18%);
  animation: slide-in 180ms ease-out;
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.drawer-head h2 {
  margin: 0;
}

.drawer .icon-button {
  background: var(--paper);
  color: var(--green);
}

.drawer-score-list {
  display: grid;
  gap: 8px;
}

.drawer-score {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 12px;
  background: var(--paper);
}

.drawer-score strong:last-child {
  font-size: 21px;
}

.drawer-actions {
  margin-top: auto;
  padding-top: 20px;
  display: grid;
  gap: 9px;
}

.podium {
  margin: 26px auto 22px;
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 10px;
}

.podium-place {
  min-height: 155px;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border-radius: 20px 20px 8px 8px;
  background: var(--paper-deep);
  text-align: center;
}

.podium-place.first {
  min-height: 205px;
  background: var(--green);
  color: white;
}

.podium-rank {
  margin-bottom: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.first .podium-rank {
  color: var(--gold);
}

.podium-name {
  max-width: 100%;
  overflow: hidden;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(19px, 3vw, 29px);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-score {
  margin-top: 7px;
  color: var(--green-2);
  font-size: 17px;
  font-weight: 900;
}

.first .podium-score {
  color: white;
}

.ranking-list {
  width: min(760px, 100%);
  margin: 0 auto;
  display: grid;
  gap: 8px;
}

.ranking-row {
  padding: 12px 18px;
  display: grid;
  grid-template-columns: 35px 1fr auto;
  align-items: center;
  gap: 12px;
}

.final-actions {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.scorecard-wrap {
  overflow: hidden;
}

.table-scroll {
  overflow: auto;
  overscroll-behavior: contain;
}

.score-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  white-space: nowrap;
}

.score-table th,
.score-table td {
  padding: 11px 12px;
  border-right: 1px solid #e2d9ca;
  border-bottom: 1px solid #e2d9ca;
  text-align: center;
}

.score-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--green);
  color: white;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.score-table th:first-child,
.score-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
}

.score-table th:first-child {
  z-index: 3;
}

.score-table td:first-child {
  background: var(--white);
  font-weight: 900;
}

.score-table tr:last-child td {
  border-bottom: 0;
}

.score-table .made {
  color: #1c694c;
  font-weight: 900;
}

.score-table .set {
  color: #a63e3b;
  font-weight: 900;
}

.empty-state {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 11px 18px;
  border-radius: 999px;
  background: #172c26;
  color: white;
  box-shadow: 0 9px 25px rgb(0 0 0 / 22%);
  font-size: 13px;
  font-weight: 800;
  transform: translateX(-50%);
}

@media (max-width: 620px) {
  .result-grid {
    grid-template-columns: 1fr;
  }

  .round-banner {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .round-stat-trump {
    justify-self: start;
    text-align: left;
  }

  .action-row {
    flex-direction: column-reverse;
  }

  .action-row .button {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .choose-result {
    display: none;
  }

  .result-card {
    grid-template-columns: minmax(80px, 1fr) auto;
    gap: 8px;
    padding-inline: 13px;
  }

  .result-toggle button {
    min-width: 62px;
  }

  .podium {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .podium-place,
  .podium-place.first {
    min-height: 112px;
    border-radius: 18px;
  }

  .podium-place.first {
    grid-row: 1;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .play-screen {
    flex-direction: row;
  }

  .trump-hero {
    flex: 0 0 auto;
    width: auto;
    height: 100%;
    aspect-ratio: 1;
  }

  .trump-hero .suit-symbol {
    font-size: min(46vh, 26vw);
  }

  .play-bids {
    flex: 1 1 55%;
    justify-content: center;
  }
}
