/* Desktop: evita scroll global fantasma */
@media (min-width: 768px) {

  html,
  body {
    height: 100%;
    overflow: hidden;
  }
}

/* ===== CSS Variables for Editorial Brutalist Theme ===== */
:root {
  --bg-main: #080808;
  --text-high: #f0f0f0;
  --text-muted: #666666;
  --board-light: #d6d0c6;  /* Stone oficial - editorial premium */
  --board-dark: #625d57;   /* Stone oficial - menos tierra, más piedra */
  --accent: #ff3e3e;

/* ===== BOARD THEMES - Editorial Collection ===== */

/* Theme: Stone (Default) - Curado final desde Stone 2 */
[data-board-theme="stone"],
[data-board-theme="stone2"] {
  --board-light: #d6d0c6;
  --board-dark: #625d57;
  --board-selected: #a29c94;
}

/* Backup: Stone original */
[data-board-theme="stone-original"] {
  --board-light: #ccc4b8;
  --board-dark: #615a53;
  --board-selected: #9f978e;
}

/* Theme: Oak - Roble moderno, cálido pero no clásico */
[data-board-theme="oak"] {
  --board-light: #d4c8b8;
  --board-dark: #6b5a4f;
  --board-selected: #a89a8c;
}

/* Theme: Oak 2 - Heritage sobrio, menos madera */
[data-board-theme="oak2"] {
  --board-light: #d2c8bd;
  --board-dark: #655953;
  --board-selected: #a1968d;
}

/* Theme: Mineral - Piedra suave, editorial y sobrio */
[data-board-theme="mineral"] {
  --board-light: #d6d1ca;
  --board-dark: #6d6862;
  --board-selected: #aaa59e;
}

/* Theme: Swiss - Papel mineral, neutro y preciso */
[data-board-theme="swiss"] {
  --board-light: #d0ccc5;
  --board-dark: #625d58;
  --board-selected: #a29d97;
}

/* Theme: Swiss 2 - Gris piedra refinado */
[data-board-theme="swiss2"] {
  --board-light: #d4cfc7;
  --board-dark: #5d5852;
  --board-selected: #9e9992;
}

/* Theme: Daily - Gris cálido de uso diario */
[data-board-theme="daily"] {
  --board-light: #d8d4ce;
  --board-dark: #78736c;
  --board-selected: #b0aba5;
}

/* Theme: Slate - Azul pizarra editorial, cool vibe */
[data-board-theme="slate"] {
  --board-light: #c8cdd5;
  --board-dark: #66707f;
  --board-selected: #9fa6b1;
}

/* Theme: Slate 2 - Grafito mineral, cool sin clínica */
[data-board-theme="slate2"] {
  --board-light: #c9ced0;
  --board-dark: #60686f;
  --board-selected: #9aa0a4;
}

/* Theme: Ember - Madera noble, cálido y elegante */
[data-board-theme="ember"] {
  --board-light: #d2bcac;
  --board-dark: #70504c;
  --board-selected: #a98f84;
}

/* Theme: Ember 2 - Cálido, menos rojizo */
[data-board-theme="ember2"] {
  --board-light: #d4c1b4;
  --board-dark: #6a5550;
  --board-selected: #a49087;
}

/* Theme: Blush - Rosa editorial suave */
[data-board-theme="blush"] {
  --board-light: #dbc6c5;
  --board-dark: #826163;
  --board-selected: #b69c9c;
}

/* Theme: Blush 2 - Tinta lavada, rosa grisáceo */
[data-board-theme="blush2"] {
  --board-light: #d7cbc9;
  --board-dark: #7a6667;
  --board-selected: #ad9e9d;
}

/* Theme: Sage - Calm editorial, antes Surf */
[data-board-theme="sage"],
[data-board-theme="surf"] {
  --board-light: #cfd8cb;
  --board-dark: #627d69;
  --board-selected: #a1b2a2;
}

/* Theme: Surf 2 - Sage mineral, menos tablero clásico */
[data-board-theme="surf2"] {
  --board-light: #d2d5cf;
  --board-dark: #66706a;
  --board-selected: #a1a8a2;
}

  /* Easing orgánico - se siente más humano */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Duraciones consistentes */
  --duration-fast: 150ms;
  --duration-normal: 280ms;
  --duration-slow: 450ms;
}

body.light-mode {
  --bg-main: var(--tc-gray-950);
  --text-high: var(--tc-text-primary);
  --text-muted: var(--tc-text-tertiary);
  --accent: var(--tc-accent);
  background: var(--bg-main) !important;
  color: var(--text-high) !important;
  color-scheme: light;
}

/* Light mode: transform ALL containers */
body.light-mode nav,
body.light-mode aside {
  background: var(--tc-gray-900) !important;
  color: var(--tc-text-primary) !important;
  border-color: var(--tc-border) !important;
}

body.light-mode main,
body.light-mode main>div {
  background: var(--tc-gray-950) !important;
  color: var(--tc-text-primary) !important;
}

/* Light mode: override inline styles */
body.light-mode [style*="--tc-black-absolute"],
body.light-mode [style*="bg-black"],
body.light-mode [style*="bg-slate-900"] {
  background: var(--tc-gray-900) !important;
}

body.light-mode [style*="--tc-white-pure"] {
  color: var(--tc-text-primary) !important;
}

/* Light mode: Tailwind palette remap */
body.light-mode .bg-black {
  background-color: var(--tc-gray-900) !important;
}

body.light-mode .bg-slate-950 {
  background-color: var(--tc-gray-950) !important;
}

body.light-mode .bg-slate-900 {
  background-color: var(--tc-gray-900) !important;
}

body.light-mode .bg-slate-800 {
  background-color: var(--tc-gray-800) !important;
}

body.light-mode .bg-slate-700 {
  background-color: var(--tc-gray-700) !important;
}

body.light-mode .bg-slate-600 {
  background-color: var(--tc-gray-600) !important;
}

body.light-mode .bg-slate-950\/80 {
  background-color: rgba(246, 241, 234, 0.9) !important;
}

body.light-mode .bg-slate-950\/70 {
  background-color: rgba(246, 241, 234, 0.82) !important;
}

body.light-mode .bg-slate-950\/40 {
  background-color: rgba(246, 241, 234, 0.5) !important;
}

body.light-mode .bg-slate-900\/70 {
  background-color: rgba(239, 233, 225, 0.82) !important;
}

body.light-mode .bg-slate-900\/40 {
  background-color: rgba(239, 233, 225, 0.55) !important;
}

body.light-mode .bg-slate-900\/30 {
  background-color: rgba(239, 233, 225, 0.4) !important;
}

body.light-mode .bg-black\/50 {
  background-color: rgba(27, 22, 18, 0.35) !important;
}

body.light-mode .border-slate-700 {
  border-color: var(--tc-border) !important;
}

body.light-mode .border-slate-800 {
  border-color: var(--tc-gray-800) !important;
}

body.light-mode .border-slate-900 {
  border-color: var(--tc-gray-900) !important;
}

body.light-mode .text-slate-100,
body.light-mode .text-slate-200 {
  color: var(--tc-text-primary) !important;
}

body.light-mode .text-slate-300,
body.light-mode .text-slate-400 {
  color: var(--tc-text-secondary) !important;
}

body.light-mode .text-slate-500,
body.light-mode .text-slate-600 {
  color: var(--tc-text-tertiary) !important;
}

body.light-mode .text-slate-700,
body.light-mode .text-slate-800,
body.light-mode .text-slate-900 {
  color: var(--tc-text-disabled) !important;
}

body.light-mode .placeholder\:text-slate-500::placeholder {
  color: var(--tc-text-tertiary) !important;
}

body.light-mode .hover\:bg-slate-700:hover {
  background-color: var(--tc-gray-700) !important;
}

body.light-mode .hover\:bg-slate-800:hover {
  background-color: var(--tc-gray-800) !important;
}

@media (min-width: 768px) {
  body.light-mode .md\:bg-slate-800 {
    background-color: var(--tc-gray-800) !important;
  }
}

/* Light mode: component harmonization */
body.light-mode .tc-input {
  background: var(--tc-gray-950);
  color: var(--tc-text-primary);
  border-color: var(--tc-border);
}

body.light-mode .tc-input::placeholder {
  color: var(--tc-text-tertiary);
}

body.light-mode .tc-input:focus {
  border-color: var(--tc-gray-600);
}

body.light-mode .tc-modal-overlay,
body.light-mode .tc-glass-overlay {
  background: rgba(27, 22, 18, 0.35);
}

body.light-mode .tc-modal {
  background: var(--tc-gray-950);
  border-color: var(--tc-border);
  box-shadow: 12px 12px 0 var(--tc-gray-800);
}

body.light-mode .tc-glass-content {
  background: rgba(251, 248, 243, 0.96);
  border: 1px solid rgba(27, 22, 18, 0.08);
  box-shadow: 0 24px 64px rgba(27, 22, 18, 0.2),
    0 0 0 1px rgba(27, 22, 18, 0.04);
}

body.light-mode .tc-glass-header {
  border-color: var(--tc-border);
}

body.light-mode .tc-glass-close {
  color: var(--tc-text-tertiary);
}

body.light-mode .tc-glass-close:hover {
  color: var(--tc-text-primary);
}

body.light-mode .tc-history-container {
  background: var(--tc-gray-950);
}

body.light-mode .tc-history-footer {
  border-color: var(--tc-border);
  background: var(--tc-gray-900);
}

body.light-mode .tc-history-nav-btn {
  border-color: var(--tc-border);
  color: var(--tc-text-secondary);
}

body.light-mode .tc-history-nav-btn:hover:not(:disabled) {
  background: var(--tc-gray-900);
  color: var(--tc-text-primary);
}

body.light-mode .tc-history-nav-btn:disabled {
  color: var(--tc-text-disabled);
  border-color: var(--tc-gray-800);
}

body.light-mode .tc-card-title,
body.light-mode .tc-glass-title,
body.light-mode .tc-history-title,
body.light-mode .tc-ingame-mode,
body.light-mode .tc-auth-title,
body.light-mode .tc-donate-title,
body.light-mode .tc-feedback-title,
body.light-mode .tc-empty-state h3,
body.light-mode .tc-result-stat-value,
body.light-mode .tc-invite-code code,
body.light-mode .tc-donate-option-name {
  color: var(--tc-text-primary);
}

body.light-mode .tc-feedback-edge-btn:hover .tc-feedback-edge-text,
body.light-mode .tc-mode-btn:hover .tc-mode-label,
body.light-mode .tc-support-btn:hover,
body.light-mode .tc-auth-tab:hover,
body.light-mode .tc-auth-forgot:hover {
  color: var(--tc-text-primary);
}

body.light-mode .tc-btn-ghost:hover {
  background: var(--tc-gray-800);
  color: var(--tc-text-primary);
  border-color: var(--tc-gray-600);
}

body.light-mode .tc-btn-primary:hover {
  background: var(--tc-gray-200);
  border-color: var(--tc-gray-200);
}

body.light-mode ::-webkit-scrollbar-track {
  background: var(--tc-gray-900);
  border-left: 1px solid var(--tc-gray-700);
}

body.light-mode ::-webkit-scrollbar-thumb {
  background: var(--tc-gray-600);
}

body.light-mode ::-webkit-scrollbar-thumb:hover {
  background: var(--tc-gray-500);
}

body.light-mode * {
  scrollbar-color: var(--tc-gray-600) var(--tc-gray-900);
}

/* ===== Board Wrapper with External Coordinates ===== */

.board-wrapper {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  max-width: 620px;
  width: 100%;
}

.rank-labels {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  height: 100%;
  padding: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  user-select: none;
}

.rank-labels span {
  height: calc(100% / 8);
  display: flex;
  align-items: center;
}

.board-with-files {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.file-labels {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  user-select: none;
}

.file-labels span {
  width: calc(100% / 8);
  text-align: center;
}

/* ===== Board Grid ===== */

.board-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  touch-action: none;
  /* Sin borde - editorial puro */
  overflow: hidden;
  /* Prevenir drag y selección nativa en todo el tablero */
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  /* Transición suave para indicadores de turno */
  transition: box-shadow 0.4s ease;
}

/* Turn indicators - Cursor + Glow combo */
.board-grid.your-turn {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4),
              0 0 20px rgba(255, 255, 255, 0.1);
}

.board-grid.your-turn .square {
  cursor: pointer;
}

.board-grid.cpu-turn {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.board-grid.check-alert {
  box-shadow: 0 0 0 2px var(--tc-champagne),
              0 0 20px rgba(212, 175, 55, 0.18);
}

.board-grid.cpu-turn .square {
  cursor: default;
}

/* Subtle opacity on pieces when not your turn */
.board-grid.cpu-turn .piece {
  opacity: 0.95;
  transition: opacity 0.3s ease;
}

.board-grid.your-turn .piece {
  opacity: 1;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter .12s ease;
  /* Prevenir drag y selección nativa */
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.square.light {
  /* Gentle tonal modulation to separate piece from square without adding edge treatment */
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), rgba(0, 0, 0, 0.025)), var(--board-light);
}

.square.dark {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.02)), var(--board-dark);
}

/* REMOVED hover filter - was inverting piece colors */

.square:hover {
  filter: brightness(1.01);
}

.square:active {
  transform: scale(.99);
}

.square.hover .piece {
  transform: translateY(-2px) scale(1.04);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25));
}

.square .piece {
  transition: transform 120ms ease, filter 120ms ease;
}


/* Selected square - color relacionado al tema */
.square.selected {
  background: var(--board-selected, #8a8a8a) !important;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

/* Guides */
.square.target::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 999px;
  border: 3px solid rgba(251, 191, 36, .9);
  box-shadow: 0 0 0 6px rgba(251, 191, 36, .12);
  animation: pulse 1.3s ease-in-out infinite;
  pointer-events: none;
}

.square.fromHint::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 14px;
  border: 3px solid var(--tc-accent-amber);
  box-shadow: 0 0 0 6px rgba(251, 191, 36, 0.12);
  animation: pulse2 1.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: .85
  }

  50% {
    transform: scale(1.07);
    opacity: .45
  }
}

@keyframes pulse2 {

  0%,
  100% {
    transform: scale(1);
    opacity: .9
  }

  50% {
    transform: scale(1.05);
    opacity: .55
  }
}

/* Move indicators */
.dot {
  width: 16%;
  height: 16%;
  background: rgba(226, 232, 240, .35);
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 0 0 6px rgba(226, 232, 240, .08);
  animation: pingIn 140ms ease-out forwards;
}

.capture-ring {
  width: 84%;
  height: 84%;
  border-radius: 999px;
  border: 2px solid rgba(226, 232, 240, .45);
  position: absolute;
  pointer-events: none;
  box-shadow: 0 0 0 6px rgba(226, 232, 240, .06) inset;
  animation: pingIn 140ms ease-out forwards;
}

/* Legal move contrast per square */
.square.light .dot {
  background: rgba(15, 23, 42, .28);
  box-shadow: 0 0 0 6px rgba(15, 23, 42, .08);
}

.square.dark .dot {
  background: rgba(226, 232, 240, .42);
  box-shadow: 0 0 0 6px rgba(226, 232, 240, .10);
}

.square.light .capture-ring {
  border-color: rgba(15, 23, 42, .32);
  box-shadow: 0 0 0 6px rgba(15, 23, 42, .06) inset;
}

.square.dark .capture-ring {
  border-color: rgba(226, 232, 240, .50);
  box-shadow: 0 0 0 6px rgba(226, 232, 240, .08) inset;
}

.ping {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.ping::before {
  content: "";
  width: 18%;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  background: rgba(255, 255, 255, .32);
  transform: scale(.6);
  animation: pingIn 120ms ease-out forwards;
}

.ping.ping-capture::before {
  width: 55%;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, .32);
}

@keyframes pingIn {
  to {
    transform: scale(1);
  }
}

.piece {
  width: 76%;
  height: 76%;
  pointer-events: none;
  user-select: none;
  display: block;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
}

/* Prevent native drag ghost on all piece images and SVGs */
.piece img,
.piece svg,
.piece-wrap img,
.piece-wrap svg,
.square img,
.square svg {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
}

/* Color the pieces using CSS filters - Minimal editorial style */
/* Force white filter on ALL white pieces - no exceptions */
.piece.white,
img.piece.white,
.white.piece,
[data-color="white"] .piece,
[data-color="white"] img {
  /* Pure white - minimal, contrasts naturally with sand-toned board */
  filter: brightness(0) invert(1) drop-shadow(0 2px 4px rgba(0, 0, 0, .15)) !important;
}

/* Prevent hover from changing white piece colors */
.square:hover .piece.white,
.square:hover img.piece.white,
.piece.white:hover {
  filter: brightness(0) invert(1) drop-shadow(0 2px 4px rgba(0, 0, 0, .15)) !important;
}

.piece.black,
img.piece.black,
.black.piece {
  /* Solid black with subtle shadow */
  filter: brightness(0) drop-shadow(0 2px 4px rgba(0, 0, 0, .1)) !important;
}

.piece-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  /* Size control lives here (not in the SVG itself), so SVG intrinsic
         width/height/viewBox won't affect board sizing. */
  /* Shift to compensate for Font Awesome's internal baseline padding */
  /* Trial reverted: editorial visibility sizing was base 0.98, p 0.92, k/q 0.99, b/n 0.97, r 0.96 */
  transform: scale(0.94);
  transform-origin: center;
}

/* Pawns a touch smaller */
.piece-wrap.piece-p {
  transform: scale(0.88);
}

/* ===== Board Theme Selector - UMV Style Horizontal ===== */
.board-theme-selector {
  position: absolute;
  bottom: -3rem;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  z-index: 20;
  width: auto;
  height: 40px;
  pointer-events: none;
}

.board-theme-selector > * {
  grid-area: 1/1;
  pointer-events: auto;
}

.theme-trigger {
  width: 3.5rem;
  height: 2px;
  background: var(--tc-gray-700);
  border: none;
  cursor: pointer;
  position: relative;
  transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
  padding: 0;
  margin: 0;
  opacity: 1;
}

.theme-trigger::after {
  content: "";
  position: absolute;
  inset: -15px -20px;
}

.theme-trigger:hover {
  background: var(--tc-gray-300);
}

.board-theme-selector.expanded .theme-trigger {
  width: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.theme-menu {
  display: flex;
  flex-direction: row;
  gap: 1rem;
  padding: 0.5rem;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(5px) scale(0.95);
  transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

.board-theme-selector.expanded .theme-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.theme-dot {
  position: relative;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  padding: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  opacity: 0.5;
}

.theme-dot:hover {
  opacity: 0.9;
  transform: scale(1.15);
}

.theme-dot.active {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.6);
}

.theme-dot .dot-preview {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

.theme-close {
  background: transparent;
  border: none;
  color: var(--tc-gray-500);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: all 0.2s ease;
  margin-left: 0.25rem;
}

.theme-close:hover {
  color: var(--tc-white-pure);
  transform: rotate(90deg);
}

/* Mobile adjustments */
@media (max-width: 767px) {
  .board-theme-selector {
    place-items: end center;
    bottom: -2rem;
  }

  .theme-menu {
    gap: 0.55rem;
    padding: 0.4rem;
  }

  .theme-dot {
    width: 1.05rem;
    height: 1.05rem;
  }

  .theme-close {
    margin-left: 0;
  }
}

/* ===== Board Footer Controls (Subtle & Elegant) ===== */

/* ===== Board Footer Controls (Subtle & Elegant) - REPLACED BY FAB ===== */
/*
.board-footer {
  display: flex;
  gap: 1.2rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.5rem;
  padding: 1rem;
  border-top: none;
  width: 100%;
  max-width: 580px;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.board-footer:hover {
  opacity: 0.85;
}

.board-footer-btn {
  background: transparent;
  border: none;
  color: var(--text-high);
  font-size: 1.1rem;
  transition: all 0.2s ease;
  cursor: pointer;
  padding: 0.5rem;
  opacity: 1;
}

.board-footer-btn:hover {
  color: var(--accent);
  transform: scale(1.1);
}

#guideToggle:checked~.board-footer label[for="guideToggle"],
#flipToggle:checked~.board-footer label[for="flipToggle"] {
  color: var(--accent);
}

.board-footer-divider {
  width: 2px;
  height: 2rem;
  background: var(--text-high);
  opacity: 0.2;
}
*/

/* ===== Ultra-Minimal Vertical (UMV) Controls (NEW) ===== */
.umv-container {
  position: absolute;
  right: -3rem;
  /* Perfect spacing restored */
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  /* Higher priority */
  display: grid;
  place-items: center;
  width: 40px;
  height: auto;
  pointer-events: none;
}

.umv-container--left {
  left: -3rem;
  right: auto;
}

.umv-container>* {
  grid-area: 1/1;
  pointer-events: auto;
}

.umv-trigger {
  width: 2px;
  height: 3.5rem;
  background: var(--tc-gray-700);
  border: none;
  cursor: pointer;
  position: relative;
  transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
  padding: 0;
  margin: 0;
  opacity: 1;
}

/* Expanded state: hide trigger smoothly */
.umv-container.expanded .umv-trigger {
  height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.umv-trigger::after {
  content: "";
  position: absolute;
  inset: -15px -20px;
}

.umv-trigger:hover {
  background: var(--tc-gray-300);
}

.umv-trigger i {
  display: none;
}

.umv-menu {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  height: auto;
  transform: translateY(5px) scale(0.95);
  transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
  align-items: center;
}

.umv-container.expanded .umv-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.umv-close {
  color: var(--tc-gray-500);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.75rem;
  background: transparent;
  border: none;
  margin-bottom: 0.5rem;
  opacity: 1;
}

.umv-close:hover {
  color: var(--tc-gray-400);
  opacity: 1;
  transform: rotate(90deg);
}

.umv-item {
  color: var(--tc-gray-500);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
}

body.zen-mode .umv-item {
  color: var(--tc-gray-500);
}

.umv-item:hover {
  color: var(--tc-gray-400);
  opacity: 1;
  transform: scale(1.15);
}

.tc-study-uvm-menu {
  gap: 0.95rem;
  position: relative;
}

.tc-study-uvm-menu > * {
  position: relative;
  z-index: 1;
}

.tc-study-uvm-mode {
  font-size: 0.9rem;
  opacity: 0.55;
}

.tc-study-uvm-mode.is-active {
  color: var(--tc-gray-500);
  opacity: 0.8;
}

.tc-study-uvm-edit {
  opacity: 0.75;
}

.tc-study-uvm-edit.is-active {
  color: var(--tc-gray-500);
  opacity: 0.8;
}

.tc-study-piece-palette {
  width: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--tc-gray-800);
}

#tcStudyUvmControls:not(.tc-study-edit-active) #tcStudyPiecePalette {
  display: none;
}

.tc-study-piece-btn {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--tc-gray-200);
  opacity: 0.72;
  border: 2px solid transparent;
  transition: border-color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.tc-study-piece-btn--black {
  color: var(--tc-gray-500);
}

.tc-study-piece-btn.is-selected {
  opacity: 0.98;
  border-color: rgba(255, 255, 255, 0.6);
}


/* Active states for checkboxes in UMV */
#guideToggle:checked~.umv-container label[for="guideToggle"],
#flipToggle:checked~.umv-container label[for="flipToggle"] {
  color: var(--tc-accent);
}

/* Mobile adjustments for UMV */
@media (max-width: 900px) {
  .umv-container {
    right: 1rem;
    flex-direction: row-reverse;
    top: auto;
    bottom: -3.5rem;
    transform: none;
  }

  .umv-container--left {
    left: 1rem;
    right: auto;
  }

  .umv-trigger {
    width: 3rem;
    height: 2px;
  }

  .umv-menu {
    flex-direction: row;
    transform: translateX(10px);
  }

  .umv-container--left .umv-menu {
    transform: translateX(-10px);
  }

  .umv-container.expanded .umv-menu {
    transform: translateX(0);
  }

  .tc-study-piece-palette {
    width: auto;
  }

  .tc-study-piece-btn {
    width: 1.5rem;
    height: 1.5rem;
  }

  /* Main mobile UVM (sound/guides/fullscreen): move to top of board,
     horizontal trigger + horizontal expansion like theme selector */
  #umvControls.umv-container {
    left: 50%;
    right: auto;
    top: calc((var(--tc-mobile-board-air, 1rem) * -1) - var(--tc-mobile-uvm-line-thickness, 2px));
    bottom: auto;
    width: max-content;
    min-width: 40px;
    height: var(--tc-mobile-uvm-line-thickness, 2px);
    place-items: start center;
    transform: translateX(-50%);
  }

  #umvControls .umv-trigger {
    align-self: start;
  }

  #umvControls .umv-menu {
    align-self: start;
  }

  #umvControls .umv-menu {
    gap: 0.8rem;
    justify-content: center;
    transform: translateY(6px) scale(0.95);
  }

  #umvControls.expanded .umv-menu {
    transform: translateY(0) scale(1);
  }

}

/* ===== Player Name Badges (Removed for minimal design) ===== */

.player-badge {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0;
  width: 100%;
  max-width: 620px;
}

.player-opponent {
  margin-bottom: 0.5rem;
}

.player-me {
  margin-top: 0.5rem;
  margin-bottom: 0;
}

/* Dot circular pequeño en lugar de cuadrado grande */
.player-icon {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--text-high);
  border-radius: 50%;
  flex-shrink: 0;
}

.player-name {
  font-weight: 600;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  color: var(--text-high);
  text-transform: uppercase;
}

/* ===== Zen Mode (Fullscreen) ===== */

body.zen-mode {
  background: var(--bg-main) !important;
  /* Use theme variable, not blue */
}

body.zen-mode nav,
body.zen-mode aside,
body.zen-mode header,
body.zen-mode .player-badge {
  display: none !important;
}

body.zen-mode main {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 3rem;
  background: var(--bg-main) !important;
  min-height: 100vh;
  overflow: visible !important;
}

body.zen-mode .tc-board-container {
  max-width: min(78vmin, calc(100vw - 6rem), calc(100vh - 10rem)) !important;
  /* Force space for UMV */
  width: min(78vmin, calc(100vw - 6rem), calc(100vh - 10rem)) !important;
  height: auto !important;
  overflow: visible !important;
  background: transparent !important;
}

body.zen-mode .umv-container {
  right: -3rem;
  /* Same distance as normal mode */
  z-index: 10000;
}

body.zen-mode .umv-container--left {
  left: -3rem;
  right: auto;
}

body.zen-mode main > .flex-1 {
  background: var(--bg-main) !important;
  padding: 0 !important;
  overflow: visible !important;
}

body.zen-mode .board-grid {
  background: transparent;
}

body.zen-mode .tc-feedback-edge-tab,
html:fullscreen .tc-feedback-edge-tab,
:fullscreen .tc-feedback-edge-tab {
  display: none !important;
}

body.zen-mode .umv-trigger {
  background: var(--tc-gray-700);
}

/* Button to exit zen mode */
.zen-exit {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 100;
  background: transparent;
  color: var(--tc-gray-500);
  border: none;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  transition: all 0.2s ease;
  display: none;
  opacity: 0.7;
}

.zen-exit:hover {
  color: var(--tc-white-pure);
  opacity: 1;
  transform: rotate(90deg);
}

body.zen-mode .zen-exit {
  display: block;
}

/* Text rendering */

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #0f172a;
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .38rem .7rem;
  border-radius: 999px;
  font-size: .75rem;
  border: 1px solid rgba(148, 163, 184, .22);
  background: rgba(15, 23, 42, .55);
  color: rgba(226, 232, 240, .92);
  user-select: none;
}

.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .72rem;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, .25);
  background: rgba(15, 23, 42, .65);
  color: rgba(226, 232, 240, .92);
}

/* Stars */
.star {
  font-size: 14px;
  line-height: 1;
  opacity: .95;
}

.star.off {
  opacity: .25;
}

/* Collapse */
details summary::-webkit-details-marker {
  display: none;
}

/* Piece move animation */
/* Piece move animation (screen-space overlay so rotation doesn't break on mobile) */
.move-ghost {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 650ms ease, opacity 200ms ease;
  will-change: transform, opacity;
  opacity: 1;
}

/* Match in-board piece sizing (avoid the "zoom" feel on opponent moves) */
.move-ghost svg {
  width: 76%;
  height: 76%;
  display: block;
}

/* Last move highlight */
.square.last-from::after,
.square.last-to::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.square.last-from::after {
  background: var(--tc-lastmove-from, rgba(4, 120, 87, 0.18));
  box-shadow: inset 0 0 0 2px var(--tc-lastmove-from-border, rgba(4, 120, 87, 0.5));
}

.square.last-to::after {
  background: var(--tc-lastmove-to, rgba(4, 120, 87, 0.35));
  box-shadow: inset 0 0 0 2px var(--tc-lastmove-to-border, rgba(4, 120, 87, 0.7));
}

/* Coach highlight (review) - unified subtle gray border */
.square.coach-from::after,
.square.coach-to::after,
.square.coach-cap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.square.coach-from::after {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.square.coach-to::after {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}

.square.coach-cap::after {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

/* Tiny additions for this 2P build */
.btn {
  transition: filter .12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.btn:hover {
  filter: brightness(1.05);
}

/* Guide coordinates (A-H / 1-8) */
.coord {
  position: absolute;
  font-family: var(--tc-font-mono, 'Space Mono', monospace);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  opacity: .55;
  user-select: none;
  pointer-events: none;
  z-index: 2;
}

/* Rank: esquina superior izquierda, pegado al borde */
.coord.rank {
  top: 2px;
  left: 3px;
}

/* File: esquina inferior derecha, pegado al borde */
.coord.file {
  right: 3px;
  bottom: 2px;
}

/* Improve coordinate contrast per square */
.square.light .coord {
  opacity: 1;
  color: rgba(15, 23, 42, .45);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
}

.square.dark .coord {
  opacity: 1;
  color: rgba(226, 232, 240, .55);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .40);
}

.square.light .coord {
  color: rgba(15, 23, 42, .58);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
  opacity: .95;
}

.square.dark .coord {
  color: rgba(226, 232, 240, .62);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .35);
  opacity: .95;
}

/* Coordinate hover highlight (reference only) */
.square.light .coord.rel {
  color: rgba(10, 10, 10, .75);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  opacity: .85;
}

.square.dark .coord.rel {
  color: rgba(245, 245, 245, .78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
  opacity: .85;
}

/* Move animation (simple visual cue) */
.move-fly {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transition: transform 180ms ease-in-out;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .35));
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .move-fly {
    transition: none;
  }
}


/* ===== Feedback widget ===== */

#fbOpen {
  background: rgba(15, 23, 42, .92);
  border: 1px solid rgba(51, 65, 85, 1);
  color: rgba(226, 232, 240, 1);
  border-radius: 9999px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .02em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

#fbOpen:hover {
  background: rgba(15, 23, 42, 1);
}

#fbFab {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 9998;
  pointer-events: auto;
  display: block;
}

#fbFab button {
  -webkit-appearance: none;
  appearance: none;
}

#fbPanel:not(.tc-glass-overlay) {
  position: fixed;
  right: 14px;
  bottom: 64px;
  z-index: 9998;
  width: 340px;
  max-width: calc(100vw - 28px);
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}

#fbPanel.open:not(.tc-glass-overlay) {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#fbScrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 9997;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s ease;
}

#fbScrim.open {
  opacity: 1;
  pointer-events: auto;
}


/* History collapse */
#historyPanel.collapsed #moves {
  display: none !important;
}

#historyPanel.collapsed #recordControls {
  display: none !important;
}

#historyPanel.collapsed {
  overflow: hidden !important;
}

/* ===== Registro: panel fijo + lista scrolleable ===== */
#historyPanel {
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#recordControls {
  flex: 0 0 auto;
}

#moves.rec-moves {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-top: 12px;
}

/* Navegación (bloque único, estilo captura) */
.rec-nav {
  display: flex;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .18);
  background: rgba(15, 23, 42, .35);
}

.rec-navbtn {
  flex: 1 1 0%;
  min-width: 52px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-right: 1px solid rgba(148, 163, 184, .12);
  background: transparent;
  color: rgba(226, 232, 240, .70);
}

.rec-navbtn:last-child {
  border-right: 0;
}

.rec-navbtn:hover {
  background: rgba(148, 163, 184, .10);
  color: rgba(226, 232, 240, .95);
}

.rec-navbtn:active {
  background: rgba(148, 163, 184, .14);
}

.rec-navbtn:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.rec-ic {
  width: 20px;
  height: 20px;
}

/* Tighten nav on very small screens so it stays on one line */
@media (max-width: 420px) {
  .rec-navbtn {
    min-width: 44px;
    height: 40px;
  }

  .rec-ic {
    width: 18px;
    height: 18px;
  }
}

/* Letras de jugadas en 600 */
#moves button {
  font-weight: 600 !important;
}


/* Registro de Jugadas UX */
@keyframes recShake {
  0% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-2px);
  }

  50% {
    transform: translateX(2px);
  }

  75% {
    transform: translateX(-1px);
  }

  100% {
    transform: translateX(0);
  }
}

.rec-shake {
  animation: recShake .35s ease-in-out;
}

@keyframes recPulse {
  0% {
    filter: brightness(1);
  }

  35% {
    filter: brightness(1.35);
  }

  100% {
    filter: brightness(1);
  }
}

.rec-pulse {
  animation: recPulse .9s ease-out;
}


/* ===== Mobile selection visibility ===== */
@media (max-width: 767px) {
  .dot {
    width: 28%;
    height: 28%;
    box-shadow: 0 0 0 10px rgba(34, 197, 94, .10);
  }

  .capture-ring {
    width: 96%;
    height: 96%;
    border-width: 5px;
    box-shadow: 0 0 0 8px rgba(239, 68, 68, .08) inset;
  }

  .square.selected::after {
    inset: 6%;
    border-width: 3px;
    box-shadow: none;
  }

  .square.lastmove-to::after {
    inset: 8%;
    border-width: 4px;
  }

  .square.lastmove-from::after {
    inset: 8%;
    border-width: 4px;
  }
}


/* ===== Select UI (custom caret + better right air) ===== */
select.select-ui {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 44px;
  /* air on the right */
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'><path d='M6 8l4 4 4-4' stroke='%23cbd5e1' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
}

select.select-ui:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(251, 191, 36, .20);
  border-color: rgba(251, 191, 36, .55);
}


/* ===== Remove mobile selection hint ===== */
#mobileSelHint {
  display: none !important;
}


/* ===== Online black view (flip board for black) ===== */
#board.black-view {
  transform: rotate(180deg);
  transform-origin: center;
}

#board.black-view .square {
  transform: rotate(180deg);
  transform-origin: center;
}

/* IMPORTANT: .square:active sets transform and would override the rotate(180deg)
       used to keep pieces upright for black-view. Preserve rotation + press effect. */
#board.black-view .square:active {
  transform: rotate(180deg) scale(.99);
  transform-origin: center;
}


/* Auth (honeypot input, keeps bots away) */
.auth-hp {
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}


/* Hide scrollbar (mobile tabs) */
.no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}


/* ===== Coach chat ===== */
.coach-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.coach-bubble {
  background: rgba(15, 23, 42, .55);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 16px;
  padding: 10px 12px;
  color: rgba(226, 232, 240, .96);
  font-size: 13px;
  line-height: 1.45;
}

.coach-bubble.muted {
  color: rgba(226, 232, 240, .82);
}

.coach-bubble.warn {
  background: rgba(51, 65, 85, .55);
  border-color: rgba(251, 191, 36, .25);
}

.coach-bubble strong {
  font-weight: 800;
}


/* ===== Arrow overlay ===== */
.arrow-overlay {
  position: absolute;
  inset: 8px;
  width: auto;
  height: auto;
  pointer-events: none;
  z-index: 10;
}

.arrow-line {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .95;
}

.arrow-line.arrow-red {
  stroke: rgba(239, 68, 68, .85);
}

.arrow-line.arrow-green {
  stroke: rgba(34, 197, 94, .85);
}

.arrow-line.arrow-neutral {
  stroke: rgba(148, 163, 184, .92);
}

.arrow-line.arrow-warning {
  stroke: rgba(245, 158, 11, .92);
}

.arrow-head {
  opacity: .95;
}

.arrow-head.arrow-red {
  fill: rgba(239, 68, 68, .85);
}

.arrow-head.arrow-green {
  fill: rgba(34, 197, 94, .85);
}

.arrow-head.arrow-neutral {
  fill: rgba(148, 163, 184, .92);
}

.arrow-head.arrow-warning {
  fill: rgba(245, 158, 11, .92);
}

.arrow-line.arrow-dashed {
  stroke-dasharray: 12 10;
}

.arrow-line.arrow-anim {
  stroke-dasharray: 500;
  stroke-dashoffset: 500;
  animation: arrowDraw .38s ease-out forwards;
}

@keyframes arrowDraw {
  to {
    stroke-dashoffset: 0;
  }
}



/* Coach: highlight the move being reviewed in the history list */
.coach-target {
  background: rgba(56, 189, 248, .10) !important;
  border-color: rgba(56, 189, 248, .55) !important;
  color: rgba(224, 242, 254, .95) !important;
}

/* Backward compatibility (older JS used these names) */
.coach-bubble--warn {
  border-color: rgba(251, 191, 36, .45);
  background: rgba(251, 191, 36, .08);
  color: rgba(254, 243, 199, .95);
}

.coach-bubble--muted {
  border-color: rgba(148, 163, 184, .18);
  background: rgba(148, 163, 184, .05);
  color: rgba(148, 163, 184, .92);
}


/* Drag & drop */
.square.dragging-from .piece-wrap {
  opacity: 0.28;
  filter: grayscale(0.15);
}

.square.drag-over {
  box-shadow: inset 0 0 0 2px rgba(226, 232, 240, .40);
}

.square.drag-over-cap {
  box-shadow: inset 0 0 0 2px rgba(239, 68, 68, .55);
}

.drag-ghost {
  transition: none !important;
  opacity: .95;
}

/* Subtle piece settle on move */
.piece-settle .piece-wrap,
.piece-settle .piece {
  animation: pieceSettle 180ms ease-out;
}

@keyframes pieceSettle {
  0% {
    transform: translateY(-2px) scale(1.02);
  }

  100% {
    transform: translateY(0) scale(1);
  }
}

/* Capture particles (soft, minimal) */
.capture-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: block;
}

.capture-particles .particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(226, 232, 240, 0.6);
  transform: translate(-50%, -50%);
  animation: particleBurst 320ms ease-out forwards;
}

.square.light .capture-particles .particle {
  background: rgba(15, 23, 42, 0.45);
}

@keyframes particleBurst {
  to {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy)));
    opacity: 0;
  }
}

/* ========================================
   THATCHESS - TRANSICIONES EDITORIALES
   Motion con intención, feedback amable
   ======================================== */

/* Panel transitions - entrada suave */
.panel-content {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
}

.panel-content.active {
  opacity: 1;
  transform: translateY(0);
}

/* Sub-panel transitions */
.sub-panel {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.sub-panel.active {
  opacity: 1;
}

/* Tab transitions */
.tab-btn {
  transition: opacity var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

/* ========================================
   FEEDBACK AMABLE - Mindful UX
   Errores como información, no castigo
   ======================================== */

/* Movimiento ilegal - shake gentil, no agresivo */
@keyframes gentleShake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-3px);
  }

  40% {
    transform: translateX(3px);
  }

  60% {
    transform: translateX(-2px);
  }

  80% {
    transform: translateX(2px);
  }
}

.gentle-shake {
  animation: gentleShake 400ms var(--ease-out);
}

/* Hint de oportunidad - pulso suave en amarillo */
@keyframes opportunityPulse {

  0%,
  100% {
    box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.4);
  }

  50% {
    box-shadow: inset 0 0 0 3px rgba(251, 191, 36, 0.6);
  }
}

.opportunity-hint {
  animation: opportunityPulse 1.5s ease-in-out infinite;
}

/* Estado de espera - breathing animation */
@keyframes breathe {

  0%,
  100% {
    opacity: 0.6;
  }

  50% {
    opacity: 1;
  }
}

.waiting-state {
  animation: breathe 2s ease-in-out infinite;
}

/* ========================================
   MEJORAS DE PIEZAS - Movimiento fluido
   ======================================== */

/* Pieza siendo arrastrada */
.square.dragging-from .piece-wrap {
  opacity: 0.25;
  filter: grayscale(0.2);
  transition: opacity var(--duration-fast) var(--ease-out),
    filter var(--duration-fast) var(--ease-out);
}

/* Pieza al aterrizar - settle effect mejorado */
.piece-settle .piece-wrap,
.piece-settle .piece {
  animation: pieceSettleSoft 200ms var(--ease-out);
}

@keyframes pieceSettleSoft {
  0% {
    transform: translateY(-4px) scale(1.03);
    filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.3));
  }

  60% {
    transform: translateY(1px) scale(0.99);
  }

  100% {
    transform: translateY(0) scale(1);
    filter: none;
  }
}

/* Ghost de movimiento - más suave */
.move-ghost {
  transition: transform 550ms var(--ease-out),
    opacity 180ms var(--ease-out);
}

/* ========================================
   BOTONES Y CONTROLES - Hover editorial
   ======================================== */

/* Botón con lift sutil */
.tc-btn,
.btn {
  transition: transform var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out);
}

.tc-btn:hover,
.btn:hover {
  transform: translateY(-1px);
}

.tc-btn:active,
.btn:active {
  transform: translateY(0);
}

/* Navegación con transiciones suaves */
.tc-nav-btn {
  transition: background var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

/* ========================================
   SIDEBAR Y PANELES - Aire editorial
   ======================================== */

/* Más espacio en el sidebar */
#sidebar {
  transition: background var(--duration-normal) var(--ease-out);
}

#right-sidebar {
  transition: background var(--duration-normal) var(--ease-out);
}

/* Input focus mejorado */
.tc-input:focus,
input:focus {
  transition: border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

/* ========================================
   ACCESIBILIDAD
   ======================================== */

/* Focus ring visible y bonito */
*:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-main),
    0 0 0 4px var(--accent);
}

/* Respeta preferencia de movimiento reducido */
@media (prefers-reduced-motion: reduce) {

  .panel-content,
  .sub-panel,
  .tab-btn,
  .tc-btn,
  .btn,
  .tc-nav-btn,
  .move-ghost,
  .piece-settle .piece-wrap,
  .piece-settle .piece,
  .gentle-shake,
  .opportunity-hint,
  .waiting-state {
    animation: none !important;
    transition: none !important;
  }
}
