:root {
  --felt: #0b5c34;
  --felt-dark: #084027;
  --gold: #d4af37;
  --panel: #ffffffee;
  --text: #1a1a1a;
  --red: #c62828;
  --black: #1a1a1a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  /* Empêche le menu natif "Copier / Rechercher / Définir" au tap-maintenu sur
     mobile (surtout iOS) quand on appuie sur une carte (ex: "K", "J"). */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

input, textarea {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.hidden { display: none !important; }

.card-panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
  text-align: center;
}

.card-panel h1 { margin-top: 0; }

label { display: block; text-align: left; font-size: 13px; color: #555; margin: 10px 0 4px; }

input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}

button {
  background: var(--felt);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 15px;
  cursor: pointer;
  margin-top: 12px;
  width: 100%;
  transition: background 0.15s;
}
button:hover:not(:disabled) { background: var(--felt-dark); }
button:disabled { background: #aaa; cursor: not-allowed; }

.closed-banner {
  background: #fde3e3;
  color: #7a1f1f;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0;
}
.home-actions { margin-top: 18px; }
.or { margin: 14px 0 8px; color: #999; font-size: 13px; }
.error { color: var(--red); font-size: 14px; min-height: 18px; margin-top: 10px; }

.link-row { display: flex; gap: 8px; margin: 10px 0 20px; }
.link-row input { flex: 1; }
.link-row button { width: auto; margin: 0; }

.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.seat-slot {
  border: 2px dashed #ccc;
  border-radius: 10px;
  padding: 12px;
  font-size: 14px;
}
.seat-slot.filled { border-style: solid; border-color: var(--felt); background: #f0f8f4; }
.seat-slot .name { font-weight: 600; }
.seat-slot .disconnected { color: var(--red); font-size: 12px; }
.seat-slot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn-add-bot, .btn-remove-bot { width: auto; margin: 0; padding: 6px 10px; font-size: 12px; }
.btn-add-bot { background: #567; }
.btn-remove-bot { background: var(--red); }
.add-bot-form { display: flex; gap: 6px; width: 100%; }
.add-bot-form input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 12px; border: 1px solid #ccc; border-radius: 6px; }
.add-bot-form button { width: auto; margin: 0; padding: 6px 10px; font-size: 12px; background: #567; }

/* --- Game screen --- */
#screen-game { flex-direction: column; padding: 10px; min-height: 100vh; justify-content: flex-start; }

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  padding: 6px 16px;
  font-size: 14px;
}
#score-board { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-leave { background: rgba(198,40,40,0.85); }
.btn-leave:hover { background: var(--red); }
#btn-leave-game { width: auto; margin: 0; padding: 8px 14px; font-size: 12px; flex-shrink: 0; }
#btn-leave-lobby { background: #999; }
#btn-leave-lobby:hover { background: var(--red); }
.capot-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.25);
  padding: 6px 12px 6px 6px;
  border-radius: 20px;
  font-size: 12px;
  text-align: left;
  line-height: 1.4;
}
.capot-tile.me { background: rgba(212,175,55,0.35); }
.capot-tile b { font-size: 15px; }
#trump-indicator { font-size: 18px; font-weight: 600; background: rgba(0,0,0,0.25); padding: 6px 12px; border-radius: 8px; }
#manche-indicator { text-align: center; color: white; font-size: 13px; opacity: 0.85; padding: 2px 0 6px; }
.trick-caption {
  text-align: center;
  color: #1a1a1a;
  background: var(--gold);
  font-weight: 700;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 20px;
  max-width: 340px;
  margin: 0 auto 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  animation: captionPop 0.25s ease-out;
}
@keyframes captionPop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.table {
  position: relative;
  flex: 1;
  min-height: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 48px auto;
  max-width: 620px;
  width: calc(100% - 70px);
  border-radius: 50%;
  background:
    repeating-linear-gradient(98deg, rgba(255,255,255,0.35) 0px, rgba(255,255,255,0.35) 1px, transparent 1px, transparent 5px),
    repeating-linear-gradient(98deg, rgba(120,90,55,0.12) 0px, rgba(120,90,55,0.12) 2px, transparent 2px, transparent 16px),
    repeating-linear-gradient(98deg, rgba(90,65,35,0.07) 0px, rgba(90,65,35,0.07) 1px, transparent 1px, transparent 34px),
    linear-gradient(98deg, #e8dbc0 0%, #ddcaa1 20%, #eaded0 42%, #d8c49a 60%, #e9dcc2 80%, #dcc9a3 100%);
  box-shadow: inset 0 0 50px rgba(90,60,25,0.35), inset 0 0 0 8px rgba(120,85,45,0.25), 0 10px 30px rgba(0,0,0,0.4);
}

.chair { position: absolute; width: 55px; height: auto; z-index: 0; pointer-events: none; }
.chair-top { top: -42px; left: 50%; transform: translateX(-50%); }
.chair-left { left: -42px; top: 50%; transform: translateY(-50%) rotate(-90deg); }
.chair-right { right: -42px; top: 50%; transform: translateY(-50%) rotate(90deg); }
.chair-bottom { bottom: -42px; left: 50%; transform: translateX(-50%) rotate(180deg); }

.avatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4), inset 0 0 0 2px rgba(255,255,255,0.25);
}

.seat {
  position: absolute;
  z-index: 2;
  color: white;
  text-align: center;
  font-size: 14px;
  background: rgba(0,0,0,0.3);
  padding: 8px 14px;
  border-radius: 14px;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: box-shadow 0.2s;
}
.seat-header { display: flex; align-items: center; gap: 6px; }
.seat-name { font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-info { font-size: 11px; opacity: 0.8; }
.seat-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.seat-tag { font-size: 10px; color: #1a1a1a; background: var(--gold); padding: 1px 8px; border-radius: 8px; font-weight: 700; }
.seat-tag.taker { background: #ff8a3d; }

.mini-hand { position: relative; width: 44px; height: 33px; margin: 2px auto; }
.mini-hand .card-back.tiny { position: absolute; left: 50%; top: 0; }
.mini-hand .card-back.tiny:nth-child(1) { transform: translateX(calc(-50% - 5px)) rotate(-6deg); z-index: 1; }
.mini-hand .card-back.tiny:nth-child(2) { transform: translateX(-50%) rotate(0deg); z-index: 2; }
.mini-hand .card-back.tiny:nth-child(3) { transform: translateX(calc(-50% + 5px)) rotate(6deg); z-index: 3; }
.trick-pile .card-back.tiny.won { border-color: var(--gold); box-shadow: 0 0 5px rgba(212,175,55,0.7); }
.trick-pile-empty { font-size: 10px; color: rgba(255,255,255,0.65); text-align: center; line-height: 33px; }
.mini-hand-count {
  position: absolute;
  right: -6px;
  bottom: -6px;
  z-index: 4;
  background: var(--gold);
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.seat.active {
  box-shadow: 0 0 0 3px var(--gold), 0 0 16px 2px rgba(212,175,55,0.8);
  animation: pulseTurn 1.4s ease-in-out infinite;
}
@keyframes pulseTurn {
  0%, 100% { box-shadow: 0 0 0 3px var(--gold), 0 0 10px 1px rgba(212,175,55,0.6); }
  50% { box-shadow: 0 0 0 3px var(--gold), 0 0 20px 6px rgba(212,175,55,0.9); }
}

.seat-top { top: -40px; left: 50%; transform: translateX(-50%); }
.seat-left { left: 0; top: 50%; transform: translateY(-50%); }
.seat-right { right: 0; top: 50%; transform: translateY(-50%); }

.trick-area {
  position: relative;
  z-index: 2;
  width: 190px;
  height: 210px;
}
.trick-card-slot {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Chaque carte posée du côté réel du joueur (droite=droite, gauche=gauche...) */
.trick-pos-top { top: 42px; left: 50%; transform: translateX(-50%); }
.trick-pos-left { left: 0; top: 50%; transform: translateY(-50%); }
.trick-pos-right { right: 0; top: 50%; transform: translateY(-50%); }
.trick-pos-bottom { bottom: 0; left: 50%; transform: translateX(-50%); }

@keyframes cardEnterTop { from { transform: translateY(-55px) scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardEnterLeft { from { transform: translateX(-55px) scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardEnterRight { from { transform: translateX(55px) scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes cardEnterBottom { from { transform: translateY(55px) scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
.trick-card-slot .playing-card.enter-top { animation: cardEnterTop 0.3s ease-out; }
.trick-card-slot .playing-card.enter-left { animation: cardEnterLeft 0.3s ease-out; }
.trick-card-slot .playing-card.enter-right { animation: cardEnterRight 0.3s ease-out; }
.trick-card-slot .playing-card.enter-bottom { animation: cardEnterBottom 0.3s ease-out; }

.trick-area.collect-top { animation: collectTop 0.9s ease-in forwards; }
.trick-area.collect-left { animation: collectLeft 0.9s ease-in forwards; }
.trick-area.collect-right { animation: collectRight 0.9s ease-in forwards; }
.trick-area.collect-bottom { animation: collectBottom 0.9s ease-in forwards; }
@keyframes collectTop { to { transform: translateY(-130px) scale(0.55); opacity: 0; } }
@keyframes collectLeft { to { transform: translateX(-130px) scale(0.55); opacity: 0; } }
@keyframes collectRight { to { transform: translateX(130px) scale(0.55); opacity: 0; } }
@keyframes collectBottom { to { transform: translateY(130px) scale(0.55); opacity: 0; } }

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 16px;
  max-width: 520px;
  margin: 10px auto;
  text-align: center;
}
.panel h3 { margin-top: 0; }
.bid-suits { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.bid-suits button { width: auto; padding: 10px 16px; font-size: 18px; color: white; }
.bid-suits button.suit-H, .bid-suits button.suit-D { background: var(--red); }
.bid-suits button.suit-S, .bid-suits button.suit-C { background: #333; }
.btn-pass { background: #888 !important; width: auto; padding: 10px 16px; }
.turned-card-row { display: flex; justify-content: center; margin: 10px 0; }
.turned-card-row .playing-card { cursor: default; }
.hint { font-size: 12px; color: #777; margin: 4px 0; }
.capot-row { background: #fdeaea; font-weight: 600; }

.my-area { padding: 10px 0 24px; }
.my-info { text-align: center; color: white; font-weight: 600; margin-bottom: 8px; min-height: 36px; }
.my-tricks { font-weight: 400; font-size: 12px; opacity: 0.85; }

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

.playing-card {
  width: 58px;
  height: 84px;
  background: linear-gradient(160deg, #ffffff 0%, #f4f4f4 100%);
  border-radius: 7px;
  border: 1px solid #999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 1px 3px 6px rgba(0,0,0,0.45);
  margin: 0 -8px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
}
.playing-card.red { color: var(--red); }
.playing-card.black { color: var(--black); }
.playing-card:hover { transform: translateY(-10px); box-shadow: 1px 6px 12px rgba(0,0,0,0.5); }
.playing-card.disabled { opacity: 0.45; cursor: not-allowed; filter: grayscale(0.3); }
.playing-card.disabled:hover { transform: none; box-shadow: 1px 3px 6px rgba(0,0,0,0.45); }
.playing-card .rank { font-size: 18px; }
.playing-card .suit { font-size: 18px; }
.playing-card::before, .playing-card::after {
  content: attr(data-rank) " " attr(data-suit);
  position: absolute;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  opacity: 0.75;
  white-space: nowrap;
}
.playing-card::before { top: 5px; left: 5px; }
.playing-card::after { bottom: 5px; right: 5px; transform: rotate(180deg); }
.playing-card.mini { width: 44px; height: 62px; font-size: 12px; margin: 0; cursor: default; }
.playing-card.mini .rank, .playing-card.mini .suit { font-size: 13px; }
.playing-card.mini::before, .playing-card.mini::after { display: none; }

.card-back.tiny {
  width: 20px;
  height: 29px;
  min-width: 20px;
  background: repeating-linear-gradient(45deg, #1c3f73, #1c3f73 3px, #24508f 3px, #24508f 6px);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  box-shadow: 1px 2px 3px rgba(0,0,0,0.4);
  cursor: default;
}
.card-back.tiny:hover { transform: none; }

.scoring-table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.scoring-table td, .scoring-table th { padding: 6px 10px; border-bottom: 1px solid #ddd; }
