:root {
  color-scheme: dark;
  --bg: #1a1b26;
  --fg: #c0caf5;
  --muted: #565f89;
  --border: #414868;
  --accent: #7aa2f7;
  --panel: #24283b;
  --red: #f7768e;
  --card-bg: #d5dbf2;
  --card-fg: #1a1b26;
  --back: #2f3650;

  /* 4-color deck. Tuned so each suit reads at a glance on both the light
     card face (#d5dbf2) and the dark panel/bid-info background (#24283b). */
  --suit-spades:   #1a1b26;  /* dark on card; overridden lighter on dark bg */
  --suit-hearts:   #d6435e;
  --suit-diamonds: #3d6dd9;
  --suit-clubs:    #2f9a44;

  --card-w: 28px;
  --card-h: 40px;
  --my-card-w: 36px;
  --my-card-h: 52px;
  --stride-h: 18px;       /* horizontal overlap stride (top seat) */
  --stride-v: 16px;       /* vertical overlap stride (left/right seats) */
  --my-stride: 22px;      /* my hand stride */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

h1 { font-size: 1.25rem; font-weight: 600; margin: 0 0 1.5rem; }

#entry {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 1rem;
  max-width: 360px;
}

label { display: block; margin-bottom: 0.5rem; color: var(--muted); }

input {
  font: inherit;
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.4rem 0.5rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  outline: none;
}
input:focus { border-color: var(--accent); }

button {
  font: inherit;
  cursor: pointer;
  padding: 0.4rem 0.9rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

#join-btn { width: 100%; margin-top: 0.25rem; }

#entry-status { color: var(--muted); margin-top: 0.5rem; font-size: 0.85rem; min-height: 1.25em; }

/* Game */

.game-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  color: var(--muted);
}
.actions { display: flex; gap: 0.5rem; }

#table {
  position: relative;
  width: 100%;
  height: 520px;
  background: #1f2335;
  border: 1px solid var(--border);
}

#deck {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 60px;
  margin: -30px 0 0 -21px;
  background: var(--back);
  border: 1px solid var(--border);
  box-shadow: 1px 1px 0 var(--border), 2px 2px 0 var(--border);
  z-index: 1;
}

.seat {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.seat .name {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
  text-align: center;
}
.seat.you .name { color: var(--accent); }

.seat .hand {
  position: relative;   /* slot positioning anchor */
}

/* Bottom (you): wide horizontal fan */
.seat.bottom {
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
}
.seat.bottom .hand {
  width: calc(var(--my-stride) * 12 + var(--my-card-w));
  height: var(--my-card-h);
}

/* Top: compact horizontal */
.seat.top {
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
}
.seat.top .hand {
  width: calc(var(--stride-h) * 12 + var(--card-w));
  height: var(--card-h);
}

/* Left/right: compact vertical */
.seat.left {
  top: 50%;
  left: 16px;
  transform: translateY(-50%);
}
.seat.right {
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
}
.seat.left .hand, .seat.right .hand {
  width: var(--card-w);
  height: calc(var(--stride-v) * 12 + var(--card-h));
}

/* Cards */

.card {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px solid var(--border);
  background: var(--back);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  user-select: none;
}

.seat.bottom .card {
  width: var(--my-card-w);
  height: var(--my-card-h);
  font-size: 0.95rem;
}

.card.face {
  background: var(--card-bg);
  color: var(--card-fg);
  line-height: 1;
}
.card.face[data-suit="S"] { color: var(--suit-spades); }
.card.face[data-suit="H"] { color: var(--suit-hearts); }
.card.face[data-suit="D"] { color: var(--suit-diamonds); }
.card.face[data-suit="C"] { color: var(--suit-clubs); }
.card.face .rank { font-size: 0.9rem; }
.card.face .suit { font-size: 1rem; }

.card.flying { z-index: 20; pointer-events: none; }

.seat.bottom .card.face {
  cursor: pointer;
  transition: transform 120ms ease;
}
.seat.bottom .card.face:hover {
  transform: translateY(-10px);
  z-index: 100;
  border-color: var(--accent);
}

/* Play area — 4 slots arranged like a cross around the center */

#play-area {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  z-index: 2;
}

.play-slot {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
}

/* Slot positions relative to the (top: 50%, left: 50%) anchor.
   Cards sit just outside the deck (which is 42×60 centered). */
.play-slot[data-pos="bottom"] { transform: translate(-50%, 36px); }
.play-slot[data-pos="top"]    { transform: translate(-50%, calc(-100% - 36px)); }
.play-slot[data-pos="left"]   { transform: translate(calc(-100% - 32px), -50%); }
.play-slot[data-pos="right"]  { transform: translate(32px, -50%); }

.play-slot .card {
  position: relative;
  left: 0;
  top: 0;
}

/* Bidding */

#bid-area {
  margin-top: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

#bid-info {
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}
#bid-info .yours { color: var(--accent); }
#bid-info .current { color: var(--fg); }

#bid-panel {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

#bid-panel label {
  display: flex;
  flex-direction: column;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0;
  gap: 0.25rem;
}

#bid-panel select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  outline: none;
  min-width: 4rem;
}
#bid-panel select:focus { border-color: var(--accent); }

#bid-error {
  color: var(--red);
  font-size: 0.8rem;
  flex-basis: 100%;
  min-height: 1em;
}

/* Suit glyphs in the bid info line / dark contexts — use the same hue but
   nudged lighter so it stays visible on the dark panel background. */
.strain-S { color: var(--fg); }
.strain-H { color: #f5687f; }
.strain-D { color: #6f95e6; }
.strain-C { color: #62b873; }
.strain-NT { color: var(--fg); }
