/* =====================
   CHESS MODULE (contact section)
===================== */
.chess-module {
  background: linear-gradient(180deg, #141414 0%, #0d0d0d 100%);
  border: 1px solid rgba(201, 168, 76, 0.18);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  aspect-ratio: 4/5;
  max-height: 560px;
  position: relative;
  overflow: hidden;
}

.chess-module::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,168,76,0.4), transparent);
}

/* Status bar */
.cw-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  font-family: var(--font-sans);
}
.cw-status-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse-dot 2s ease-in-out infinite;
  flex-shrink: 0;
}
.cw-status-pip.away { background: #ef4444; box-shadow: 0 0 6px #ef4444; animation: none; }
.cw-status-pip.bot { background: #eab308; box-shadow: 0 0 6px #eab308; animation: none; }
.cw-status-stats {
  margin-left: auto;
  opacity: 0.55;
  font-size: 10px;
  letter-spacing: 1.2px;
}

/* Mute toggle (always visible) */
.cw-mute {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(201, 168, 76, 0.18);
  color: rgba(255, 255, 255, 0.6);
  padding: 3px 6px;
  border-radius: 3px;
  cursor: pointer;
  margin-left: 8px;
  font-size: 12px;
  line-height: 1;
  transition: all 0.18s ease;
}
.cw-mute:hover {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.08);
}
.cw-mute.is-muted {
  opacity: 0.55;
}
.cw-mute-icon { font-size: 11px; line-height: 1; }

/* Reset/new-game button (visible during play) */
.cw-reset {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: 1px solid rgba(201, 168, 76, 0.25);
  color: rgba(255, 255, 255, 0.6);
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.18s ease;
  margin-left: 10px;
  white-space: nowrap;
}
.cw-reset:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(201, 168, 76, 0.06);
}
.cw-reset-icon {
  font-size: 13px;
  line-height: 1;
  display: inline-block;
}
.cw-reset.is-confirming {
  border-color: rgba(239, 68, 68, 0.7);
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
  animation: cw-confirm-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes cw-confirm-pulse {
  from { background: rgba(239, 68, 68, 0.08); }
  to   { background: rgba(239, 68, 68, 0.18); }
}
.cw-reset.is-confirming .cw-reset-icon { display: none; }

/* Hide reset button before game has started (poster overlay covers it visually anyway,
   but keep it clean). Also hide on end-state since end panel has its own restart. */
.chess-module:not(.is-playing) .cw-reset {
  visibility: hidden;
  pointer-events: none;
}

/* Board */
.cw-board-wrap {
  position: relative;
  padding: 10px;
  background: linear-gradient(135deg, rgba(201,168,76,0.12) 0%, rgba(201,168,76,0.04) 100%);
  border: 1px solid rgba(201, 168, 76, 0.25);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.cw-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 3px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  position: relative;
}

.cw-sq {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: background-color 0.12s ease;
}

/* Warm wood-toned dark theme */
.cw-light { background-color: #2e2a24; }
.cw-dark  { background-color: #19150f; }

/* Coordinate labels (a-h, 1-8) — subtle gold on edges */
.cw-sq[data-sq$="1"]::before {
  content: attr(data-file);
  position: absolute;
  bottom: 1px;
  right: 3px;
  font-size: 9px;
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: 0.5px;
  color: rgba(201, 168, 76, 0.4);
  pointer-events: none;
}
.cw-sq[data-sq^="a"]::after {
  content: attr(data-rank);
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 9px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: rgba(201, 168, 76, 0.4);
  pointer-events: none;
}

.cw-sq.cw-selected {
  background-color: rgba(201, 168, 76, 0.32) !important;
  box-shadow: inset 0 0 0 2px rgba(201, 168, 76, 0.6);
}

.cw-sq.cw-legal::after {
  content: '';
  position: absolute;
  width: 28%;
  height: 28%;
  background: rgba(201, 168, 76, 0.5);
  border-radius: 50%;
  pointer-events: none;
}
.cw-sq.cw-legal.cw-has-piece::after {
  width: 90%;
  height: 90%;
  background: transparent;
  border: 3px solid rgba(201, 168, 76, 0.55);
  border-radius: 6px;
  box-sizing: border-box;
}

.cw-sq.cw-last-move {
  background-color: rgba(201, 168, 76, 0.12);
}

.cw-sq.cw-check {
  box-shadow: inset 0 0 0 3px rgba(239, 68, 68, 0.7);
}

.cw-piece {
  width: 86%;
  height: 86%;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
  will-change: transform;
}

/* Slide animation for the piece on the destination square after a move.
   --cw-from-x / --cw-from-y are set inline by the renderer (px deltas). */
.cw-piece[data-anim="1"] {
  animation: cw-piece-slide 240ms cubic-bezier(0.4, 0, 0.2, 1) both;
  z-index: 2;
}
@keyframes cw-piece-slide {
  from {
    transform: translate(var(--cw-from-x, 0), var(--cw-from-y, 0));
  }
  to {
    transform: translate(0, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .cw-piece[data-anim="1"] { animation: none; }
}
.cw-piece.cw-b {
  /* Gold-tinted pieces — slightly stronger shadow for depth */
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.75));
}

.cw-sq:hover .cw-piece { transform: scale(1.06); }
.cw-sq.cw-selected .cw-piece { transform: scale(1.1); }

/* Meta strip below board */
.cw-meta {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  letter-spacing: 0.4px;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cw-yourmove {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.6px;
}

/* City ranking strip (static, no rotation) */
.cw-ticker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 10px;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.55);
  padding: 10px 8px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin-top: 4px;
  min-height: 28px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.cw-ticker.is-in { opacity: 1; }

.cw-rank-label {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 1.4px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 9px;
  margin-right: 2px;
}

.cw-rank-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.cw-rank-num {
  color: var(--gold);
  font-weight: 700;
  font-size: 10px;
}
.cw-rank-num::after { content: '.'; }
.cw-rank-city {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: none;
}
.cw-rank-n {
  color: rgba(255, 255, 255, 0.4);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
  .cw-ticker { font-size: 9px; gap: 6px 8px; }
  .cw-rank-label { display: none; }
}
.cw-thinking {
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
}
.cw-thinking::after {
  content: '';
  display: inline-block;
  width: 12px;
  text-align: left;
  animation: cw-dots 1.4s infinite steps(4);
}
@keyframes cw-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* Idle overlay (poster before first move) */
.cw-idle-poster {
  position: absolute;
  inset: 18px;
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(13, 13, 13, 0.92) 0%, rgba(13, 13, 13, 0.78) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 16px;
  z-index: 5;
  cursor: pointer;
  transition: opacity 0.4s ease;
}
.cw-idle-poster.is-hidden { opacity: 0; pointer-events: none; }

.cw-idle-headline {
  font-family: var(--font-serif);
  font-size: clamp(20px, 3.4vw, 32px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.5px;
  color: var(--white);
}
.cw-idle-headline .cw-accent { color: var(--gold); }

.cw-idle-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.55;
  max-width: 280px;
}

.cw-idle-cta {
  margin-top: 4px;
  background: var(--gold);
  color: var(--black);
  border: 1.5px solid var(--gold);
  padding: 12px 22px;
  border-radius: 4px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.cw-idle-cta:hover { background: var(--gold-light); transform: translateY(-1px); }

.cw-idle-counter {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 6px;
}

/* Email gate (slide-in panel under board) */
.cw-gate {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 24px;
  z-index: 10;
  animation: cw-fade-in 0.25s ease;
  isolation: isolate;
  transform: translateZ(0);
}
@keyframes cw-fade-in {
  from { opacity: 0; transform: translateZ(0) translateY(8px); }
  to   { opacity: 1; transform: translateZ(0) translateY(0); }
}

.cw-gate-title {
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.3;
  color: var(--white);
  margin-bottom: 6px;
}
.cw-gate-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.55);
  line-height: 1.5;
  margin-bottom: 18px;
}

.cw-gate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cw-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--white);
  outline: none;
  transition: border-color 0.2s;
}
.cw-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.cw-input:focus { border-color: var(--gold); }

.cw-gate-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.cw-btn-primary {
  background: var(--gold);
  color: var(--black);
  border: none;
  padding: 12px;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
}
.cw-btn-primary:hover { background: var(--gold-light); }

.cw-btn-skip {
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  border: none;
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px;
  font-family: var(--font-sans);
}
.cw-btn-skip:hover { color: rgba(255, 255, 255, 0.7); }

/* End-of-game panel */
.cw-end {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.95);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 30px 24px;
  z-index: 11;
  isolation: isolate;
  transform: translateZ(0);
}
.cw-end-icon { font-size: 44px; margin-bottom: 8px; }
.cw-end-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}
.cw-end-title.loss { color: rgba(255,255,255,0.5); }
.cw-end-sub {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.6;
  margin-bottom: 18px;
  max-width: 280px;
}
.cw-coupon {
  background: rgba(201, 168, 76, 0.1);
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-family: 'Courier New', monospace;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 14px;
  user-select: all;
  cursor: copy;
  transition: background 0.18s, transform 0.12s;
  position: relative;
}
.cw-coupon::after {
  content: '⧉';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 12px;
  opacity: 0.5;
}
.cw-coupon:hover {
  background: rgba(201, 168, 76, 0.18);
  transform: translateY(-1px);
}
.cw-toast {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid rgba(201, 168, 76, 0.4);
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.6px;
  padding: 8px 14px;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  max-width: 90%;
  text-overflow: ellipsis;
  overflow: hidden;
  z-index: 12;
}
.cw-toast.is-shown {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.cw-end-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 260px;
}
.cw-end-actions .cw-btn-primary,
.cw-end-actions .cw-btn-secondary,
.cw-end-actions .cw-coupon { width: 100%; box-sizing: border-box; text-align: center; }
.cw-btn-secondary {
  background: transparent;
  color: var(--gold);
  border: 1.5px solid var(--gold);
  padding: 11px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
}
.cw-btn-secondary:hover { background: var(--gold); color: var(--black); }

/* Tabs (game/chat) */
.cw-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.cw-tab {
  flex: 1;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  padding: 8px 4px;
  font-family: var(--font-sans);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  position: relative;
}
.cw-tab.is-active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.cw-tab .cw-tab-badge {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.2s;
}
.cw-tab.has-update .cw-tab-badge { opacity: 1; animation: pulse-dot 1.6s ease-in-out infinite; }

/* Mobile — show chess module above form */
@media (max-width: 760px) {
  .contact-grid {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }
  .chess-module {
    display: flex !important; /* override .contact-image display:none */
    aspect-ratio: auto;
    max-height: none;
    order: -1;
    padding: 14px;
  }
  .cw-idle-poster { inset: 14px; }
}

@media (max-width: 480px) {
  .chess-module { padding: 12px; }
  .cw-piece { font-size: clamp(20px, 11vw, 36px); }
  .cw-status { font-size: 10px; letter-spacing: 1.2px; }
  .cw-status-stats { font-size: 9px; }
}
