/* Structure: one column on a phone, two where there is room. */

.sheet {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 0 16px 8px;
  display: grid;
  gap: 16px;
  /* Stacked on a phone, with the money last: cards first, then the odds,
     then what it costs you. Wide screens pair it with the table instead. */
  grid-template-areas:
    'table'
    'hand'
    'odds'
    'call';
}

.panel--table {
  grid-area: table;
}

.panel--call {
  grid-area: call;
}

.hand-row {
  grid-area: hand;
}

.panel--felt {
  grid-area: odds;
}

/* With the money put away, the table takes the whole width: the areas are
   redeclared rather than just hiding the panel, or its empty row would still
   sit there collecting a gap. */
:root[data-call='off'] .panel--call {
  display: none;
}

:root[data-call='off'] .sheet {
  grid-template-areas:
    'table'
    'hand'
    'odds';
}

/* --- table controls --- */

.table-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.stepper,
.precision,
.buyin {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper__label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--ink-soft);
}

.stepper__btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--brass);
  background: linear-gradient(180deg, var(--raised-top), var(--raised-bottom));
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.stepper__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stepper__value {
  font-family: var(--display);
  font-size: 1.4rem;
  min-width: 1.4ch;
  text-align: center;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  font-family: var(--body);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 6px 11px;
  border: 0;
  border-left: 1px solid rgba(176, 141, 87, 0.6);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}

.segmented button:first-child {
  border-left: 0;
}

.segmented button[aria-pressed='true'] {
  background: var(--blood);
  color: #f6ecd8;
}

/* --- seats --- */

.seats {
  list-style: none;
  margin: 0;
  padding: 0;
  /* A grid rather than a wrapping flex row: seats stay in tidy columns even
     when a folded one grows taller to hold the cards you saw. */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  align-items: start;
  gap: 10px;
}

.seat {
  border: 1px solid var(--paper-edge);
  border-radius: var(--radius);
  background: var(--seat-bg);
  padding: 8px 10px;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.seat__btn {
  font-family: var(--display);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  background: none;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  padding: 2px 4px;
  display: grid;
  gap: 2px;
  justify-items: center;
}

.seat__state {
  font-family: var(--body);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-soft);
}

.seat--hero {
  border-color: var(--brass);
  background: rgba(216, 185, 106, 0.22);
}

.seat--hero .seat__btn {
  color: var(--blood);
  cursor: default;
}

.seat--folded {
  background: var(--sunken-strong);
  border-style: dashed;
}

.seat--folded .seat__btn {
  color: var(--ink-soft);
  text-decoration: line-through;
}

/* The per-seat number is off by default, and takes no room when it is: an empty
   seat__odds would still open a gap in the seat's grid. */
.seat__odds {
  display: none;
  font-family: var(--display);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--ink);
}

:root[data-seat-odds='on'] .seat__odds:not(:empty) {
  display: block;
}

.seat--hero .seat__odds {
  color: var(--blood);
}

.seat--folded .seat__odds {
  color: var(--ink-soft);
}

/* Dimmed while the next answer is on its way, like the results panel. */
.seats--stale .seat__odds {
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.seat__dead {
  display: grid;
  /* Takes the scaled size where there is room, shrinks rather than spilling
     out of a narrow seat when the cards are turned right up. */
  grid-template-columns: repeat(2, minmax(0, calc(30px * var(--card-scale))));
  gap: 5px;
  width: 100%;
  justify-content: center;
}

.seat__dead-label {
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* --- hands and board --- */

.hand-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, calc(68px * var(--card-scale))));
  gap: 10px;
}

.board {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.street {
  display: grid;
  gap: 6px;
  justify-items: center;
}

.street__label {
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.street__cards {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}

.street__cards > * {
  width: calc(56px * var(--card-scale));
}

/* --- results --- */

.results--stale {
  opacity: 0.45;
  transition: opacity 0.2s ease;
}

.headline {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: center;
  margin-bottom: 12px;
}

.headline__value {
  font-family: var(--display);
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  line-height: 1.1;
}

.headline__label {
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.8;
}

.headline__item--win .headline__value {
  color: #8fd19e;
}

.headline__item--tie .headline__value {
  color: var(--gold);
}

.headline__item--lose .headline__value {
  color: #e39184;
}

.stack {
  display: flex;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(216, 185, 106, 0.45);
  background: rgba(0, 0, 0, 0.25);
}

.stack__part--win {
  background: linear-gradient(180deg, #74b487, #4a7c4e);
}

.stack__part--tie {
  background: linear-gradient(180deg, #d8b96a, #a8853c);
}

.stack__part--lose {
  background: linear-gradient(180deg, #c4634f, #8b2c1f);
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
}

.result-grid h3 {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.rows {
  display: grid;
  gap: 6px;
}

.row {
  display: grid;
  grid-template-columns: 5.6em minmax(0, 1fr) 3.9em;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
}

/* Hand names run long, so give them their own column width. */
.rows--wide .row {
  grid-template-columns: 9.2em minmax(0, 1fr) 3.9em;
}

.row--folded {
  opacity: 0.45;
}

.row--hero .row__name {
  color: var(--gold);
  font-weight: 600;
}

.row__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row__meter {
  height: 9px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.row__fill {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #7fae8c, #d8b96a);
}

.row--hero .row__fill {
  background: linear-gradient(90deg, #d8b96a, #f0d79a);
}

.row__value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.note {
  margin: 14px 0 0;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  opacity: 0.7;
}

.notice {
  margin: 0;
  font-style: italic;
  opacity: 0.85;
}

.notice--error {
  color: #f2b8ad;
  font-style: normal;
}

.notice ul {
  margin: 8px 0 0;
  padding-left: 20px;
  font-style: normal;
  font-size: 0.86rem;
}

/* --- pot odds --- */

.buyin {
  margin-bottom: 14px;
}

.money-stack {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.money-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brass);
  font-size: 0.7rem;
  line-height: 1;
}

.money-divider::before,
.money-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass), transparent);
}

.field {
  display: grid;
  gap: 4px;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.money-field {
  display: grid;
  gap: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  font-family: var(--body);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  padding: 4px 9px;
  min-width: 2.6rem;
  border-radius: 999px;
  border: 1px solid var(--brass);
  background: linear-gradient(180deg, var(--raised-top), var(--raised-bottom));
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}

.chip:hover {
  background: linear-gradient(180deg, var(--raised-top-hot), var(--raised-bottom-hot));
}

.chip:active {
  transform: translateY(1px);
}

/* The chips that do something other than add an amount: a ghost of the rest. */
.chip--zero,
.chip--round {
  background: transparent;
  color: var(--ink-soft);
  border-style: dashed;
}

.chip--zero:hover,
.chip--round:hover {
  background: rgba(176, 141, 87, 0.18);
  color: var(--ink);
}

/* Its label is a word rather than a figure, so let it take the room it needs.
   In the narrow money column it drops below the amounts, which reads fine. */
.chip--round {
  min-width: auto;
}

.field input {
  font-family: var(--body);
  font-size: 1.05rem;
  width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  background: var(--input-bg);
  color: var(--ink);
}

.pot-odds {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.pot-odds p {
  margin: 0;
}

.verdict {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--display);
  font-size: 1.5rem;
  padding: 6px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--brass);
  justify-self: start;
}

.verdict--call {
  background: rgba(74, 124, 78, 0.18);
  color: var(--verdict-call);
}

.verdict--fold {
  background: rgba(139, 44, 31, 0.14);
  color: var(--blood);
}

.verdict__ev {
  font-family: var(--body);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

.pot-line {
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.pot-line strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* --- modals: the card picker and the settings sheet --- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 18, 12, 0.66);
}

.modal__panel {
  position: relative;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: linear-gradient(180deg, var(--panel-solid-top), var(--paper-deep));
  border: 1px solid var(--brass);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  padding: 14px;
}

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

.modal__head h3 {
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blood);
}

.modal__actions {
  display: flex;
  gap: 6px;
}

.picker__grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  gap: 4px;
}

.modal__panel--narrow {
  width: min(420px, 100%);
}

.modal__panel--picker {
  width: min(calc(560px * var(--picker-scale)), 100%);
}

/* --- settings --- */

.settings {
  display: grid;
  gap: 20px;
}

.setting {
  display: grid;
  gap: 9px;
}

/* The segmented control hugs its buttons here rather than filling the row. */
.settings .segmented {
  justify-self: start;
}

.setting__label {
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.setting__hint {
  margin: 0;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--ink-soft);
  min-height: 2.4em;
}

.bias {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.bias__end {
  font-family: var(--display);
  font-size: 0.8rem;
  color: var(--ink);
}

/* One slider, two uses: the track colour is all that differs. */
.bias__input,
.scale__input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 24px;
  background: none;
  cursor: pointer;
}

/* Tight on the fold side, loose on the call side. */
.bias__input {
  --slider-track: linear-gradient(90deg, var(--blood), var(--brass) 50%, var(--win));
}

.scale__input {
  --slider-track: linear-gradient(90deg, var(--paper-edge), var(--brass));
}

.bias__input::-webkit-slider-runnable-track,
.scale__input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  border: 1px solid var(--paper-edge);
  background: var(--slider-track);
}

.bias__input::-moz-range-track,
.scale__input::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  border: 1px solid var(--paper-edge);
  background: var(--slider-track);
}

.bias__input::-webkit-slider-thumb,
.scale__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  margin-top: -8px;
  border-radius: 50%;
  border: 1px solid var(--ink-soft);
  background: radial-gradient(circle at 34% 30%, var(--raised-top-hot), var(--brass));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.bias__input::-moz-range-thumb,
.scale__input::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border-radius: 50%;
  border: 1px solid var(--ink-soft);
  background: radial-gradient(circle at 34% 30%, var(--raised-top-hot), var(--brass));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

.toggles {
  display: grid;
  gap: 10px;
}

.toggle {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
}

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

.toggle__box {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--brass);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--raised-top), var(--raised-bottom));
}

.toggle__box::after {
  content: '\2714';
  font-size: 12px;
  line-height: 1;
  color: var(--blood);
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.toggle input:checked + .toggle__box::after {
  opacity: 1;
  transform: scale(1);
}

.toggle input:focus-visible + .toggle__box {
  outline: 2px solid var(--blood);
  outline-offset: 2px;
}

.scale {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.scale__value {
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 3.2em;
  text-align: right;
}

.pot-line--setting {
  color: var(--brass);
  font-style: italic;
}

@media (min-width: 720px) {
  /* The hand column grows with the cards, or they hit its ceiling and stop. */
  .hand-row {
    grid-template-columns: minmax(0, calc(200px * var(--card-scale))) minmax(0, 1fr);
  }

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

/* Wide enough to sit the money beside the table without squeezing the seats. */
@media (min-width: 900px) {
  .sheet {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas:
      'table call'
      'hand hand'
      'odds odds';
  }

  :root[data-call='off'] .sheet {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'table'
      'hand'
      'odds';
  }
}

@media (max-width: 420px) {
  .picker__grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .street__cards > * {
    width: calc(46px * var(--card-scale));
  }
}
