
/* Tiến Lên Pro - Fresh UI Theme (tabletop neon) */

:root{
  --bg1:#0b1020;
  --bg2:#071220;
  --felt:#0e3b2c;
  --felt2:#0a2f23;
  --panel: rgba(255,255,255,.06);
  --panel2: rgba(0,0,0,.35);
  --stroke: rgba(255,255,255,.12);
  --text: rgba(255,255,255,.92);
  --muted: rgba(255,255,255,.66);
  --accent:#ff3c7d;
  --accent2:#7c5cff;
  --good:#39d98a;
  --warn:#ffcc00;
  --danger:#ff5c5c;

  /* Card sizing (responsive) */
  --cardW: clamp(46px, 7.2vw, 96px);
  --cardH: calc(var(--cardW) * 1.38);
  --cardR: 14px;
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: Roboto, system-ui, -apple-system, Segoe UI, Arial, sans-serif;
  color:var(--text);
  background:
    radial-gradient(900px 500px at 50% 20%, rgba(124,92,255,.20), transparent 60%),
    radial-gradient(700px 500px at 20% 70%, rgba(255,60,125,.18), transparent 60%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  overflow-x:hidden;
}

a{ color:inherit; }
.hidden{ display:none !important; }

/* ---------- Top bar ---------- */
.topbar{
  position: sticky;
  top:0;
  z-index:50;
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding: 12px 14px;
  background: rgba(5,8,18,.75);
  border-bottom:1px solid rgba(255,255,255,.10);
  backdrop-filter: blur(10px);
}
.topbar-left{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

.chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.chip i{ opacity:.9; }

.btn-secondary{
  display:inline-flex;
  align-items:center;
  gap:10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color:var(--text);
  cursor:pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.btn-secondary:hover{ transform: translateY(-1px); background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.18); }

/* ---------- Auth screen ---------- */
.auth-screen{
  min-height: calc(100vh - 0px);
  display:flex;
  justify-content:center;
  align-items:center;
  padding: 24px 14px;
}
.auth-card{
  width: min(460px, 96vw);
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(14px);
}
.game-title{
  font-family: "Playfair Display", serif;
  letter-spacing:.5px;
  text-align:center;
  margin: 0 0 14px;
  font-size: clamp(34px, 5vw, 46px);
}
.game-title.small{ font-size: clamp(34px, 5vw, 46px); }

.tabs{ display:flex; gap:10px; margin: 8px 0 14px; }
.tab{
  flex:1;
  padding: 10px 12px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.22);
  color: var(--muted);
  cursor:pointer;
  transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.tab:hover{ transform: translateY(-1px); background: rgba(255,255,255,.06); }
.tab.active{
  color: var(--text);
  background: linear-gradient(135deg, rgba(255,60,125,.22), rgba(124,92,255,.20));
  border-color: rgba(255,255,255,.18);
}

.auth-form{ display:flex; flex-direction:column; gap:10px; }
.auth-form label{ font-size: 13px; color: var(--muted); }
.auth-form input{
  padding: 12px 12px;
  border-radius: 14px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.25);
  color: var(--text);
  outline:none;
}
.auth-form input:focus{ border-color: rgba(255,60,125,.35); box-shadow: 0 0 0 4px rgba(255,60,125,.12); }

.join-button{
  margin-top: 6px;
  padding: 12px 14px;
  border: 0;
  border-radius: 16px;
  color: white;
  cursor:pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 16px 40px rgba(255,60,125,.20);
  font-weight: 700;
  letter-spacing:.2px;
  transition: transform .12s ease, filter .12s ease;
}
.join-button:hover{ transform: translateY(-1px); filter: brightness(1.05); }
.join-button:active{ transform: translateY(0px); }

.auth-error{
  background: rgba(255,92,92,.12);
  border:1px solid rgba(255,92,92,.22);
  padding: 10px 12px;
  border-radius: 14px;
  color: rgba(255,255,255,.9);
}
.auth-hint{ margin: 12px 0 0; color: rgba(255,255,255,.65); font-size: 12px; text-align:center; }

/* ---------- Lobby ---------- */
#lobby-screen{
  display:none;
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 14px 24px;
  text-align:center;
}
#tables-container{ display:grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.table-card{
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  text-align:left;
}
.table-card h3{ margin: 4px 0 10px; }
.table-card .meta{ display:flex; gap:10px; flex-wrap:wrap; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.table-card button{ width:100%; }

/* ---------- Game screen ---------- */
#game-screen{
  display:none;
  padding: 10px 10px 20px;
}
.game-wrapper{
  max-width: 1200px;
  margin: 0 auto;
}

.game-table{
  position: relative;
  width: min(1100px, 96vw);
  height: min(760px, calc(100vh - 140px));
  margin: 0 auto;
  border-radius: 28px;
  background:
    radial-gradient(600px 380px at 50% 45%, rgba(255,255,255,.08), transparent 60%),
    radial-gradient(650px 460px at 50% 52%, rgba(0,0,0,.22), transparent 62%),
    linear-gradient(180deg, var(--felt), var(--felt2));
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: 0 30px 100px rgba(0,0,0,.55);
  overflow:hidden;
}

.player-area{
  position:absolute;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 10px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
}
.player-area.hidden-player{ display:none; }

.player-area.active-turn{
  border-color: rgba(255,60,125,.35);
  box-shadow: 0 0 0 4px rgba(255,60,125,.10);
}

.player-info{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 4px;
}
.player-name{ font-weight: 800; }
.card-count{ color: var(--muted); font-size: 12px; }

/* seat placement */
#player-2{ top: 14px; left: 50%; transform: translateX(-50%); width: min(340px, 92%); }
#player-3{ left: 14px; top: 50%; transform: translateY(-50%); width: 170px; }
#player-4{ right: 14px; top: 50%; transform: translateY(-50%); width: 170px; }

.center-table-area{
  position:absolute;
  inset: 92px 200px 160px 200px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 12px;
  justify-content:flex-start;
}
@media (max-width: 860px){
  .center-table-area{ inset: 92px 120px 170px 120px; }
  #player-3, #player-4{ width: 140px; }
}
@media (max-width: 640px){
  .game-table{ height: calc(100vh - 120px); }
  .center-table-area{ inset: 86px 16px 210px 16px; }
  #player-3, #player-4{ display:none; } /* small screens: simplify */
}

.table-info-row{ display:flex; gap:10px; flex-wrap:wrap; justify-content:center; }

.table-info-panel{
  width: 100%;
  max-width: 520px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  padding: 12px;
  text-align:center;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}

.played-cards-label{ color: var(--muted); display:block; margin-bottom: 6px; }
#table-cards-container{
  min-height: calc(var(--cardH) + 42px);
  display:flex;
  align-items:center;
  justify-content:center;
  position: relative;
}

/* pile visuals */
.pile{
  position:relative;
  width: min(460px, 92vw);
  height: calc(var(--cardH) + 48px);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
}
.pile-mess{
  position:absolute;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}
.pile-top{
  position: relative;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}
.pile-by{
  margin-top: 10px;
  font-weight: 800;
  color: rgba(255,255,255,.90);
  text-shadow: 0 6px 14px rgba(0,0,0,.35);
}

/* cards */
.card{
  width: var(--cardW);
  height: var(--cardH);
  border-radius: var(--cardR);
  user-select:none;
  -webkit-user-drag:none;
}
.pile-card{
  box-shadow: 0 16px 30px rgba(0,0,0,.35);
}
.mess-card{
  position:absolute;
  box-shadow: 0 12px 26px rgba(0,0,0,.30);
  opacity: .9;
}

/* opponent back cards */
.opponent-back-cards-container{
  display:flex;
  justify-content:center;
  align-items:center;
  gap: 2px;
  height: 70px;
}
.back-card{
  width: calc(var(--cardW) * 0.52);
  height: calc(var(--cardH) * 0.52);
  border-radius: 10px;
  opacity: .92;
  box-shadow: 0 10px 18px rgba(0,0,0,.25);
}

/* Your hand zone */
#player-1{
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(960px, 96vw);
  background: rgba(0,0,0,.22);
}
#player-1-name{
  margin: 0;
  font-size: 16px;
  color: rgba(255,255,255,.9);
}
#cards.hand{
  width: 100%;
  overflow-x:auto;
  overflow-y:hidden;
  display:flex;
  align-items:flex-end;
  justify-content:flex-start;
  padding: 10px 6px 2px;
  scroll-behavior:smooth;
}
#cards.hand::-webkit-scrollbar{ height: 10px; }
#cards.hand::-webkit-scrollbar-thumb{
  background: rgba(255,255,255,.12);
  border-radius: 999px;
}
#cards.hand .card{
  margin-left: calc(var(--cardW) * -0.52);
  transform: translateY(0px) rotate(0deg);
  transition: transform .14s ease, filter .14s ease;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,.25));
}
#cards.hand .card:first-child{ margin-left: 0; }
#cards.hand .card:hover{
  transform: translateY(-8px) rotate(-1deg);
}
#cards.hand .card.selected{
  transform: translateY(-18px) rotate(-2deg) scale(1.04);
  filter: drop-shadow(0 16px 30px rgba(0,0,0,.35));
}
#cards.hand .card.playing-out{
  opacity: 0.15;
  filter: none;
}

/* Buttons */
.button-group{
  display:flex;
  gap: 10px;
  width: 100%;
  justify-content:center;
  flex-wrap:wrap;
}
#playBtn, #passBtn{
  min-width: 160px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text);
  cursor:pointer;
  font-weight: 800;
  transition: transform .12s ease, background .12s ease, border-color .12s ease, opacity .12s ease;
}
#playBtn:hover, #passBtn:hover{
  transform: translateY(-1px);
  background: rgba(255,255,255,.10);
  border-color: rgba(255,255,255,.18);
}
#playBtn:disabled, #passBtn:disabled{
  opacity: .45;
  cursor:not-allowed;
}
#playBtn{
  background: linear-gradient(135deg, rgba(57,217,138,.22), rgba(124,92,255,.16));
  border-color: rgba(57,217,138,.22);
}
#passBtn{
  background: linear-gradient(135deg, rgba(255,92,92,.18), rgba(255,204,0,.10));
  border-color: rgba(255,92,92,.22);
}

/* Turn timer */
.turn-timer{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 12px;
}
.turn-timer-bar{
  width: min(360px, 80vw);
  height: 12px;
  border-radius: 999px;
  overflow:hidden;
  background: rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.12);
}
.turn-timer-fill{
  height:100%;
  width:0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .18s linear;
}
.turn-timer-text{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(255,255,255,.12);
  font-weight: 900;
}

/* Toast */
.toast{
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.68);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 10px 14px;
  opacity: 0;
  pointer-events:none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 999;
}
.toast.show{
  opacity: 1;
  transform: translateX(-50%) translateY(0px);
}

/* Modal */
.overlay{
  position: fixed;
  inset:0;
  background: rgba(0,0,0,.55);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 9999;
}
.modal{
  width: min(420px, 92vw);
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0,0,0,.55);
  backdrop-filter: blur(14px);
  text-align:center;
}
.modal button{
  margin-top: 10px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color:white;
  font-weight: 800;
  cursor:pointer;
}

/* Anim layer */
#animLayer{
  position: fixed;
  inset:0;
  pointer-events:none;
  z-index: 9998;
}
.fly-card{
  border-radius: var(--cardR);
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
}
.fly-card.face{ box-shadow: 0 22px 50px rgba(0,0,0,.45); }

/* PASS badge */
.pass-badge{
  position:absolute;
  top: 12px;
  right: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16);
  font-weight: 900;
  letter-spacing: .8px;
  box-shadow: 0 16px 40px rgba(0,0,0,.35);
  animation: pop .9s ease forwards;
}
@keyframes pop{
  0%{ transform: translateY(8px) scale(.95); opacity: 0; }
  20%{ opacity: 1; }
  100%{ transform: translateY(0px) scale(1); opacity: 0; }
}
