/* ============================================================
   Ajedrez Online — Modern Chess Club
   Full visual redesign. NO logic changes.
   Every class/ID referenced by chess-client.js is preserved.
   ============================================================ */

/* ── 1. DESIGN TOKENS ─────────────────────────────────────── */

.chess-app {
  --bg:           #080b0d;
  --bg-deep:      #050708;
  --surface:      #101417;
  --surface-2:    #171c20;
  --surface-3:    #1d2328;

  --board-light:       #ead3aa;
  --board-light-hover: #f1ddb8;
  --board-dark:        #ad805b;
  --board-dark-hover:  #bd9067;

  --gold:        #d4af5a;
  --gold-light:  #e7ca7a;
  --gold-dim:    #a9863f;

  --text:        #f4f1e8;
  --text-soft:   #c8c3b8;
  --text-muted:  #858d91;

  --green:       #2d9b68;
  --green-light: #45bd82;
  --danger:      #c95757;

  --border:      rgba(255,255,255,.08);
  --border-gold: rgba(212,175,90,.35);

  --shadow-lg:    0 25px 70px rgba(0,0,0,.55);
  --shadow-board: 0 25px 60px rgba(0,0,0,.5),
                  0 0 0 1px rgba(255,255,255,.04);

  /* alias to keep style.css vars working inside .chess-app */
  --hairline:   var(--border);
  --accent:     var(--gold);
  --accent-soft: var(--gold-light);

  --font-sans: 'Plus Jakarta Sans', 'Inter', ui-sans-serif, system-ui, sans-serif;

  background: var(--bg) !important;
  color: var(--text) !important;
  font-family: var(--font-sans) !important;
}


/* ── 2. LANDING OVERRIDES ──────────────────────────────────── */

.chess-app .menu-card,
.chess-app .panel {
  background: linear-gradient(170deg, var(--surface), var(--surface-2)) !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 24px 60px rgba(0,0,0,.75), inset 0 1px 0 rgba(255,255,255,.03) !important;
}

.chess-app .site-header {
  background: rgba(7,10,12,.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  height: 54px;
  padding: 0 20px;
}

.chess-app .btn--primary {
  background: linear-gradient(180deg, #36aa73, #238858) !important;
  border-color: rgba(255,255,255,.08) !important;
  box-shadow: 0 7px 18px rgba(35,136,88,.22) !important;
  color: #fff !important;
}
.chess-app .btn--primary em,
.chess-app .btn--primary strong { color: #fff !important; }

.chess-app .hero__sub--sm {
  font-size: 13px;
  color: var(--text-muted);
  letter-spacing: .04em;
  margin-top: 8px;
}


/* ── 3. DIFFICULTY CARDS ───────────────────────────────────── */

.chess-app .diffcards button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  transition: border-color .16s, background .16s, transform .16s;
  padding: 14px 12px;
}
.chess-app .diffcards button:hover {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.18);
  transform: translateY(-1px);
}
.chess-app .diffcards button.is-active {
  border-color: var(--gold) !important;
  background: rgba(212,175,90,.08) !important;
  box-shadow: inset 0 0 0 1px rgba(212,175,90,.25) !important;
}
.chess-app .diffcards__name { color: var(--text); }
.chess-app .diffcards button.is-active .diffcards__name { color: var(--gold-light); }


/* ── 4. GAME SHELL ─────────────────────────────────────────── */

.chess-app .screen--game {
  background:
    radial-gradient(circle at 50% 30%, rgba(38,52,45,.22), transparent 55%),
    var(--bg-deep) !important;
}

/* The game HUD header — compact, professional */
.chess-app .hud {
  background: rgba(7,10,12,.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  z-index: 100;
  position: sticky;
  top: 0;
}

.chess-app .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.04);
  color: var(--text-soft);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chess-app .icon-btn:hover {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.15);
}

/* ── 5. GAME AREA (chess-wrap) ─────────────────────────────── */

.chess-app .chess-wrap {
  flex: 1;
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px 24px 28px;
  gap: 0;
  min-height: calc(100dvh - 48px);
  box-sizing: border-box;
}


/* ── 6. PLAYER CARDS ───────────────────────────────────────── */

.chess-app .chess-hud__names {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 0;
}

.chess-app .chess-plate {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.018));
  border: 1px solid var(--border);
  box-shadow: 0 8px 25px rgba(0,0,0,.18);
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.chess-app .chess-plate__color {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.15);
  flex: 0 0 auto;
}
.chess-app .chess-plate__color.is-white { background: #ead3aa; }
.chess-app .chess-plate__color.is-black { background: #1a1a1a; border-color: rgba(255,255,255,.08); }

.chess-app .chess-plate__name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.chess-app .chess-plate__name .badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Active turn state */
.chess-app .chess-plate.is-turn {
  border-color: var(--border-gold);
  box-shadow: 0 8px 30px rgba(0,0,0,.2), 0 0 0 1px rgba(212,175,90,.08);
}
.chess-app .chess-plate.is-turn .chess-plate__name { color: var(--gold-light); }

.chess-app .chess-plate.is-turn .badge {
  background: rgba(212,175,90,.16);
  border: 1px solid rgba(212,175,90,.3);
  color: var(--gold-light);
}

.chess-app .chess-captured {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  font-size: 15px;
  line-height: 1;
  min-height: 18px;
  opacity: .65;
}


/* ── 7. BOARD ──────────────────────────────────────────────── */

.chess-app .chess-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows:    repeat(8, 1fr);
  width: min(78vw, 680px);
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  background: var(--board-dark);
  box-shadow:
    0 30px 70px rgba(0,0,0,.55),
    0 10px 25px rgba(0,0,0,.35),
    0 0 0 5px rgba(255,255,255,.035);
  user-select: none;
  touch-action: manipulation;
  margin: 10px 0;
  position: relative;
}


/* ── 8. SQUARES ────────────────────────────────────────────── */

.chess-app .chess-sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--board-light);
  transition: background-color .16s ease, box-shadow .16s ease;
}

.chess-app .chess-sq.is-dark {
  background: var(--board-dark);
}

/* Selected square */
.chess-app .chess-sq.is-selected {
  box-shadow: inset 0 0 0 999px rgba(212,175,90,.38),
              inset 0 0 0 2px rgba(255,255,255,.15) !important;
}

/* Last move highlight */
.chess-app .chess-sq.is-last {
  box-shadow: inset 0 0 0 999px rgba(212,175,90,.22) !important;
}

/* Check — radial gradient, elegant red glow */
.chess-app .chess-sq.is-check {
  background:
    radial-gradient(circle, rgba(201,87,87,.78), rgba(201,87,87,.25) 55%, transparent 75%) !important;
}

/* Legal move dot */
.chess-app .chess-sq .chess-dot {
  position: absolute;
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(20,30,25,.32);
  pointer-events: none;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Capture indicator */
.chess-app .chess-sq.is-target-piece::after {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 4px solid rgba(20,30,25,.28);
  pointer-events: none;
  background: transparent;
}

/* Coordinates */
.chess-app .chess-sq__coord {
  position: absolute;
  bottom: 2px;
  left: 3px;
  font-size: 10px;
  font-weight: 600;
  opacity: .5;
  pointer-events: none;
  color: var(--board-dark);
}
.chess-app .chess-sq.is-dark .chess-sq__coord {
  color: var(--board-light);
  opacity: .45;
}


/* ── 9. PIECES ─────────────────────────────────────────────── */

/* "Base" de la ficha: una sombra elíptica bajo la pieza para que se vea
   apoyada sobre la casilla en vez de flotando, como una Staunton real. */
.chess-app .chess-sq:has(.chess-piece)::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 44%;
  height: 13%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(0,0,0,.4), rgba(0,0,0,0) 72%);
  pointer-events: none;
}

.chess-app .chess-sq .chess-piece {
  pointer-events: none;
  font-size: min(9.2vw, 52px);
  line-height: 1;
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "DejaVu Sans", sans-serif;
  transform: translateZ(0);
  transition: transform .14s ease, filter .14s ease;
  position: relative;
}

/* Relieve: la pieza se rellena con un degradado (marfil pulido / madera
   oscura) recortado a la propia forma del glifo, más un realce arriba y
   una sombra propia abajo, para que parezca tallada en vez de plana. */
.chess-app .chess-sq .chess-piece.is-white {
  background: linear-gradient(165deg, #fffdf7 0%, #f3e8cb 38%, #dcc999 72%, #c3a875 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px rgba(42, 28, 15, .6);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, .55),
    0 2px 1px rgba(120, 90, 40, .3);
  filter:
    drop-shadow(0 3px 2px rgba(0, 0, 0, .55))
    drop-shadow(0 7px 8px rgba(0, 0, 0, .25));
}

.chess-app .chess-sq .chess-piece.is-black {
  background: linear-gradient(165deg, #4d4944 0%, #2a2622 45%, #0e0c0a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px rgba(0, 0, 0, .55);
  text-shadow:
    0 1px 0 rgba(255, 255, 255, .1),
    0 2px 2px rgba(0, 0, 0, .6);
  filter:
    drop-shadow(0 3px 2px rgba(0, 0, 0, .8))
    drop-shadow(0 7px 8px rgba(0, 0, 0, .35));
}

/* Desktop hover on pieces: además de agrandar un poco, "levanta" la pieza
   subiendo la sombra proyectada, reforzando la sensación de volumen. */
@media (hover: hover) {
  .chess-app .chess-sq:hover .chess-piece {
    transform: scale(1.045) translateY(-2px);
  }
  .chess-app .chess-sq:hover .chess-piece.is-white {
    filter:
      drop-shadow(0 5px 3px rgba(0, 0, 0, .5))
      drop-shadow(0 10px 10px rgba(0, 0, 0, .3));
  }
  .chess-app .chess-sq:hover .chess-piece.is-black {
    filter:
      drop-shadow(0 5px 3px rgba(0, 0, 0, .75))
      drop-shadow(0 10px 10px rgba(0, 0, 0, .4));
  }
}

/* Sin soporte para background-clip:text (muy poco común hoy): que se vea
   la pieza sólida de toda la vida en vez de invisible. */
@supports not (background-clip: text) {
  .chess-app .chess-sq .chess-piece.is-white { color: #fff; background: none; }
  .chess-app .chess-sq .chess-piece.is-black { color: #1a1a1a; background: none; }
}


/* ── 10. TURN BAR ──────────────────────────────────────────── */

.chess-app .chess-turnbar {
  text-align: center;
  padding: 11px 15px;
  border-radius: 9px;
  background: rgba(255,255,255,.035);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 14px;
  width: 100%;
  max-width: 680px;
  margin: 6px 0;
  transition: border-color .2s, color .2s, background .2s;
}

.chess-app .chess-turnbar.is-my-turn {
  border-color: rgba(212,175,90,.28);
  color: var(--gold-light);
  background: rgba(212,175,90,.055);
}

.chess-app .turnbar__title {
  font-weight: 650;
  letter-spacing: .02em;
}


/* ── 11. ACTION BAR ────────────────────────────────────────── */

.chess-app .chess-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 680px;
  margin-top: 4px;
}

.chess-app .chess-actions .btn--side {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.045);
  color: var(--text-soft);
  flex-direction: row;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.chess-app .chess-actions .btn--side:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,.065);
  border-color: rgba(255,255,255,.15);
}
.chess-app .chess-actions .btn--side:active {
  transform: translateY(0);
}

/* Resign button — subtle danger */
.chess-app #btn-resign {
  border-color: rgba(201,87,87,.28);
  color: #e7a0a0;
}
.chess-app #btn-resign:hover {
  background: rgba(201,87,87,.10);
  border-color: rgba(201,87,87,.4);
}
.chess-app #btn-resign:disabled {
  opacity: .4;
  cursor: default;
  transform: none;
}
.chess-app #btn-draw-offer:disabled {
  opacity: .4;
  cursor: default;
  transform: none;
}


/* ── 12. DRAW OFFER BAR ───────────────────────────────────── */

.chess-app .draw-offer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 9px;
  background: rgba(212,175,90,.08);
  border: 1px solid rgba(212,175,90,.25);
  margin: 6px 0;
  width: 100%;
  max-width: 680px;
}


/* ── 13. FEED (move log) ───────────────────────────────────── */

.chess-app .feed {
  position: relative;
  left: auto;
  bottom: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  display: none;          /* hidden on game screen — small viewport priority */
  gap: 3px;
  font-size: 11.5px;
  color: rgba(255,255,255,.45);
  pointer-events: none;
  max-width: 680px;
  width: 100%;
}


/* ── 14. PROMOTION PICKER ──────────────────────────────────── */

.chess-app .promo-picker {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 20px;
}

.chess-app .promo-picker button {
  width: 68px;
  height: 68px;
  font-size: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  color: var(--text);
  transition: background .16s, border-color .16s, transform .16s;
  font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", "DejaVu Sans", sans-serif;
}

.chess-app .promo-picker button:hover {
  background: var(--surface-3);
  border-color: var(--gold);
  transform: scale(1.06);
}


/* ── 15. OVERLAYS ──────────────────────────────────────────── */

.chess-app .overlay {
  background: rgba(5,7,8,.78);
  backdrop-filter: blur(8px);
}

.chess-app .overlay__card {
  background: linear-gradient(170deg, var(--surface-2), var(--surface)) !important;
  border: 1px solid var(--border) !important;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.chess-app .overlay__card h3 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.chess-app .overlay__card.is-win h3 { color: var(--gold-light); }
.chess-app .overlay__card.is-lose h3 { color: #e09090; }

.chess-app .chess-result {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.chess-app .overlay__card .btn--ghost {
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
}


/* ── 16. CHAT PANEL ────────────────────────────────────────── */

.chess-app .chat-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}

.chess-app .chat-panel__head {
  border-bottom: 1px solid var(--border);
}

.chess-app .icon-btn.has-unread::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}


/* ── 17. CONNECTION BANNER ─────────────────────────────────── */

.chess-app .conn-banner {
  background: var(--surface);
  border-top: 1px solid var(--border);
}


/* ── 18. TOAST ─────────────────────────────────────────────── */

.chess-app .toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
}


/* ── 19. DESKTOP ───────────────────────────────────────────── */

@media (min-width: 1000px) {
  .chess-app .chess-wrap {
    max-width: 1050px;
    padding: 18px 24px 28px;
  }
  .chess-app .chess-board {
    width: min(70vh, 680px);
  }
}


/* ── 20. MOBILE ────────────────────────────────────────────── */

@media (max-width: 700px) {
  .chess-app .chess-wrap {
    padding: 8px 8px 14px;
    min-height: calc(100dvh - 48px);
  }

  .chess-app .chess-board {
    width: min(calc(100vw - 16px), calc(100dvh - 220px));
    max-width: 100%;
    border-radius: 4px;
    box-shadow:
      0 15px 40px rgba(0,0,0,.5),
      0 0 0 3px rgba(255,255,255,.025);
  }

  .chess-app .chess-sq .chess-piece {
    font-size: min(10.8vw, 42px);
  }

  .chess-app .chess-plate {
    padding: 8px 10px;
  }

  .chess-app .chess-hud__names {
    padding: 0 4px;
    margin: 0 auto;
  }

  .chess-app .chess-turnbar {
    margin: 4px 0;
    padding: 9px;
    font-size: 13px;
  }

  .chess-app .chess-actions .btn--side {
    min-height: 40px;
    padding: 0 14px;
    font-size: 12px;
  }
}


/* ── 21. MOBILE LANDSCAPE ──────────────────────────────────── */

@media (max-height: 600px) and (orientation: landscape) {
  .chess-app .chess-wrap {
    padding: 6px 12px;
    min-height: auto;
  }
  .chess-app .chess-board {
    width: auto;
    height: calc(100dvh - 100px);
    max-width: calc(100vw - 260px);
  }
}


/* ── 22. REDUCED MOTION ────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .chess-app *,
  .chess-app *::before,
  .chess-app *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}


/* ── 23. LANDING: FAQ & INFO CARDS ─────────────────────────── */

.chess-app .info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: 12px;
}

.chess-app .faq__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.chess-app .faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.chess-app .faq summary {
  padding: 16px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  color: var(--text);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chess-app .faq summary::-webkit-details-marker { display: none; }

.chess-app .faq summary::after {
  content: "+";
  font-size: 20px;
  color: var(--gold);
  transition: transform .15s;
}

.chess-app .faq details[open] summary::after {
  transform: rotate(45deg);
}

.chess-app .faq p {
  padding: 0 16px 16px;
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}


/* ── 24. RADIO OVERRIDE ────────────────────────────────────── */

.chess-app .radio-widget { bottom: 16px; right: 16px; }

.chess-app .radio-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  color: var(--gold);
}

.chess-app .radio-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.6);
}
