/* ── CSS variables ───────────────────────────────────────────────── */
:root { --card-w: 80px; }

/* ── Reset & Base ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #1a472a;
  color: #f0e6d3;
  min-height: 100vh;
  overflow-x: hidden;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }

input[type="text"], input[type="number"] {
  border: 2px solid #4a7c59;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 15px;
  background: #0f2d1a;
  color: #f0e6d3;
  outline: none;
}
input[type="text"]:focus, input[type="number"]:focus {
  border-color: #7ec8a0;
}

/* ── Join Screen ────────────────────────────────────────────────── */
#join-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.join-box {
  background: #0f2d1a;
  border: 2px solid #4a7c59;
  border-radius: 16px;
  padding: 40px;
  min-width: 340px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.join-box h1 {
  font-size: 2.2rem;
  color: #f5d76e;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.subtitle {
  color: #7ec8a0;
  font-size: 0.9rem;
  margin-bottom: 28px;
  letter-spacing: 1px;
}

.join-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}
.join-form input { flex: 1; }
.join-form button {
  background: #f5d76e;
  color: #1a2e0a;
}
.join-form button:hover { background: #f7e28a; }

#player-list-section h3 { color: #7ec8a0; margin-bottom: 10px; }
#player-list {
  list-style: none;
  margin-bottom: 16px;
}
#player-list li {
  padding: 6px 0;
  border-bottom: 1px solid #2a4f35;
  color: #f0e6d3;
}
#player-list li:last-child { border-bottom: none; }

.lobby-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

#add-bot-btn {
  background: #3a6ea8;
  color: #fff;
  padding: 10px 20px;
  font-size: 15px;
}
#add-bot-btn:hover { background: #4d84c4; }

#start-btn {
  background: #4caf76;
  color: #fff;
  padding: 10px 28px;
  font-size: 16px;
}
#start-btn:hover { background: #5dce8a; }

.bot-badge {
  font-size: 11px;
  background: #3a6ea8;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  font-weight: 700;
}

.error-msg { color: #ff6b6b; margin-top: 10px; font-size: 14px; }

/* ── Game Screen ─────────────────────────────────────────────────── */
#game-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 0 12px 0;
}

.game-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #0f2d1a;
  border-bottom: 2px solid #2a4f35;
  padding: 10px 20px;
  flex-wrap: wrap;
}

.game-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #f5d76e;
  letter-spacing: 1px;
  margin-right: auto;
}

#round-info { color: #7ec8a0; font-size: 14px; }
#trump-info { font-size: 14px; display: flex; align-items: center; gap: 6px; }

#reset-btn {
  background: #8b1a1a;
  color: #fff;
  padding: 6px 14px;
  font-size: 13px;
}
#reset-btn:hover { background: #b22222; }

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.zoom-controls button {
  background: #2a4f35;
  color: #f0e6d3;
  border: 1px solid #4a7c59;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  border-radius: 6px;
}
.zoom-controls button:hover { background: #3a6a49; }
.zoom-controls button:disabled { opacity: 0.35; cursor: default; transform: none; }

/* ── Other Players ───────────────────────────────────────────────── */
#other-players {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: #163a22;
  border-bottom: 1px solid #2a4f35;
  min-height: 80px;
  align-items: flex-start;
}

.other-player {
  background: #0f2d1a;
  border: 1px solid #2a4f35;
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.other-player.disconnected { opacity: 0.5; }
.other-player .op-name { font-weight: 700; color: #f5d76e; font-size: 14px; }
.other-player .op-stats { font-size: 12px; color: #aaa; }
.other-player .op-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}
.other-player .op-played { margin-top: 6px; }
.other-player .op-played .card { transform: scale(0.8); transform-origin: left; }

/* ── Table / Current Plays ───────────────────────────────────────── */
#table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 16px;
  min-height: 160px;
}

#current-plays {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  min-height: 100px;
}

#last-winner {
  font-size: 14px;
  color: #7ec8a0;
  min-height: 20px;
  text-align: center;
}

/* ── My Area ─────────────────────────────────────────────────────── */
#my-area {
  background: #0f2d1a;
  border-top: 2px solid #2a4f35;
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#my-info {
  font-size: 13px;
  color: #aaa;
}

#my-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

#announce-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
#announce-area label { font-size: 14px; color: #f0e6d3; display: flex; align-items: center; gap: 8px; }
#announce-input { width: 60px; text-align: center; }
#announce-btn {
  background: #f5d76e;
  color: #1a2e0a;
  padding: 7px 18px;
}
#announce-btn:hover { background: #f7e28a; }

#status-msg {
  font-size: 14px;
  color: #7ec8a0;
  min-height: 20px;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  width: var(--card-w);
  height: calc(var(--card-w) * 1.5);
  border-radius: calc(var(--card-w) * 0.1);
  border: 2px solid #555;
  background: #fff;
  color: #222;
  position: relative;
  font-weight: 700;
  user-select: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

/* Top-left corner label */
.card .card-tl {
  position: absolute;
  top: calc(var(--card-w) * 0.06);
  left: calc(var(--card-w) * 0.09);
  font-size: calc(var(--card-w) * 0.163);
  line-height: 1.2;
  text-align: center;
}

/* Bottom-right corner label (mirrored) */
.card .card-br {
  position: absolute;
  bottom: calc(var(--card-w) * 0.06);
  right: calc(var(--card-w) * 0.09);
  font-size: calc(var(--card-w) * 0.163);
  line-height: 1.2;
  text-align: center;
  transform: rotate(180deg);
}

/* Large suit symbol centered on the card */
.card .card-suit-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w) * 0.45);
  pointer-events: none;
}

.card.red { color: #cc0000; }
.card.black { color: #111; }

/* Back of card (hidden) */
.card.card-back {
  background: repeating-linear-gradient(
    45deg,
    #2a4f7a,
    #2a4f7a 4px,
    #1e3a5f 4px,
    #1e3a5f 8px
  );
  border-color: #2a4f7a;
  color: transparent;
}

/* Valid (can play) */
.card.valid {
  border-color: #4caf50;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.6), 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer;
}
.card.valid:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 18px rgba(76, 175, 80, 0.7), 0 2px 6px rgba(0,0,0,0.4);
}

/* Invalid (can't play now) */
.card.invalid {
  opacity: 0.45;
  cursor: default;
}

/* Not your turn */
.card.inactive {
  opacity: 0.7;
  cursor: default;
}

/* Winning card during the trick display window */
.card.winning-card {
  border-color: #f5d76e;
  box-shadow: 0 0 18px rgba(245, 215, 110, 0.85), 0 2px 6px rgba(0,0,0,0.4);
  transform: translateY(-8px);
  z-index: 1;
}

/* Trump card display */
.trump-card {
  display: inline-flex;
}
.trump-card .card {
  transform: scale(0.75);
  transform-origin: left center;
}

/* Mini back card (for other players' hand) */
.card-mini-back {
  width: calc(var(--card-w) * 0.225);
  height: calc(var(--card-w) * 0.325);
  border-radius: calc(var(--card-w) * 0.04);
  background: repeating-linear-gradient(
    45deg,
    #2a4f7a,
    #2a4f7a 2px,
    #1e3a5f 2px,
    #1e3a5f 4px
  );
  border: 1px solid #2a4f7a;
  display: inline-block;
}

/* ── Overlay ─────────────────────────────────────────────────────── */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#overlay-content {
  background: #0f2d1a;
  border: 2px solid #4a7c59;
  border-radius: 16px;
  padding: 36px 44px;
  min-width: 340px;
  max-width: 520px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
#overlay-content h2 {
  color: #f5d76e;
  font-size: 1.5rem;
  margin-bottom: 20px;
}

/* Score table */
.score-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 14px;
}
.score-table th {
  color: #7ec8a0;
  border-bottom: 1px solid #2a4f35;
  padding: 6px 10px;
  text-align: right;
}
.score-table th:first-child { text-align: left; }
.score-table td {
  padding: 8px 10px;
  text-align: right;
  border-bottom: 1px solid #1a3a25;
}
.score-table td:first-child { text-align: left; font-weight: 600; }
.score-table tr.winner td { color: #f5d76e; }
.score-plus { color: #4caf76; }
.score-minus { color: #ff6b6b; }

.overlay-btn {
  background: #4caf76;
  color: #fff;
  padding: 11px 30px;
  font-size: 15px;
  margin-top: 8px;
}
.overlay-btn:hover { background: #5dce8a; }

.dealer-badge {
  font-size: 11px;
  background: #f5d76e;
  color: #1a2e0a;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  font-weight: 700;
}

.current-turn-badge {
  font-size: 11px;
  background: #4caf76;
  color: #fff;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
}

.play-label {
  font-size: 11px;
  color: #aaa;
  text-align: center;
  margin-top: 2px;
}

.play-entry {
  display: flex;
  flex-direction: column;
  align-items: center;
}
