/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a1628;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Language switcher */
#lang-switch {
  background: rgba(10, 22, 40, 0.9);
  border-radius: 8px;
  padding: 4px;
}

.lang-btn {
  padding: 4px 10px;
  border: 1px solid #2a3a4a;
  background: #12223a;
  color: #8899aa;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
}

.lang-btn.active {
  background: #4a9eff;
  color: #fff;
  border-color: #4a9eff;
}

.lang-btn:hover:not(.active) {
  background: #1e3050;
  color: #ccc;
}

.screen { display: none; width: 100%; min-height: 100vh; }
.screen.active { display: flex; }

/* ===== LOBBY ===== */
#lobby {
  justify-content: center;
  align-items: center;
}

.lobby-container {
  text-align: center;
  padding: 2rem;
}

.lobby-container h1 {
  font-size: 3rem;
  color: #fff;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: #8899aa;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

#lobby form, #join-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  width: 300px;
}

#join-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  width: 320px;
}

input[type="text"] {
  padding: 0.75rem 1rem;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
  background: #12223a;
  color: #fff;
  font-size: 1rem;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  border-color: #4a9eff;
}

.separator {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: #445566;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.separator::before, .separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #223344;
}

.error {
  color: #ff6b6b;
  margin-top: 1rem;
  font-size: 0.9rem;
  min-height: 1.2rem;
}

/* ===== BUTTONS ===== */
.btn-primary {
  padding: 0.75rem 2rem;
  background: #4a9eff;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  width: 100%;
  font-weight: 600;
}

.btn-primary:hover { background: #3a8eef; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  padding: 0.75rem 2rem;
  background: #2a3a4a;
  color: #ccc;
  border: 1px solid #3a4a5a;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.btn-secondary:hover { background: #3a4a5a; }

.btn-start {
  padding: 1rem 2rem;
  background: #22c55e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s, transform 0.1s;
}

.btn-start:hover { background: #16a34a; }
.btn-start:active { transform: scale(0.98); }

/* ===== GAME ===== */
#game.active {
  display: flex;
  flex-direction: column;
}

.game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 0.5rem;
}

/* Middle row: table + side panel side by side */
.middle-row {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0.5rem;
}

.table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

/* Trump side panel */
.trump-side-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 80px;
  padding: 0.5rem;
}

.trump-side-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8899aa;
}

.trump-side-card {
  width: 60px;
  height: 84px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  position: relative;
  border: 2px solid #2a4a6a;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  /* Tilted to match the classic trump card look */
  transform: rotate(-15deg);
  background: linear-gradient(135deg, #12223a, #1a2a3a);
}

.trump-side-card .rank-top {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.55rem;
  line-height: 1;
}

.trump-side-card .rank {
  font-size: 1rem;
  line-height: 1;
}

.trump-side-card .suit-small {
  font-size: 0.85rem;
  line-height: 1;
}

.trump-side-card .rank-bottom {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 0.55rem;
  transform: rotate(180deg);
  line-height: 1;
}

.trump-side-card.red {
  color: #ef4444;
  border-color: #ef444444;
}

.trump-side-card.black {
  color: #aaa;
  border-color: #333;
}

/* Top bar */
.top-bar {
  padding: 0.5rem 1rem;
  display: flex;
  justify-content: center;
}

.opponent-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #12223a;
  padding: 0.5rem 1.5rem;
  border-radius: 12px;
  border: 1px solid #1a2a3a;
}

.opponent-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.hand-count {
  background: #1e3050;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #8899aa;
}

#table-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  max-width: 100%;
  padding: 0.5rem;
  min-height: 140px;
}

.message-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

#game-message {
  font-size: 1rem;
  color: #8899aa;
  text-align: center;
  min-height: 1.4rem;
}

/* Action buttons */
#action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-action {
  padding: 0.6rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s, transform 0.1s;
}

.btn-action:active { transform: scale(0.97); }

.btn-take {
  background: #ef4444;
  color: #fff;
}

.btn-take:hover { background: #dc2626; }

.btn-pass {
  background: #f59e0b;
  color: #000;
}

.btn-pass:hover { background: #d97706; }

.btn-play {
  background: #22c55e;
  color: #fff;
}

.btn-play:hover { background: #16a34a; }

/* Bottom info */
.bottom-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  padding: 0.5rem;
}

.deck-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #12223a;
  padding: 0.4rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #8899aa;
}

.deck-count {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

.trump-display {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: #8899aa;
}

.trump-suit {
  font-size: 1.4rem;
}

.trump-suit.red { color: #ef4444; }
.trump-suit.black { color: #888; }

/* Player hand */
.player-area {
  padding: 0.5rem 0 1rem;
  text-align: center;
}

.player-name {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #8899aa;
}

.player-name-text { font-weight: 600; color: #fff; }

.attacker-badge, .defender-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
}

.attacker-badge {
  background: #ef4444;
  color: #fff;
}

.defender-badge {
  background: #3b82f6;
  color: #fff;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  min-height: 130px;
}

/* ===== CARDS ===== */
.card {
  width: 70px;
  height: 100px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, margin-top 0.15s;
  position: relative;
  user-select: none;
  border: 2px solid transparent;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  z-index: 10;
}

.card.selected {
  transform: translateY(-12px);
  border-color: #4a9eff;
  box-shadow: 0 0 12px rgba(74,158,255,0.5);
  z-index: 20;
}

.card.playable {
  border-color: #22c55e44;
}

.card.playable:hover {
  border-color: #22c55e;
}

.card.red { color: #ef4444; }
.card.black { color: #ccc; }

.card .rank { font-size: 1.2rem; line-height: 1; }
.card .suit-small { font-size: 1rem; line-height: 1; }

.card .rank-top {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 0.7rem;
}

.card .rank-bottom {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 0.7rem;
  transform: rotate(180deg);
}

/* Table pair */
.table-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  width: 80px;
  height: 120px;
}

.table-pair .card {
  position: absolute;
  width: 65px;
  height: 92px;
  font-size: 0.85rem;
  cursor: default;
}

.table-pair .card:hover { transform: none; }
.table-pair .card.selected { transform: none; border-color: #4a9eff; }

.table-pair .card.attack-card {
  top: 0;
  left: 0;
  z-index: 1;
}

.table-pair .card.defend-card {
  top: 15px;
  left: 15px;
  z-index: 2;
}

/* Back of card (opponent hand) */
.card-back {
  width: 45px;
  height: 64px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1e3a5f, #2a4a6a);
  border: 2px solid #2a4a6a;
  display: inline-block;
  transition: transform 0.15s;
}

.card-back:hover { transform: translateY(-3px); }

/* ===== WIN SCREEN ===== */
#win-screen {
  justify-content: center;
  align-items: center;
}

#win-screen h1 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

#win-message {
  color: #8899aa;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.win-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 300px;
}

.win-buttons button { width: 100%; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .card {
    width: 55px;
    height: 80px;
  }

  .card .rank { font-size: 1rem; }
  .card .suit-small { font-size: 0.85rem; }

  .table-pair .card {
    width: 55px;
    height: 78px;
    font-size: 0.75rem;
  }

  .lobby-container h1 { font-size: 2rem; }
}

.hidden { display: none !important; }
