/* ============ POSTAL POKER ============ */
:root {
  --navy: #1c3f6e;
  --navy-dark: #122a4b;
  --navy-deep: #0d1f38;
  --red: #d33a2f;
  --red-dark: #a92920;
  --cream: #f4ead8;
  --paper: #efe3cc;
  --kraft: #b08d57;
  --kraft-dark: #8a6c3f;
  --ink: #22263a;
  --gold: #e8b64c;
  --green: #3f9c5a;
  --felt: #24507f;
  --airmail: repeating-linear-gradient(45deg,
    var(--red) 0 12px, var(--cream) 12px 24px, #2a5aa8 24px 36px, var(--cream) 36px 48px);
  --slab: "Rockwell", "Roboto Slab", "Courier New", serif;
  --mono: "Consolas", "Courier New", monospace;
}

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

html, body { height: 100%; }
body {
  font-family: system-ui, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 20%, rgba(28,63,110,.06) 0 60px, transparent 61px),
    radial-gradient(circle at 85% 70%, rgba(211,58,47,.05) 0 80px, transparent 81px),
    var(--paper);
  color: var(--ink);
  overflow: hidden;
}

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* ---------- shared bits ---------- */
.airmail-strip { height: 12px; background: var(--airmail); }

.btn-primary {
  background: var(--red); color: var(--cream); border: none;
  font-family: var(--slab); font-size: 16px; letter-spacing: 2px;
  padding: 12px 26px; border-radius: 6px;
  box-shadow: 0 3px 0 var(--red-dark);
  transition: transform .06s;
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(2px); box-shadow: none; }

.btn-secondary {
  background: var(--navy); color: var(--cream); border: none;
  font-family: var(--slab); font-size: 13px; letter-spacing: 1.5px;
  padding: 10px 18px; border-radius: 6px;
  box-shadow: 0 3px 0 var(--navy-dark);
}

.btn-mini {
  background: var(--navy); color: var(--cream); border: none;
  font-family: var(--slab); font-size: 11px; letter-spacing: 1px;
  padding: 7px 10px; border-radius: 5px;
}
.btn-mini.danger { background: var(--red); }

.fine-print { font-size: 11px; opacity: .65; margin-top: 10px; font-family: var(--mono); }

/* ---------- toasts ---------- */
.toasts { position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 300;
  display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--navy-deep); color: var(--cream); font-family: var(--mono); font-size: 13px;
  padding: 10px 18px; border-radius: 6px; border-left: 5px solid var(--red);
  animation: toast-in .2s ease-out; box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- join screen ---------- */
#screen-join { align-items: center; justify-content: center; }
.join-card {
  width: min(440px, 92vw); background: var(--cream); border-radius: 10px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(13,31,56,.4), 0 0 0 1px rgba(0,0,0,.08);
}
.join-inner { padding: 34px 36px; text-align: center; }
.logo-stamp {
  width: 74px; height: 74px; margin: 0 auto 14px; font-size: 38px; line-height: 70px;
  background: var(--navy); color: var(--cream); border-radius: 6px;
  outline: 3px dashed var(--cream); outline-offset: -8px;
  transform: rotate(-4deg);
}
.join-inner h1 { font-family: var(--slab); letter-spacing: 6px; color: var(--navy); font-size: 30px; }
.join-inner .sub { font-family: var(--mono); font-size: 11px; letter-spacing: 4px; color: var(--red); margin-top: 4px; }
.motto { font-size: 12.5px; font-style: italic; opacity: .7; margin: 18px 0 22px; line-height: 1.5; }
#join-name {
  width: 100%; padding: 13px 16px; font-size: 16px; text-align: center;
  border: 2px solid var(--navy); border-radius: 6px; background: #fff; margin-bottom: 14px;
  font-family: var(--mono); letter-spacing: 1px;
}
#join-btn { width: 100%; }

/* ---------- topbar ---------- */
.topbar {
  height: 52px; flex: 0 0 52px; background: var(--navy-deep); color: var(--cream);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  border-bottom: 4px solid; border-image: var(--airmail) 1;
  z-index: 50;
}
.brand { font-family: var(--slab); letter-spacing: 3px; font-size: 16px; white-space: nowrap; overflow: hidden; }
.stakes { font-family: var(--mono); font-size: 12px; opacity: .7; letter-spacing: 0; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.bankroll { font-family: var(--mono); font-size: 13px; }
.playername { font-family: var(--mono); font-size: 13px; opacity: .8; }

/* ---------- lobby ---------- */
.lobby-body { padding: 28px; max-width: 900px; margin: 0 auto; width: 100%; overflow-y: auto; }
.lobby-body h2 { font-family: var(--slab); letter-spacing: 4px; color: var(--navy); margin-bottom: 18px; }
.table-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.route-card {
  background: var(--cream); border-radius: 8px; padding: 18px;
  border: 1px solid rgba(0,0,0,.1); box-shadow: 0 3px 10px rgba(13,31,56,.12);
  position: relative; overflow: hidden;
}
.route-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px; background: var(--airmail); }
.route-name { font-family: var(--slab); font-size: 17px; color: var(--navy); margin-top: 6px; }
.route-meta { font-family: var(--mono); font-size: 12px; opacity: .75; margin: 8px 0 14px; line-height: 1.6; }
.route-card .btn-primary { font-size: 13px; padding: 9px 18px; }
.lobby-actions { margin-top: 22px; display: flex; gap: 12px; }
.create-form {
  margin-top: 16px; background: var(--cream); padding: 16px; border-radius: 8px;
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  border: 1px dashed var(--kraft);
}
.create-form input, .create-form select {
  padding: 9px 10px; border: 1.5px solid var(--navy); border-radius: 5px; font-size: 14px;
}
.create-form label { font-family: var(--mono); font-size: 12px; display: flex; gap: 6px; align-items: center; }
.create-form input[type=number] { width: 78px; }

/* ---------- table screen ---------- */
#screen-table { background: var(--navy-deep); }
.table-wrap { flex: 1; display: flex; min-height: 0; position: relative; }
.table-zone { flex: 1; position: relative; min-width: 0; }

.felt {
  position: absolute; inset: 4% 3% 6% 3%;
  background:
    radial-gradient(ellipse at 50% 42%, #2d5f95 0%, var(--felt) 55%, #1c3f68 100%);
  border-radius: 46% / 52%;
  border: 10px solid transparent;
  background-clip: padding-box;
  box-shadow:
    0 0 0 10px var(--kraft),
    0 0 0 14px var(--kraft-dark),
    0 24px 60px rgba(0,0,0,.55),
    inset 0 0 90px rgba(0,0,0,.35);
}
.felt::before {
  content: ""; position: absolute; inset: -22px; border-radius: 46% / 52%;
  border: 8px solid transparent;
  border-image: var(--airmail) 8;
  opacity: .0; /* subtle option; kept off, rail is kraft */
}
.felt-watermark {
  position: absolute; top: 62%; left: 50%; transform: translateX(-50%);
  font-family: var(--slab); letter-spacing: 5px; font-size: clamp(9px, 1.4vw, 14px);
  color: rgba(244,234,216,.13); white-space: nowrap; pointer-events: none;
}

/* board + pot */
.board {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
  display: flex; gap: 7px; min-height: 66px; align-items: center;
}
.pot {
  position: absolute; top: 56%; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 14px; color: var(--gold);
  background: rgba(13,31,56,.55); padding: 5px 14px; border-radius: 14px;
  white-space: nowrap;
}
.pot:empty { display: none; }

/* cards */
.card {
  width: 46px; height: 64px; border-radius: 5px; background: #fdfbf5;
  box-shadow: 0 2px 5px rgba(0,0,0,.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--slab); position: relative;
  animation: deal-in .25s ease-out;
}
@keyframes deal-in { from { transform: scale(.6) rotate(-6deg); opacity: 0; } }
.card .rk { font-size: 20px; line-height: 1; font-weight: bold; }
.card .st { font-size: 16px; line-height: 1.1; }
.card.red { color: #c22a20; }
.card.blk { color: #1b2430; }
.card.small { width: 30px; height: 42px; border-radius: 4px; }
.card.small .rk { font-size: 13px; }
.card.small .st { font-size: 11px; }
.card.back {
  background: var(--navy);
  background-image: repeating-linear-gradient(45deg,
    rgba(211,58,47,.9) 0 5px, rgba(244,234,216,.9) 5px 10px, rgba(42,90,168,.9) 10px 15px, rgba(244,234,216,.9) 15px 20px);
  background-size: 100% 8px; background-repeat: repeat-y;
  background-position: 0 0;
}
.card.back::after {
  content: "✉"; position: absolute; inset: 6px; border-radius: 3px;
  background: var(--navy); color: rgba(244,234,216,.65);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}

/* seats */
.seat {
  position: absolute; transform: translate(-50%, -50%);
  width: 128px; text-align: center; z-index: 5;
}
.seat-cards { display: flex; justify-content: center; gap: 3px; min-height: 44px; margin-bottom: -8px; position: relative; z-index: 1; }
.seat-plate {
  background: var(--cream); border-radius: 7px; padding: 5px 8px 6px;
  box-shadow: 0 3px 8px rgba(0,0,0,.45); position: relative; z-index: 2;
  border: 2px solid transparent;
}
.seat.turn .seat-plate { border-color: var(--gold); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 16px rgba(232,182,76,.85); } }
.seat.folded { opacity: .45; }
.seat-name { font-family: var(--slab); font-size: 12.5px; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-chips { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.seat-status { font-family: var(--mono); font-size: 10px; color: var(--red); min-height: 12px; }
.seat-hand { font-family: var(--mono); font-size: 9.5px; color: var(--green); }
.seat-timer { height: 3px; background: rgba(0,0,0,.15); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.seat-timer i { display: block; height: 100%; background: var(--gold); width: 100%; }
.dealer-btn {
  position: absolute; top: -10px; right: -6px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--cream); color: var(--red); font-family: var(--mono); font-size: 7px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 1.5px dashed var(--red); transform: rotate(8deg); font-weight: bold;
  box-shadow: 0 2px 5px rgba(0,0,0,.4); z-index: 3; line-height: 1.1;
}
.sit-btn {
  background: rgba(244,234,216,.14); color: var(--cream); border: 2px dashed rgba(244,234,216,.5);
  border-radius: 8px; padding: 14px 20px; font-family: var(--slab); letter-spacing: 2px; font-size: 12px;
}
.sit-btn:hover { background: rgba(244,234,216,.25); }

/* bet chips on felt */
.bet-chip {
  position: absolute; transform: translate(-50%, -50%); z-index: 4;
  display: flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 12px; color: var(--cream);
  background: rgba(13,31,56,.6); border-radius: 12px; padding: 3px 9px 3px 4px;
}
.chip-disc {
  width: 18px; height: 18px; border-radius: 50%; background: var(--red);
  border: 2px dashed var(--cream); flex: 0 0 18px;
}

/* winner + banners */
.winner-banner {
  position: absolute; top: 16%; left: 50%; transform: translateX(-50%) rotate(-2deg);
  background: var(--cream); color: var(--navy); font-family: var(--slab);
  padding: 14px 26px; border-radius: 6px; font-size: 17px; letter-spacing: 1px;
  border: 3px double var(--red); box-shadow: 0 10px 30px rgba(0,0,0,.5);
  z-index: 60; text-align: center; max-width: 80%;
}
.winner-banner .wb-tag { font-family: var(--mono); font-size: 10px; letter-spacing: 4px; color: var(--red); }
.away-banner, .rebuy-strip {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: var(--cream); padding: 10px 16px; border-radius: 8px; z-index: 70;
  font-family: var(--slab); font-size: 14px; color: var(--navy);
  display: flex; gap: 12px; align-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}

/* ---------- feed ---------- */
.feed {
  width: 290px; flex: 0 0 290px; background: var(--cream); display: flex; flex-direction: column;
  border-left: 4px solid; border-image: var(--airmail) 1;
}
.feed-tabs { display: flex; }
.feed-tab {
  flex: 1; padding: 10px 0; border: none; background: var(--navy); color: rgba(244,234,216,.6);
  font-family: var(--slab); font-size: 11px; letter-spacing: 2px;
}
.feed-tab.active { background: var(--cream); color: var(--navy); }
.feed-body { flex: 1; overflow-y: auto; padding: 10px 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.55; }
.feed-body div { margin-bottom: 3px; word-wrap: break-word; }
.log-hand { color: var(--navy); font-weight: bold; margin-top: 6px; }
.log-win { color: var(--red-dark); font-weight: bold; }
.log-info { opacity: .6; }
.log-chat b { color: var(--navy); }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(0,0,0,.12); }
.chat-form input { flex: 1; padding: 8px; border: 1.5px solid var(--navy); border-radius: 5px; font-size: 13px; min-width: 0; }

/* ---------- actions ---------- */
.actions {
  flex: 0 0 auto; background: var(--navy-deep); padding: 8px 14px 14px;
  border-top: 3px solid var(--kraft); z-index: 40;
}
.timerbar { height: 5px; border-radius: 3px; background: rgba(244,234,216,.15); overflow: hidden; margin-bottom: 9px; }
.timerbar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); }
.action-row { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; }
.act-btn {
  border: none; border-radius: 7px; font-family: var(--slab); letter-spacing: 2px;
  font-size: 15px; padding: 13px 22px; color: var(--cream);
}
.act-btn.fold { background: #6b2320; box-shadow: 0 3px 0 #471512; }
.act-btn.check { background: var(--green); box-shadow: 0 3px 0 #2b6e3f; min-width: 150px; }
.act-btn.bet { background: var(--red); box-shadow: 0 3px 0 var(--red-dark); min-width: 150px; }
.act-btn:active { transform: translateY(2px); box-shadow: none; }
.raise-box { flex: 1; display: flex; gap: 9px; align-items: center; min-width: 280px; }
.presets { display: flex; gap: 5px; }
.presets button {
  background: var(--navy); border: 1px solid rgba(244,234,216,.25); color: var(--cream);
  font-family: var(--mono); font-size: 10.5px; padding: 6px 8px; border-radius: 4px;
}
.presets button:hover { background: var(--felt); }
#bet-range { flex: 1; accent-color: var(--red); min-width: 80px; }
#bet-num {
  width: 88px; padding: 9px 8px; font-family: var(--mono); font-size: 14px;
  border-radius: 5px; border: 1.5px solid var(--kraft); background: var(--cream);
}

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(13,31,56,.72); z-index: 200;
  display: flex; align-items: center; justify-content: center; }
.modal-card { width: min(400px, 92vw); background: var(--cream); border-radius: 10px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-inner { padding: 24px 26px; }
.modal-inner h3 { font-family: var(--slab); letter-spacing: 3px; color: var(--navy); margin-bottom: 16px; }
.modal-row { display: flex; gap: 12px; align-items: center; }
#buyin-range { flex: 1; accent-color: var(--red); }
#buyin-num { width: 90px; padding: 9px; font-family: var(--mono); font-size: 15px;
  border: 1.5px solid var(--navy); border-radius: 5px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .feed {
    position: absolute; right: 0; top: 0; bottom: 0; z-index: 90;
    transform: translateX(100%); transition: transform .2s; width: min(300px, 85vw);
  }
  .feed.open { transform: translateX(0); }
  .card { width: 38px; height: 54px; }
  .card .rk { font-size: 16px; }
  .seat { width: 104px; }
  .act-btn { font-size: 13px; padding: 11px 14px; }
  .act-btn.check, .act-btn.bet { min-width: 110px; }
  .raise-box { min-width: 220px; }
  .brand { font-size: 13px; letter-spacing: 1px; }
}
