/* ============================================================
   Chess.com-style dark theme
   ============================================================ */
:root {
  --bg: #302e2b;
  --panel: #262421;
  --panel-2: #21201e;
  --input-bg: #1b1a18;
  --border: #1f1d1a;
  --border-2: #3a3733;
  --text: #e5e4e2;
  --muted: #9e9c98;
  --dim: #77736e;
  --green: #81b64c;
  --green-hover: #9ecb64;
  --green-edge: #4f7a34;
  --red: #d34c3d;
  --red-soft: #ff8a7a;
  --light-sq: #eeeed2;
  --dark-sq: #769656;
  --bs: 480px; /* board size, set by JS */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.hidden { display: none !important; }

button { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #403c38; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #4c4742; }

/* ---------------------------------------------------- screens */

.screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---------------------------------------------------- top bar */

.topbar {
  height: 52px;
  flex: 0 0 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
}

.logo-mark {
  color: var(--green);
  font-size: 30px;
  line-height: 1;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.4);
}

.logo-text {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  opacity: 0.85;
}
.icon-btn:hover { background: #34312e; opacity: 1; }
.icon-btn.off { opacity: 0.4; }

/* ---------------------------------------------------- buttons */

.btn {
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: background 0.12s, transform 0.05s;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22);
}
.btn-primary:hover { background: var(--green-hover); }
.btn-primary:active { transform: translateY(2px); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.22); }
.btn-primary:disabled { background: #55524e; cursor: default; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18); }

.btn-secondary {
  background: #3d3a36;
  color: #fff;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}
.btn-secondary:hover { background: #484440; }
.btn-secondary:active { transform: translateY(2px); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--muted);
  width: auto;
  padding: 6px 14px;
  font-size: 13px;
}
.btn-ghost:hover { color: #fff; border-color: #55514c; }

/* ---------------------------------------------------- home */

.home-main {
  flex: 1;
  overflow-y: auto;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
  padding: 46px 24px 30px;
  background:
    radial-gradient(1100px 460px at 50% -140px, rgba(129, 182, 76, 0.10), transparent 70%);
}

.home-hero h1 {
  font-size: 40px;
  font-weight: 800;
  text-align: center;
  letter-spacing: -1px;
}

.home-hero .sub {
  text-align: center;
  color: var(--muted);
  margin-top: 10px;
  font-size: 16px;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 40px;
}

.home-category { margin-top: 36px; }
.home-category-heading h2 { font-size: 24px; font-weight: 800; }
.home-category-heading p { color: var(--muted); margin-top: 6px; line-height: 1.45; }
.home-category .home-cards { margin-top: 16px; }
.online-games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.play-online-card { grid-column: 1 / -1; }
#onlineWaiting { flex-wrap: wrap; }
#onlineWaiting .btn-ghost { margin-left: auto; }
.community-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; margin-top: 16px; }
.community-card .btn { margin-top: auto; }
/* Leaderboards card: "Official rankings" sits directly under "View rankings". */
.community-card .card-actions { display: grid; gap: 8px; margin-top: auto; }
.community-card .card-actions .btn { margin-top: 0; }
.watch-permission { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.watch-permission input { accent-color: var(--green); }
@media (max-width: 850px) {
  .home-cards, .community-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .home-cards, .online-games-grid, .community-cards { grid-template-columns: 1fr; }
  .home-category { margin-top: 28px; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
}

.card-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 27px;
}
.card-icon.green { background: rgba(129, 182, 76, 0.16); color: var(--green); }
.card-icon.blue  { background: rgba(96, 165, 250, 0.16); color: #7cb3f5; }
.card-icon.amber { background: rgba(240, 171, 74, 0.16); color: #f0ab4a; }
.tasks-card .card-desc { margin-bottom: 10px; }
.task-menu { display: grid; gap: 4px; margin-top: 2px; }
.task-menu-row { min-height: 39px; display: flex; align-items: center; gap: 11px; width: 100%; padding: 7px 9px; border: 1px solid transparent; border-radius: 7px; background: var(--panel-2); color: var(--text); font-family: inherit; font-size: 13px; text-align: left; cursor: pointer; transition: background 0.12s, border-color 0.12s, transform 0.06s; }
.task-menu-row:hover { background: var(--panel-3, #2f2c29); border-color: rgba(255, 255, 255, 0.08); }
.task-menu-row:active { transform: translateY(1px); }
.task-menu-row:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.task-menu-row span { width: 23px; text-align: center; font-size: 17px; }
.task-menu-row b { font-weight: 700; }
.task-menu-row small { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
@media (max-width: 720px) { .task-menu-row small { display: none; } }

/* Improve menu dialogs: course/class rows and the Aimchess 8x8 grid. */
.course-row, .class-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--panel-2); border-radius: 8px; padding: 11px 12px; }
.course-info, .class-info { display: grid; gap: 3px; min-width: 0; flex: 1; }
.course-info b, .class-info b { font-size: 14px; overflow-wrap: anywhere; }
.course-info span, .class-info span { color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.course-row .btn, .class-row .btn { width: auto; flex: none; white-space: nowrap; padding: 9px 14px; font-size: 13px; }
.aim-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; margin-top: 12px; aspect-ratio: 1; }
.aim-cell { border: 0; border-radius: 6px; background: var(--panel-2); cursor: pointer; transition: background 0.1s; }
.aim-cell:nth-child(16n+1), .aim-cell:nth-child(16n+3), .aim-cell:nth-child(16n+5), .aim-cell:nth-child(16n+7),
.aim-cell:nth-child(16n+10), .aim-cell:nth-child(16n+12), .aim-cell:nth-child(16n+14), .aim-cell:nth-child(16n+16) { background: #2c2a27; }
.aim-cell:hover { filter: brightness(1.35); }
.aim-cell.hot { background: var(--green) !important; box-shadow: 0 0 0 2px rgba(129, 182, 76, 0.4); }
.aim-cell.hot:hover { filter: none; }

.card h2 {
  font-size: 20px;
  margin: 14px 0 16px;
}

.card-desc {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 18px;
}

.field {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.field input,
.field select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.12s;
}

.field input:focus,
.field select:focus {
  border-color: var(--green);
}

.field input::placeholder { color: #6b6763; }

.custom-time-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: -4px 0 12px;
}
.custom-time-fields .field {
  min-width: 0;
  margin-bottom: 0;
  font-size: 11px;
  line-height: 1.25;
}
.custom-time-fields .field input {
  box-sizing: border-box;
  padding: 8px 7px;
  font-size: 14px;
}
.custom-time-fields .form-error {
  grid-column: 1 / -1;
  margin: 0;
}

.room-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--border-2);
  text-align: center;
}

.room-code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 12px;
  padding-left: 12px; /* compensate trailing letter-spacing */
  color: var(--green);
}

.room-hint {
  font-size: 12px;
  color: var(--dim);
  margin-top: 2px;
}

.ip-list { margin-top: 12px; }

.ip-row {
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  background: var(--input-bg);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.12s;
}
.ip-row:hover { border-color: var(--green); }
.ip-row .tag {
  font-family: "Segoe UI", sans-serif;
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.ip-row:hover .tag { color: var(--green); }

.waiting {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #4a4642;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.form-error {
  color: var(--red-soft);
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

.home-footer {
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  margin-top: 34px;
}
.home-footer b { color: var(--muted); font-family: Consolas, monospace; }

/* ---------------------------------------------------- game layout */

.game-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 27vw, 380px);
}

.board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  min-height: 0;
  min-width: 0;
}

/* player cards */

.player-card {
  width: var(--bs);
  display: flex;
  align-items: center;
  gap: 11px;
  height: 46px;
}

.pc-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  text-transform: uppercase;
}
.pc-avatar.av0 { background: linear-gradient(135deg, #81b64c, #4f8f3a); }
.pc-avatar.av1 { background: linear-gradient(135deg, #5a9cf8, #3a6fd0); }
.pc-avatar.av2 { background: linear-gradient(135deg, #f0ab4a, #d07f2a); }
.pc-avatar.av3 { background: linear-gradient(135deg, #e06c75, #b03f4c); }
.pc-avatar.av4 { background: linear-gradient(135deg, #9b7ff0, #6f4fd0); }
.pc-avatar.av5 { background: linear-gradient(135deg, #4ec9c0, #2a918a); }

.pc-info { min-width: 0; }

.pc-line { display: flex; align-items: baseline; gap: 7px; }

.pc-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.pc-rating { color: var(--muted); font-size: 13px; }

.pc-caps {
  display: flex;
  align-items: center;
  height: 17px;
  font-size: 16px;
  line-height: 1;
  margin-top: 2px;
  font-family: "Segoe UI Symbol", "Segoe UI Historic", "Arial Unicode MS", sans-serif;
}

.pc-caps .cap-p { margin-right: -5px; }
.pc-caps .piece-b { color: #171513; -webkit-text-stroke: 0.8px rgba(232, 230, 226, 0.55); }
.pc-caps .piece-w { -webkit-text-stroke: 0.9px #4b453f; }
.pc-caps .adv { color: var(--muted); font-size: 13px; font-weight: 700; margin-left: 8px; font-family: "Segoe UI", sans-serif; }

.piece-w { color: #f9f9f7; -webkit-text-stroke: 1.1px #4b453f; }
.piece-b { color: #34302d; }

.pc-clock {
  margin-left: auto;
  background: var(--panel);
  color: var(--muted);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 3px 11px;
  border-radius: 6px;
  min-width: 96px;
  text-align: center;
  letter-spacing: 0.5px;
}
.pc-clock.active { background: var(--green); color: #fff; }
.pc-clock.low { background: var(--red); color: #fff; }
.pc-clock.off { opacity: 0.55; }
.pc-clock.long { font-size: 14px; min-width: 126px; }

/* board */

.board-wrap {
  position: relative;
  line-height: 0;
}

.board {
  position: relative;
  width: var(--bs);
  height: var(--bs);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.45);
  touch-action: none;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sq { position: absolute; width: 12.5%; height: 12.5%; }
.sq.light { background: var(--light-sq); }
.sq.dark { background: var(--dark-sq); }

/* highlights */
.hl { position: absolute; width: 12.5%; height: 12.5%; }
.hl-last, .hl-sel { background: rgba(255, 255, 105, 0.44); }
.hl-check {
  background: radial-gradient(circle, rgba(255, 70, 55, 0.95) 0%, rgba(235, 45, 35, 0.72) 30%, rgba(169, 0, 0, 0) 89%);
}
.hint {
  position: absolute;
  width: 3.75%;
  height: 3.75%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.14);
}
.hint.cap {
  width: 100%;
  height: 100%;
  background: transparent;
  border: max(4px, calc(var(--bs) * 0.015)) solid rgba(0, 0, 0, 0.16);
}

/* chess.com-style annotation arrows: a right-drag draws one (orange by
   default; Ctrl = red, Alt = blue, Shift = green - the fill is set per
   arrow in js/ui.js), a right-click marks a square, a left press clears
   everything. The SVG uses an 8x8 viewBox so one unit is one square. */
#arrowLayer svg { position: absolute; inset: 0; width: 100%; height: 100%; }
#arrowLayer path {
  fill: rgba(255, 153, 0, 0.85);
  stroke: rgba(0, 0, 0, 0.25);
  stroke-width: 0.025;
  stroke-linejoin: round;
}
#arrowLayer rect { fill: rgba(255, 153, 0, 0.6); }

/* coordinates */
.coord {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  font-size: calc(var(--bs) * 0.026);
  font-weight: 700;
  padding: 2px 3px;
}
.coord.file { align-items: flex-end; justify-content: flex-end; padding: 0 4px 6px 0; }
.coord.rank { align-items: flex-start; justify-content: flex-start; padding: 6px 0 0 4px; }
.coord.on-light { color: var(--dark-sq); }
.coord.on-dark { color: var(--light-sq); }

/* pieces */
.piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, 0.32));
  will-change: left, top;
}
.piece-image { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; filter: var(--set-filter, none); transition: filter 0.25s ease; }
.piece.moving { transition: left 0.16s ease-out, top 0.16s ease-out; }
.piece.dragging {
  transition: none;
  z-index: 30;
  cursor: grabbing;
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.45));
}
.piece.fading { transition: opacity 0.15s; opacity: 0; }

/* promotion picker */
.promo { position: absolute; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.35); }
.promo-col {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.5);
  line-height: 0;
}
.promo-opt {
  width: calc(var(--bs) * 0.125);
  height: calc(var(--bs) * 0.125);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: #fff;
  border: none;
}
.promo-opt:hover { background: #dfe3d4; }
.promo-opt img { width: 88%; height: 88%; object-fit: contain; pointer-events: none; }

/* action bar */
.action-bar {
  width: var(--bs);
  display: flex;
  gap: 8px;
}

.action-btn {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 7px 6px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.action-btn:hover { background: #2e2b28; color: #fff; }
.action-btn.danger:hover { color: var(--red-soft); border-color: #5a322d; }
.action-btn:disabled { opacity: 0.4; cursor: default; }
.action-btn:disabled:hover { background: var(--panel); color: var(--muted); }

/* ---------------------------------------------------- sidebar */

.sidebar {
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.side-head {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.side-title {
  font-weight: 700;
  font-size: 15px;
}

.side-status {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.side-status.turn { color: var(--green); font-weight: 700; }
.side-status.check { color: var(--red-soft); font-weight: 700; }

.moves {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px 0;
}

.moves-empty {
  color: var(--dim);
  font-size: 13px;
  text-align: center;
  padding: 26px 16px;
}

.move-row {
  display: grid;
  grid-template-columns: 46px 1fr 1fr;
  align-items: center;
  padding: 1px 14px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  min-height: 28px;
}

.move-num { color: var(--dim); font-size: 13px; }

.move-cell {
  color: #d8d4d0;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  width: fit-content;
  min-width: 54px;
}
.move-cell.cur { background: rgba(129, 182, 76, 0.30); color: #fff; }
.move-cell.empty { background: transparent; }

/* chat */
.chat {
  border-top: 1px solid var(--border);
  height: 152px;
  flex: 0 0 152px;
  display: flex;
  flex-direction: column;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 13px;
  font-size: 13px;
  user-select: text;
}

.chat-msg { margin-bottom: 5px; line-height: 1.35; word-wrap: break-word; }
.chat-msg .who { font-weight: 700; }
.chat-msg .who.me { color: var(--green); }
.chat-msg .who.them { color: #7cb3f5; }
.chat-msg .txt { color: #d8d4d0; }
.chat-msg.system { color: var(--dim); font-style: italic; }

.chat-form {
  display: flex;
  gap: 8px;
  padding: 9px 12px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--border-2);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.chat-form input:focus { border-color: var(--green); }

.chat-form button {
  width: 36px;
  background: var(--green);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.chat-form button:hover { background: var(--green-hover); }

/* ping */
.ping-pill {
  font-size: 12px;
  color: var(--muted);
  background: var(--input-bg);
  border: 1px solid var(--border-2);
  padding: 3px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.ping-pill.ok { color: var(--green); border-color: rgba(129, 182, 76, 0.4); }
.ping-pill.warn { color: #f0c04a; border-color: rgba(240, 192, 74, 0.4); }
.ping-pill.bad { color: var(--red-soft); border-color: rgba(211, 76, 61, 0.5); }

/* ---------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s ease-out;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: 14px;
  padding: 26px;
  width: 370px;
  max-width: 92%;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: pop 0.18s ease-out;
}

.modal h3 { font-size: 23px; font-weight: 800; }
.modal p { color: var(--muted); font-size: 14px; margin-top: 8px; margin-bottom: 20px; line-height: 1.45; }

.result-glyph {
  font-size: 52px;
  line-height: 1;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
  margin-bottom: 12px;
}
.result-glyph.win { color: var(--green); }
.result-glyph.lose { color: var(--red); }
.result-glyph.draw { color: var(--muted); }

.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; padding: 11px; font-size: 14px; }

/* ---------------------------------------------------- toast */

.toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  background: #1b1a18;
  border: 1px solid var(--border-2);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 120;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  animation: slideDown 0.2s ease-out;
  pointer-events: none;
}

/* ---------------------------------------------------- animations */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: scale(1); } }
@keyframes slideDown { from { opacity: 0; transform: translate(-50%, -12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------------------------------------------- beginner piece lessons */
.lesson-modal { width: min(720px, 92vw); text-align: left; }
.modal:has(.lesson-modal) { width: min(720px, 94vw); max-height: 92vh; overflow-y: auto; }
.lesson-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.lesson-kicker { color: var(--green); font-size: 11px; letter-spacing: 1.5px; font-weight: 800; margin-bottom: 5px; }
.lesson-heading h3 { font-size: 25px; }
.lesson-close { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 28px; line-height: 1; }
.lesson-close:hover { color: #fff; }
.lesson-intro { margin: 6px 0 15px !important; }
.lesson-tabs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-bottom: 18px; }
.lesson-tab { min-width: 0; border: 1px solid var(--border-2); border-radius: 8px; background: var(--panel-2); color: var(--muted); cursor: pointer; padding: 7px 3px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 22px; }
.lesson-tab span { font-size: 11px; }
.lesson-tab.active { border-color: var(--green); color: #fff; background: rgba(129,182,76,.15); }
.lesson-content { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 24px; align-items: center; }
.lesson-board { display: grid; grid-template-columns: repeat(7, 1fr); aspect-ratio: 1; border-radius: 5px; overflow: hidden; box-shadow: 0 6px 18px #0005; }
.lesson-square { display: grid; place-items: center; font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif; font-size: clamp(18px, 5vw, 34px); }
.lesson-square.light { background: var(--light-sq); color: #fff; }
.lesson-square.dark { background: var(--dark-sq); color: #fff; }
.lesson-square.target.move { background: #a6cf70; }
.lesson-square.target.capture { background: #e2b548; }
.lesson-square.occupied span { filter: drop-shadow(0 2px 1px #3338); }
.lesson-copy { align-self: center; }
.lesson-piece-icon { color: #fff; font: 42px/1 "Segoe UI Symbol", "Arial Unicode MS", sans-serif; }
.lesson-copy h4 { font-size: 22px; margin: 6px 0; }
.lesson-copy > p { margin: 0 0 14px !important; }
.lesson-tip { background: var(--panel-2); border-left: 3px solid var(--green); border-radius: 4px; padding: 11px 13px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.lesson-tip b { color: var(--green-hover); }
.lesson-tip p { margin: 4px 0 0; }
.lesson-footer { border-top: 1px solid var(--border-2); padding-top: 14px; margin-top: 18px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
.lesson-actions { display: flex; gap: 8px; }
.lesson-actions .btn { width: auto; padding: 9px 14px; font-size: 13px; }
.lesson-actions .btn:disabled { opacity: .4; cursor: default; }
@media (max-width: 600px) {
  .lesson-content { grid-template-columns: minmax(130px, 1fr) 1fr; gap: 14px; }
  .lesson-tabs { gap: 4px; }
  .lesson-tab { font-size: 19px; }
  .lesson-tab span { font-size: 10px; }
  .lesson-copy h4 { font-size: 19px; }
  .lesson-tip { padding: 8px; font-size: 12px; }
}
/* ---------------------------------------------------- trainer choices */
.coach-picker-wrap { margin: 0 0 15px; }
.coach-picker-label { color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 7px; }
.coach-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.coach-option { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 8px 10px; text-align: left; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 8px; color: var(--text); cursor: pointer; }
.coach-option:hover { border-color: #77736e; }
.coach-option.active { border-color: var(--green); background: rgba(129,182,76,.13); box-shadow: inset 0 0 0 1px rgba(129,182,76,.2); }
.coach-avatar { width: 32px; height: 32px; flex: 0 0 32px; display: grid; place-items: center; border-radius: 50%; background: #3c3935; color: var(--green-hover); font: 21px/1 "Segoe UI Symbol", "Arial Unicode MS", sans-serif; }
.coach-option-copy { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.coach-option-copy b { font-size: 13px; }
.coach-option-copy small { color: var(--muted); font-size: 10px; white-space: nowrap; }
@media (max-width: 600px) {
  .coach-picker { gap: 5px; }
  .coach-option { padding: 7px 5px; gap: 5px; }
  .coach-avatar { width: 27px; height: 27px; flex-basis: 27px; font-size: 18px; }
  .coach-option-copy b { font-size: 12px; }
  .coach-option-copy small { font-size: 9px; white-space: normal; }
}
.practice-coach-name { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; padding: 4px 9px; border: 1px dashed var(--border-2); border-radius: 14px; background: var(--panel-2); color: var(--green-hover); font-family: inherit; font-size: 12px; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.practice-coach-name:hover { border-color: var(--green); background: rgba(129, 182, 76, 0.12); }
.practice-coach-name:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.practice-coach-name b { color: var(--text); }
.account-screen { background: radial-gradient(900px 500px at 50% 10%, rgba(129,182,76,.12), transparent 70%), var(--bg); }
.account-main { flex: 1; display: grid; place-items: center; overflow-y: auto; padding: 28px 18px; }
.account-card { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; padding: 30px; box-shadow: 0 14px 40px #0005; }
.account-kicker { color: var(--green); font-size: 11px; letter-spacing: 1.5px; font-weight: 800; }
.account-card h1 { font-size: 29px; margin-top: 6px; }
.account-intro { color: var(--muted); line-height: 1.45; margin: 8px 0 18px; }
.avatar-preview { width: 76px; height: 76px; flex: 0 0 76px; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: #3c3935; color: #fff; font: 42px/1 "Segoe UI Symbol", "Arial Unicode MS", sans-serif; border: 2px solid var(--green); }
.avatar-preview.large { width: 92px; height: 92px; margin: 0 auto 18px; font-size: 50px; }
.avatar-preview img, .profile-button-avatar img, .pc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.default-pawn-avatar { filter: grayscale(1); }
.custom-profile-avatar { filter: none; }
.account-name-field { margin-bottom: 16px; }
.profile-label { color: var(--muted); font-size: 13px; font-weight: 700; margin: 12px 0 8px; }
.avatar-picker { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.avatar-choice { aspect-ratio: 1; border: 1px solid var(--border-2); border-radius: 50%; background: var(--panel-2); color: #fff; font: 24px/1 "Segoe UI Symbol", "Arial Unicode MS", sans-serif; cursor: pointer; }
.avatar-choice:hover { border-color: #77736e; }
.avatar-choice.active { border: 2px solid var(--green); background: rgba(129,182,76,.2); }
.upload-picture { display: block; color: var(--muted); font-size: 12px; margin: 12px 0 16px; cursor: pointer; }
.upload-picture input { display: block; max-width: 100%; margin-top: 6px; color: var(--muted); font-size: 12px; }
.account-local-note { margin-top: 14px; text-align: center; color: var(--dim); font-size: 11px; }
.profile-button { display: inline-flex; align-items: center; gap: 8px; max-width: 180px; border: 1px solid var(--border-2); border-radius: 22px; padding: 4px 11px 4px 4px; background: transparent; color: #fff; cursor: pointer; font-weight: 700; font-size: 13px; }
.profile-button:hover { background: #34312e; border-color: #55514c; }
.profile-button-avatar { width: 29px; height: 29px; display: grid; place-items: center; overflow: hidden; border-radius: 50%; background: #3c3935; color: #fff; font: 17px/1 "Segoe UI Symbol", "Arial Unicode MS", sans-serif; }
.profile-button-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-choice img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; filter: grayscale(1); }
.profile-modal { text-align: left; }
.modal:has(.profile-modal) { width: min(760px, 94vw); max-height: 90vh; overflow-y: auto; text-align: left; }
.profile-modal-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
/* Black cards so the light rating text always stays readable. */
.profile-rating { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; background: #000; color: var(--text); border: 1px solid var(--border-2); border-radius: 12px; padding: 11px 15px; margin-bottom: 10px; }
.profile-rating-label { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.profile-rating-value { font-size: 27px; line-height: 1; font-variant-numeric: tabular-nums; color: #fff; }
.profile-rating-unit { font-size: 13px; font-weight: 700; color: var(--muted); }
.profile-rating-note { margin-left: auto; font-size: 12.5px; color: var(--muted); }
/* One row per game mode: Bullet, Blitz, Rapid, Daily. */
.profile-modes { display: grid; gap: 6px; margin-bottom: 16px; }
.profile-mode-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto minmax(0, auto); align-items: baseline; gap: 8px; background: #000; color: var(--text); border: 1px solid var(--border-2); border-radius: 9px; padding: 8px 13px; }
.profile-mode-name { font-size: 13px; font-weight: 700; color: var(--text); }
.profile-mode-rating { font-size: 17px; font-variant-numeric: tabular-nums; color: #fff; }
.profile-mode-unit { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.profile-mode-games { justify-self: end; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.profile-modal-heading h3 { margin-top: 4px; }
.profile-edit-row { display: flex; gap: 18px; align-items: center; }
.profile-edit-fields { flex: 1; min-width: 0; }
.profile-edit-fields .field { margin-bottom: 8px; }
.profile-edit-fields .field input { margin-top: 5px; }
.avatar-picker.compact { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.avatar-picker.compact .avatar-choice { font-size: 19px; }
.profile-save { margin-top: 14px; }
.profile-history { border-top: 1px solid var(--border-2); margin-top: 22px; padding-top: 15px; }
.profile-history-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.profile-history-heading h4 { font-size: 17px; }
.profile-history-heading span { color: var(--muted); font-size: 12px; }
.profile-match-list { display: flex; flex-direction: column; gap: 7px; max-height: 290px; overflow-y: auto; }
.history-row { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; background: var(--panel-2); }
.history-result { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.history-result.won { color: var(--green-hover); }
.history-result.lost { color: var(--red-soft); }
.history-result.draw { color: #f0c04a; }
.history-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.history-main b { font-size: 13px; }
.history-main span, .history-date { color: var(--muted); font-size: 11px; }
.history-date { text-align: right; }
.history-empty { padding: 24px 12px; text-align: center; color: var(--muted); background: var(--panel-2); border-radius: 8px; font-size: 13px; }
.shop-coins, .shop-open-btn { border: 1px solid var(--border-2); border-radius: 20px; padding: 7px 12px; background: var(--panel-2); color: var(--text); font-weight: 800; cursor: pointer; white-space: nowrap; }
.shop-coins span { color: #f4c542; font-size: 15px; text-shadow: 0 0 7px #f4c54266; }
.shop-coins:hover, .shop-open-btn:hover { border-color: var(--green); background: #34312e; }
.shop-open-btn { background: var(--green); color: #17200f; border-color: var(--green); }
.shop-open-btn:hover { background: var(--green-hover); color: #17200f; }

/* Copy URL button (top-right): sends this site's link to a friend */
.share-link-btn {
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 7px 12px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.share-link-btn:hover { border-color: var(--green); background: #34312e; }
.share-link-btn:active { transform: translateY(1px); }
.modal:has(.shop-modal) { width: min(720px, 94vw); max-height: 90vh; overflow-y: auto; text-align: left; }
.shop-modal .profile-modal-heading { margin-bottom: 8px; }
.shop-intro { color: var(--muted); margin: 0 0 15px; line-height: 1.45; }
.shop-intro b { color: #f4c542; }

/* Section heading that splits the piece list into its two groups */
.shop-group-head { margin: 18px 0 9px; padding-top: 14px; border-top: 1px solid var(--border-2); display: flex; flex-direction: column; gap: 3px; }
.shop-group-head:first-child { margin-top: 4px; padding-top: 0; border-top: 0; }
.shop-group-head b { font-size: 13px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--green); }
.shop-group-head span { font-size: 12px; color: var(--muted); line-height: 1.4; }
.shop-items { display: grid; gap: 9px; }
.shop-item { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 13px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 10px; padding: 10px; }
.shop-board-preview { display: grid; grid-template-columns: repeat(4, 1fr); width: 58px; height: 58px; border-radius: 5px; overflow: hidden; }
.shop-board-preview i { display: block; background: var(--preview-dark); }
.shop-board-preview i:nth-child(8n+1), .shop-board-preview i:nth-child(8n+3), .shop-board-preview i:nth-child(8n+6), .shop-board-preview i:nth-child(8n+8) { background: var(--preview-light); }
.shop-item-copy { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
.shop-item-copy b { font-size: 14px; }
.shop-item-copy span { color: var(--muted); font-size: 12px; }
.shop-item-copy small { color: #f4c542; font-size: 11px; }
.shop-item-action { width: auto; min-width: 112px; padding: 9px 12px; font-size: 12px; }
.shop-local-note { margin-top: 13px; color: var(--dim); text-align: center; font-size: 11px; }

/* ---- shop categories (boards / pieces) ---- */
.shop-tabs { display: flex; gap: 8px; margin: 0 0 13px; }
.shop-tabs .btn { width: auto; flex: 1; padding: 10px 8px; font-size: 13px; }
.shop-tabs .btn.active { background: var(--green); border-color: var(--green); color: #17200f; }
.shop-piece-preview { display: grid; grid-template-columns: repeat(2, 1fr); width: 58px; height: 58px; border-radius: 5px; overflow: hidden; }
.shop-piece-preview i { position: relative; display: block; }
.shop-piece-preview i:nth-child(1), .shop-piece-preview i:nth-child(4) { background: var(--preview-light, #eeeed2); }
.shop-piece-preview i:nth-child(2), .shop-piece-preview i:nth-child(3) { background: var(--preview-dark, #769656); }
.shop-piece-preview img { width: 100%; height: 100%; object-fit: contain; padding: 5%; pointer-events: none; user-select: none; filter: var(--set-filter, none); }
.shop-owner-line, .shop-owner-badge { display: flex; align-items: center; gap: 10px; margin-top: 13px; padding: 10px 12px; border: 1px dashed var(--border-2); border-radius: 9px; background: var(--panel-2); color: var(--muted); font-size: 12px; }
.shop-owner-line span, .shop-owner-badge span { flex: 1; min-width: 0; }
.shop-owner-badge { border-style: solid; border-color: rgba(129, 182, 76, 0.45); background: rgba(129, 182, 76, 0.12); }
.shop-owner-badge b { color: var(--green-hover); font-size: 12px; white-space: nowrap; }
.shop-owner-badge span { color: var(--text); }
.shop-owner-btn { width: auto; white-space: nowrap; padding: 7px 11px; font-size: 11px; }

/* ---- piece set looks: shapes and colors are baked into the SVG pieces by
   js/piece-art.js, so filters only add glow/shadow effects ---- */
:is([data-piece-set="classic"], .set-classic) { --set-filter: none; }
:is([data-piece-set="custom"], .set-custom) { --set-filter: none; }
:is([data-piece-set="glass"], .set-glass) { --set-filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.55)); }
:is([data-piece-set="spaces"], .set-spaces) { --set-filter: drop-shadow(0 0 4px rgba(120, 160, 255, 0.6)); }
:is([data-piece-set="king-queen"], .set-kingqueen) { --set-filter: drop-shadow(0 0 3px rgba(244, 197, 66, 0.55)); }
:is([data-piece-set="sunrise"], .set-sunrise) { --set-filter: drop-shadow(0 0 4px rgba(255, 140, 60, 0.5)); }
:is([data-piece-set="neon"], .set-neon) { --set-filter: drop-shadow(0 0 6px rgba(60, 255, 160, 0.8)); }
:is([data-piece-set="shiny"], .set-shiny) { --set-filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.6)); }
:is([data-piece-set="gold"], .set-gold) { --set-filter: drop-shadow(0 0 3px rgba(255, 214, 92, 0.55)); }
:is([data-piece-set="ice"], .set-ice) { --set-filter: drop-shadow(0 0 5px rgba(140, 220, 255, 0.7)); }
:is([data-piece-set="inferno"], .set-inferno) { --set-filter: drop-shadow(0 0 6px rgba(255, 90, 40, 0.7)); }
:is([data-piece-set="royal"], .set-royal) { --set-filter: drop-shadow(0 0 4px rgba(90, 110, 255, 0.55)); }
:is([data-piece-set="light"], .set-light) { --set-filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.65)); }
:is([data-piece-set="sky"], .set-sky) { --set-filter: drop-shadow(0 0 5px rgba(130, 200, 255, 0.7)); }
:is([data-piece-set="dash"], .set-dash) { --set-filter: drop-shadow(0 0 4px rgba(255, 90, 60, 0.5)); }
:is([data-piece-set="cartoon"], .set-cartoon) { --set-filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.45)); }
.modal:has(.community-modal) { width: min(680px, 94vw); max-height: 90vh; overflow-y: auto; text-align: left; }
.community-modal .profile-modal-heading { margin-bottom: 8px; }
.community-note, .community-source { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 8px 0 14px; }
.community-source { border-top: 1px solid var(--border-2); padding-top: 10px; font-size: 11px; }
.community-source a, .community-friend-row a, .community-ranking-row a { color: var(--green-hover); }
.community-add-form { display: flex; gap: 12px; align-items: end; }
.community-add-form .field { flex: 1; margin: 0; }
.community-add-form .btn, .community-external-link { width: auto; white-space: nowrap; }
.community-external-link { display: inline-flex; text-decoration: none; }
.community-list { display: grid; gap: 7px; margin-top: 13px; }
.community-ranking-list { display: grid; gap: 7px; }
.community-empty { color: var(--dim); background: var(--panel-2); border-radius: 8px; padding: 14px; text-align: center; }
.community-friend-row, .community-ranking-row, .community-coach-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 8px; padding: 9px 11px; }
.community-friend-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.community-friend-rating { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.community-remove { width: auto; padding: 6px 10px; }
.community-ranking-row a { overflow: hidden; text-overflow: ellipsis; }
.community-rank { color: var(--dim); font-weight: 800; }
.community-ranking-row b { color: #f4c542; text-align: right; white-space: nowrap; }
.community-coach-row { grid-template-columns: 1fr; gap: 3px; }
.community-coach-row span { color: var(--muted); font-size: 12px; }
.community-join-form { margin-top: 10px; }
.community-code-result { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 9px; padding: 12px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.community-code-result .room-code { color: var(--green-hover); font-size: 21px; letter-spacing: 3px; }
.community-subheading { margin-top: 20px; font-size: 16px; }
.community-club-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; background: var(--panel-2); border-radius: 8px; padding: 10px 12px; }
.community-club-row span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.community-streamer-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; background: var(--panel-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.community-streamer-row a { color: var(--green-hover); }
.community-streamer-row button { width: auto; padding: 7px 10px; font-size: 11px; }
.community-friend-name, .community-ranking-name { overflow: hidden; text-overflow: ellipsis; }
.community-event-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; background: var(--panel-2); border-radius: 8px; padding: 11px 12px; }
.community-event-details { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.community-event-details span { color: var(--muted); font-size: 12px; }
.community-event-row .btn { width: auto; white-space: nowrap; }
.watch-video-shell { width: 100%; aspect-ratio: 16/9; min-height: 220px; overflow: hidden; border-radius: 10px; background: #111; display: grid; place-items: center; }
.watch-video-shell iframe { width: 100%; height: 100%; min-height: 250px; border: 0; }
.watch-game-view { margin-top: 14px; }
.watch-live-label { color: var(--green-hover); font-weight: 800; margin-bottom: 10px; }
.watch-board { display: grid; grid-template-columns: repeat(8, 1fr); width: min(460px, 100%); aspect-ratio: 1; border-radius: 5px; overflow: hidden; margin: auto; }
.watch-square { display: grid; place-items: center; }
.watch-square.light { background: var(--light-sq); }
.watch-square.dark { background: var(--dark-sq); }
.watch-square span { font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif; font-size: clamp(20px, 6vw, 48px); line-height: 1; }
.watch-cards .community-card { min-height: 220px; }
.community-tabs { display: flex; gap: 8px; margin: 12px 0; }
.community-tabs .btn { width: auto; flex: 1; padding: 9px 8px; }
.community-tabs .btn.active { background: var(--green); border-color: var(--green); color: #17200f; }
.community-board-select { max-width: 260px; margin-bottom: 10px; }
@media (max-width: 560px) {
  .account-card { padding: 22px; }
  .avatar-picker.compact { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .history-row { grid-template-columns: 48px 1fr; }
  .history-date { grid-column: 2; text-align: left; }
  .profile-button { max-width: 128px; padding-right: 8px; font-size: 12px; }
  .topbar-right { gap: 5px; }
  .community-add-form { align-items: stretch; flex-direction: column; }
  .community-add-form .btn { width: 100%; }
  .community-streamer-row { grid-template-columns: 1fr auto; }
  .community-tabs { gap: 4px; }
  .community-tabs .btn { font-size: 11px; padding: 8px 4px; }
  .shop-coins, .shop-open-btn { padding: 6px 8px; font-size: 11px; }
  .share-link-btn { padding: 6px 8px; font-size: 10px; }
  .shop-item { grid-template-columns: 48px minmax(0, 1fr); gap: 9px; }
  .shop-board-preview { width: 46px; height: 46px; }
  .shop-piece-preview { width: 46px; height: 46px; }
  .shop-item-action { grid-column: 2; justify-self: start; }
  .shop-owner-line, .shop-owner-badge { flex-wrap: wrap; }
}
.trainer-setup-main { flex: 1; display: grid; place-items: center; overflow-y: auto; padding: 28px 18px; }
.trainer-setup-card { width: min(840px, 100%); background: var(--panel); border: 1px solid var(--border-2); border-radius: 14px; padding: 30px; box-shadow: 0 14px 40px #0005; }
.trainer-setup-card h1 { font-size: 29px; margin-top: 6px; }
.trainer-setup-card > .account-intro { max-width: 560px; }
.trainer-setup-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 22px 0; }
.trainer-setup-option { min-height: 190px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 7px; padding: 17px; border: 1px solid var(--border-2); border-radius: 11px; background: var(--panel-2); color: var(--text); cursor: pointer; }
.trainer-setup-option:hover { border-color: #77736e; transform: translateY(-1px); }
.trainer-setup-option.active { border-color: var(--green); background: rgba(129,182,76,.14); box-shadow: inset 0 0 0 1px rgba(129,182,76,.22); }
.trainer-setup-glyph { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: #3c3935; color: var(--green-hover); font: 29px/1 "Segoe UI Symbol", "Arial Unicode MS", sans-serif; margin-bottom: 3px; }
.trainer-setup-option b { font-size: 17px; }
.trainer-setup-option small { color: var(--green-hover); font-size: 12px; }
.trainer-setup-blurb { color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: 3px; }
.trainer-setup-card > .btn { max-width: 360px; }
@media (max-width: 620px) {
  .trainer-setup-card { padding: 22px; }
  .trainer-setup-options { grid-template-columns: 1fr; gap: 8px; margin: 16px 0; }
  .trainer-setup-option { min-height: 0; display: grid; grid-template-columns: 42px 1fr; gap: 2px 10px; padding: 10px; }
  .trainer-setup-glyph { width: 42px; height: 42px; grid-row: span 3; margin: 0; }
  .trainer-setup-blurb { margin: 0; }
}
/* Larger coach roster */
.coach-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.coach-option { padding: 6px 7px; gap: 6px; }
.coach-avatar { width: 30px; height: 30px; flex-basis: 30px; font-family: "Segoe UI", Roboto, sans-serif; font-size: 11px; font-weight: 800; }
.coach-option-copy b { font-size: 12px; line-height: 1.2; }
.coach-option-copy small { font-size: 9px; line-height: 1.2; }
.trainer-setup-card { max-height: calc(100vh - 90px); overflow-y: auto; }
.trainer-setup-options { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.trainer-setup-option { min-height: 128px; padding: 11px; gap: 5px; }
.trainer-setup-glyph { width: 38px; height: 38px; font-family: "Segoe UI", Roboto, sans-serif; font-size: 13px; font-weight: 800; }
.trainer-setup-option b { font-size: 14px; }
.trainer-setup-option small { font-size: 10px; }
.trainer-setup-blurb { font-size: 11px; line-height: 1.3; }
@media (max-width: 620px) {
  .trainer-setup-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .trainer-setup-option { min-height: 120px; display: flex; align-items: flex-start; padding: 10px; gap: 4px; }
  .trainer-setup-glyph { width: 34px; height: 34px; flex-basis: 34px; margin: 0 0 2px; }
  .coach-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .coach-option-copy small { white-space: normal; }
}
.copy-room-btn { width: auto; margin: 10px auto 0; padding: 7px 16px; font-size: 12px; }
.room-box { text-align: center; }

/* Club member list: name, rating, and an Add friend button. */
.community-member-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.community-member-rating { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Rating line under the result of a rated game. */
.result-rating { margin: 4px 0 10px; color: var(--muted); font-size: 14px; }
.result-rating b { color: var(--text); }

.modal-actions { flex-wrap: wrap; }

