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

:root {
  --bg:        #080812;
  --bg2:       #0f0f1e;
  --panel:     #13132a;
  --border:    rgba(180, 140, 40, 0.25);
  --border-hi: rgba(212, 175, 55, 0.6);
  --gold:      #d4af37;
  --gold-dim:  #8b6914;
  --text:      #e8e6f0;
  --text-dim:  #8888aa;
  --green:     #4caf7d;
  --red:       #e05555;
  --blue:      #5b9bd5;
  --purple:    #9c6fc8;
  --font-title: 'Cinzel', serif;
  --font-body:  'Inter', sans-serif;
  --radius:    10px;
  --shadow:    0 8px 32px rgba(0,0,0,0.6);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

body {
  background-image:
    radial-gradient(ellipse at 20% 10%, rgba(80, 30, 120, 0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 90%, rgba(20, 60, 120, 0.15) 0%, transparent 60%);
}

/* ── Screens ─────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ── JOIN SCREEN ─────────────────────────────────────────────── */
#screen-join {
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.join-container {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.logo-block {
  text-align: center;
}

.logo-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 12px rgba(212,175,55,0.6));
}

.logo-title {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f0d060, var(--gold), #b8860b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
  margin-bottom: 0.3rem;
}

.logo-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

.join-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── LOBBY SCREEN ────────────────────────────────────────────── */
#screen-lobby {
  flex-direction: column;
  padding: 1.5rem;
}

.lobby-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  flex: 1;
}

.lobby-left, .lobby-right {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Room header */
.room-header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.room-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-bottom: 0.2rem;
}

.room-code {
  font-family: var(--font-title);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.3em;
  text-shadow: 0 0 20px rgba(212,175,55,0.4);
}

.btn-copy {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-copy:hover { border-color: var(--gold); color: var(--gold); }

.player-count {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  letter-spacing: 0.05em;
}

/* Players list */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
}

.player-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: stretch;
  min-height: 80px;
  transition: border-color 0.3s, box-shadow 0.3s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.player-card.is-ready {
  border-color: var(--green);
  box-shadow: 0 0 16px rgba(76,175,125,0.2);
}

.player-card.is-me {
  border-color: rgba(212,175,55,0.4);
}

.player-art {
  width: 72px;
  min-width: 72px;
  background: var(--bg2);
  overflow: hidden;
  position: relative;
}

.player-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
}

.player-art-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--text-dim);
  opacity: 0.4;
}

.player-info {
  flex: 1;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.player-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-host {
  font-size: 0.65rem;
  background: rgba(212,175,55,0.15);
  color: var(--gold);
  border: 1px solid rgba(212,175,55,0.3);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge-me {
  font-size: 0.65rem;
  background: rgba(100,100,200,0.15);
  color: #aab;
  border: 1px solid rgba(100,100,200,0.2);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.player-commander {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-status {
  display: flex;
  align-items: center;
  padding-right: 1rem;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-ready   { color: var(--green); }
.status-waiting { color: var(--text-dim); }
.status-deck    { color: var(--blue); }

/* Color pips */
.color-pips { display: flex; gap: 3px; margin-top: 3px; }
.pip {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
}
.pip-W { background: #f9f6ee; }
.pip-U { background: #0e68ab; }
.pip-B { background: #150b00; border-color: rgba(255,255,255,0.3); }
.pip-R { background: #d3202a; }
.pip-G { background: #00733e; }
.pip-C { background: #ccc; }

.lobby-hint {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 0.5rem;
  line-height: 1.8;
}
.lobby-hint span { color: var(--gold-dim); }

/* Deck panel */
.deck-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.panel-title {
  font-family: var(--font-title);
  font-size: 1.1rem;
  color: var(--gold);
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

/* ── FORMS ───────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.label-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.7;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

input[type="text"], textarea {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.65rem 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px rgba(212,175,55,0.1);
}

textarea {
  min-height: 200px;
  resize: vertical;
  font-size: 0.82rem;
  font-family: 'Courier New', monospace;
  line-height: 1.6;
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 7px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.04em;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #b8860b, var(--gold), #b8860b);
  color: #0a0805;
  box-shadow: 0 4px 16px rgba(212,175,55,0.25);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 24px rgba(212,175,55,0.45);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-hi);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(212,175,55,0.05);
}

.btn-ready {
  background: linear-gradient(135deg, #2d7a52, var(--green), #2d7a52);
  color: #fff;
  font-size: 1rem;
  padding: 0.9rem;
  box-shadow: 0 4px 16px rgba(76,175,125,0.3);
  animation: pulse-ready 2s ease-in-out infinite;
}
.btn-ready:hover:not(:disabled) {
  box-shadow: 0 4px 28px rgba(76,175,125,0.5);
  transform: translateY(-1px);
}

@keyframes pulse-ready {
  0%, 100% { box-shadow: 0 4px 16px rgba(76,175,125,0.3); }
  50%       { box-shadow: 0 4px 28px rgba(76,175,125,0.55); }
}

.btn-link {
  background: none;
  border: none;
  color: var(--gold-dim);
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  padding: 0;
  transition: color 0.2s;
  font-family: var(--font-body);
}
.btn-link:hover { color: var(--gold); }

/* ── PROGRESS ────────────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  text-align: center;
}

/* ── DECK STATUS ─────────────────────────────────────────────── */
.deck-valid-box {
  background: rgba(76,175,125,0.08);
  border: 1px solid rgba(76,175,125,0.3);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.deck-valid-art {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  border: 1px solid rgba(76,175,125,0.3);
}
.deck-valid-art img { width: 100%; height: 100%; object-fit: cover; }

.deck-valid-info { flex: 1; }
.deck-valid-title {
  font-size: 0.75rem;
  color: var(--green);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}
.deck-valid-name { font-weight: 600; font-size: 0.95rem; }
.deck-valid-count { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.2rem; }

.deck-errors-box {
  background: rgba(224,85,85,0.08);
  border: 1px solid rgba(224,85,85,0.3);
  border-radius: 8px;
  padding: 1rem;
}
.deck-errors-title {
  font-size: 0.75rem;
  color: var(--red);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.6rem;
}
.deck-errors-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.deck-errors-list li {
  font-size: 0.82rem;
  color: #f0a0a0;
  padding-left: 1rem;
  position: relative;
}
.deck-errors-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--red);
}

/* ── DIVIDER ─────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-dim);
  font-size: 0.75rem;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── STARTING SCREEN ─────────────────────────────────────────── */
#screen-starting {
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.starting-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.starting-icon {
  font-size: 4rem;
  animation: float 2s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(212,175,55,0.6));
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.starting-title {
  font-family: var(--font-title);
  font-size: 2rem;
  background: linear-gradient(135deg, #f0d060, var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.starting-sub { color: var(--text-dim); }

.starting-loader {
  display: flex;
  gap: 0.5rem;
}

.loader-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
  animation: bounce 1.2s ease-in-out infinite;
}
.loader-dot:nth-child(2) { animation-delay: 0.2s; }
.loader-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%            { transform: scale(1);   opacity: 1; }
}

.starting-players {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.starting-player-chip {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── ERROR MSG ───────────────────────────────────────────────── */
.error-msg {
  color: var(--red);
  font-size: 0.82rem;
  text-align: center;
}

/* ── TOAST ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 9999;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1.2rem;
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  animation: slide-in 0.3s ease;
  max-width: 300px;
}

.toast.toast-error  { border-color: rgba(224,85,85,0.5); color: #f0a0a0; }
.toast.toast-success { border-color: rgba(76,175,125,0.5); color: #a0f0c0; }
.toast.toast-info   { border-color: rgba(91,155,213,0.5); color: #a0c8f0; }

@keyframes slide-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── BOUTON PARCOURIR ────────────────────────────────────────── */
.btn-browse {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
  padding: 0.6rem;
  transition: all 0.2s;
}
.btn-browse:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: rgba(212,175,55,0.05);
}

/* ── DECK BROWSER MODAL ──────────────────────────────────────── */
.browser-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.browser-modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.8);
  overflow: hidden;
}

.browser-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.browser-title {
  font-family: var(--font-title);
  font-size: 1rem;
  color: var(--gold);
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
}

.browser-count {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
  letter-spacing: 0;
}

.browser-filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
}

.filter-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all 0.15s;
  white-space: nowrap;
}
.filter-btn:hover   { border-color: var(--gold-dim); color: var(--text); }
.filter-btn.active  {
  background: rgba(212,175,55,0.15);
  border-color: var(--gold);
  color: var(--gold);
}

.browser-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.browser-close:hover { border-color: var(--red); color: var(--red); }

.browser-body {
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  flex: 1;
}

.browser-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

/* Carte dans la grille */
.browser-card {
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid transparent;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  background: var(--panel);
  aspect-ratio: 63/88;
}

.browser-card:hover {
  transform: translateY(-4px) scale(1.03);
  border-color: var(--gold-dim);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  z-index: 2;
}

.browser-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 7px;
}

.browser-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.3;
}

.browser-card.is-commander {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(212,175,55,0.3);
}
.browser-card.is-commander::after {
  content: '⚔';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 0.75rem;
  background: rgba(0,0,0,0.7);
  border-radius: 4px;
  padding: 1px 4px;
}

/* Zoom flottant */
.card-zoom {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 240px;
  filter: drop-shadow(0 8px 32px rgba(0,0,0,0.9));
  transition: opacity 0.1s;
}

.card-zoom img {
  width: 100%;
  border-radius: 12px;
  display: block;
}

/* Section label dans la grille */
.browser-section-label {
  grid-column: 1 / -1;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 0.5rem 0 0.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.25rem;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .lobby-layout { grid-template-columns: 1fr; }
  .lobby-left { order: 2; }
  .lobby-right { order: 1; }
}
