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

:root {
  --bg:       #0a0b0c;
  --gold:     #c9a84c;
  --gold-dim: #7a6030;
  --cream:    #ede5d0;
  --dim:      #6a6a6a;
  --border:   #222426;
  --surface:  #111315;
  --sq-light: #e8d5a3;
  --sq-dark:  #8b6440;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--cream);
  overflow: hidden;
  position: relative;
}

/* background grid */
.bg-grid {
  position: fixed; inset: 0; z-index: 0;
  background-image:
    linear-gradient(rgba(201,168,76,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,168,76,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}
.bg-glow {
  position: fixed;
  top: -20%; left: -10%;
  width: 60vw; height: 60vw;
  background: radial-gradient(circle, rgba(201,168,76,0.06) 0%, transparent 65%);
  pointer-events: none; z-index: 0;
}

/* LAYOUT */
.layout {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  align-items: center;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 40px;
  gap: 60px;
}

/* ---- LEFT SIDE ---- */
.side-text {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 48px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
}
.logo-e2 { color: var(--cream); }
.logo-arrow { color: var(--gold); margin: 0 4px; }
.logo-e4 { color: var(--gold); }

.tagline {
  font-family: 'Playfair Display', serif;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 700;
  color: var(--cream);
  line-height: 1.2;
}

.desc {
  font-size: 15px;
  color: var(--dim);
  line-height: 1.8;
  max-width: 380px;
}

/* INVITE BLOCK */
.invite-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.invite-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.invite-input-row {
  display: flex;
  gap: 8px;
}
.invite-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--cream);
  font-family: 'Inter', monospace;
  font-size: 14px;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  outline: none;
  transition: border-color 0.2s;
}
.invite-input:focus { border-color: var(--gold-dim); }
.invite-input::placeholder { color: #3a3a3a; }

.btn-enter {
  background: var(--gold);
  color: #0a0b0c;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 24px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-enter:hover { background: #d4b45c; transform: translateY(-1px); }
.btn-enter:active { transform: translateY(0); }

.invite-error {
  font-size: 13px;
  color: #e05252;
  min-height: 18px;
  transition: opacity 0.3s;
}

.closed-note {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #3d3d3d;
  letter-spacing: 0.04em;
}
.lock { color: var(--gold-dim); font-size: 14px; }

/* ---- RIGHT SIDE: BOARD ---- */
.side-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.board-glow {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(201,168,76,0.1) 0%, transparent 65%);
  pointer-events: none;
}

.board-col-labels {
  display: flex;
  margin-left: 22px;
  margin-bottom: 4px;
  width: 400px;
}
.board-col-labels span {
  width: 50px;
  text-align: center;
  font-size: 11px;
  color: #c8c0b0;
  letter-spacing: 0.05em;
}

.board-row-wrap {
  display: flex;
  align-items: flex-start;
  position: relative;
  z-index: 1;
}

.board-row-labels {
  display: flex;
  flex-direction: column;
  margin-right: 6px;
}
.board-row-labels span {
  height: 50px;
  display: flex;
  align-items: center;
  font-size: 11px;
  color: #c8c0b0;
}

.chess-board {
  display: grid;
  grid-template-columns: repeat(8, 50px);
  grid-template-rows: repeat(8, 50px);
  border: 1px solid var(--gold-dim);
  border-radius: 2px;
  overflow: hidden;
  box-shadow:
    0 0 60px rgba(0,0,0,0.7),
    0 0 120px rgba(201,168,76,0.06);
}

.square {
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  user-select: none;
  position: relative;
}
.square.light { background: var(--sq-light); }
.square.dark  { background: var(--sq-dark); }
.square.hl-from { background: rgba(201,168,76,0.55) !important; }
.square.hl-to   { background: rgba(201,168,76,0.8) !important; }
.square.last-from { background: rgba(201,168,76,0.28) !important; }
.square.last-to   { background: rgba(201,168,76,0.42) !important; }

.piece {
  display: block; line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  pointer-events: none;
}
.piece.black {
  filter: brightness(0) drop-shadow(0 2px 3px rgba(0,0,0,0.7));
}
.piece-pop { animation: pop 0.22s ease-out; }
@keyframes pop {
  0%   { transform: scale(1.0); }
  45%  { transform: scale(1.28); }
  100% { transform: scale(1.0); }
}

.move-indicator {
  margin-top: 12px;
  display: flex; align-items: center; gap: 8px;
  font-family: 'Inter', monospace;
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 0.08em;
  min-height: 20px;
}
.move-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:0.3; transform:scale(0.6); }
}

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.modal-overlay.visible { opacity: 1; pointer-events: all; }

.modal {
  background: #141618;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  text-align: center;
  max-width: 340px;
  width: 90%;
  display: flex; flex-direction: column; gap: 16px;
  transform: translateY(10px);
  transition: transform 0.25s;
}
.modal-overlay.visible .modal { transform: translateY(0); }
.modal-icon { font-size: 40px; }
.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: var(--cream);
}
.modal-text { font-size: 14px; color: var(--dim); line-height: 1.6; }

/* RESPONSIVE */
@media (max-width: 860px) {
  body { overflow: auto; }
  .layout {
    grid-template-columns: 1fr;
    padding: 60px 24px;
    gap: 48px;
    min-height: auto;
  }
  .side-board { order: -1; }
  .chess-board {
    grid-template-columns: repeat(8, 40px);
    grid-template-rows: repeat(8, 40px);
  }
  .square { width: 40px; height: 40px; font-size: 22px; }
  .board-col-labels { width: 320px; }
  .board-col-labels span { width: 40px; }
  .board-row-labels span { height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .piece-pop, .move-dot { animation: none; }
}
