/* Play / lobby page: you on the left (name, stats, friends online), a big
   Quick match banner, and two smaller ways to play under it. On phones it
   all stacks: you, Quick match, the two modes, then friends. */


/* --- Layout --- */
.lobby {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-areas:
    "me      hero"
    "friends modes";
  grid-template-rows: auto auto;
  align-content: center;
  gap: 18px 22px;
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding: clamp(14px, 3vh, 28px) clamp(14px, 3vw, 28px) clamp(18px, 4vh, 40px);
}
.me-card { grid-area: me; }
.friends-card { grid-area: friends; align-self: start; }
.play-hero { grid-area: hero; }
.modes { grid-area: modes; }

/* Shared dark panel */
.me-card,
.friends-card {
  border-radius: 26px;
  background:
    radial-gradient(ellipse 90% 40% at 50% 0%, rgba(255, 255, 255, 0.1), transparent 70%),
    linear-gradient(180deg, #33206b, #22134a);
  border: 2px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 0 #120634, 0 20px 40px rgba(5, 0, 20, 0.45);
}

/* --- You --- */
.me-card { display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 18px; }
.me-top { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: none;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0, #fff 6%, var(--p-red) 28%, #9c1022 90%);
  box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(255, 197, 61, 0.45), 0 6px 12px rgba(0, 0, 0, 0.45);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.player-plate { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; cursor: text; }
.plate-label { font-size: 11px; font-weight: 800; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.plate-field {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(10, 4, 30, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.12);
  transition: border-color 0.15s ease;
}
.player-plate:focus-within .plate-field { border-color: var(--gold); }
.player-plate.needs-name .plate-field { border-color: var(--danger); animation: shake 0.4s ease; }
.player-plate input {
  flex: 1;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font: 800 20px/1.3 var(--font-display);
  outline: none;
}
.player-plate input::placeholder { color: rgba(255, 255, 255, 0.45); }
.plate-edit { flex: none; width: 16px; height: 16px; color: var(--muted); }

.me-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.me-stats[hidden] { display: none; }
.me-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 16px;
  background: rgba(10, 4, 30, 0.45);
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease;
}
.me-stat:hover { background: rgba(255, 255, 255, 0.08); }
.me-stat b { font: 800 22px/1.2 var(--font-display); color: #4be38a; }
.me-stat.is-streak b { color: #ff9a3d; }
.me-stat.is-coins b { color: var(--gold); }
.me-stat span { font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }

.me-guest { display: flex; flex-direction: column; gap: 10px; }
.me-guest[hidden] { display: none; }
.me-guest p { color: var(--muted); font-weight: 600; font-size: 15px; line-height: 1.45; }
.me-guest-actions { display: flex; gap: 8px; }
.me-guest-actions .btn { flex: 1; }

/* --- Friends --- */
.friends-card { padding: 16px; }
.friends-card[hidden] { display: none; }
.me-friends-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.me-friends-head h2 { font-size: 18px; font-weight: 800; }
.me-friends-head a { color: var(--gold); font-weight: 800; font-size: 14px; text-decoration: none; }
.me-friend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.me-friend-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 14px; background: rgba(10, 4, 30, 0.35); }
.me-friend-list .chip-avatar { position: relative; overflow: visible; width: 34px; height: 34px; }
.me-friend-list .chip-avatar img { border-radius: 50%; }
.me-friend-list .chip-avatar.is-online::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #35d07f;
  box-shadow: 0 0 0 3px #22134a;
}
.me-friend-list .f-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.me-friend-list .f-name b { font: 800 15px var(--font-display); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-friend-list .f-name small { font-size: 12px; font-weight: 700; color: var(--muted); }
.me-friend-list .btn { padding: 6px 12px; font-size: 14px; }
.me-friend-list .f-empty { justify-content: center; color: var(--muted); font-weight: 600; font-size: 14px; text-align: center; }

/* --- Quick match banner --- */
.play-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr);
  align-items: center;
  gap: 12px;
  overflow: hidden;
  min-height: 270px;
  padding: clamp(20px, 3vw, 32px);
  border-radius: 32px;
  background: linear-gradient(135deg, #ff5fa2 0%, #b23cff 48%, #6a1fd0 100%);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 0 #46118f, 0 24px 60px rgba(178, 60, 255, 0.45);
}
.play-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 85% 50%, rgba(255, 255, 255, 0.25), transparent 70%),
    radial-gradient(ellipse 90% 45% at 30% 0%, rgba(255, 255, 255, 0.22), transparent 70%),
    var(--suits);
  pointer-events: none;
}
.play-hero > * { position: relative; }
.hero-text { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.hero-text h1 {
  font-size: clamp(32px, 4.2vw, 52px);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.hero-text p { font-weight: 600; color: rgba(255, 255, 255, 0.9); max-width: 32ch; }
.btn-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
  min-width: 220px;
  padding: 16px 34px;
  font-size: 26px;
  letter-spacing: 1.5px;
  box-shadow: 0 6px 0 var(--gold-dark), inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 0 24px rgba(255, 197, 61, 0.45);
  animation: play-pulse 2.4s ease-out infinite;
}
.btn-play svg { width: 1em; height: 1em; }
@keyframes play-pulse {
  0%   { box-shadow: 0 6px 0 var(--gold-dark), 0 0 0 0 rgba(255, 197, 61, 0.55); }
  70%  { box-shadow: 0 6px 0 var(--gold-dark), 0 0 0 16px rgba(255, 197, 61, 0); }
  100% { box-shadow: 0 6px 0 var(--gold-dark), 0 0 0 0 rgba(255, 197, 61, 0); }
}

.hero-art { position: relative; display: grid; place-items: center; min-height: 0; }
.hero-art svg {
  position: relative;
  width: 100%;
  max-width: 300px;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.35));
  animation: bob 4s ease-in-out infinite;
}
.hero-card {
  position: absolute;
  width: 26%;
  max-width: 86px;
  border-radius: 7px;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.4));
}
.hero-card.c1 { top: 2%; left: 4%; transform: rotate(-18deg); }
.hero-card.c2 { bottom: 0; right: 2%; transform: rotate(14deg); }
.play-hero .sparkle { animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: 0.3; } }
@keyframes bob { 50% { transform: translateY(-8px); } }

/* The table picked last time; PLAY opens the setup pop-up. */
.tile-setup {
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(10, 4, 40, 0.35);
  font: 800 13px/1.5 var(--font-display);
  color: rgba(255, 255, 255, 0.9);
}

/* --- Private room and practice --- */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; align-self: start; }
.mode {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  padding: 18px;
  border-radius: 26px;
  border: 2px solid rgba(255, 255, 255, 0.2);
}
.mode::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 45% at 50% 0%, rgba(255, 255, 255, 0.24), transparent 70%), var(--suits);
  pointer-events: none;
}
.mode > * { position: relative; }
.mode-private {
  background: linear-gradient(160deg, #48b6ff 0%, #5a4cf2 60%, #3b25b8 100%);
  box-shadow: 0 8px 0 #22137a, 0 18px 36px rgba(5, 0, 20, 0.45);
}
.mode-bots {
  background: linear-gradient(160deg, #3be0ad 0%, #1b9e78 60%, #116652 100%);
  box-shadow: 0 8px 0 #0a4638, 0 18px 36px rgba(5, 0, 20, 0.45);
}
.mode-head { display: flex; align-items: center; gap: 12px; }
.mode-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
}
.mode-icon svg { width: 30px; height: 30px; }
.mode-private .mode-icon { color: #3b25b8; }
.mode-bots .mode-icon { color: #0f6a3a; }
.mode h2 { font-size: 22px; font-weight: 800; line-height: 1.15; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }
.mode p { font-size: 14px; font-weight: 600; color: rgba(255, 255, 255, 0.88); line-height: 1.35; }
.mode .tile-setup { align-self: flex-start; }
.mode .btn { width: 100%; }
.mode-bots .btn { margin-top: auto; }
.mode-private .btn-secondary { background: #fff; color: #3b25b8; box-shadow: 0 4px 0 #b7aef0; }

.join-form { display: flex; gap: 8px; width: 100%; }
.join-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(10, 4, 40, 0.35);
  color: #fff;
  font: 800 18px/1.2 var(--font-display);
  letter-spacing: 4px;
  text-transform: uppercase;
  text-align: center;
}
.join-form input::placeholder { color: rgba(255, 255, 255, 0.55); letter-spacing: 1px; }
.join-form input:focus { outline: none; border-color: var(--gold); }
.join-form .btn { width: auto; flex: none; }

.btn[disabled] { cursor: progress; filter: saturate(0.6); transform: none; }

/* Links like /play#private highlight that box. */
.is-target { animation: glow 1.4s ease 2; }
@keyframes glow { 50% { outline: 4px solid var(--gold); outline-offset: 4px; } }
@keyframes shake {
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* --- Tablets and phones: one column --- */
@media (max-width: 900px) {
  .lobby {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "me" "hero" "modes" "friends";
    grid-template-rows: none;
    align-content: start;
    gap: 14px;
  }
  .me-card { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 14px; }
  .me-top { flex: 1 1 240px; }
  .me-stats { flex: 1 1 240px; }
  .me-guest { flex: 1 1 100%; flex-direction: row; align-items: center; }
  .me-guest p { flex: 1; font-size: 14px; }
  .me-guest-actions .btn { flex: none; }
  .avatar { width: 52px; height: 52px; }
  .play-hero { min-height: 0; grid-template-columns: minmax(0, 1fr) 34%; padding: 18px 18px 20px; }
  .btn-play { min-width: 0; padding: 13px 24px; font-size: 22px; }
}
@media (max-width: 600px) {
  .modes { grid-template-columns: 1fr; gap: 14px; }
  .me-guest { flex-direction: column; align-items: stretch; }
  .me-guest-actions .btn { flex: 1; }
  .hero-text h1 { font-size: 30px; }
  .hero-text p { font-size: 14px; }
  .hero-card { display: none; }
  .play-hero .btn-play { align-self: stretch; }
}

@media (prefers-reduced-motion: reduce) {
  .btn-play, .hero-art svg, .play-hero .sparkle { animation: none; }
}

/* Setup pop-up: players, teams, bot level */
.setup-dialog { gap: 16px; }
.setup-row { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.setup-label { font-size: 13px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.setup-seg { flex-wrap: wrap; justify-content: center; gap: 2px; }
.setup-seg .seg-btn { padding: 8px 16px; font-size: 17px; }
.setup-cancel { border: 0; background: none; font: inherit; font-weight: 700; cursor: pointer; }
@media (max-width: 420px) {
  .setup-seg { align-self: stretch; }
  .setup-seg .seg-btn { flex: 1; padding: 8px 6px; font-size: 15px; }
}
