/* ============================================================
   Белот Онлайн — "Sofia card salon": deep emerald felt,
   warm brass, ivory cards. Forum (display) + Manrope (UI).
   ============================================================ */
:root {
  --felt-1: #0c3b2e;
  --felt-2: #0a2c22;
  --felt-edge: #06201a;
  --gold: #d9b25f;
  --gold-bright: #f1d695;
  --gold-deep: #9c7a33;
  --ivory: #f6efdd;
  --ivory-dim: #e7dcc1;
  --ink: #1c1814;
  --red: #b0282e;
  --red-soft: #c8413f;
  --shadow: rgba(0, 0, 0, .45);
  --us: #f1d695;
  --them: #79b6e6;
  --ok: #6fcf97;
  --bad: #e57373;
}

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

html, body { height: 100%; }

body {
  font-family: 'Manrope', system-ui, sans-serif;
  color: var(--ivory);
  background:
    radial-gradient(120% 90% at 50% 0%, #14513c 0%, var(--felt-1) 38%, var(--felt-2) 72%, var(--felt-edge) 100%);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* subtle felt grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.035'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0;
}

#app { position: relative; z-index: 1; height: 100vh; }

.screen { display: none; height: 100vh; }
.screen.active { display: block; }

.btn {
  font-family: 'Manrope', sans-serif;
  font-weight: 700; font-size: 15px;
  border: none; border-radius: 10px;
  padding: 13px 22px; cursor: pointer;
  letter-spacing: .02em; transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-gold {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold) 55%, var(--gold-deep));
  color: #3a2c08; box-shadow: 0 6px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.4);
}
.btn-gold:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.btn-outline { background: transparent; color: var(--gold-bright); border: 1.5px solid var(--gold); }
.btn-outline:hover { background: rgba(217,178,95,.12); }
.btn-ghost { background: rgba(255,255,255,.06); color: var(--ivory-dim); }
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-mini { padding: 7px 12px; font-size: 12px; border-radius: 8px; background: rgba(0,0,0,.25); color: var(--gold-bright); border: 1px solid rgba(217,178,95,.4); }
.btn-mini:hover { background: rgba(217,178,95,.15); }

/* ===================== LOBBY ===================== */
#lobby { display: none; place-items: center; }
#lobby.active { display: grid; }

.lobby-card {
  width: min(440px, 92vw);
  background: linear-gradient(180deg, rgba(12,59,46,.85), rgba(6,32,26,.92));
  border: 1px solid rgba(217,178,95,.35);
  border-radius: 20px;
  padding: 40px 36px 30px;
  box-shadow: 0 30px 80px var(--shadow), inset 0 1px 0 rgba(255,255,255,.06);
  text-align: center;
}
.brand-pips { font-size: 26px; letter-spacing: 6px; margin-bottom: 8px; }
.brand-pips .s, .brand-pips .c { color: var(--ivory); }
.brand-pips .h, .brand-pips .d { color: var(--red-soft); }
.brand h1 {
  font-family: 'Forum', serif; font-weight: 400;
  font-size: 52px; line-height: 1; letter-spacing: .01em;
  color: var(--ivory);
}
.brand h1 em { color: var(--gold-bright); font-style: normal; }
.tagline { color: var(--ivory-dim); font-size: 14px; margin-top: 10px; opacity: .85; }

.lobby-forms { margin-top: 28px; text-align: left; }
.field label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--gold); margin-bottom: 7px; }
input[type=text] {
  width: 100%; font-family: 'Manrope', sans-serif; font-size: 16px;
  padding: 13px 14px; border-radius: 10px;
  background: rgba(0,0,0,.28); color: var(--ivory);
  border: 1.5px solid rgba(217,178,95,.3); outline: none;
  transition: border-color .15s ease, background .15s ease;
}
input[type=text]:focus { border-color: var(--gold); background: rgba(0,0,0,.4); }
input::placeholder { color: rgba(246,239,221,.35); }

.lobby-actions { margin-top: 22px; }
.lobby-actions .btn-gold { width: 100%; }
.or { text-align: center; color: var(--ivory-dim); font-size: 12px; margin: 16px 0; position: relative; opacity: .6; }
.or::before, .or::after { content: ""; position: absolute; top: 50%; width: 38%; height: 1px; background: rgba(217,178,95,.25); }
.or::before { left: 0; } .or::after { right: 0; }
.join-row { display: flex; gap: 10px; }
.join-row input { text-transform: uppercase; letter-spacing: .3em; font-weight: 700; text-align: center; }
.join-row .btn { white-space: nowrap; }
.hint { margin-top: 22px; font-size: 12px; color: var(--ivory-dim); opacity: .7; }

/* ===================== WAITING ===================== */
#waiting { display: none; place-items: center; }
#waiting.active { display: grid; }
.waiting-card {
  width: min(460px, 92vw); text-align: center;
  background: linear-gradient(180deg, rgba(12,59,46,.85), rgba(6,32,26,.92));
  border: 1px solid rgba(217,178,95,.35); border-radius: 20px;
  padding: 34px 32px; box-shadow: 0 30px 80px var(--shadow);
}
.waiting-card h2 { font-family: 'Forum', serif; font-weight: 400; font-size: 28px; color: var(--gold-bright); }
.code-box { margin: 16px 0 6px; display: flex; align-items: center; justify-content: center; gap: 14px; }
.code {
  font-family: 'Forum', serif; font-size: 56px; letter-spacing: .18em;
  color: var(--ivory); background: rgba(0,0,0,.3); padding: 6px 22px 10px;
  border-radius: 14px; border: 1px dashed rgba(217,178,95,.5);
}
.share-hint { color: var(--ivory-dim); font-size: 13px; opacity: .8; margin-bottom: 22px; }
.seat-list { display: grid; gap: 10px; margin-bottom: 24px; }
.seat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 12px;
  background: rgba(0,0,0,.22); border: 1px solid rgba(255,255,255,.06);
}
.seat-row .dot { width: 10px; height: 10px; border-radius: 50%; background: #555; }
.seat-row.filled .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.seat-row .who { flex: 1; text-align: left; font-weight: 600; }
.seat-row .team-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; padding: 3px 9px; border-radius: 20px; }
.team-tag.a { background: rgba(241,214,149,.16); color: var(--us); }
.team-tag.b { background: rgba(121,182,230,.16); color: var(--them); }
.seat-row .host-tag { font-size: 11px; color: var(--gold); }
.waiting-foot { display: grid; gap: 12px; }
.waiting-foot .btn-gold { width: 100%; }
.wait-msg { font-size: 13px; color: var(--ivory-dim); opacity: .8; min-height: 1em; }

/* ===================== TABLE ===================== */
#table { display: none; flex-direction: column; }
#table.active { display: flex; }

.hud {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; gap: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.28), rgba(0,0,0,0));
  z-index: 5;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 12px; }
.scoreboard {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0,0,0,.32); border: 1px solid rgba(217,178,95,.3);
  border-radius: 14px; padding: 8px 18px;
}
.scoreboard .team { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.scoreboard .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; opacity: .7; margin-bottom: 3px; }
.scoreboard .val { font-family: 'Forum', serif; font-size: 26px; }
.scoreboard .us .val { color: var(--us); }
.scoreboard .them .val { color: var(--them); }
.team-sep { font-size: 20px; opacity: .4; }
.pill { font-size: 12px; padding: 6px 12px; border-radius: 20px; background: rgba(0,0,0,.3); border: 1px solid rgba(255,255,255,.1); color: var(--ivory-dim); }
.contract-badge {
  font-family: 'Forum', serif; font-size: 20px; letter-spacing: .03em;
  padding: 8px 20px; border-radius: 30px;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  color: #3a2c08; box-shadow: 0 6px 18px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: 8px;
}
.contract-badge .ct-suit.red { color: var(--red); }
.contract-badge .ct-x { font-size: 13px; background: var(--red); color: #fff; padding: 2px 8px; border-radius: 12px; font-family: 'Manrope'; font-weight: 800; }

.felt {
  position: relative; flex: 1;
  margin: 4px 26px; border-radius: 50% / 26%;
  background:
    radial-gradient(80% 80% at 50% 45%, rgba(28,96,72,.65), rgba(8,40,30,.2) 70%, transparent 80%);
  box-shadow: inset 0 0 90px rgba(0,0,0,.5), inset 0 0 0 2px rgba(217,178,95,.18);
  min-height: 0;
}

/* seats */
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 3; }
.seat-top { top: 8px; left: 50%; transform: translateX(-50%); }
.seat-bottom { bottom: 6px; left: 50%; transform: translateX(-50%); }
.seat-left { left: 14px; top: 50%; transform: translateY(-50%); }
.seat-right { right: 14px; top: 50%; transform: translateY(-50%); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #1a6b50, #0a2c22);
  border: 2px solid rgba(217,178,95,.4);
  display: grid; place-items: center; font-family: 'Forum', serif; font-size: 22px; color: var(--gold-bright);
  transition: box-shadow .2s ease, border-color .2s ease;
}
.nameplate {
  font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 20px;
  background: rgba(0,0,0,.4); border: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
}
.nameplate .badge { font-size: 10px; padding: 1px 6px; border-radius: 10px; }
.badge.dealer { background: var(--gold); color: #3a2c08; }
.badge.dc { background: var(--bad); color: #fff; }
.seat.team-a .avatar { border-color: var(--us); }
.seat.team-b .avatar { border-color: var(--them); }
.seat.active .avatar { box-shadow: 0 0 0 3px var(--gold-bright), 0 0 22px var(--gold-bright); }
.seat.active .nameplate { background: rgba(217,178,95,.25); }
.mini-hand { display: flex; gap: -8px; height: 26px; }
.mini-hand .cardback { width: 18px; height: 26px; margin-left: -10px; border-radius: 3px;
  background: repeating-linear-gradient(45deg, #7a1f23, #7a1f23 3px, #5c1418 3px, #5c1418 6px);
  border: 1px solid rgba(217,178,95,.4); box-shadow: 0 1px 2px rgba(0,0,0,.4); }
.mini-hand .cardback:first-child { margin-left: 0; }

/* trick */
.trick-area { position: absolute; inset: 0; pointer-events: none; }
.trick-slot { position: absolute; left: 50%; top: 50%; transition: all .25s ease; }
.trick-slot[data-pos=top] { transform: translate(-50%, -118%); }
.trick-slot[data-pos=bottom] { transform: translate(-50%, 18%); }
.trick-slot[data-pos=left] { transform: translate(-128%, -50%); }
.trick-slot[data-pos=right] { transform: translate(28%, -50%); }

.center-msg {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  font-family: 'Forum', serif; font-size: 22px; color: var(--gold-bright);
  text-align: center; text-shadow: 0 2px 10px rgba(0,0,0,.6); pointer-events: none;
  opacity: .9; max-width: 60%;
}

/* cards */
.card {
  width: 62px; height: 90px; border-radius: 8px;
  background: linear-gradient(160deg, #fffdf6, var(--ivory) 70%, var(--ivory-dim));
  color: var(--ink); box-shadow: 0 6px 14px rgba(0,0,0,.4), inset 0 0 0 1px rgba(0,0,0,.06);
  position: relative; user-select: none; flex: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 6px 7px;
}
.card.red { color: var(--red); }
.card .corner { font-weight: 800; line-height: .9; font-size: 17px; display: flex; flex-direction: column; align-items: center; width: fit-content; }
.card .corner .pip { font-size: 15px; }
.card .corner.br { align-self: flex-end; transform: rotate(180deg); }
.card .center-pip { position: absolute; inset: 0; display: grid; place-items: center; font-size: 30px; opacity: .9; }
.card.sm { width: 46px; height: 66px; padding: 4px 5px; }
.card.sm .corner { font-size: 13px; } .card.sm .corner .pip { font-size: 11px; } .card.sm .center-pip { font-size: 22px; }

/* player's hand */
.hand {
  display: flex; justify-content: center; align-items: flex-end;
  padding: 8px 20px 20px; gap: 0; min-height: 110px; z-index: 4;
}
.hand .card {
  margin-left: -14px; transition: transform .15s ease, box-shadow .15s ease, margin .15s ease;
  cursor: default;
}
.hand .card:first-child { margin-left: 0; }
.hand .card.playable { cursor: pointer; }
.hand .card.playable:hover { transform: translateY(-18px); box-shadow: 0 14px 26px rgba(0,0,0,.5); z-index: 10; }
.hand .card.disabled { filter: grayscale(.4) brightness(.82); }
.hand .card.belot::after {
  content: "♛"; position: absolute; top: -8px; right: -4px; font-size: 14px;
  color: var(--gold-deep); background: var(--gold-bright); border-radius: 50%;
  width: 18px; height: 18px; display: grid; place-items: center;
}

/* bidding panel */
.bid-panel {
  position: absolute; left: 50%; bottom: 130px; transform: translateX(-50%);
  width: min(560px, 94vw); z-index: 12;
  background: linear-gradient(180deg, rgba(10,44,34,.96), rgba(6,32,26,.98));
  border: 1px solid rgba(217,178,95,.4); border-radius: 16px;
  padding: 16px 18px; box-shadow: 0 20px 60px var(--shadow);
}
.bid-info { text-align: center; font-size: 14px; color: var(--ivory-dim); margin-bottom: 12px; }
.bid-info b { color: var(--gold-bright); }
.bid-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.bid-btn {
  font-family: 'Manrope'; font-weight: 700; font-size: 15px;
  padding: 11px 16px; border-radius: 10px; cursor: pointer;
  background: rgba(255,255,255,.06); color: var(--ivory); border: 1.5px solid rgba(217,178,95,.3);
  display: flex; align-items: center; gap: 6px; transition: all .12s ease;
}
.bid-btn:hover { background: rgba(217,178,95,.18); border-color: var(--gold); transform: translateY(-2px); }
.bid-btn .suit.red { color: var(--red-soft); }
.bid-btn.pass { color: var(--ivory-dim); }
.bid-btn.contra { background: rgba(176,40,46,.3); border-color: var(--red-soft); color: #ffd9d9; }
.bid-btn.recontra { background: rgba(176,40,46,.5); border-color: var(--red); color: #fff; }

/* log */
.log-feed {
  position: absolute; left: 18px; bottom: 16px; width: 250px; z-index: 5;
  display: flex; flex-direction: column; gap: 4px; pointer-events: none;
}
.log-feed .line {
  font-size: 12px; color: var(--ivory-dim); background: rgba(0,0,0,.3);
  padding: 5px 10px; border-radius: 8px; opacity: .85;
  border-left: 2px solid rgba(217,178,95,.4);
}

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(3,16,12,.72); backdrop-filter: blur(4px);
}
.modal {
  width: min(520px, 92vw);
  background: linear-gradient(180deg, #103f30, #08281f);
  border: 1px solid rgba(217,178,95,.4); border-radius: 18px;
  padding: 28px 30px; box-shadow: 0 30px 90px var(--shadow);
  max-height: 86vh; overflow: auto;
}
.modal h2 { font-family: 'Forum', serif; font-weight: 400; font-size: 30px; color: var(--gold-bright); text-align: center; margin-bottom: 6px; }
.modal .sub { text-align: center; color: var(--ivory-dim); margin-bottom: 18px; font-size: 14px; }
.result-tag { text-align: center; font-family: 'Forum', serif; font-size: 22px; margin-bottom: 16px; }
.result-tag.made { color: var(--ok); } .result-tag.down { color: var(--bad); } .result-tag.hanging { color: var(--gold-bright); }
.score-grid { display: grid; grid-template-columns: 1fr auto auto; gap: 8px 14px; margin: 12px 0; font-size: 14px; }
.score-grid .h { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; opacity: .6; }
.score-grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.decl-line { font-size: 13px; color: var(--ivory-dim); margin: 3px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
.rules-list { font-size: 14px; line-height: 1.6; color: var(--ivory-dim); }
.rules-list h3 { color: var(--gold-bright); font-family: 'Forum', serif; font-weight: 400; font-size: 18px; margin: 14px 0 4px; }
.rules-list table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.rules-list td { padding: 2px 6px; border-bottom: 1px solid rgba(255,255,255,.06); }

/* toast */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: rgba(176,40,46,.95); color: #fff; padding: 12px 22px; border-radius: 12px;
  z-index: 60; font-weight: 600; font-size: 14px; box-shadow: 0 10px 30px var(--shadow);
  opacity: 0; transition: opacity .2s ease, transform .2s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

@keyframes dealIn { from { opacity: 0; transform: translateY(20px) scale(.9); } to { opacity: 1; } }
.card.deal { animation: dealIn .3s ease both; }

/* responsive */
@media (max-width: 720px) {
  .felt { margin: 2px 8px; }
  .card { width: 50px; height: 72px; }
  .hand .card { margin-left: -18px; }
  .brand h1 { font-size: 42px; }
  .log-feed { display: none; }
  .seat-left { left: 2px; } .seat-right { right: 2px; }
}
