:root {
  /* Club palette: paper cards on a walnut parlor, brass for labels, felt for the board.
     The company window uses night ink so it sits apart from the tables. */
  --ink: #241c14;
  --paper: #f4ecdf;
  --paper-2: #fff8ee;
  --line: #e0d0b6;
  --brass: #9a7040;
  --brass-bright: #d7b072;
  --felt: #1b5c3c;
  --felt-dark: #10281c;
  --light-sq: #f0d9a6;
  --dark-sq: #b58863;
  --red: #c2452d;
  --good: #1e6a43;
  --bad: #9d2c2c;
  --night: #16110d;
  --night-2: #241c16;
  --cream: #f6efe4;
  --shadow: 0 18px 50px rgba(12, 8, 4, 0.28);
  color: var(--ink);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  background:
    linear-gradient(180deg, rgba(14, 9, 6, 0.72), rgba(10, 7, 5, 0.82)),
    url("/parlor-room.jpg") center / cover no-repeat fixed,
    #14100c;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 560; margin: 0; }

.shell { max-width: 1100px; margin: 0 auto; padding: 28px 20px 64px; }
body.company-open .shell { max-width: calc(100vw - 400px); margin-right: 380px; }
.top {
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-end;
  margin-bottom: 22px;
}
.brand { letter-spacing: 0.04em; font-size: 13px; text-transform: uppercase; color: #f3ddb0; }
.top h1 { font-size: 40px; line-height: 1; color: var(--cream); }
.who { text-align: right; color: var(--cream); }
.who strong { display: block; }
.links { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

.card {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.grid { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }
.stack { display: grid; gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label { display: grid; gap: 4px; font-size: 14px; }
input, select {
  background: white; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.btn {
  background: var(--ink); color: var(--paper); border: 0; border-radius: 999px; padding: 8px 14px;
}
.btn.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.top .btn.secondary, .who .btn.secondary { color: var(--cream); border-color: rgba(246, 239, 228, 0.35); }
.btn.danger { background: var(--bad); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.banner {
  background: #fff4d8; color: var(--ink); border: 1px solid #e6d3a4; padding: 10px 12px; border-radius: 12px; margin-bottom: 12px;
}
.banner.error { background: #fde8e4; border-color: #f0c2ba; }
.list { display: grid; gap: 8px; }
.item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 10px 12px; border-radius: 12px; background: var(--paper); text-decoration: none; color: inherit;
  border: 1px solid transparent;
}
.item:hover { border-color: var(--brass); }
.muted { color: #6d6256; font-size: 14px; }
.pill { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: #6e4e28; }

.layout { display: grid; grid-template-columns: auto 280px; gap: 18px; align-items: start; }
.board-wrap {
  padding: 14px;
  background:
    linear-gradient(rgba(10, 28, 18, 0.45), rgba(10, 28, 18, 0.55)),
    url("/felt-texture.jpg") center / cover;
  border-radius: 18px;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(215, 176, 114, 0.25);
}
.board { display: grid; grid-template-columns: repeat(8, 52px); grid-template-rows: repeat(8, 52px); }
.sq {
  width: 52px; height: 52px; border: 0; padding: 0; display: grid; place-items: center; position: relative;
}
.sq.light { background: var(--light-sq); }
.sq.dark { background: var(--dark-sq); }
.sq.selected { outline: 3px solid #f2e27a; outline-offset: -3px; }
.sq.legal::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%; background: rgba(20, 60, 30, 0.45); position: absolute;
}
.board.aiming .sq.legal {
  box-shadow: inset 0 0 0 3px rgba(242, 226, 122, 0.95);
}
.board.aiming .sq.legal::after {
  width: 22px; height: 22px; background: rgba(242, 226, 122, 0.72);
}
.sq.drag-over {
  box-shadow: inset 0 0 0 3px #fff6c2;
}
.sq.mine { cursor: grab; }
.sq.mine:active { cursor: grabbing; }
.board.checkers { touch-action: none; }
.piece {
  width: 36px; height: 36px; border-radius: 50%; z-index: 1; display: grid; place-items: center;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.25);
}
.piece.lifted {
  position: fixed; z-index: 40; margin: 0; pointer-events: none;
  transform: scale(1.12);
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.4));
}
.piece.red { background: radial-gradient(circle at 35% 35%, #ef7a64, var(--red)); }
.piece.black { background: radial-gradient(circle at 35% 35%, #4a4a4a, #161616); }
.piece.king { box-shadow: inset 0 0 0 3px #f2e27a, inset 0 -4px 0 rgba(0,0,0,0.25); }
.chess-piece { font-size: 34px; line-height: 1; z-index: 1; text-shadow: 0 1px 0 rgba(255,255,255,0.4); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.login-card { max-width: 460px; margin: 8vh auto; }
.password-backup { font-size: 14px; }
.password-backup summary { cursor: pointer; color: #6d6256; }
.password-backup a { color: inherit; }
.history { max-height: 240px; overflow: auto; font-variant-numeric: tabular-nums; }
.shortlink { display: grid; gap: 6px; }
.shortlink input, .chat-link {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.shortlink input { width: 100%; }

.company {
  position: fixed;
  z-index: 30;
  right: 18px;
  top: 18px;
  bottom: 18px;
  width: min(340px, calc(100vw - 36px));
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(36, 28, 22, 0.96), rgba(16, 12, 9, 0.98));
  color: var(--cream);
  border: 1px solid rgba(215, 176, 114, 0.55);
  border-radius: 20px;
  box-shadow: 18px 22px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.company.shut {
  top: auto;
  width: auto;
  height: auto;
  background: transparent;
  border: 0;
  box-shadow: none;
  overflow: visible;
}
.company-tab {
  align-self: flex-end;
  writing-mode: vertical-rl;
  background: var(--night);
  color: #f3ddb0;
  border: 1px solid rgba(215, 176, 114, 0.7);
  border-radius: 14px 0 0 14px;
  padding: 22px 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 14px;
}
.company.shut .company-body { display: none; }
.company:not(.shut) .company-tab { display: none; }
.company-body { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.company-head, .company-block, .company-chat { padding: 14px 14px 0; }
.company-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.company-head h2 { font-size: 28px; color: var(--cream); }
.company .aside { margin: 4px 0 0; color: #f3eadf; font-size: 13px; }
.company .icon {
  background: transparent; color: var(--brass-bright); border: 1px solid rgba(215, 176, 114, 0.45);
  border-radius: 999px; width: 32px; height: 32px;
}
.company-scroll { overflow: auto; display: grid; gap: 12px; padding-bottom: 12px; min-height: 0; }
.company-block h3 { font-size: 16px; color: #f3ddb0; }
.company .muted { color: #f3eadf; }
.company-note { margin: 0; color: #f3ddb0; font-size: 14px; }
.company input, .company select { background: #2a221b; border-color: #4a3b2c; color: var(--cream); }
.company .btn { background: #3a2c1c; color: var(--cream); border: 1px solid #f3ddb0; }
.company .btn.secondary { background: transparent; color: var(--cream); border-color: #4a3b2c; }
.friend {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  width: 100%; text-align: left; background: transparent; border: 1px solid transparent;
  border-radius: 12px; padding: 8px; color: inherit;
}
.friend.active, .friend:hover { border-color: var(--brass); background: rgba(215, 176, 114, 0.08); }
.company .item { background: #2a221b; color: var(--cream); }
.company-chat { display: flex; flex-direction: column; gap: 8px; min-height: 220px; padding-bottom: 14px; }
.thread { overflow: auto; display: grid; gap: 6px; align-content: start; max-height: 180px; min-height: 72px; }
.bubble { background: #2a221b; border-radius: 12px; padding: 8px 10px; font-size: 14px; overflow-wrap: anywhere; }
.bubble.mine { background: #3a2c1c; margin-left: 24px; }
.bubble .who { color: #f3ddb0; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.chat-link { color: #f3ddb0; }
.company-chat form, .challenge-row { display: flex; gap: 8px; }
.company-chat input { flex: 1; }

@media (max-width: 860px) {
  .grid, .layout { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
  .who { text-align: left; }
  .board { grid-template-columns: repeat(8, 40px); grid-template-rows: repeat(8, 40px); }
  .sq { width: 40px; height: 40px; }
  .piece { width: 28px; height: 28px; }
  .chess-piece { font-size: 26px; }
  .company { left: 12px; right: 12px; top: auto; height: min(70vh, 560px); width: auto; }
  .company.shut { left: auto; height: auto; }
  body.company-open { padding-bottom: 0; }
  body.company-open .shell { max-width: none; margin-right: auto; padding-bottom: 72vh; }
}
