/* ═══════════════════════════════════════════════════════════
   PREFERANS ONLINE — Stylesheet
   Tamna tema, zeleni sto, karte sa senkom
════════════════════════════════════════════════════════════ */

:root {
  --green:       #2d6a4f;
  --green-light: #40916c;
  --green-dark:  #1b4332;
  --felt:        #1e6b45;
  --felt-dark:   #145232;
  --card-w:      68px;
  --card-h:      96px;
  --card-r:      8px;
  --red:         #c0392b;
  --gold:        #f0c040;
  --dark:        #1a1a2e;
  --panel-bg:    rgba(0,0,0,.55);
  --text:        #e8e8e8;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--dark);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ── SCREENS ─────────────────────────────────────────── */
.screen { display: none; width: 100vw; height: 100vh; }
.screen.active { display: block; }

/* ── AUTH ────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0d2137 0%, #030a0f 100%);
}

.auth-card {
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 380px;
  text-align: center;
}
.auth-logo { font-size: 3.5rem; line-height: 1; margin-bottom: .5rem; }
.auth-card h1 { font-size: 2rem; font-weight: 700; color: var(--gold); }
.auth-sub { color: #aaa; margin-bottom: 1.5rem; font-size: .9rem; }

.nav-auth { border-bottom: 1px solid rgba(255,255,255,.15); margin-bottom: 1.2rem; }
.nav-auth .nav-link { color: #aaa; border: none; cursor: pointer; background: none; padding: .5rem 1.2rem; }
.nav-auth .nav-link.active { color: var(--gold); border-bottom: 2px solid var(--gold); }

.auth-form input.form-control {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  border-radius: 8px;
}
.auth-form input::placeholder { color: #666; }
.auth-form input:focus { background: rgba(255,255,255,.12); border-color: var(--gold); box-shadow: none; color: #fff; }

/* ── NAVBAR ──────────────────────────────────────────── */
.navbar-game {
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

/* ── LOBBY ───────────────────────────────────────────── */
#screen-lobby { overflow-y: auto; }

.lobby-panel {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 1.5rem;
}
.lobby-panel h5 { color: var(--gold); margin-bottom: 1rem; }

.table-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
  margin-bottom: .5rem;
  border: 1px solid rgba(255,255,255,.07);
  transition: background .2s;
}
.table-row:hover { background: rgba(255,255,255,.08); }
.table-row .seats-info { color: #aaa; font-size: .85rem; }
.table-row .seat-pip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #555; margin: 0 2px; }
.table-row .seat-pip.filled { background: var(--green-light); }

/* ── WAITING ROOM ────────────────────────────────────── */
.waiting-room {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: radial-gradient(ellipse, #0d2137 0%, #030a0f 100%);
}
.waiting-card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 2.5rem;
  width: 480px;
  text-align: center;
}
.waiting-card h3 { color: var(--gold); margin-bottom: 1.5rem; }
.invite-code-box {
  background: rgba(0,0,0,.3);
  border-radius: 10px;
  padding: .8rem 1.5rem;
  margin-bottom: 1.5rem;
  font-size: .95rem;
  color: #ccc;
}
.invite-code {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--gold);
  font-family: monospace;
}
.seats-preview {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.seat-box {
  background: rgba(255,255,255,.05);
  border: 2px solid rgba(255,255,255,.15);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  min-width: 120px;
  font-size: .9rem;
}
.seat-box.filled { border-color: var(--green-light); }
.seat-box.mine   { border-color: var(--gold); }
.seat-box .seat-label { font-size: .7rem; color: #888; text-transform: uppercase; }
.seat-box .seat-player { font-weight: 600; margin-top: .3rem; }
.waiting-actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; }

/* ═══════════════════════════════════════════════════════
   GAME LAYOUT — CSS Grid
════════════════════════════════════════════════════════ */
.game-layout {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: 110px 1fr 110px 220px;
  grid-template-rows: 130px 1fr 130px 160px;
  grid-template-areas:
    "top-l    player-top    top-r    bula"
    "player-left  center  player-right bula"
    "bot-l   player-bot  bot-r    bula"
    "chat     hand-me    ui       bula";
  background: var(--felt);
  background-image:
    radial-gradient(ellipse 80% 80% at 50% 50%, var(--green-light) 0%, var(--felt-dark) 100%);
  position: relative;
}

/* ── PLAYER AREAS ────────────────────────────────────── */
.player-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .4rem;
  position: relative;
}
.player-top    { grid-area: player-top;   }
.player-left   { grid-area: player-left;  }
.player-right  { grid-area: player-right; }
.player-bottom { grid-area: player-bot; grid-column: 2; grid-row: 3 / 5; justify-content: flex-end; padding-bottom: .5rem; }

.player-name {
  font-size: .8rem;
  font-weight: 600;
  color: rgba(255,255,255,.85);
  background: rgba(0,0,0,.35);
  border-radius: 20px;
  padding: 2px 10px;
  margin-bottom: 4px;
  white-space: nowrap;
}
.player-name.active-turn {
  background: var(--gold);
  color: #000;
  animation: pulse-name .8s ease-in-out infinite alternate;
}
@keyframes pulse-name { from { transform: scale(1); } to { transform: scale(1.05); } }

.player-tricks {
  font-size: .75rem;
  color: rgba(255,255,255,.6);
  margin: 2px 0;
}

/* ── CENTER ──────────────────────────────────────────── */
.game-table-center {
  grid-area: center;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ── TRICK AREA ──────────────────────────────────────── */
.trick-area {
  position: relative;
  width: 220px;
  height: 180px;
}
.trick-slot {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
}
.trick-slot-top    { top: 0;   left: 50%; transform: translateX(-50%); }
.trick-slot-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.trick-slot-left   { left: 0;  top: 50%; transform: translateY(-50%); }
.trick-slot-right  { right: 0; top: 50%; transform: translateY(-50%); }

/* ── TALON AREA ──────────────────────────────────────── */
.talon-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}
.talon-label { font-size: .7rem; color: rgba(255,255,255,.6); margin-bottom: 4px; }
.talon-cards { display: flex; gap: 6px; justify-content: center; }

/* ── GAME STATUS ─────────────────────────────────────── */
.game-status {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,.6);
  color: #fff;
  font-size: .8rem;
  padding: 4px 14px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .3s;
}
.game-status.visible { opacity: 1; }

/* ── HANDS ───────────────────────────────────────────── */
.player-hand { display: flex; flex-direction: row; }
.player-hand-vertical { flex-direction: column; }

/* Bottom hand container */
#screen-game .player-bottom .player-hand {
  display: flex;
  flex-direction: row;
  justify-content: center;
  flex-wrap: nowrap;
  padding: 0 8px;
}

/* ═══════════════════════════════════════════════════════
   KARTE
════════════════════════════════════════════════════════ */
.card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: var(--card-r);
  background: #fff;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px 5px;
  cursor: default;
  user-select: none;
  transition: transform .15s, box-shadow .15s;
  position: relative;
  flex-shrink: 0;
}

/* Fan effect za ruku */
.player-hand .card { margin-left: -26px; }
.player-hand .card:first-child { margin-left: 0; }
.player-hand .card:hover { transform: translateY(-12px) scale(1.05); z-index: 10; box-shadow: 0 8px 20px rgba(0,0,0,.6); }

/* Vertikalne ruke */
.player-hand-vertical .card { margin-left: 0; margin-top: -60px; }
.player-hand-vertical .card:first-child { margin-top: 0; }

/* Selektovana karta */
.card.selected {
  transform: translateY(-18px) scale(1.08) !important;
  box-shadow: 0 0 0 3px var(--gold), 0 8px 20px rgba(0,0,0,.6) !important;
  z-index: 20;
}

/* Karta koja se može igrati */
.card.playable { cursor: pointer; }
.card.playable:hover { transform: translateY(-16px) scale(1.07); }

/* Karta na stolu (štih) */
.trick-slot .card { cursor: default !important; }
.trick-slot .card:hover { transform: none; }

/* Lice karte */
.card-rank-top, .card-rank-bot { font-size: .75rem; font-weight: 700; line-height: 1; }
.card-suit-top, .card-suit-bot { font-size: .75rem; line-height: 1; }
.card-rank-bot, .card-suit-bot { align-self: flex-end; transform: rotate(180deg); }
.card-center { font-size: 2rem; text-align: center; line-height: 1; }

.card.red .card-rank-top, .card.red .card-rank-bot,
.card.red .card-suit-top,  .card.red .card-suit-bot,
.card.red .card-center { color: var(--red); }

/* Naličje karte */
.card.back {
  background: repeating-linear-gradient(
    45deg, #1a237e 0px, #1a237e 4px, #283593 4px, #283593 8px
  );
  border-color: #0d1b6e;
  cursor: default;
}
.card.back::after {
  content: '🃏';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  font-size: 1.6rem;
  opacity: .3;
}

/* ── UI PANEL ────────────────────────────────────────── */
.ui-panel {
  grid-column: 3;
  grid-row: 4;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  border-radius: 14px 14px 0 0;
  border: 1px solid rgba(255,255,255,.1);
  padding: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phase-panel { width: 100%; }
.panel-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: .6rem;
  text-align: center;
}

/* Bid buttons */
.bid-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.btn-bid {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  border-radius: 8px;
  padding: .45rem .3rem;
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s;
}
.btn-bid:hover:not(:disabled)  { background: rgba(255,255,255,.18); }
.btn-bid:disabled { opacity: .35; cursor: default; }
.btn-bid[data-suit="H"], .btn-bid[data-suit="D"] { color: #ff8080; }

.igra-toggle { display: flex; align-items: center; gap: 6px; font-size: .8rem; cursor: pointer; }
.igra-toggle input { cursor: pointer; }

.follow-info {
  background: rgba(255,255,255,.06);
  border-radius: 8px;
  padding: .5rem;
  font-size: .85rem;
  text-align: center;
}

.talon-selected-cards { display: flex; gap: 6px; justify-content: center; min-height: 30px; }

/* Waiting dots */
.waiting-dots { display: flex; gap: 6px; justify-content: center; }
.waiting-dots span {
  width: 8px; height: 8px;
  background: var(--gold);
  border-radius: 50%;
  animation: bounce .9s ease-in-out infinite;
}
.waiting-dots span:nth-child(2) { animation-delay: .15s; }
.waiting-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

/* ── BULA SIDEBAR ────────────────────────────────────── */
.bula-sidebar {
  grid-area: bula;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(8px);
  border-left: 1px solid rgba(255,255,255,.1);
  padding: .8rem .6rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.bula-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold);
  margin-bottom: .6rem;
  text-align: center;
}
.bula-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  flex: 1;
}
.bula-table th {
  text-align: center;
  padding: 3px 2px;
  border-bottom: 2px solid rgba(255,255,255,.2);
  color: var(--gold);
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 60px;
}
.bula-table td {
  text-align: center;
  padding: 2px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  color: #ccc;
}
.bula-table tfoot td {
  font-weight: 700;
  color: #fff;
  border-top: 2px solid rgba(255,255,255,.2);
  font-size: .85rem;
}
.bula-row-new { animation: bula-flash .6s ease; }
@keyframes bula-flash { from { background: rgba(240,192,64,.3); } to { background: transparent; } }

.supa-mark { color: var(--red); font-weight: 700; }
.refe-mark { color: var(--gold); font-style: italic; font-size: .72rem; }

/* ── CHAT ────────────────────────────────────────────── */
.chat-panel {
  grid-area: chat;
  grid-column: 1;
  grid-row: 4;
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  border-radius: 14px 14px 0 0;
  border: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  padding: .5rem;
  overflow: hidden;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  font-size: .72rem;
  padding-right: 2px;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }
.chat-msg { margin-bottom: 3px; }
.chat-msg .chat-user { font-weight: 600; color: var(--gold); }
.chat-msg.system { color: #88a; font-style: italic; }
.chat-input { display: flex; gap: 4px; margin-top: 4px; }
.chat-input input {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  font-size: .75rem;
  border-radius: 6px;
}
.chat-input input:focus { background: rgba(255,255,255,.12); border-color: var(--gold); box-shadow: none; color: #fff; outline: none; }

/* ── HAND (my bottom hand) ───────────────────────────── */
.player-bottom {
  grid-area: hand-me;
  grid-column: 2;
  grid-row: 4;
  background: rgba(0,0,0,.25);
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .4rem 0;
}

/* ── TOAST ───────────────────────────────────────────── */
.toast {
  background: rgba(30,30,50,.95);
  color: #fff;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px;
}
.toast.toast-success { border-color: var(--green-light); }
.toast.toast-error   { border-color: #c0392b; }
.toast.toast-info    { border-color: var(--gold); }

/* ── MODAL ───────────────────────────────────────────── */
.gameover-icon { font-size: 4rem; margin-bottom: .5rem; }
#modal-round-body .result-row {
  display: flex;
  justify-content: space-between;
  padding: .3rem 0;
  border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: .9rem;
}
.result-good { color: #7cfc00; }
.result-bad  { color: #ff6b6b; }
.result-neutral { color: #aaa; }

/* ── MISC ────────────────────────────────────────────── */
.contract-badge {
  display: inline-block;
  background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: .78rem;
  margin-top: 2px;
}
.badge-suit-H, .badge-suit-D { color: #ff8080; }
.badge-suit-S, .badge-suit-C { color: #ddd; }

/* Scrollbar global */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

/* Responsive: manji ekrani */
@media (max-width: 900px) {
  :root { --card-w: 52px; --card-h: 74px; }
  .bula-sidebar { display: none; }
  .game-layout { grid-template-columns: 90px 1fr 90px; }
}
