/* The Split — one committed dark look, tuned for large type and whitespace. */

:root {
  --bg:        #0A0A0B;
  --fg:        #F2F1ED;
  --muted:     #6E6E77;
  --dim:       #45454D;
  --line:      #1E1E22;
  --track:     #212127;
  --accent:    #E4B363;
  --accept:    #86D9A4;
  --reject:    #E88C7D;

  --ease: cubic-bezier(.22, .61, .36, 1);

  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Helvetica, Arial, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ------------------------------------------------------------- screens -- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem
           max(1.25rem, env(safe-area-inset-bottom));
}

.screen.is-active {
  display: flex;
  animation: screen-in .45s var(--ease) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- start -- */

.start {
  margin: auto;
  width: 100%;
  max-width: 30rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.title {
  font-size: clamp(2.6rem, 12vw, 5rem);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1;
}

.blurb {
  font-size: clamp(1rem, 3.6vw, 1.15rem);
  line-height: 1.85;
  color: var(--muted);
}

.rules {
  font-size: .8rem;
  line-height: 1.7;
  color: var(--dim);
  max-width: 25rem;
  text-wrap: balance;
}

/* --------------------------------------------------------------- setup -- */

.setup {
  margin: auto;
  width: 100%;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.15rem;
  padding: 1.5rem 0;
}

.setup-title,
.howto-title {
  font-size: .72rem;
  letter-spacing: .3em;
  color: var(--muted);
  font-weight: 600;
}

.mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .8rem;
  width: 100%;
}

/* Three separate buttons on an equal grid, so every mode reads as an equally
 * weighted choice rather than segments of one control. */
.mode-opts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .55rem;
  width: 100%;
  max-width: 27rem;
}

.mode-btn {
  font: inherit;
  font-size: .62rem;
  letter-spacing: .08em;
  font-weight: 600;
  padding: .85rem .4rem;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s var(--ease), color .2s var(--ease),
              border-color .2s var(--ease);
}

@media (hover: hover) {
  .mode-btn:hover { color: var(--fg); border-color: var(--dim); }
}

.mode-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.mode-btn[aria-pressed="true"] {
  background: var(--fg);
  border-color: var(--fg);
  color: #0A0A0B;
}

.mode-caption {
  font-size: .66rem;
  letter-spacing: .1em;
  color: var(--dim);
  text-align: center;
  min-height: 1em;
  text-wrap: balance;
}

#custom-options[hidden] { display: none; }

/* ---------------------------------------------------------- how to play -- */

.howto {
  margin: auto;
  width: 100%;
  max-width: 31rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.6rem;
  padding: 2rem 0;
  max-height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.howto-block { width: 100%; text-align: left; }

.howto-block h3 {
  font-size: .62rem;
  letter-spacing: .24em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: .5rem;
}

.howto-block p {
  font-size: .88rem;
  line-height: 1.75;
  color: var(--muted);
  text-wrap: pretty;
}

.howto-block em { color: var(--fg); font-style: normal; }

/* ------------------------------------------------------------- switch -- */

.switch {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .25rem;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
  transition: color .2s var(--ease);
}

@media (hover: hover) { .switch:hover { color: var(--fg); } }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 99px; }

.switch-track {
  position: relative;
  width: 2.35rem;
  height: 1.3rem;
  border-radius: 99px;
  background: var(--track);
  border: 1px solid var(--line);
  flex: 0 0 auto;
  transition: background .22s var(--ease);
}

.switch[aria-checked="true"] .switch-track { background: rgba(228, 179, 99, .3); }

.switch-knob {
  position: absolute;
  top: 50%;
  left: .19rem;
  width: .8rem;
  height: .8rem;
  border-radius: 99px;
  background: var(--dim);
  transform: translateY(-50%);
  transition: left .22s var(--ease), background .22s var(--ease);
}

.switch[aria-checked="true"] .switch-knob { left: 1.28rem; background: var(--accent); }

.switch-label { font-size: .68rem; letter-spacing: .16em; }

.options { display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; }

/* ------------------------------------------------------- segmented choice -- */

.choice {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .5rem .25rem;
}

.choice-label {
  font-size: .68rem;
  letter-spacing: .16em;
  color: var(--muted);
  min-width: 4.4rem;   /* keeps the two pickers' controls aligned */
}

.name-input {
  font: inherit;
  font-size: .68rem;
  letter-spacing: .1em;
  font-weight: 600;
  width: 11.2rem;
  padding: .48rem .8rem;
  text-align: center;
  color: var(--fg);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 99px;
  outline: none;
  transition: border-color .2s var(--ease);
}

.name-input::placeholder {
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .1em;
}

@media (hover: hover) { .name-input:hover { border-color: var(--dim); } }
.name-input:focus { border-color: var(--accent); }

.choice-opts {
  display: flex;
  gap: .25rem;
  padding: .18rem;
  border: 1px solid var(--line);
  border-radius: 99px;
}

.choice-btn {
  font: inherit;
  font-size: .68rem;
  letter-spacing: .1em;
  font-weight: 600;
  min-width: 2.6rem;
  padding: .4rem .5rem;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s var(--ease), color .2s var(--ease);
}

@media (hover: hover) { .choice-btn:hover { color: var(--fg); } }
.choice-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.choice-btn[aria-pressed="true"] {
  background: var(--fg);
  color: #0A0A0B;
}

/* Blind mode: no running totals anywhere during play. */
body.is-blind .holds,
body.is-blind .hud-right { display: none; }

/* ----------------------------------------------------------------- hud -- */

.hud {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .68rem;
  letter-spacing: .16em;
  color: var(--muted);
  flex: 0 0 auto;
}

.hud-right { color: var(--fg); }
.hud-sep { color: var(--dim); margin: 0 .35em; }
#hud-rank { color: var(--muted); }

/* --------------------------------------------------------------- stage -- */

.game-body {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  gap: clamp(1rem, 3vw, 2.5rem);
}

.stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.1rem, 3.4vh, 2rem);
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding-bottom: 2vh;
}

.eyebrow {
  font-size: .7rem;
  letter-spacing: .28em;
  color: var(--muted);
  text-align: center;
  min-height: 1em;
  transition: color .3s var(--ease);
}

.eyebrow.is-accept { color: var(--accept); }
.eyebrow.is-reject { color: var(--reject); }

.eyebrow.is-result {
  animation: pop .4s var(--ease) both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px); letter-spacing: .5em; }
  to   { opacity: 1; transform: none; letter-spacing: .28em; }
}

/* --------------------------------------------------------------- split -- */

.split {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: clamp(.75rem, 4vw, 1.75rem);
  width: 100%;
}

.side { text-align: center; min-width: 0; }

.amount {
  font-size: clamp(1.45rem, 7.4vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -.04em;
  line-height: 1.05;
  transition: color .35s var(--ease), opacity .35s var(--ease);
}

.side-opp .amount { color: #A9A9B2; }

.amount.is-zero { color: var(--dim); }

/* The player's amount is typeable. The grid column sizes it, so no auto-width
 * measuring is needed — it just fills its side. */
.amount-input {
  display: block;
  width: 100%;
  font-family: inherit;
  text-align: center;
  color: var(--fg);
  background: transparent;
  border: 0;
  border-bottom: 1px dashed transparent;
  border-radius: 0;
  padding: 0 0 .12em;
  -webkit-appearance: none;
  appearance: none;
}

.amount-input:read-only { border-bottom-color: transparent !important; cursor: default; }

@media (hover: hover) {
  .amount-input:not(:read-only):hover { border-bottom-color: var(--dim); }
}

.amount-input:not(:read-only):focus {
  outline: none;
  border-bottom-color: var(--accent);
}

.amount-input::selection { background: rgba(228, 179, 99, .28); }

.who {
  margin-top: .65rem;
  font-size: .68rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-opp .who { color: #A9A9B2; }

.holds {
  margin-top: .3rem;
  font-size: .62rem;
  letter-spacing: .12em;
  color: var(--dim);
  white-space: nowrap;
}

/* How this opponent has answered their last few offers. Not a running total,
 * so it survives the standings switch. */
.form {
  margin-top: .5rem;
  display: flex;
  gap: .45rem;
  justify-content: center;
  min-height: 1.1rem;
}

body:not(.is-form) .form { display: none; }

.mark {
  position: relative;
  font-size: 1.05rem;
  line-height: 1;
  opacity: .9;
  cursor: default;
}

.mark.is-yes { color: var(--accept); }
.mark.is-no  { color: var(--reject); }

/* Hovering a mark reveals the amount that was on the table that round. Sits
 * below, where there is empty space, rather than over the opponent's name. */
.mark::after {
  content: attr(data-label);
  position: absolute;
  top: calc(100% + .45rem);
  left: 50%;
  transform: translateX(-50%) translateY(-3px);
  z-index: 5;
  white-space: nowrap;
  font-size: .58rem;
  letter-spacing: .13em;
  color: var(--fg);
  background: #17171A;
  border: 1px solid var(--line);
  border-radius: .3rem;
  padding: .34rem .5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}

@media (hover: hover) {
  .mark:hover { opacity: 1; }
  .mark:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.split-rule {
  width: 1px;
  align-self: stretch;
  background: var(--line);
  margin-bottom: 1.6rem;
}

/* ----------------------------------------------------------------- bar -- */

.bar-wrap {
  width: 100%;
  transition: opacity .35s var(--ease);
}

.bar-wrap.is-locked { pointer-events: none; }

.bar {
  position: relative;
  height: 10px;
  border-radius: 99px;
  background: var(--track);
  overflow: visible;
}

.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  border-radius: 99px;
  background: var(--fg);
  transition: width .28s var(--ease), background .3s var(--ease);
}

.bar-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 30px;
  border-radius: 99px;
  background: var(--fg);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 5px var(--bg);
  transition: left .28s var(--ease), opacity .25s var(--ease);
}

.bar-input {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 44px;
  transform: translateY(-50%);
  margin: 0;
  opacity: 0;
  cursor: grab;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.bar-input:active { cursor: grabbing; }

/* A hairline thumb keeps the native value mapping aligned with our handle. */
.bar-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1px;
  height: 44px;
  background: transparent;
}

.bar-input::-moz-range-thumb {
  width: 1px;
  height: 44px;
  border: 0;
  background: transparent;
}

.bar-input:focus-visible ~ .bar-handle,
.bar:has(.bar-input:focus-visible) .bar-handle {
  box-shadow: 0 0 0 5px var(--bg), 0 0 0 7px var(--accent);
}

.ticks {
  position: relative;
  height: 1.1rem;
  margin-top: .85rem;
}

.tick {
  position: absolute;
  top: 0;
  width: 2px;
  height: 2px;
  border-radius: 99px;
  background: var(--dim);
  transform: translateX(-50%);
  transition: background .2s var(--ease), transform .2s var(--ease);
}

.tick.is-on {
  background: var(--fg);
  transform: translateX(-50%) scale(1.6);
}

/* Locked (responding / resolved) — hide the handle, keep the proportion. */
.bar-wrap.is-locked .bar-handle,
.bar-wrap.is-locked .ticks { opacity: 0; }

.bar-fill.is-dead { background: var(--dim); }

/* ---------------------------------------------------------- memo / hint -- */

.memo, .hint {
  font-size: .68rem;
  letter-spacing: .1em;
  color: var(--dim);
  text-align: center;
  min-height: 1em;
  line-height: 1.6;
  text-wrap: balance;
}

.memo { color: var(--muted); }

/* ------------------------------------------------------------- actions -- */

.actions {
  display: flex;
  gap: .7rem;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 3rem;
  align-items: center;
}

.btn {
  font: inherit;
  font-size: .78rem;
  letter-spacing: .18em;
  font-weight: 600;
  padding: 1.05rem 2rem;
  border-radius: 99px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .18s var(--ease), background .18s var(--ease),
              color .18s var(--ease), border-color .18s var(--ease),
              opacity .18s var(--ease);
  white-space: nowrap;
}

.btn-primary { background: var(--fg); color: #0A0A0B; }
.btn-ghost   { background: transparent; color: var(--muted); border-color: var(--line); }

@media (hover: hover) {
  .btn-primary:hover { transform: translateY(-1px); }
  .btn-ghost:hover   { color: var(--fg); border-color: var(--dim); }
}

.btn:active { transform: translateY(1px) scale(.985); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn[hidden] { display: none; }

.thinking {
  font-size: .7rem;
  letter-spacing: .28em;
  color: var(--muted);
  animation: breathe 1.15s ease-in-out infinite;
}

@keyframes breathe { 0%,100% { opacity: .3; } 50% { opacity: 1; } }

/* ---------------------------------------------------- live leaderboard -- */

.live {
  position: relative;   /* anchors the role tooltip outside the scrolling list */
  flex: 0 0 15rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: .35rem 0 0 clamp(1rem, 2.5vw, 2rem);
  border-left: 1px solid var(--line);
}

body:not(.is-live) .live { display: none; }

.live-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: .62rem;
  letter-spacing: .2em;
  color: var(--muted);
  padding: 0 .55rem .6rem;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.live-delta { font-size: .66rem; letter-spacing: .06em; }
.live-delta.is-up { color: var(--accept); }
.live-delta.is-down { color: var(--reject); }

.board-live {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  margin: 0;
  border: 0;
  /* Fade the scroll edges so partly-visible rows look deliberate. */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 14px,
                      #000 calc(100% - 14px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 14px,
              #000 calc(100% - 14px), transparent 100%);
}

.board-live .row {
  grid-template-columns: 1.5rem .75rem 1fr auto;
  gap: .45rem;
  padding: .3rem .55rem;
  font-size: .72rem;
  border-bottom: 0;
}

.board-live .row .rk { font-size: .6rem; }

/* What each player is doing this round. Offering is the stronger position, so
 * it reads brighter; receiving recedes. */
.role {
  font-size: .62rem;
  font-weight: 600;
  letter-spacing: 0;
  text-align: center;
}

.role.is-offering { color: var(--fg); }
.role.is-receiving { color: var(--dim); }

.row.is-you .role.is-offering { color: var(--accent); }
.row.is-you .role.is-receiving { color: rgba(228, 179, 99, .5); }

.role-tip {
  position: absolute;
  z-index: 8;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  font-size: .58rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg);
  background: #17171A;
  border: 1px solid var(--line);
  border-radius: .3rem;
  padding: .32rem .5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s var(--ease);
}

.role-tip.is-on { opacity: 1; }

/* Amounts are a running total, so they follow that switch. */
body.is-blind .board-live .amt { display: none; }

.live-wait {
  font-size: .62rem;
  letter-spacing: .16em;
  color: var(--dim);
  padding: 1.1rem .55rem;
  flex: 0 0 auto;
}

.board-live .row.is-you.is-moved { animation: rowpulse .7s var(--ease); }

@keyframes rowpulse {
  from { background: rgba(228, 179, 99, .34); }
  to   { background: rgba(228, 179, 99, .09); }
}

/* Below this width the panel drops under the decision instead of beside it. */
@media (max-width: 880px) {
  .game-body { flex-direction: column; gap: .75rem; }
  .live {
    flex: 0 0 auto;
    max-height: 30vh;
    padding: 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .live-head { padding-top: .6rem; }
  .stage { padding-bottom: 0; }
}

/* --------------------------------------------------------------- final -- */

.final {
  margin: auto;
  width: 100%;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  padding: 1.5rem 0;
}

.final-score {
  font-size: clamp(2.4rem, 11vw, 4rem);
  font-weight: 600;
  letter-spacing: -.045em;
  line-height: 1.05;
}

.final-rank { font-size: 1rem; color: var(--fg); margin-top: .5rem; }
.final-beat { font-size: .85rem; color: var(--muted); margin-bottom: 1.4rem; }

.board {
  list-style: none;
  position: relative;   /* makes row offsetTop relative to the list itself */
  width: 100%;
  max-height: min(42vh, 24rem);
  overflow-y: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.75rem;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  overscroll-behavior: contain;
}

.board::-webkit-scrollbar { width: 3px; }
.board::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.row {
  display: grid;
  grid-template-columns: 2.1rem 1fr auto;
  align-items: baseline;
  gap: .75rem;
  padding: .62rem .8rem;
  font-size: .85rem;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, .035);
}

.row:last-child { border-bottom: 0; }
.row .rk { font-size: .68rem; color: var(--dim); letter-spacing: .06em; }
.row .nm { color: #9A9AA3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .amt { color: var(--fg); font-weight: 500; }

.row.is-you {
  background: rgba(228, 179, 99, .09);
  box-shadow: inset 2px 0 0 var(--accent);
}

/* This round's opponent. Deliberately quieter than your own row — neutral
 * rather than amber — so the two never compete for attention. */
.row.is-opponent {
  background: rgba(255, 255, 255, .05);
  box-shadow: inset 2px 0 0 var(--muted);
}

.row.is-opponent .nm { color: var(--fg); }
.row.is-opponent .rk { color: var(--muted); }

.row.is-you .rk,
.row.is-you .nm,
.row.is-you .amt { color: var(--accent); font-weight: 600; }

/* -------------------------------------------------------------- motion -- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --------------------------------------------------------------- small -- */

@media (max-height: 620px) {
  .stage { gap: .85rem; }
  .holds { display: none; }
  .btn { padding: .9rem 1.6rem; }
}
