/* ==========================================================================
   Client pages: lobby, auth, profile, decks + builder, friends, history, sandbox.
   The app chrome is a fixed top bar plus one internally scrolling content column.
   ========================================================================== */

.boot { height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s4); }
.boot-text { font-family: var(--font-display); letter-spacing: 0.14em; color: var(--gold); font-size: 13px; text-transform: uppercase; }
.boot-text.err { color: var(--bad); }

.shell { height: 100dvh; display: grid; grid-template-rows: 52px minmax(0, 1fr); }
body.table-mode .shell { display: none; }

.shell-top {
  display: flex;
  align-items: center;
  gap: var(--s5);
  padding: 0 var(--s5);
  border-bottom: 1px solid var(--gold-line);
  background: linear-gradient(180deg, rgba(14, 22, 40, 0.94), rgba(7, 11, 22, 0.9));
  backdrop-filter: blur(8px);
}
.shell-top .brand { display: flex; align-items: center; gap: 8px; }
.shell-top .brand-mark { color: var(--gold); font-size: 17px; }
.shell-top .brand-name { font-family: var(--font-display); font-size: 13px; letter-spacing: 0.22em; color: var(--gold-hi); text-transform: uppercase; }
.nav-links { display: flex; gap: 2px; flex: 1 1 auto; }
.nav-link {
  padding: 6px 13px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  transition: color var(--t-fast), background var(--t-fast);
}
.nav-link:hover { color: var(--gold-hi); background: rgba(200, 170, 110, 0.08); }
.nav-link.on { color: var(--gold-hi); background: rgba(200, 170, 110, 0.16); box-shadow: inset 0 -2px 0 var(--gold); }
.nav-right { display: flex; align-items: center; gap: 9px; }
.nav-user { display: flex; align-items: center; gap: 7px; color: var(--ink); font-size: 12px; max-width: 180px; }
.nav-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background-size: 190%;
  background-position: center 22%;
  border: 1px solid var(--gold-line-hi);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-size: 12px;
}
.nav-avatar.blank { background: var(--navy-700); }

.page-content { padding: var(--s5) var(--s5) 64px; }
.page { max-width: 1080px; margin: 0 auto; }
.page-content.wide .page { max-width: 1420px; }
.page.narrow { max-width: 520px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.page-head h1 { color: var(--gold-hi); }
.page-sub { margin: 4px 0 0; color: var(--ink-mute); font-size: 13px; max-width: 60ch; }
.section-h { color: var(--gold); font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; margin: var(--s5) 0 var(--s3); }

.stub-note {
  border: 1px dashed var(--gold-line-hi);
  border-radius: var(--r-md);
  padding: 10px 14px;
  color: var(--ink-soft);
  font-size: 12px;
  background: rgba(200, 170, 110, 0.06);
}
.stub-note b { color: var(--gold); }
.stub-note.err { border-color: rgba(226, 88, 74, 0.5); background: rgba(226, 88, 74, 0.08); color: #ffc0b8; }
.form-error { color: #ff9d92; font-size: 12px; margin-bottom: var(--s3); }

.list-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.list-row:last-child { border-bottom: 0; }
.stat-row { font-size: 13px; color: var(--ink-soft); padding: 3px 0; }
.stat-row b { color: var(--gold-hi); font-size: 17px; margin-right: 5px; }

/* ----------------------------------------------------------------- lobby -- */

.lobby-hero {
  position: relative;
  height: 132px;
  border-radius: var(--r-lg);
  border: 1px solid var(--gold-line);
  overflow: hidden;
  margin-bottom: var(--s4);
  background: linear-gradient(120deg, var(--navy-700), var(--navy-900));
}
.hero-art {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center 24%;
  filter: saturate(1.05) contrast(1.03);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 42%);
  mask-image: linear-gradient(90deg, transparent, #000 42%);
  opacity: 0.62;
}
.lobby-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(6, 10, 20, 0.96) 12%, rgba(6, 10, 20, 0.45) 55%, rgba(6, 10, 20, 0.8));
}
.hero-text { position: absolute; left: var(--s5); top: 50%; transform: translateY(-50%); z-index: 1; max-width: 60%; }
.hero-deck { font-family: var(--font-display); font-size: 22px; color: var(--gold-hi); text-shadow: 0 2px 10px #000; }
.hero-legend { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); margin-top: 5px; }

.lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s4); }
.play-card { display: flex; flex-direction: column; }
.play-card.hero { border-color: var(--gold-line-hi); box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55), 0 0 40px rgba(200, 170, 110, 0.1); }
.play-card .modal-body { display: flex; flex-direction: column; gap: 0; }
.play-card .btn.wide { margin-top: 4px; }

/* ------------------------------------------------------------- auth/profile */

.auth-page .panel { box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6); }
.profile-grid { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: var(--s5); align-items: start; }
.profile-avatar { display: flex; flex-direction: column; gap: 8px; }
.avatar-big {
  width: 160px;
  height: 160px;
  border-radius: var(--r-lg);
  border: 1px solid var(--gold-line-hi);
  background-size: 165%;
  background-position: center 20%;
  background-color: var(--navy-700);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}
.avatar-blank { font-size: 40px; color: var(--gold-dim); }
.record-row { display: flex; gap: var(--s6); }
.record-cell { display: flex; flex-direction: column; }
.record-cell b { font-size: 30px; color: var(--gold-hi); line-height: 1; }
.record-cell b.good { color: var(--good); }
.record-cell b.bad { color: var(--bad); }
.record-cell span { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-mute); margin-top: 4px; }
@media (max-width: 620px) { .profile-grid { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------------- decks -- */

.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--s3); }
.deck-card {
  border: 1px solid var(--gold-line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--glass);
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast), border-color var(--t-fast);
}
.deck-card:hover { transform: translateY(-3px); border-color: var(--gold-line-hi); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55); }
.deck-art {
  height: 104px;
  background-size: cover;
  background-position: center 18%;
  background-color: var(--navy-700);
  position: relative;
}
.deck-art::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(8, 13, 26, 0.92)); }
.deck-body { padding: 10px 12px 12px; }
.deck-name { font-family: var(--font-display); font-size: 14px; color: var(--gold-hi); }

/* --------------------------------------------------------- deck builder --- */

.builder-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: var(--s4); margin-top: var(--s3); height: calc(100dvh - 210px); min-height: 420px; }
.builder-list, .builder-browse { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.deck-list { flex: 1 1 auto; padding: 8px 10px; }
.dl-section { margin-bottom: 12px; }
.dl-title { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); border-bottom: 1px solid var(--gold-line); padding-bottom: 3px; margin-bottom: 4px; }
.dl-title .num { color: var(--ink-soft); }
.dl-row { display: flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 4px; border-radius: 4px; }
.dl-row:hover { background: rgba(200, 170, 110, 0.1); }
.dl-n { color: var(--gold); font-weight: 700; min-width: 16px; }
.builder-problems { border-top: 1px solid var(--gold-line); padding: 8px 10px; max-height: 30%; overflow-y: auto; flex: 0 0 auto; }
.prob-title { font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--warn); margin-bottom: 4px; }
.prob { font-size: 11.5px; color: #ffc7a8; padding: 2px 0 2px 10px; border-left: 2px solid rgba(230, 178, 74, 0.5); margin-bottom: 3px; }
.filters { display: grid; grid-template-columns: minmax(120px, 2fr) repeat(4, minmax(78px, 1fr)); gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--gold-line); flex: 0 0 auto; }
.filters input, .filters select { padding: 5px 8px; font-size: 12px; }
.card-browser { flex: 1 1 auto; padding: 10px; }
.browse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.browse-item { display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; }
.browse-item .card { width: 100%; height: auto; aspect-ratio: 744 / 1039; }
.browse-item .card[data-orient='landscape'] { aspect-ratio: 1038 / 744; }
.browse-item.in-deck .card { box-shadow: 0 0 0 2px var(--gold), 0 4px 14px rgba(0, 0, 0, 0.6); }
.bi-name { font-size: 10px; color: var(--ink-soft); max-width: 100%; text-align: center; }
.bi-ctl { display: flex; align-items: center; gap: 4px; }
.bi-n { font-size: 12px; color: var(--gold-hi); min-width: 12px; text-align: center; }
.bi-flag { position: absolute; top: 3px; left: 3px; font-size: 11px; color: var(--warn); text-shadow: 0 1px 3px #000; }
.picker-grid { max-height: 46vh; overflow-y: auto; }
@media (max-width: 900px) { .builder-grid { grid-template-columns: 1fr; height: auto; } .card-browser { max-height: 60vh; } }

/* --------------------------------------------------------------- friends -- */

.friend-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s4); margin-top: var(--s4); }
.friend-list { display: flex; flex-direction: column; gap: 4px; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.friend-row:last-child { border-bottom: 0; }
.fr-name { font-size: 13px; color: var(--ink); }

/* --------------------------------------------------------------- history -- */

.game-row { font-size: 12.5px; }
.replay-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border: 1px solid var(--gold-line); border-radius: var(--r-md); background: var(--glass); margin-bottom: var(--s3); }
.replay-controls input[type='range'] { flex: 1 1 200px; width: auto; padding: 0; accent-color: var(--gold); }
.replay-last { flex: 1 1 100%; font-size: 12px; color: var(--gold); }
.replay-stage { border: 1px solid var(--gold-line); border-radius: var(--r-lg); overflow: hidden; background: var(--navy-900); }
.replay-stage .table { height: min(70dvh, 620px); }
.replay-stage .actionbar { pointer-events: none; }

/* --------------------------------------------------------------- sandbox -- */

.sandbox-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--s4); height: calc(100dvh - 190px); min-height: 420px; }
.sandbox-side { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.sandbox-tray { flex: 1 1 auto; padding: 0 10px 10px; }
.sandbox-table { position: relative; overflow: hidden; }
.felt {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 20%, rgba(46, 84, 66, 0.5), transparent 65%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.012) 0 6px, transparent 6px 12px),
    linear-gradient(180deg, #0d2019, #060d13);
  overflow: hidden;
}
.free-card { position: absolute; cursor: grab; transform-origin: center; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.75); transition: box-shadow var(--t-fast); }
.free-card:active { cursor: grabbing; }
.free-card:hover { box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85), 0 0 0 1px var(--gold-line-hi); }
@media (max-width: 900px) { .sandbox-grid { grid-template-columns: 1fr; height: auto; } .sandbox-table { height: 60vh; } }

/* ------------------------------------------------------------ bot picker -- */
/* Named opponents with a rating, chess.com style — never an engine name. */

.bot-picker { display: flex; flex-direction: column; gap: 3px; max-height: 260px; overflow-y: auto; }
.bot-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 5px 9px 5px 5px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  border-radius: var(--r-md);
  color: var(--ink-soft);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.bot-row:hover { background: rgba(200, 170, 110, 0.1); color: var(--gold-hi); }
.bot-row.on { border-color: var(--gold); background: rgba(200, 170, 110, 0.16); color: var(--gold-hi); }
.bot-face {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--navy-700) center 20% / 165% no-repeat;
  box-shadow: 0 0 0 1px var(--gold-line);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bot-face-blank { color: var(--gold-dim); font-size: 15px; }
.bot-text { display: flex; flex-direction: column; min-width: 0; }
.bot-name { font-family: var(--font-display); font-size: 13px; color: inherit; }
.bot-rating { font-size: 13px; color: var(--gold); flex: 0 0 auto; }
.bot-row.on .bot-rating { color: var(--gold-hi); }
