/* ============================================================
   Fort Payne Chess — Study Hall theme
   Palette supplied by client: wood tans, brass gold, deep black.
   ============================================================ */

:root {
  --color-black: #000000;
  --color-tan: #86745c;
  --color-light-tan: #c2baab;
  --color-dark-tan: #6a5c48;
  --color-white: #ffffff;
  --color-black-63: rgba(0, 0, 0, 0.63);
  --color-black-80: rgba(0, 0, 0, 0.8);
  --color-black-88: rgba(0, 0, 0, 0.88);
  --color-gold: #b19977;
  --color-accent: #b19977;
  --color-accent-light: #c2baab;

  --font-display: "Playfair Display", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;

  --square-light: var(--color-light-tan);
  --square-dark: var(--color-dark-tan);
  --square-size: min(7.4vw, 68px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(ellipse at top, #1c1712 0%, var(--color-black) 62%);
  color: var(--color-light-tan);
  font-family: var(--font-body);
}

/* ---------- Layout shell ---------- */

.hall {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.hall__header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.crest {
  font-size: 2.4rem;
  color: var(--color-gold);
  line-height: 1;
  text-shadow: 0 0 18px rgba(177, 153, 119, 0.45);
}

.hall__titles h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  letter-spacing: 0.01em;
  color: var(--color-white);
}

.eyebrow {
  margin: 2px 0 0;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-tan);
}

/* ---------- Brass turn plate (signature element) ---------- */

.plate {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 26px;
  border-radius: 3px;
  background: linear-gradient(180deg, #cdb48c 0%, var(--color-gold) 45%, #8f7a5a 100%);
  color: #2a2116;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 -2px 4px rgba(0, 0, 0, 0.35) inset,
    0 6px 14px rgba(0, 0, 0, 0.45);
  transition: background 0.35s ease;
}

.plate.is-black {
  background: linear-gradient(180deg, #4a4136 0%, #241f19 45%, #14110d 100%);
  color: var(--color-light-tan);
}

.plate.is-check {
  animation: plate-pulse 1.1s ease-in-out infinite;
}

@keyframes plate-pulse {
  0%, 100% { box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, 0 -2px 4px rgba(0,0,0,0.35) inset, 0 6px 14px rgba(0,0,0,0.45); }
  50% { box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset, 0 -2px 4px rgba(0,0,0,0.35) inset, 0 0 0 6px rgba(177,153,119,0.28); }
}

.plate__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-white);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.25) inset;
}

.plate.is-black .plate__dot {
  background: #17140f;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.25) inset;
}

/* ---------- Board room (trays + board) ---------- */

.board-room {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 22px;
  width: 100%;
}

.board-case {
  background: linear-gradient(160deg, #a08a68 0%, var(--color-tan) 45%, #5c4d3a 100%);
  padding: 18px;
  border-radius: 6px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.15) inset,
    0 18px 40px rgba(0,0,0,0.55),
    0 0 0 1px rgba(0,0,0,0.4);
  position: relative;
}

.board-case::before,
.board-case::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-gold);
  opacity: 0.85;
}

.board-case::before { top: 6px; left: 6px; border-right: none; border-bottom: none; }
.board-case::after { bottom: 6px; right: 6px; border-left: none; border-top: none; }

.board-case__inner {
  background: var(--color-black-63);
  padding: 6px;
  border-radius: 3px;
}

.coords-row {
  display: flex;
  align-items: center;
}

.board-stack {
  position: relative;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, var(--square-size));
  grid-template-rows: repeat(8, var(--square-size));
  box-shadow: 0 0 0 3px var(--color-black-80);
}

/* ---------- On-board announcements (Check / Checkmate / Draw) ---------- */

.board-announce {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 68%);
}

.board-announce__main {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1.7rem, 6.2vw, 3rem);
  color: var(--color-white);
  letter-spacing: 0.03em;
  text-shadow:
    0 2px 0 #000,
    0 0 24px rgba(0,0,0,0.85),
    0 0 46px rgba(177,153,119,0.55);
}

.board-announce__sub {
  margin-top: 6px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(0.82rem, 2.3vw, 1.05rem);
  color: var(--color-gold);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.85);
}

.board-announce.is-flash {
  animation: announce-flash 1.7s ease forwards;
}

.board-announce.is-stay {
  animation: announce-in 0.55s ease forwards;
}

@keyframes announce-flash {
  0%   { opacity: 0; transform: scale(0.55); }
  14%  { opacity: 1; transform: scale(1.12); }
  24%  { opacity: 1; transform: scale(1); }
  78%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.03); }
}

@keyframes announce-in {
  0%   { opacity: 0; transform: scale(0.55); }
  65%  { opacity: 1; transform: scale(1.1); }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .board-announce.is-flash,
  .board-announce.is-stay {
    animation: none;
    opacity: 1;
  }
}

.coords {
  display: grid;
  grid-template-columns: repeat(8, var(--square-size));
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--color-tan);
}
.coords span { display: flex; align-items: center; justify-content: center; }

.coords--ranks {
  grid-template-columns: none;
  grid-template-rows: repeat(8, var(--square-size));
  width: 20px;
}

.square {
  width: var(--square-size);
  height: var(--square-size);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.square--light { background: var(--square-light); }
.square--dark { background: var(--square-dark); }

.square--selected::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(177, 153, 119, 0.55);
  box-shadow: inset 0 0 0 3px var(--color-gold);
}

.square--last-move::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 244, 214, 0.22);
}

.square--check::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(178, 40, 30, 0.65) 0%, rgba(178, 40, 30, 0.15) 70%);
}

.square--move-hint::before {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(20, 16, 12, 0.35);
}

.square--capture-hint::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  border: 4px solid rgba(20, 16, 12, 0.4);
  background: transparent;
}

.piece {
  font-size: calc(var(--square-size) * 0.72);
  line-height: 1;
  pointer-events: none;
  transform: translateY(-2%);
}

.piece--white {
  color: #f7f1e6;
  text-shadow:
    0 1px 0 #7a6a52,
    0 2px 3px rgba(0,0,0,0.55);
}

.piece--black {
  color: #171310;
  text-shadow:
    0 1px 0 rgba(255,255,255,0.12),
    0 2px 4px rgba(0,0,0,0.6);
}

/* ---------- Trays ---------- */

.tray {
  width: 168px;
  min-height: 300px;
  background: linear-gradient(160deg, #2a241d 0%, #17130f 100%);
  border-radius: 6px;
  padding: 14px;
  box-shadow: inset 0 0 0 1px rgba(177,153,119,0.25), inset 0 3px 10px rgba(0,0,0,0.6);
}

.tray__label {
  margin: 0 0 8px;
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-tan);
  font-weight: 600;
}

.tray__label--log { margin-top: 16px; }

.tray__pieces {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  min-height: 34px;
  font-size: 1.3rem;
}

.tray__pieces .piece { font-size: 1.3rem; }

.movelog {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.78rem;
  color: var(--color-light-tan);
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.movelog li {
  display: flex;
  gap: 6px;
}

.movelog .movelog__num {
  color: var(--color-tan);
  width: 20px;
  flex-shrink: 0;
}

/* ---------- Controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  padding: 10px 18px;
  border-radius: 4px;
  border: 1px solid rgba(177,153,119,0.5);
  background: transparent;
  color: var(--color-light-tan);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn:hover { background: rgba(177,153,119,0.16); }

.btn--primary {
  background: var(--color-gold);
  border-color: var(--color-gold);
  color: #241d15;
}

.btn--primary:hover { background: #c2ab88; }

.btn:focus-visible, .square:focus-visible, .check input:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--color-tan);
}

.hall__footer {
  color: var(--color-tan);
  font-size: 0.76rem;
  text-align: center;
}

/* ---------- Modals ---------- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal[hidden] { display: none; }

.modal__card {
  background: linear-gradient(160deg, #3a3226 0%, #17130f 100%);
  border: 1px solid rgba(177,153,119,0.4);
  border-radius: 8px;
  padding: 26px 30px;
  text-align: center;
  max-width: 320px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.modal__card h3 {
  font-family: var(--font-display);
  color: var(--color-white);
  margin: 0 0 6px;
}

.modal__card p {
  color: var(--color-tan);
  margin: 0 0 18px;
}

.modal__choices {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal__choices button {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  border-radius: 4px;
  border: 1px solid rgba(177,153,119,0.5);
  background: var(--color-black-63);
  color: var(--color-white);
  cursor: pointer;
}

.modal__choices button:hover { background: rgba(177,153,119,0.25); }

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
  :root { --square-size: min(10vw, 44px); }
  .board-room { flex-direction: column; align-items: center; }
  .tray { width: min(90vw, 420px); min-height: unset; }
  .tray--left, .tray--right { order: 2; }
  .board-case { order: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .plate.is-check { animation: none; }
}
