/* ==================== RESET & BASE ==================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
}

a { color: #64b5f6; }

/* ==================== LOGIN ==================== */
.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-container {
  background: #16213e;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  text-align: center;
  width: 380px;
  max-width: 90vw;
}

.login-container h1 {
  font-size: 2rem;
  margin-bottom: 8px;
  color: #e94560;
}

.subtitle {
  color: #aaa;
  margin-bottom: 24px;
}

.login-step label {
  display: block;
  text-align: left;
  margin-bottom: 6px;
  color: #ccc;
  font-size: 0.9rem;
}

.login-step input {
  width: 100%;
  padding: 12px;
  border: 2px solid #2a2a4a;
  border-radius: 8px;
  background: #0f0f23;
  color: #fff;
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.login-step input:focus {
  border-color: #e94560;
}

.login-step button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #e94560;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.login-step button:hover:not(:disabled) {
  background: #c73050;
}

.login-step button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error {
  color: #ff6b6b;
  margin-top: 12px;
  font-size: 0.9rem;
}

.hint {
  color: #888;
  font-size: 0.85rem;
  margin-top: 8px;
}

/* ==================== HEADER ==================== */
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #16213e;
  border-bottom: 1px solid #2a2a4a;
}

.header-left {
  font-size: 1.1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#user-name {
  color: #64b5f6;
}

/* ==================== BUTTONS ==================== */
.btn-primary {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: #e94560;
  color: #fff;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover { background: #c73050; }

.btn-secondary {
  padding: 10px 24px;
  border: 2px solid #555;
  border-radius: 8px;
  background: transparent;
  color: #ccc;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: #888;
  color: #fff;
}

.btn-small {
  padding: 6px 14px;
  border: 1px solid #555;
  border-radius: 6px;
  background: transparent;
  color: #ccc;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-small:hover { border-color: #aaa; color: #fff; }

.btn-leave-game {
  margin-left: auto;
  border-color: #c73050;
  color: #e94560;
}
.btn-leave-game:hover { background: #e94560; color: #fff; border-color: #e94560; }

.abort-text {
  color: #ff9800;
  font-size: 1rem;
  margin-bottom: 8px;
}

/* ==================== LOBBY ==================== */
.lobby-container {
  max-width: 700px;
  margin: 30px auto;
  padding: 0 20px;
}

.lobby-container h2 {
  margin-bottom: 20px;
  color: #e94560;
}

.user-stats {
  margin-bottom: 20px;
}

.stats-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.stat-item {
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  padding: 12px 20px;
  text-align: center;
  flex: 1;
  min-width: 100px;
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffd700;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: #aaa;
  margin-top: 2px;
}

.lobby-container h3 {
  margin: 20px 0 10px;
  color: #ccc;
}

.lobby-actions {
  margin-bottom: 20px;
}

.room-panel {
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.room-panel h3 {
  margin: 0 0 12px;
  color: #64b5f6;
}

.room-player {
  padding: 6px 12px;
  background: #0f0f23;
  border-radius: 6px;
  margin: 4px 0;
  display: inline-block;
  margin-right: 8px;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 10px;
  padding: 14px 18px;
  transition: border-color 0.2s;
}

.room-card:hover { border-color: #555; }

.room-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.room-id {
  font-weight: 600;
  color: #64b5f6;
}

.room-players-count {
  font-size: 0.85rem;
  color: #aaa;
}

.room-player-names {
  color: #ccc;
  font-size: 0.9rem;
  flex: 1;
  margin: 0 20px;
}

.btn-join {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}

.btn-join:hover { background: #c73050; border-color: #c73050; }

/* ==================== GAME VIEW ==================== */
.game-container {
  display: grid;
  grid-template-columns: 1fr 220px;
  grid-template-rows: auto 1fr;
  gap: 0;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.game-info-bar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 30px;
  padding: 10px 20px;
  background: #0f0f23;
  border-bottom: 1px solid #2a2a4a;
  font-size: 0.95rem;
}

.game-info-bar span {
  color: #aaa;
}

#game-turn {
  color: #4caf50;
  font-weight: 600;
}

.game-table {
  position: relative;
  background: #1b5e20;
  background-image: radial-gradient(ellipse at center, #2e7d32 0%, #1b5e20 60%, #0d3d12 100%);
  border-radius: 0;
  overflow: hidden;
}

/* ==================== PLAYER AREAS ==================== */
.player-area {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.player-top {
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.player-left {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.player-right {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.player-bottom {
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 95%;
}

.player-label {
  background: rgba(0,0,0,0.5);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.player-label.active-player {
  background: #e94560;
  color: #fff;
  font-weight: 600;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(233,69,96,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(233,69,96,0); }
}

.player-score {
  font-size: 0.8rem;
  color: #ffd700;
  background: rgba(0,0,0,0.4);
  padding: 2px 8px;
  border-radius: 8px;
}

.player-cards {
  display: flex;
  gap: -15px;
}

.player-cards .card {
  width: 30px;
  height: 44px;
  margin: 0 -8px;
}

/* ==================== CARDS ==================== */
.card {
  width: 65px;
  height: 95px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid #ccc;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: default;
  font-size: 14px;
  box-shadow: 2px 2px 6px rgba(0,0,0,0.3);
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  user-select: none;
  flex-shrink: 0;
}

.card.red { color: #d32f2f; }
.card.black { color: #212121; }

.card-back {
  background: linear-gradient(135deg, #1565c0 0%, #0d47a1 50%, #1565c0 100%);
  border-color: #0d47a1;
  position: relative;
  overflow: hidden;
}

.card-back::after {
  content: '🂠';
  font-size: 22px;
  color: rgba(255,255,255,0.3);
}

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.top-left {
  top: 4px;
  left: 5px;
}

.card-corner.bottom-right {
  bottom: 4px;
  right: 5px;
  transform: rotate(180deg);
}

.card-value {
  font-weight: 700;
  font-size: 0.85rem;
}

.card-suit-small {
  font-size: 0.7rem;
}

.card-center-suit {
  font-size: 1.8rem;
  line-height: 1;
}

/* Player hand */
.player-hand {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0;
  padding: 0 20px;
}

.player-hand .card {
  margin: 0 -5px;
  transition: transform 0.15s, box-shadow 0.15s, margin-top 0.15s;
}

.player-hand .card.playable {
  cursor: pointer;
  border-color: #4caf50;
  box-shadow: 0 0 8px rgba(76,175,80,0.5);
}

.player-hand .card.playable:hover {
  transform: translateY(-15px);
  box-shadow: 0 4px 16px rgba(76,175,80,0.7);
  z-index: 10;
}

.player-hand .card.disabled {
  opacity: 0.6;
}

/* Mini cards (center area) */
.mini-card {
  width: 55px;
  height: 80px;
}

/* ==================== CENTER AREA ==================== */
.center-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 200px;
  min-height: 120px;
}

.center-msg {
  background: rgba(0,0,0,0.6);
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 1.1rem;
  white-space: nowrap;
}

.center-label {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: #ccc;
  white-space: nowrap;
}

/* Trick cards positioned around center */
.trick-area {
  position: relative;
  width: 200px;
  height: 180px;
}

.trick-card {
  position: absolute;
}

.trick-card.trick-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }
.trick-card.trick-top { top: 0; left: 50%; transform: translateX(-50%); }
.trick-card.trick-left { left: 0; top: 50%; transform: translateY(-50%); }
.trick-card.trick-right { right: 0; top: 50%; transform: translateY(-50%); }

/* ==================== PASS BUTTON ==================== */
#pass-container {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
}

/* ==================== SCOREBOARD ==================== */
.scoreboard {
  background: #16213e;
  padding: 16px;
  overflow-y: auto;
  border-left: 1px solid #2a2a4a;
}

.scoreboard h3 {
  color: #e94560;
  margin-bottom: 12px;
  font-size: 1rem;
}

#score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#score-table th {
  text-align: left;
  padding: 6px 4px;
  color: #aaa;
  border-bottom: 1px solid #2a2a4a;
  font-size: 0.75rem;
}

#score-table td {
  padding: 6px 4px;
  border-bottom: 1px solid #1a1a2e;
}

.my-row {
  background: rgba(233,69,96,0.1);
}

/* Round history */
.round-history {
  background: #16213e;
  padding: 16px;
  overflow-y: auto;
  border-left: 1px solid #2a2a4a;
  border-top: 1px solid #2a2a4a;
  max-height: 200px;
}

.round-history h3 {
  color: #64b5f6;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.history-row {
  font-size: 0.8rem;
  padding: 4px 0;
  border-bottom: 1px solid #1a1a2e;
  color: #bbb;
}

/* ==================== OVERLAYS ==================== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.overlay-content {
  background: #16213e;
  border: 1px solid #2a2a4a;
  border-radius: 16px;
  padding: 30px 40px;
  max-width: 500px;
  width: 90vw;
  text-align: center;
  max-height: 90vh;
  overflow-y: auto;
}

.overlay-content h2 {
  color: #e94560;
  margin-bottom: 16px;
}

.overlay-content p {
  color: #ccc;
  margin-bottom: 16px;
}

/* ==================== GAME CHOICES ==================== */
.game-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.game-choice-btn {
  width: 100%;
  padding: 14px 18px;
  border: 2px solid #2a2a4a;
  border-radius: 10px;
  background: #0f0f23;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}

.game-choice-btn:hover {
  border-color: #e94560;
  background: #1a1a3e;
}

.game-choice-name {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 2px;
}

.game-choice-desc {
  font-size: 0.85rem;
  color: #aaa;
}

/* ==================== SCORE TABLE OVERLAY ==================== */
.score-table-overlay {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

.score-table-overlay th,
.score-table-overlay td {
  padding: 8px 12px;
  border-bottom: 1px solid #2a2a4a;
  text-align: left;
}

.score-table-overlay th {
  color: #aaa;
  font-size: 0.85rem;
}

.winner-text {
  font-size: 1.2rem;
  margin-bottom: 16px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  .game-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .scoreboard, .round-history {
    border-left: none;
    border-top: 1px solid #2a2a4a;
    max-height: 150px;
  }

  .card {
    width: 50px;
    height: 72px;
  }

  .card-center-suit { font-size: 1.3rem; }
  .card-value { font-size: 0.75rem; }

  .player-hand .card {
    margin: 0 -8px;
  }

  .mini-card {
    width: 42px;
    height: 60px;
  }
}
