/*
 * Games lobby ("Your games") for client_games.html. Scoped to body.lobby.
 * Desktop first; below 720px it becomes the mobile layout, with the
 * "New game" button in a bar at the bottom.
 */

body.lobby {
  margin: 0;
  padding: 0;
  background-color: #1F5C41;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    radial-gradient(rgba(0, 0, 0, 0.14) 1px, transparent 1px);
  background-size: 4px 4px, 7px 7px;
  background-position: 0 0, 2px 3px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  color: #1B1F1C;
}

/* Fill the screen so the credit sits at the bottom */
body.lobby > .games-page {
  display: flex !important;
  flex-direction: column;
  box-sizing: border-box;
  min-height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* ---------- Header ---------- */

.lb-header {
  box-sizing: border-box;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.lb-logo { display: flex; gap: 5px; }

.lb-tile {
  position: relative;
  width: 40px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: #F6E2AE;
  color: #24190C;
  box-shadow: inset 0 -4px 0 rgba(120, 84, 20, 0.32), 0 3px 6px rgba(0, 0, 0, 0.3);
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.lb-tile sub {
  position: absolute;
  right: 4px;
  bottom: 5px;
  font-size: 9px;
  font-weight: 700;
  vertical-align: baseline;
}

.lb-tile:nth-child(1) { transform: rotate(-4deg); }
.lb-tile:nth-child(2) { transform: rotate(2deg); }
.lb-tile:nth-child(3) { transform: rotate(-1deg); }
.lb-tile:nth-child(4) { transform: rotate(4deg); }

body.lobby #signinState { float: none; margin: 0; }

body.lobby .lb-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.lb-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 14px 0 6px;
  box-sizing: border-box;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.lb-avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #F6E2AE;
  color: #24190C;
  font-size: 13px;
  font-weight: 700;
}

body.lobby #id {
  display: inline;
  margin: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  font-weight: 600;
}

.lb-ghost,
.lb-icon {
  box-sizing: border-box;
  height: 44px;
  margin: 0 !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  background: transparent !important;
  background-image: none !important;
  color: #fff !important;
  box-shadow: none !important;
  font-family: inherit;
  font-size: 15px !important;
  font-weight: 600;
  cursor: pointer;
}

.lb-ghost { padding: 0 18px !important; border-radius: 999px !important; }

.lb-icon {
  width: 44px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
}

.lb-icon svg { width: 20px; height: 20px; }
.lb-icon .ui-icon, .lb-icon .ui-button-icon { display: none !important; }
.lb-ghost:hover, .lb-icon:hover { background: rgba(255, 255, 255, 0.12) !important; }

/* ---------- Signed out ---------- */

body.lobby .signin-hero { color: #fff; }
body.lobby.signed-out .lb-main { display: none; }

/* ---------- Main ---------- */

.lb-main {
  box-sizing: border-box;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.lb-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.lb-title { display: flex; flex-direction: column; gap: 6px; }

.lb-title h1 {
  margin: 0;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
}

.lb-title p {
  margin: 0;
  font-size: 15px;
  color: #CFE3D6;
}

.lb-sub-narrow { display: none; }

.lb-actions { display: flex; align-items: center; gap: 12px; }

.lb-ghost-light { height: 44px; }

.lb-new {
  height: 52px;
  margin: 0;
  padding: 0 24px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  border-radius: 14px;
  background: #F2A23A;
  color: #2A1A05;
  box-shadow: 0 4px 0 #B8701A, 0 10px 24px rgba(0, 0, 0, 0.25);
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.lb-new:hover { background: #F5AE50; }
.lb-new:active { transform: translateY(1px); }

.lb-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 8px;
}

.lb-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.lb-tabs button {
  height: 40px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.lb-tabs button[aria-selected="true"] {
  background: #F8F3E6;
  color: #1B1F1C;
}

.lb-sorted {
  margin: 0;
  font-size: 13px;
  color: #CFE3D6;
}

/* ---------- Game cards ---------- */

#lobbyList {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lb-card {
  box-sizing: border-box;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  border-radius: 16px;
  background: #F8F3E6;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
  color: #1B1F1C;
  cursor: pointer;
}

.lb-avatars { display: flex; }

.lb-av {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #F8F3E6;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.lb-av + .lb-av { margin-left: -12px; }
.lb-av.is-robot { background: #E2D8C3; color: #3A3E39; }

.lb-av.is-empty {
  border: 2px dashed #B9AE97;
  background: transparent;
  color: #5B5F59;
}

.lb-info {
  flex: 1 1 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-names { font-size: 17px; font-weight: 700; }
.lb-meta { font-size: 13px; color: #5B5F59; }

.lb-pill {
  height: 32px;
  box-sizing: border-box;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.lb-pill.is-mine { background: #FDEBC8; color: #7A4A0A; }
.lb-pill.is-mine i { width: 8px; height: 8px; border-radius: 50%; background: #E58E1A; }
.lb-pill.is-waiting, .lb-pill.is-over { background: #E6DECB; color: #3A3E39; }
.lb-pill.is-turn { background: #DCEADF; color: #1E4A3B; }

.lb-btns { display: flex; gap: 8px; }

.lb-btn {
  height: 44px;
  margin: 0;
  box-sizing: border-box;
  padding: 0 20px;
  border: 0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.lb-btn-dark { background: #1E4A3B; color: #fff; }
.lb-btn-dark:hover { background: #255A49; }

.lb-btn-light {
  padding: 0 16px;
  border: 1px solid #CFC5B1;
  background: #fff;
  color: #2A2E29;
}

.lb-btn-light:hover { background: #FBF7EE; }

.lb-btn-orange {
  background: #F2A23A;
  color: #2A1A05;
  font-weight: 700;
  box-shadow: 0 3px 0 #B8701A;
}

.lb-narrow { display: none; }

.lb-empty {
  display: none;
  padding: 48px 24px;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  text-align: center;
}

.lb-empty-title {
  margin: 0 0 8px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.lb-empty-sub { margin: 0; font-size: 14px; color: #CFE3D6; }
.lb-empty-sub:empty { display: none; }

/* ---------- Leaderboard ---------- */

.lb-board {
  padding: 20px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
}

.lb-board h2 {
  margin: 0 0 8px;
  font-family: "Space Grotesk", Inter, sans-serif;
  font-size: 16px;
  font-weight: 700;
}

.lb-board .player-cumulative {
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 14px;
}

.lb-board .player-cumulative:first-child { border-top: 0; }

/* ---------- Footer credit ---------- */

body.lobby .source-credit {
  margin: auto 0 0;
  padding: 24px 0 20px;
  text-align: center;
  font-size: 12px;
}

body.lobby .source-credit a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  opacity: 0.5;
}

body.lobby .source-credit a:hover { opacity: 0.9; }
body.lobby .source-credit img { height: 1.4em; }

/* ---------- Mobile ---------- */

@media screen and (max-width: 720px) {
  .lb-header {
    height: 64px;
    padding: 0 12px 0 16px;
    flex-wrap: nowrap;
  }

  .lb-tile {
    width: 28px;
    height: 30px;
    border-radius: 5px;
    font-size: 15px;
    box-shadow: inset 0 -3px 0 rgba(120, 84, 20, 0.32), 0 2px 4px rgba(0, 0, 0, 0.3);
  }

  .lb-tile sub { right: 3px; bottom: 3px; font-size: 7px; }
  .lb-logo { gap: 3px; }

  body.lobby .lb-user { gap: 4px; }

  /* Just the round avatar; the name is in the subtitle */
  .lb-chip { height: 44px; padding: 0 5px; background: none; }
  body.lobby .lb-chip #id { display: none; }
  .lb-avatar { width: 34px; height: 34px; }

  .lb-ghost { height: 36px; padding: 0 12px !important; font-size: 13px !important; }
  .lb-icon { border: 0 !important; }

  .lb-main {
    padding: 8px 16px 110px;
    gap: 16px;
  }

  .lb-title { gap: 4px; }
  .lb-title h1 { font-size: 30px; }
  .lb-title p { font-size: 14px; }
  .lb-sub-wide { display: none; }
  .lb-sub-narrow { display: inline; }

  /* New game sits in a bar along the bottom of the screen */
  .lb-title-row { display: block; }

  .lb-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    box-sizing: border-box;
    padding: 12px 16px 24px;
    background: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(6px);
  }

  .lb-actions #reminders-button { display: none; }

  .lb-new {
    width: 100%;
    justify-content: center;
  }

  .lb-filter-row { padding-top: 0; }

  .lb-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .lb-sorted { display: none; }

  #lobbyList { gap: 10px; }

  .lb-card {
    padding: 16px;
    display: grid;
    grid-template-areas: "pill" "info" "btns";
    gap: 12px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  }

  .lb-avatars { display: none; }
  .lb-pill { grid-area: pill; justify-self: start; height: 28px; padding: 0 10px; font-size: 12px; }
  .lb-info { grid-area: info; flex: none; gap: 3px; }
  .lb-names { font-size: 16px; }
  .lb-btns { grid-area: btns; }
  .lb-btn { flex: 1; padding: 0 10px; font-size: 14px; white-space: nowrap; }
  .lb-wide { display: none; }
  .lb-narrow { display: inline; }

  .lb-empty { padding: 40px 20px; }
  .lb-empty-title { font-size: 18px; }
}

/* ---------- Signed out: the sign-in card sits on the page ---------- */

/* The card has its own logo, so the header one is not needed */
body.lobby.signed-out .lb-header { display: none; }

#loginInline {
  display: flex;
  justify-content: center;
  padding: 12vh 16px 0;
}

#loginInline .inline-dialog {
  box-sizing: border-box;
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  border-radius: 18px;
  background: #fff;
  color: #1c2b25;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

@media screen and (max-width: 720px) {
  #loginInline { padding-top: 6vh; }
}
