/* Lobby, waiting room, screen switching and shared online-table pieces. Builds on tokens from style.css. */
:root {
  --serif: "Noto Serif Georgian", Georgia, serif;
  --glass: linear-gradient(160deg, rgba(14, 52, 38, 0.82), rgba(4, 22, 15, 0.9));
  --glass-border: rgba(232, 194, 106, 0.22);
  --radius: 22px;
  font-family: "Noto Sans Georgian", "Segoe UI", "Sylfaen", sans-serif;
}

/* ---------- screens ---------- */
.screen { display: none; }
body[data-screen="lobby"] #lobbyScreen { display: block; }
body[data-screen="wait"] #waitScreen { display: grid; }
body[data-screen="game"] #gameScreen { display: flex; }
.lobby-screen { height: 100%; overflow-y: auto; overflow-x: hidden; user-select: text; position: relative; }
.wait-screen { height: 100%; place-items: center; padding: 24px 16px; overflow: auto; }
.game-screen { flex-direction: column; height: 100%; min-height: 0; }

.muted { color: var(--muted); }
.center { text-align: center; justify-content: center; }
.eyebrow { font-size: 12.5px; letter-spacing: 3px; text-transform: uppercase; color: var(--gold); opacity: 0.85; font-weight: 700; }
.logo { font-family: var(--serif); }

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  padding: 22px;
}
.glass h3 { margin: 0 0 16px; font-size: 13px; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); }

/* ---------- lobby header + hero ---------- */
.lobby-top {
  display: flex; align-items: center; gap: 16px;
  max-width: 1240px; margin: 0 auto; padding: 18px 24px 0;
}
.hero {
  max-width: 1240px; margin: 0 auto; padding: 36px 24px 28px;
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; align-items: center;
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 5.4vw, 64px);
  line-height: 1.08;
  margin: 12px 0 16px;
  font-weight: 900;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.45);
}
.hero h1 span {
  background: linear-gradient(100deg, #ffe7a8 0%, var(--gold) 45%, #b88a32 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { font-size: 17px; line-height: 1.65; color: #cfe0d6; max-width: 540px; margin: 0; }

.hero-fan { position: relative; height: 230px; }
.hero-fan .card.fan {
  --cw: 104px;
  position: absolute; left: 50%; bottom: 0;
  transform-origin: 50% 115%;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  animation: fanIn 0.9s cubic-bezier(.2, .9, .3, 1.2) backwards, floaty 6s ease-in-out infinite;
}
.hero-fan .f0 { --r: -28deg; animation-delay: 0.05s, 1s; }
.hero-fan .f1 { --r: -14deg; animation-delay: 0.12s, 1.2s; }
.hero-fan .f2 { --r: 0deg; animation-delay: 0.19s, 1.4s; z-index: 2; }
.hero-fan .f3 { --r: 14deg; animation-delay: 0.26s, 1.6s; }
.hero-fan .f4 { --r: 28deg; animation-delay: 0.33s, 1.8s; }
.hero-fan .card.fan { transform: translateX(-50%) rotate(var(--r)); }
@keyframes fanIn { from { transform: translateX(-50%) rotate(0deg) translateY(60px); opacity: 0; } }
@keyframes floaty { 50% { transform: translateX(-50%) rotate(var(--r)) translateY(-8px); } }

/* ---------- lobby grid ---------- */
.lobby-grid {
  max-width: 1240px; margin: 0 auto; padding: 0 24px 24px;
  display: grid; grid-template-columns: 1.15fr 1fr 0.85fr; gap: 22px; align-items: start;
}
.lobby-foot { text-align: center; color: rgba(255, 255, 255, 0.3); font-size: 13px; padding: 10px 0 30px; letter-spacing: 1px; }

.field { display: block; margin-bottom: 18px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.field input, .code-input, .invite input {
  width: 100%;
  font: inherit; font-size: 18px;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .code-input:focus, .invite input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(232, 194, 106, 0.15); }
.field input::placeholder, .code-input::placeholder { color: rgba(255, 255, 255, 0.28); }

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; border-radius: 14px; background: rgba(0, 0, 0, 0.3); margin-bottom: 18px; }
.tab {
  font: inherit; font-weight: 700; font-size: 14.5px;
  padding: 10px; border-radius: 10px; border: 0; cursor: pointer;
  color: var(--muted); background: transparent; transition: background 0.15s, color 0.15s;
}
.tab.active { background: rgba(232, 194, 106, 0.16); color: var(--gold); box-shadow: inset 0 0 0 1px rgba(232, 194, 106, 0.35); }
.tab:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.mode-card {
  position: relative; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.mode-card:hover { transform: translateY(-2px); border-color: rgba(232, 194, 106, 0.5); }
.mode-card input { position: absolute; opacity: 0; pointer-events: none; }
.mode-card b { font-size: 16.5px; }
.mode-card small { color: var(--muted); line-height: 1.45; font-size: 12.5px; }
.mode-ico {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(232, 194, 106, 0.12); color: var(--gold); font-size: 18px;
}
.mode-card:has(input:checked) {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(232, 194, 106, 0.18), rgba(232, 194, 106, 0.04));
  box-shadow: 0 0 0 3px rgba(232, 194, 106, 0.12);
}
.mode-card:has(input:checked)::after {
  content: "✓"; position: absolute; top: 12px; right: 14px;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: #2a1d05; font-size: 13px; font-weight: 800;
}
.mode-card:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn.big { width: 100%; padding: 15px; font-size: 17px; border-radius: 14px; box-shadow: 0 10px 30px rgba(232, 194, 106, 0.25); }

.join-row { display: flex; gap: 10px; margin-bottom: 20px; }
.code-input { text-transform: uppercase; letter-spacing: 8px; font-weight: 800; text-align: center; font-size: 22px; }
.join-row .btn { padding: 0 22px; }
.entry h4 { margin: 0 0 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.open-tables { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: auto; }
.open-table {
  font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1);
  transition: border-color 0.15s, background 0.15s;
}
.open-table:hover { border-color: var(--gold); background: rgba(232, 194, 106, 0.08); }
.ot-code { font-weight: 800; letter-spacing: 3px; color: var(--gold); font-size: 17px; }
.ot-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ot-info b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ot-info small { color: var(--muted); }
.ot-go { color: var(--gold); font-size: 13px; font-weight: 700; white-space: nowrap; }
.empty { margin: 4px 0; font-size: 14px; }

.resume {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; margin-bottom: 18px; border-radius: 14px;
  background: linear-gradient(90deg, rgba(232, 194, 106, 0.2), rgba(232, 194, 106, 0.05));
  border: 1px solid var(--gold-dark);
}

/* ---------- profile ---------- */
.profile-empty { text-align: center; padding: 18px 8px; color: var(--muted); line-height: 1.6; }
.big-suit { font-size: 56px; color: rgba(232, 194, 106, 0.35); line-height: 1; margin-bottom: 8px; }
.me-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.me-name { font-size: 20px; font-weight: 800; }
.avatar.lg { width: 56px; height: 56px; font-size: 24px; }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.ghost { background: rgba(255, 255, 255, 0.08); color: var(--muted); border: 1px dashed rgba(255, 255, 255, 0.3); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
.stat {
  padding: 12px 6px; border-radius: 14px; text-align: center;
  background: rgba(0, 0, 0, 0.25); border: 1px solid rgba(255, 255, 255, 0.06);
}
.stat b { display: block; font-size: 21px; font-weight: 800; }
.stat span { font-size: 11.5px; color: var(--muted); }
.ph-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.ph-row {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 11px; border-radius: 12px; background: rgba(255, 255, 255, 0.035);
}
.ph-medal { font-size: 20px; text-align: center; }
.ph-main { display: flex; flex-direction: column; min-width: 0; }
.ph-main b { font-size: 16px; }
.ph-main small, .ph-date small { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-date { text-align: right; font-size: 12.5px; display: flex; flex-direction: column; }

/* ---------- leaderboard ---------- */
.leader {
  display: grid; grid-template-columns: 30px 32px 1fr auto; gap: 10px; align-items: center;
  padding: 9px 10px; border-radius: 12px;
}
.leader + .leader { margin-top: 4px; }
.leader.top { background: rgba(232, 194, 106, 0.07); }
.lr-pos { text-align: center; font-weight: 800; color: var(--muted); font-size: 16px; }
.lr-name { display: flex; flex-direction: column; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-name small, .lr-wins small { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.lr-wins { text-align: right; display: flex; flex-direction: column; }
.lr-wins b { color: var(--gold); font-size: 18px; }

/* ---------- waiting room ---------- */
.wait-card { width: min(640px, 100%); text-align: center; }
.wait-code {
  font-family: var(--serif); font-weight: 900;
  font-size: clamp(48px, 10vw, 76px); letter-spacing: 14px; padding-left: 14px;
  background: linear-gradient(180deg, #ffe7a8, var(--gold-dark));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 4px 0 2px;
}
.invite { display: flex; gap: 10px; margin: 18px 0 8px; }
.invite input { font-size: 14px; padding: 11px 14px; }
.mini-table { position: relative; height: 290px; margin: 18px auto 6px; max-width: 460px; }
.mini-felt {
  position: absolute; left: 50%; top: 50%; width: 62%; height: 52%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, #1c8a5d, #0b4a31 70%);
  border: 8px solid #5a3a1c;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5), 0 14px 40px rgba(0, 0, 0, 0.5), 0 0 0 2px rgba(232, 194, 106, 0.4);
  display: grid; place-items: center;
}
.mini-felt span { font-size: 40px; color: rgba(196, 38, 46, 0.55); }
.wseat {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 140px; animation: pop2 0.3s ease-out;
}
.wseat span { font-weight: 700; font-size: 14.5px; }
.wseat small { color: var(--muted); font-size: 12px; }
.wseat.empty span { color: var(--muted); font-weight: 400; }
.wseat.empty .avatar { animation: breathe 1.8s ease-in-out infinite; }
.wseat.me .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 24px rgba(232, 194, 106, 0.5); }
.wseat.w0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.wseat.w1 { left: 0; top: 18px; }
.wseat.w2 { right: 0; top: 18px; }
@keyframes breathe { 50% { opacity: 0.45; } }

/* ---------- game additions ---------- */
.char-wrap.mini { --charw: 64px; }
.wseat .char-wrap.mini { --charw: 70px; }
.wseat.me .char-wrap.mini::before { opacity: 1; }
.wseat.empty .avatar { width: 56px; height: 56px; }
.message.mine { border-color: var(--gold); color: #ffe7a8; box-shadow: 0 0 0 3px rgba(232, 194, 106, 0.18), 0 6px 18px rgba(0, 0, 0, 0.35); }
.message b { color: var(--gold); }
.ptags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.ptags:empty { display: none; }
.ptags .tag { margin-left: 0; }
.tag.bot { background: rgba(159, 211, 255, 0.15); color: #9fd3ff; }
.tag.off { background: rgba(255, 123, 123, 0.15); color: var(--bad); }
.player-card.offline { opacity: 0.6; }
.you { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.hand .card.sent { transform: translateY(-40px); opacity: 0.5; pointer-events: none; }
.ready-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.ready-pill {
  padding: 5px 12px; border-radius: 999px; font-size: 13px;
  background: rgba(255, 255, 255, 0.06); color: var(--muted); border: 1px solid rgba(255, 255, 255, 0.1);
}
.ready-pill.ok { color: var(--good); border-color: rgba(111, 220, 140, 0.4); background: rgba(111, 220, 140, 0.08); }
.final-crown { text-align: center; font-size: 60px; color: var(--gold); line-height: 1; text-shadow: 0 0 30px rgba(232, 194, 106, 0.6); animation: crown 1.2s ease-out; }
@keyframes crown { from { transform: translateY(-30px) scale(0.6); opacity: 0; } }
.modal h2.center { text-align: center; }
.modal .row.center, .wait-card .row.center { justify-content: center; }

/* ---------- toast + connection banner ---------- */
.toast, .net-banner {
  position: fixed; left: 50%; z-index: 50;
  transform: translate(-50%, 20px);
  padding: 12px 20px; border-radius: 14px;
  font-weight: 600; font-size: 14.5px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  max-width: calc(100vw - 32px); text-align: center;
}
.toast { bottom: 28px; background: #1d1408; color: #ffe7a8; border: 1px solid var(--gold-dark); }
.net-banner { top: 14px; background: #3a0f12; color: #ffd0d0; border: 1px solid var(--bad); }
.toast.show, .net-banner.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .topbar { gap: 10px; padding: 8px 14px; flex-wrap: wrap; }
  .topbar .logo { font-size: 21px; }
  .topbar .chip { font-size: 12.5px; padding: 4px 10px; }
  .topbar .btn { padding: 6px 11px; font-size: 13px; }
  .sidebar { width: 250px; }
}
@media (max-width: 1080px) {
  .lobby-grid { grid-template-columns: 1fr 1fr; }
  .lobby-grid .entry { grid-row: span 2; }
}
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding-top: 18px; }
  .hero-fan { height: 170px; }
  .hero-fan .card.fan { --cw: 74px; }
  .lobby-grid { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .lobby-top { padding: 14px 16px 0; }
  .hero { padding-left: 16px; padding-right: 16px; }
  .modes { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-table { height: 260px; }
  .wseat { width: 110px; }
  .sidebar { display: none; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .topbar .chip { font-size: 12px; }
}
