* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --felt: #0b6b3a;
  --felt-dark: #084d29;
  --card-w: 54px;
  --card-h: 76px;
  --gold: #f5c542;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  color: #fff;
  min-height: 100dvh;
  overflow-x: hidden;
}
.hidden { display: none !important; }
.screen { max-width: 560px; margin: 0 auto; padding: 18px 14px 24px; }

/* ---------- Home ---------- */
.logo { font-size: 64px; text-align: center; color: #fff; text-shadow: 0 4px 14px rgba(0,0,0,.4); }
h1 { text-align: center; font-size: 34px; letter-spacing: .5px; }
.tagline { text-align: center; opacity: .85; margin: 8px auto 20px; max-width: 420px; line-height: 1.45; font-size: 15px; }
.field { display: block; margin: 0 auto 14px; max-width: 340px; }
.field span { display: block; font-size: 13px; opacity: .85; margin-bottom: 5px; }
.field input, .joinRow input {
  width: 100%; padding: 12px; font-size: 17px; border-radius: 10px; border: none;
  background: rgba(255,255,255,.95); color: #123; outline: none;
}
.btn {
  display: block; width: 100%; max-width: 340px; margin: 10px auto; padding: 13px;
  font-size: 17px; font-weight: 600; border: none; border-radius: 12px; cursor: pointer;
  background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.35);
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--gold); color: #231a00; border-color: var(--gold); }
.divider { display: flex; align-items: center; gap: 10px; max-width: 340px; margin: 18px auto 4px; opacity: .75; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: rgba(255,255,255,.4); }
.joinRow { display: flex; gap: 8px; max-width: 340px; margin: 10px auto; }
.joinRow input { flex: 1; text-transform: uppercase; text-align: center; letter-spacing: 3px; font-weight: 700; }
.joinRow .btn { width: auto; margin: 0; flex: 1; }
.error { color: #ffb3b3; text-align: center; min-height: 20px; font-size: 14px; }
.roomPanel { max-width: 340px; margin: 14px auto; background: rgba(0,0,0,.25); border-radius: 14px; padding: 16px; text-align: center; }
.roomCode { font-size: 40px; font-weight: 800; letter-spacing: 8px; color: var(--gold); margin: 6px 0 10px; }
.roomPlayers { list-style: none; text-align: left; margin: 8px 0; }
.roomPlayers li { padding: 7px 10px; background: rgba(255,255,255,.1); border-radius: 8px; margin-bottom: 6px; font-size: 15px; }
.hint { font-size: 13px; opacity: .8; }

/* ---------- Game ---------- */
#gameScreen { display: flex; flex-direction: column; min-height: 100dvh; padding: 10px 10px 8px; }
.topbar { display: flex; align-items: center; gap: 8px; }
.roundInfo { font-weight: 700; font-size: 14px; background: rgba(0,0,0,.3); padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.statusText { flex: 1; text-align: center; font-size: 15px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.chipBtn { background: rgba(0,0,0,.3); color: #fff; border: 1px solid rgba(255,255,255,.3); padding: 6px 12px; border-radius: 999px; font-size: 14px; cursor: pointer; }

.table { position: relative; flex: 1; min-height: 300px; margin-top: 6px; }
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px; z-index: 2; }
.seat-top { top: 0; left: 50%; transform: translateX(-50%); }
.seat-left { left: 0; top: 38%; transform: translateY(-50%); }
.seat-right { right: 0; top: 38%; transform: translateY(-50%); }
.avatar {
  width: 46px; height: 46px; border-radius: 50%; background: #12406e; border: 2px solid rgba(255,255,255,.6);
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700;
}
.seat.active .avatar { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,197,66,.5), 0 0 18px rgba(245,197,66,.6); }
.seat .sname { font-size: 13px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.6); max-width: 90px; text-align: center; }
.seat .schip { font-size: 11.5px; background: rgba(0,0,0,.45); padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.seat .backs { display: flex; }
.seat .backs .miniBack { width: 14px; height: 20px; margin-left: -8px; }

.center { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); width: 220px; height: 170px; }
.trickArea { position: relative; width: 100%; height: 130px; }
.logLine { text-align: center; font-size: 12.5px; opacity: .9; min-height: 18px; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

.card {
  width: var(--card-w); height: var(--card-h); background: #fff; border-radius: 8px; color: #111;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); position: relative; user-select: none;
  display: flex; flex-direction: column; padding: 4px 6px; font-weight: 700;
}
.card .rank { font-size: 17px; line-height: 1; }
.card .suit { font-size: 16px; line-height: 1.1; }
.card .bigSuit { position: absolute; right: 5px; bottom: 2px; font-size: 24px; opacity: .9; }
.card.red { color: #d21f3c; }
.card.back {
  background: repeating-linear-gradient(45deg, #b3232f 0 6px, #8f1d27 6px 12px);
  border: 2px solid #fff;
}
.trickArea .card { position: absolute; transition: all .25s ease; }
.trickArea .pos0 { left: 83px; top: 48px; }   /* you */
.trickArea .pos1 { left: 8px; top: 22px; }    /* left */
.trickArea .pos2 { left: 83px; top: 0; }      /* top */
.trickArea .pos3 { left: 158px; top: 22px; }  /* right */
.trickArea .card.winning { box-shadow: 0 0 0 3px var(--gold), 0 4px 14px rgba(0,0,0,.4); }

.bidPanel { background: rgba(0,0,0,.35); border-radius: 14px; padding: 12px; margin: 4px 0 8px; }
.bidTitle { text-align: center; font-weight: 600; margin-bottom: 10px; font-size: 15px; }
.bidRow { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.bidRow button {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5);
  background: rgba(255,255,255,.12); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer;
}
.bidRow button:active { background: var(--gold); color: #231a00; }

.myArea { padding-top: 4px; }
.myInfo { text-align: center; font-size: 14px; font-weight: 600; margin-bottom: 6px; text-shadow: 0 1px 3px rgba(0,0,0,.5); }
.hand { display: flex; justify-content: center; align-items: flex-end; min-height: 96px; padding: 10px 2px 2px; }
.hand .card { margin-left: calc(var(--card-w) * -0.52); cursor: pointer; transition: transform .15s ease; }
.hand .card:first-child { margin-left: 0; }
.hand .card.playable { transform: translateY(-10px); box-shadow: 0 0 0 2px var(--gold), 0 6px 12px rgba(0,0,0,.4); }
.hand .card.dim { opacity: .55; }
.hand .card:not(.playable) { cursor: default; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modalCard { background: #10312a; border: 1px solid rgba(255,255,255,.25); border-radius: 16px; padding: 20px; width: 100%; max-width: 430px; max-height: 85dvh; overflow-y: auto; }
.modalCard h2 { text-align: center; margin-bottom: 12px; font-size: 22px; }
table.scores { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.scores th, table.scores td { padding: 6px 4px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.15); }
table.scores th { opacity: .85; font-weight: 600; }
table.scores td.me, table.scores th.me { color: var(--gold); font-weight: 700; }
.winnerLine { text-align: center; font-size: 17px; margin: 10px 0 2px; color: var(--gold); font-weight: 700; }
.modalBtns { margin-top: 14px; }
.modalBtns .btn { max-width: none; }

@media (min-width: 480px) {
  :root { --card-w: 60px; --card-h: 84px; }
  .center { width: 250px; }
  .trickArea .pos0 { left: 95px; } .trickArea .pos2 { left: 95px; } .trickArea .pos3 { left: 182px; }
}
