/* DnD Chess */
:root {
  --bg: #0a0c12;
  --bg2: #12151f;
  --panel: #161a26;
  --panel2: #1d2230;
  --line: #2b3243;
  --ink: #e8e6df;
  --dim: #8d93a6;
  --gold: #f2c74e;
  --gold-soft: #6a5216;
  --crim: #e0454f;
  --crim-soft: #5e1218;
  --sq-light: #b9a887;
  --sq-dark: #4e4436;
  --ok: #4ecb8b;
  --warn: #f0a441;
}

* { box-sizing: border-box; }

/* class-level display rules would otherwise beat the hidden attribute */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 700px at 50% -12%, #1e2333 0%, transparent 62%),
    radial-gradient(700px 500px at 88% 108%, #241a1c 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ---------- shell ---------- */
.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 18px 16px 40px;
}

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.brand {
  font-size: 25px;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0;
  background: linear-gradient(180deg, #fff6d6, #f2c74e 45%, #a9740f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 26px rgba(242, 199, 78, .18);
}
.brand span { color: var(--crim); -webkit-text-fill-color: var(--crim); }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 11px;
  background: rgba(0, 0, 0, .3);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.dot.on { background: var(--ok); box-shadow: 0 0 9px var(--ok); }
.dot.off { background: var(--crim); box-shadow: 0 0 9px var(--crim); }
.dot.wait { background: var(--warn); box-shadow: 0 0 9px var(--warn); }

/* ---------- layout ---------- */
.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 880px) {
  .game { grid-template-columns: minmax(0, 1fr); }
  .wrap { padding: 12px 10px 30px; }
}

/* ---------- board ---------- */
.boardwrap { min-width: 0; }

.board {
  position: relative;
  display: grid;
  /* Both axes must be explicit and floored at 0. Without the rows the eight ranks
     are implicit auto tracks: each rank's base size comes from its own contents and
     only the leftover is shared out, so a rank holding pieces stays taller than an
     empty one. minmax(0, 1fr) also stops an oversized piece forcing a track wider
     than its share. */
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid #2a2318;
  box-shadow:
    0 0 0 1px rgba(242, 199, 78, .22),
    0 26px 60px rgba(0, 0, 0, .65),
    inset 0 0 90px rgba(0, 0, 0, .5);
  touch-action: manipulation;
  user-select: none;
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  /* a grid item's automatic minimum size is its content; without this a piece can
     still push its own square out once the tracks are definite */
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.sq.l { background: linear-gradient(150deg, #c6b492, var(--sq-light)); }
.sq.d { background: linear-gradient(150deg, #5a4f3e, var(--sq-dark)); }

.sq .coord {
  position: absolute;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: .05em;
  opacity: .5;
  pointer-events: none;
}
.sq .coord.f { right: 3px; bottom: 1px; }
.sq .coord.r { left: 3px; top: 1px; }
.sq.l .coord { color: #4e4436; }
.sq.d .coord { color: #b9a887; }

.pc {
  width: 92%;
  height: 92%;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .55));
  transition: transform .12s ease;
}
.sq.pickable { cursor: pointer; }
.sq.pickable:hover .pc { transform: translateY(-2px) scale(1.04); }

.sq.last::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(242, 199, 78, .17);
  pointer-events: none;
}
.sq.sel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(242, 199, 78, .3);
  box-shadow: inset 0 0 0 3px var(--gold);
  pointer-events: none;
}
.sq.tgt { cursor: pointer; }
.sq.tgt::before {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(20, 12, 4, .42);
  box-shadow: 0 0 0 2px rgba(242, 199, 78, .5);
  pointer-events: none;
  z-index: 2;
}
.sq.tgt.cap::before {
  width: 84%;
  height: 84%;
  background: transparent;
  border-radius: 50%;
  box-shadow: inset 0 0 0 5px rgba(224, 69, 79, .8);
}
.sq.chk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(224, 69, 79, .75), transparent 68%);
  pointer-events: none;
  animation: pulse 1.3s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .6 } 50% { opacity: 1 } }

.board.locked .sq { cursor: default; }

/* ---------- player cards ---------- */
.seat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 8px 0;
}
.seat.turn { border-color: var(--gold); box-shadow: 0 0 20px rgba(242, 199, 78, .13); }
.seat .who { font-size: 15px; font-weight: 600; }
.seat .side {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--dim);
}
.seat.w .side { color: var(--gold); }
.seat.b .side { color: var(--crim); }
.seat .grow { flex: 1; min-width: 0; }
.seat .taken { display: flex; align-items: center; gap: 1px; flex-wrap: wrap; max-width: 150px; }
.seat .taken svg { width: 21px; height: 21px; opacity: .85; }
.seat .adv {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--ok);
}
.badge-you {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: .1em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--gold);
  color: #1a1405;
  font-weight: 700;
}

/* ---------- panel ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 14px;
}
.panel h2 {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dim);
  font-weight: 600;
}

.status {
  font-size: 16px;
  min-height: 24px;
  margin-bottom: 10px;
}
.status .em { color: var(--gold); }
.status .bad { color: var(--crim); }

.btns { display: flex; flex-wrap: wrap; gap: 7px; }
button {
  background: #232939;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 7px;
  padding: 9px 13px;
  cursor: pointer;
  transition: background .13s, border-color .13s, transform .06s;
  font-size: 14px;
}
button:hover:not(:disabled) { background: #2d3446; border-color: #46506b; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .38; cursor: not-allowed; }
button.gold { background: linear-gradient(180deg, #f2c74e, #b8860d); color: #1a1405; border-color: #8a6408; font-weight: 700; }
button.gold:hover:not(:disabled) { background: linear-gradient(180deg, #ffd968, #c9930f); }
button.danger { border-color: var(--crim-soft); color: #ff9a9f; }
button.danger:hover:not(:disabled) { background: #3a1a1e; }

/* ---------- moves ---------- */
.moves {
  max-height: 190px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  gap: 1px 6px;
  align-content: start;
}
.moves .n { color: var(--dim); }
.moves .mv { padding: 1px 4px; border-radius: 4px; }
.moves .mv.cur { background: rgba(242, 199, 78, .2); color: var(--gold); }
.moves .empty { grid-column: 1 / -1; color: var(--dim); font-family: inherit; }

/* ---------- chat ---------- */
.chatlog {
  height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 9px;
  padding-right: 4px;
}
.msg { font-size: 14px; line-height: 1.4; }
.msg .from {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  letter-spacing: .08em;
  text-transform: uppercase;
  display: block;
  color: var(--dim);
}
.msg.w .from { color: var(--gold); }
.msg.b .from { color: var(--crim); }
.msg.sys { color: var(--dim); font-style: italic; font-size: 13px; }
.chatform { display: flex; gap: 7px; }
.chatform input {
  flex: 1;
  min-width: 0;
  background: #0e1119;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
}
.chatform input:focus { outline: none; border-color: var(--gold); }

/* ---------- invite ---------- */
.invite code {
  display: block;
  background: #0e1119;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 11px;
  word-break: break-all;
  margin-bottom: 9px;
  color: var(--gold);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.hint { color: var(--dim); font-size: 13px; margin: 0 0 10px; }

/* ---------- modals ---------- */
.veil {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, .84);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 20px;
  backdrop-filter: blur(3px);
}
.veil[hidden] { display: none; }
/* a question always sits above the game-over card */
#veil-ask { z-index: 50; }
#veil-promo { z-index: 60; }
.card {
  background: linear-gradient(180deg, var(--panel), #101420);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 1px rgba(242, 199, 78, .16), 0 30px 70px rgba(0, 0, 0, .7);
  border-radius: 12px;
  padding: 22px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}
.card h3 { margin: 0 0 6px; font-size: 21px; letter-spacing: .04em; }
.card p { color: var(--dim); margin: 0 0 16px; }
.promo { display: flex; gap: 8px; justify-content: center; }
.promo button { padding: 6px; width: 74px; height: 74px; }
.promo svg { width: 100%; height: 100%; }

/* ---------- lobby ---------- */
.lobby { max-width: 560px; margin: 6vh auto 0; text-align: center; }
.lobby .tag { color: var(--dim); margin: 0 0 26px; font-size: 17px; }
.lobby .roster {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 26px 0;
}
.lobby .roster figure { margin: 0; }
.lobby .roster svg { width: 100%; height: auto; }
.lobby .roster figcaption {
  font-size: 9px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--dim);
  margin-top: 2px;
}
.lobby .go { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.lobby .go button { padding: 13px 22px; font-size: 16px; }

.foot {
  text-align: center;
  color: var(--dim);
  font-size: 12px;
  margin-top: 26px;
}

/* ---------- turn bar ---------- */
.turnbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  font-size: 15px;
  letter-spacing: .02em;
}
.turnbar .pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dim);
  flex: none;
}
.turnbar.mine {
  border-color: var(--gold);
  color: #ffeaa8;
  background: linear-gradient(90deg, rgba(242, 199, 78, .2), rgba(242, 199, 78, .05));
  box-shadow: 0 0 24px rgba(242, 199, 78, .18);
  font-weight: 600;
}
.turnbar.mine .pip {
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold);
  animation: pip 1.6s ease-in-out infinite;
}
.turnbar.over { border-color: var(--line); color: var(--dim); }
@keyframes pip {
  0%, 100% { transform: scale(1); opacity: 1 }
  50% { transform: scale(1.45); opacity: .55 }
}
@media (prefers-reduced-motion: reduce) {
  .turnbar.mine .pip { animation: none }
}

/* ---------- pack picker ---------- */
#packpick {
  width: 100%;
  background: #0e1119;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
}
#packpick:focus { outline: none; border-color: var(--gold); }

/* ---------- pack artwork ---------- */
/* img and svg pieces must be interchangeable in a square */
img.pc {
  width: 92%;
  height: 92%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .55));
  transition: transform .12s ease;
}
.pc.mirror { transform: scaleX(-1); }
.sq.pickable:hover .pc.mirror { transform: scaleX(-1) translateY(-2px) scale(1.04); }

/* ---------- effects layer ---------- */
/* absolutely positioned so it never becomes a grid cell */
.fxlayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.fxpc {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}
.fxpc .pc { width: 92%; height: 92%; }

/* the piece being animated is hidden in its own square until the sprite lands */
.sq.inflight .pc { visibility: hidden; }

/* Fallback motion, used whenever a pack supplies no frames for that beat.
   Real frames replace these without any code change. */
.fx-lunge .pc { animation: lunge .26s ease-out; }
@keyframes lunge {
  0% { transform: scale(1) }
  40% { transform: scale(1.22) rotate(-5deg) }
  100% { transform: scale(1) }
}
.fx-victim { z-index: 4; }
.fx-die .pc { animation: die .34s ease-in forwards; transform-origin: 50% 90%; }
@keyframes die {
  0% { transform: rotate(0) translateY(0); opacity: 1 }
  100% { transform: rotate(58deg) translateY(14%); opacity: 0 }
}

/* ---------- computer toggles ---------- */
.cpu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
}
.cpu input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 38px;
  height: 21px;
  margin: 0;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.cpu input::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform .15s ease, background .15s ease;
}
.cpu input:checked {
  background: var(--gold-soft);
  border-color: var(--gold);
}
.cpu input:checked::after {
  transform: translateX(17px);
  background: var(--gold);
}
.cpu input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

#cpu-level {
  width: 100%;
  margin-top: 11px;
  padding: 9px 11px;
  background: var(--panel2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
}
#cpu-level:focus { outline: none; border-color: var(--gold); }

/* ---------- footer ---------- */
/* Fan Site Policy disclaimer, same wording the dice roller carries. */
.site-footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.site-footer .copy {
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--dim);
}
.site-footer .wizards {
  margin: 0 auto;
  max-width: 780px;
  font-size: 10.5px;
  line-height: 1.6;
  color: #5f6577;
}
.site-footer a { color: #7d8496; text-decoration: underline; }
.site-footer a:hover { color: var(--gold); }

/* ---------- choosing a side ---------- */
/* One link seats whoever opens it, so the two sides are handed out here rather
   than by which link somebody was sent. */
.pick .btns { margin-bottom: 4px; }
.pick #pick-b { border-color: rgba(198, 63, 63, .45); color: var(--crim); }
.pick .wait {
  font-size: 14px;
  color: var(--gold);
  margin: 2px 0 6px;
}
