/* Trapline Bridge — phone-first table styles (BBO-inspired, not a copy) */

:root {
  --felt: #1a3d2e;
  --felt-deep: #0f241a;
  --felt-light: #245c45;
  --felt-mist: #2f6b52;
  --wood: #2c2118;
  --wood-edge: #4a3728;
  --ivory: #f3efe6;
  --ivory-muted: #cfc6b6;
  --ink: #1c1814;
  --gold: #c4a35a;
  --gold-soft: #e0c98a;
  --vul: #c45c4a;
  --club: #1a1a1a;
  --diamond: #c45c4a;
  --heart: #c45c4a;
  --spade: #1a1a1a;
  --panel: rgba(15, 36, 26, 0.92);
  --line: rgba(243, 239, 230, 0.12);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-sans: 'Outfit', 'Segoe UI', sans-serif;
  --bid-h: 210px;
  --nav-h: 48px;
  --status-h: 36px;
}

body.four-color {
  --club: #1f7a4c;
  --diamond: #2f6fed;
  --heart: #c45c4a;
  --spade: #1a1a1a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  color: var(--ivory);
  background: var(--felt-deep);
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--gold-soft); text-decoration: none; }
a:hover { color: var(--gold); }

button, input {
  font: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
.btn:active { transform: scale(0.98); }
.btn--primary {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  color: var(--ink);
  font-weight: 600;
}
.btn--primary:hover { filter-color: #fff6; }
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ivory);
}
.btn--ghost:hover { background: rgba(255,255,255,0.06); }
.btn--lg { padding: 0.85rem 1.6rem; font-size: 1.05rem; }
.btn--block { width: 100%; }
.btn--ghost[href] { display: inline-flex; }

/* —— Nav —— */
.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  padding: 0 1rem;
  background: rgba(12, 28, 20, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.app-nav__brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ivory);
}
.app-nav__links {
  display: flex;
  gap: 0.9rem;
  font-size: 0.92rem;
}
.app-nav__links a { color: var(--ivory-muted); }
.app-nav__links a:hover { color: var(--ivory); }

/* —— Splash —— */
.page-splash {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 60% at 50% 20%, rgba(196, 163, 90, 0.18), transparent 60%),
    radial-gradient(ellipse 100% 80% at 80% 100%, rgba(36, 92, 69, 0.55), transparent 50%),
    linear-gradient(165deg, #0c1c14 0%, #1a3d2e 45%, #12291f 100%);
}
.splash {
  position: relative;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem 3rem;
  overflow: hidden;
}
.splash__atmosphere {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, transparent 40%, rgba(15, 36, 26, 0.55)),
    repeating-linear-gradient(
      -12deg,
      transparent 0 14px,
      rgba(255,255,255,0.015) 14px 15px
    );
  animation: mist 12s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes mist {
  from { opacity: 0.7; transform: translateY(0); }
  to { opacity: 1; transform: translateY(-8px); }
}
.splash__content {
  position: relative;
  text-align: center;
  max-width: 28rem;
  animation: rise 700ms ease-out both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.splash__eyebrow {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--gold);
  margin: 0 0 1rem;
}
.splash__brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.8rem, 12vw, 4.4rem);
  line-height: 0.95;
  margin: 0 0 1rem;
  color: var(--ivory);
  text-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.splash__tagline {
  margin: 0 0 2rem;
  color: var(--ivory-muted);
  font-size: 1.05rem;
  line-height: 1.45;
}
.splash__cta .btn {
  animation: pulse-cta 2.4s ease-in-out infinite;
}
@keyframes pulse-cta {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196,163,90,0.35); }
  50% { box-shadow: 0 0 0 10px rgba(196,163,90,0); }
}

/* —— Login —— */
.page-login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 20% 0%, rgba(196,163,90,0.12), transparent 40%),
    linear-gradient(180deg, #12291f, #0c1c14);
}
.login__panel {
  width: min(100%, 22rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.75rem 1.4rem 1.5rem;
  box-shadow: var(--shadow);
  animation: rise 500ms ease-out both;
}
.login__brand {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--ivory);
  display: inline-block;
  margin-bottom: 0.75rem;
}
.login__title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}
.login__hint {
  margin: 0 0 1.25rem;
  color: var(--ivory-muted);
  font-size: 0.92rem;
}
.login__error {
  background: rgba(196, 92, 74, 0.18);
  border: 1px solid rgba(196, 92, 74, 0.45);
  color: #f0c2ba;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
  font-size: 0.88rem;
  color: var(--ivory-muted);
}
.field input {
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.25);
  color: var(--ivory);
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
}
.field input:focus {
  outline: 2px solid rgba(196,163,90,0.45);
  border-color: var(--gold);
}

/* —— Table app —— */
.page-table {
  min-height: 100dvh;
  background: var(--felt-deep);
}

.table-app {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--nav-h));
  padding-bottom: calc(var(--bid-h) + 0.5rem);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  min-height: var(--status-h);
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  background: rgba(0,0,0,0.28);
  border-bottom: 1px solid var(--line);
}
.status-strip__vul.is-vul {
  color: var(--vul);
  font-weight: 600;
}
.status-strip__turn {
  margin-left: auto;
  color: var(--gold-soft);
}

.table-layout {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem 0.75rem;
  flex: 1;
}

.auction-panel {
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.45rem 0.5rem 0.55rem;
}
.auction-grid__head,
.auction-grid__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.2rem;
  text-align: center;
}
.auction-grid__head {
  font-size: 0.72rem;
  color: var(--ivory-muted);
  margin-bottom: 0.2rem;
}
.auction-grid__cell {
  min-height: 1.55rem;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  border-radius: 6px;
}
.auction-grid__cell.has-call {
  background: rgba(255,255,255,0.05);
}
.auction-grid__cell.is-turn {
  color: var(--gold);
  animation: blink 1.1s ease-in-out infinite;
}
@keyframes blink {
  50% { opacity: 0.35; }
}
.contract-line {
  margin-top: 0.45rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--gold-soft);
}

.felt {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    ". N ."
    "W C E"
    ". S .";
  gap: 0.35rem;
  min-height: 280px;
  padding: 0.55rem;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 45%, var(--felt-mist), var(--felt) 55%, var(--felt-deep)),
    var(--felt);
  border: 3px solid var(--wood-edge);
  box-shadow: inset 0 0 40px rgba(0,0,0,0.35), var(--shadow);
}
.felt__center {
  grid-area: C;
  display: grid;
  place-items: center;
  position: relative;
}
.felt__ring {
  width: min(42vw, 120px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px dashed rgba(243,239,230,0.18);
  opacity: 0.7;
}
.felt__hint {
  position: absolute;
  margin: 0;
  font-size: 0.85rem;
  color: var(--ivory-muted);
  text-align: center;
  max-width: 8rem;
}
.felt__seat--N { grid-area: N; }
.felt__seat--E { grid-area: E; align-self: center; }
.felt__seat--S { grid-area: S; }
.felt__seat--W { grid-area: W; align-self: center; }

.felt__seat {
  border-radius: 12px;
  padding: 0.25rem;
  transition: box-shadow 180ms ease, background 180ms ease;
}
.felt__seat.is-turn {
  box-shadow: 0 0 0 2px rgba(196,163,90,0.55);
  background: rgba(196,163,90,0.08);
}
.felt__seat.is-vul .seat-dir {
  color: var(--vul);
}

.seat-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  padding: 0.15rem 0.2rem;
  font-size: 0.78rem;
}
.seat-label--static { cursor: default; }
.seat-dir {
  font-weight: 700;
  min-width: 1rem;
}
.seat-you {
  color: var(--gold-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.seat-summary {
  color: var(--ivory-muted);
  font-variant-numeric: tabular-nums;
}

.hand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.2rem 0.25rem 0.35rem;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.hand.is-hidden { display: none; }
.hand--south {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.85rem;
  font-size: 1.05rem;
  padding: 0.35rem 0.2rem 0.15rem;
}
.hand--south .suit-line {
  flex-direction: row;
  align-items: baseline;
  gap: 0.2rem;
}
.suit-line {
  display: flex;
  gap: 0.25rem;
  line-height: 1.2;
}
.suit-sym { font-weight: 600; }
.suit-ranks { letter-spacing: 0.02em; }

.suit-C, .suit-C .suit-sym, .suit-C .bid-strain { color: var(--club); }
.suit-D, .suit-D .suit-sym, .suit-D .bid-strain { color: var(--diamond); }
.suit-H, .suit-H .suit-sym, .suit-H .bid-strain { color: var(--heart); }
.suit-S, .suit-S .suit-sym, .suit-S .bid-strain { color: var(--spade); }
.suit-NT, .suit-NT .bid-strain { color: var(--ivory); }

/* On dark felt, red/black cards need light background chips for readability */
.hand .suit-line {
  background: rgba(243, 239, 230, 0.94);
  color: #1a1a1a;
  border-radius: 6px;
  padding: 0.12rem 0.35rem;
}
.hand--south .suit-line {
  padding: 0.2rem 0.45rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.seat-summary .suit-C { color: #9fd6b5; }
.seat-summary .suit-D,
.seat-summary .suit-H { color: #f0a79b; }
.seat-summary .suit-S { color: var(--ivory-muted); }

.tools-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: center;
  padding: 0.35rem 0.15rem;
}
.tools-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.tools-panel__actions .btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}
.tools-panel__status {
  width: 100%;
  margin: 0;
  min-height: 1.1rem;
  font-size: 0.8rem;
  color: var(--gold-soft);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--ivory-muted);
  cursor: pointer;
}

/* —— Bid box —— */
.bid-box {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: linear-gradient(180deg, rgba(18, 41, 31, 0.92), rgba(12, 28, 20, 0.98));
  border-top: 1px solid var(--line);
  padding: 0.45rem 0.45rem calc(0.55rem + env(safe-area-inset-bottom));
  backdrop-filter: blur(10px);
  max-height: var(--bid-h);
  overflow: auto;
  transition: transform 220ms ease, opacity 220ms ease;
}
.bid-box.is-done {
  opacity: 0.55;
  pointer-events: none;
}
.bid-box__row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.25rem;
  margin-bottom: 0.25rem;
}
.bid-box__specials {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 0.3rem;
  margin-top: 0.3rem;
}
.bid-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ivory);
  border-radius: 8px;
  min-height: 2rem;
  padding: 0.2rem 0.15rem;
  cursor: pointer;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
}
.bid-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}
.bid-btn.is-legal:not(:disabled):hover {
  background: rgba(196,163,90,0.18);
  border-color: rgba(196,163,90,0.45);
}
.bid-btn--pass { font-weight: 600; }
.bid-btn--x, .bid-btn--xx { font-weight: 700; color: var(--gold-soft); }
.bid-btn--strain {
  background: rgba(243, 239, 230, 0.92);
  color: #1a1a1a;
}
.bid-btn--strain:disabled {
  background: rgba(243, 239, 230, 0.25);
  color: #666;
}
.bid-level { font-weight: 600; }
.bid-strain { font-weight: 700; }

/* —— Modal —— */
.modal {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0;
  background: #16281f;
  color: var(--ivory);
  width: min(92vw, 36rem);
}
.modal::backdrop { background: rgba(0,0,0,0.55); }
.modal__inner { margin: 0; padding: 1rem 1rem 1.1rem; }
.modal__inner h2 {
  font-family: var(--font-display);
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}
.modal textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(0,0,0,0.3);
  color: var(--ivory);
  padding: 0.65rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  resize: vertical;
}
.modal__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

/* —— History —— */
.history {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}
.history__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.history__header h1 {
  font-family: var(--font-display);
  margin: 0;
  font-size: 1.7rem;
}
.history__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.history__item a {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "board contract"
    "meta when";
  gap: 0.15rem 0.85rem;
  padding: 0.85rem 0.95rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  color: inherit;
}
.history__board { grid-area: board; font-weight: 600; }
.history__contract { grid-area: contract; text-align: right; color: var(--gold-soft); }
.history__meta { grid-area: meta; font-size: 0.85rem; color: var(--ivory-muted); }
.history__when { grid-area: when; text-align: right; font-size: 0.78rem; color: var(--ivory-muted); }
.vul-text.is-vul { color: var(--vul); font-weight: 600; }
.history__empty, .history__error { color: var(--ivory-muted); }

/* —— Wider layouts —— */
@media (min-width: 768px) {
  :root { --bid-h: 0px; }

  .table-app {
    padding-bottom: 1rem;
  }

  .table-layout {
    display: grid;
    grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(200px, 260px);
    grid-template-areas:
      "auction felt tools"
      "bidbox felt tools";
    gap: 0.85rem;
    align-items: stretch;
    padding: 0.85rem 1rem 1rem;
  }

  .auction-panel { grid-area: auction; align-self: start; }
  .felt {
    grid-area: felt;
    aspect-ratio: 1;
    max-width: 640px;
    min-height: 420px;
    margin: 0 auto;
    width: 100%;
    align-self: center;
  }
  .tools-panel {
    grid-area: tools;
    flex-direction: column;
    align-items: stretch;
    align-self: start;
  }
  .tools-panel__actions {
    flex-direction: column;
  }
  .tools-panel__actions .btn { width: 100%; }

  .bid-box {
    position: static;
    grid-area: bidbox;
    max-height: none;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.55rem;
    align-self: start;
  }
  .bid-box.is-done {
    pointer-events: auto;
    opacity: 0.75;
  }

  .hand--south {
    font-size: 1.12rem;
  }
}

@media (min-width: 1100px) {
  .felt {
    max-width: 700px;
  }
  .hand {
    font-size: 1rem;
  }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
