/*
 * The coin flip board.
 *
 * Every game is a card with two seats facing each other: the player who
 * started it on the left, the seat you can take on the right, and the coin
 * turning between them once both are filled. That shape is the convention for
 * this game and a player arriving from anywhere else already knows how to read
 * it, which is worth more than any arrangement of my own.
 *
 * A card that has just been decided keeps its result for a few seconds: the
 * winning seat lit with what it took, the losing seat dimmed with what it put
 * in. Then it leaves the board.
 */

/* ------------------------------------------------------------ the header */

.cf-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.cf-head h2 {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.cf-count {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 15px;
}

.cf-filters {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  flex-wrap: wrap;
}

.cf-filters label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint);
}

.cf-filters select {
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #0b1424;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.cf-filters select:hover {
  border-color: var(--line-2);
}

/* -------------------------------------------------------------- the grid */

.cf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  list-style: none;
}

.cf-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1626;
}

.cf-card.is-mine {
  box-shadow: inset 2px 0 0 var(--gold);
}

.cf-card.is-locked {
  border-color: #27385a;
}

/* ------------------------------------------------------------- the seats */

.cf-seat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 10px 8px;
  border-radius: 6px;
  background: #0a1220;
}

.cf-seat.is-empty {
  justify-content: center;
  background: transparent;
}

.cf-seat.is-lost {
  opacity: 0.45;
}

.cf-seat.is-won {
  background: linear-gradient(180deg, rgba(245, 185, 66, 0.12), #0a1220);
}

.cf-avatar {
  position: relative;
  width: 54px;
  height: 54px;
}

.cf-avatar .face {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  font-size: 18px;
}

.house-face {
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, #3a2c10, #140e04);
  border: 1px solid var(--gold-dark);
  color: var(--gold);
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
}

/* The side the seat is on, worn in the corner like a shoulder patch. */
.cf-side {
  position: absolute;
  right: -7px;
  top: -7px;
}

.cf-side .flip-face {
  width: 26px;
  height: 26px;
  border-width: 2px;
  box-shadow: 0 0 0 3px #0d1626;
}

.cf-level {
  position: absolute;
  left: -7px;
  bottom: -6px;
}

.cf-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.cf-seat.is-won .cf-name {
  color: var(--text);
}

.cf-amount {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 5px;
  background: #0f1a2d;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 600;
}

.cf-amount-coin {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  color: #a9bdf5;
}

.cf-amount-coin svg {
  width: 100%;
  height: 100%;
}

.cf-amount.is-up {
  border-color: rgba(52, 211, 153, 0.4);
  color: var(--up);
}

.cf-amount.is-down {
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--down);
}

/* ------------------------------------------------------------ the middle */

.cf-middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 62px;
}

.cf-vs {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.cf-countdown {
  font-size: 13px;
  color: var(--gold);
}

/* The coin is larger here than in a list, because it is the whole event. */
.cf-middle .flip-coin {
  width: 58px;
  height: 58px;
}

.cf-card.is-locked .cf-middle .flip-coin {
  filter: drop-shadow(0 0 14px rgba(245, 185, 66, 0.35));
}

/* ---------------------------------------------------------- join and fair */

.cf-join {
  height: 38px;
  padding: 0 18px;
  border: 1px solid var(--lime-dark);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--lime), var(--lime-dark));
  color: var(--on-lime);
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.cf-join:hover:not(:disabled) {
  filter: brightness(1.08);
}

.cf-join:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cf-join.ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--text-dim);
}

.cf-join.ghost:hover {
  color: var(--text);
  border-color: var(--gold-dark);
}

.cf-fair {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.cf-fair:hover {
  color: var(--gold);
  text-decoration: underline;
}

.cf-proof {
  overflow-wrap: anywhere;
  font-size: 11px;
}

/* --------------------------------------------------------- narrow glass */

@media (max-width: 720px) {
  .cf-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .cf-filters {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    gap: 8px;
  }
}

/* A past flip is a button now, so it has to stop looking like a list item. */
.flip-history-list li {
  display: flex;
}

button.flip-past {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

button.flip-past:hover {
  border-color: var(--gold-dark);
}

/* ---------------------------------------------------- one game, framed */

/*
 * A game that has just been made gets a screen of its own over the lobby: a
 * dark stage with the coin in the middle, a strip of controls under it and the
 * name of the game beside them. The lobby stays underneath, dimmed, so leaving
 * the frame is one button and no reload.
 */
.cf-frame {
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}

.cf-frame[hidden] {
  display: none;
}

.cf-frame-stage {
  display: grid;
  place-items: center;
  min-height: 340px;
  padding: 24px;
  background:
    radial-gradient(70% 90% at 50% 40%, color-mix(in srgb, var(--gold) 12%, #0d1626), #070c15);
}

.cf-grid-one {
  width: min(760px, 100%);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cf-grid-one .cf-card {
  transform: scale(1.06);
}

.cf-frame-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: #0b1424;
}

.cf-frame-tools {
  display: flex;
  gap: 6px;
}

.cf-frame-tools button {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
}

.cf-frame-tools button:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.cf-frame-tools svg {
  width: 16px;
  height: 16px;
}

.cf-frame-name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 auto;
}

.cf-frame-name b {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cf-frame-name small {
  font-size: 11px;
  color: var(--text-faint);
}

.cf-frame-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cf-frame-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
}

.cf-frame-live::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

/* The lobby behind the frame steps back rather than disappearing. */
.flip-lobby.is-behind {
  opacity: 0.45;
  transition: opacity 200ms ease;
}
