:root {
  --light: #e9edf2;
  --dark: #6f8bab;
  --sel: #f6d36b;
  --tgt: rgba(40, 180, 99, 0.55);
  --hang: #e5484d;
  --panel: #17203200;
  --card: #16203400;
  --line: #2a3a58;
  --accent: #9fc0ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0f1420;
  color: #e7ecf3;
  display: flex;
  justify-content: center;
}

main {
  padding: 24px;
  max-width: 920px;
  width: 100%;
}

header h1 {
  margin: 0 0 2px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tag {
  font-size: 0.5em;
  vertical-align: middle;
  background: #22314a;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--accent);
}

.tagline {
  margin: 0 0 14px;
  color: #8ea0b8;
  font-style: italic;
}

.ratings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.ratings label {
  font-size: 0.9em;
  color: #b9c6da;
}

input,
button,
select {
  background: #22314a;
  color: #e7ecf3;
  border: 1px solid #35507a;
  border-radius: 6px;
  padding: 6px 10px;
  font: inherit;
}
input {
  width: 76px;
}
button {
  cursor: pointer;
}

.status {
  margin: 8px 0 14px;
  font-weight: 600;
  min-height: 1.4em;
}

.layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  flex: 1 1 380px;
  max-width: 480px;
  min-width: 300px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.sq {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}
.sq.light {
  background: var(--light);
}
.sq.dark {
  background: var(--dark);
}
.sq.selected {
  box-shadow: inset 0 0 0 4px var(--sel);
}
.sq.hanging {
  box-shadow: inset 0 0 0 4px var(--hang);
}
.sq.target::after {
  content: "";
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--tgt);
  z-index: 2;
}
.sq.lastmove::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(246, 211, 107, 0.38);
  pointer-events: none;
}

/* Coordinate labels tucked into the edge squares. */
.coord {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.9;
}
.coord.file {
  right: 3px;
  bottom: 1px;
}
.coord.rank {
  left: 3px;
  top: 1px;
}
.sq.light .coord {
  color: #4a5b76;
}
.sq.dark .coord {
  color: #eaf0f8;
}

.piece {
  font-size: clamp(26px, 7.5vw, 50px);
  line-height: 1;
  position: relative;
  z-index: 1;
  /* Render chess glyphs as text (respecting color), never as color emoji. */
  font-variant-emoji: text;
}
/* Solid glyphs for both colors, distinguished by fill + outline so pieces
   stay crisp on light and dark squares alike. */
.piece.white {
  color: #f7fafc;
  -webkit-text-stroke: 1.4px #263042;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.piece.black {
  color: #121722;
  -webkit-text-stroke: 1.2px rgba(233, 237, 242, 0.55);
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.12);
}

.panels {
  flex: 1 1 300px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 1em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  font-size: 0.72em;
  text-transform: capitalize;
  background: #23406e;
  color: var(--accent);
  padding: 2px 9px;
  border-radius: 999px;
}

.hint {
  font-size: 0.72em;
  font-weight: 400;
  color: #7f92ab;
}

.assist,
.glass {
  font-size: 0.9em;
  color: #cdd8e8;
}

.assist .warn {
  color: var(--hang);
  font-weight: 600;
}
.assist .msg {
  margin: 3px 0;
  color: #b9c6da;
}
.assist .cand {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  margin: 4px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  background: #14203699;
}
.assist .cand:hover {
  border-color: var(--accent);
}
.assist .cand.rec {
  border-color: #2fa96b;
}
.assist .cand .score {
  color: #8ea0b8;
  font-variant-numeric: tabular-nums;
}
.assist .none {
  color: #7f92ab;
  font-style: italic;
}

.glass .ev {
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
  color: #b9c6da;
}
.glass .ev:last-child {
  border-bottom: none;
}
.glass .ev .who {
  color: var(--accent);
  text-transform: capitalize;
}
.glass .none {
  color: #7f92ab;
  font-style: italic;
}

.foot {
  margin-top: 18px;
  color: #7f92ab;
  font-size: 0.88em;
  line-height: 1.5;
}

/* 2-player role picker */
.role-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #b9c6da;
  font-size: 0.9em;
}
.role {
  padding: 5px 12px;
}
.role.active {
  background: #2fa96b;
  border-color: #2fa96b;
  color: #06210f;
  font-weight: 700;
}

/* invite match-card (context when arriving from a shared link) */
.match-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  margin-bottom: 16px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
}
.mc-eyebrow { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.16em; color: var(--accent); font-weight: 650; }
.mc-title { margin: 9px 0 4px; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.mc-sub { color: #8ea0b8; font-size: 0.92rem; margin-bottom: 18px; max-width: 60ch; }
.mc-controls { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.mc-field { font-size: 0.78rem; color: #b9c6da; display: flex; flex-direction: column; gap: 7px; }
.mc-field input { width: 120px; }
.mc-handi { margin-top: 14px; font-size: 0.92rem; color: #b9c6da; line-height: 1.55; }
.mc-handi b { color: #e7ecf3; font-weight: 600; }
.mc-join {
  margin-left: auto; border: 0; border-radius: 11px; padding: 12px 22px; font-weight: 650; font-size: 0.96rem;
  color: #06121a; background: linear-gradient(140deg, #9fd0ff, #6aa8e6); cursor: pointer; transition: filter 0.15s, transform 0.14s;
}
.mc-join:hover { filter: brightness(1.07); transform: translateY(-1px); }
.mc-adv { margin-top: 16px; }
.mc-adv summary { cursor: pointer; color: #7f92ab; font-size: 0.82rem; list-style: revert; }
.mc-adv label { display: inline-flex; gap: 6px; align-items: center; margin: 12px 14px 0 0; font-size: 0.8rem; color: #8ea0b8; }
.mc-adv input { width: 220px; }
.mc-intro { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; font-size: 0.86rem; color: #93a2c0; line-height: 1.55; margin-bottom: 18px; }
.mc-intro b { color: #e7ecf3; font-weight: 600; }
