/* ═══════════════════════════════════════════════
   FOTOTERAPIA — Estilos principales
   Ratio de imagen: 1980×1535 (~1.29:1, horizontal)
═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Jost:wght@300;400;500&display=swap');

/* ── Variables modo claro ── */
:root {
  --accent: #7C6A8E;
  --accent-light: color-mix(in srgb, var(--accent) 20%, white);
  --bg: #F5F0EB;
  --bg2: #EDE6DC;
  --surface: #FDFAF6;
  --surface2: #F0EAE0;
  --text: #2C2420;
  --text-muted: #8A7B70;
  --border: #D8CECC;
  --shadow: 0 2px 12px rgba(44,36,32,0.10);
  --shadow-lg: 0 8px 40px rgba(44,36,32,0.16);
  --radius: 12px;
  --radius-sm: 6px;
  --sidebar-w: 280px;
  --flip-duration: 0.5s;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Jost', system-ui, sans-serif;
  /* Ratio horizontal 1980x1535 */
  --card-ratio: 1980 / 1535;
}

/* ── Modo oscuro: sistema ── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1A1714;
    --bg2: #231F1C;
    --surface: #211E1B;
    --surface2: #2C2825;
    --text: #EDE6DC;
    --text-muted: #8A7B70;
    --border: #3A3330;
    --shadow: 0 2px 12px rgba(0,0,0,0.35);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
    --accent-light: color-mix(in srgb, var(--accent) 25%, #1A1714);
  }
}

/* ── Modo oscuro: toggle manual ── */
[data-theme="dark"] {
  --bg: #1A1714;
  --bg2: #231F1C;
  --surface: #211E1B;
  --surface2: #2C2825;
  --text: #EDE6DC;
  --text-muted: #8A7B70;
  --border: #3A3330;
  --shadow: 0 2px 12px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --accent-light: color-mix(in srgb, var(--accent) 25%, #1A1714);
}

/* ── Modo claro: toggle manual forzado ── */
[data-theme="light"] {
  --bg: #F5F0EB;
  --bg2: #EDE6DC;
  --surface: #FDFAF6;
  --surface2: #F0EAE0;
  --text: #2C2420;
  --text-muted: #8A7B70;
  --border: #D8CECC;
  --shadow: 0 2px 12px rgba(44,36,32,0.10);
  --shadow-lg: 0 8px 40px rgba(44,36,32,0.16);
  --accent-light: color-mix(in srgb, var(--accent) 20%, white);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }

/* ── App Layout ── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.3s ease, background 0.3s;
  z-index: 10;
}

.sidebar-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-header h1 em { font-style: italic; color: var(--accent); }

/* ── Theme toggle ── */
#btn-theme {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
#btn-theme:hover { border-color: var(--accent); background: var(--accent-light); }

.sidebar-section {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.section-label {
  font-size: 0.63rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Deck Selector — dorsos grandes ── */
#deck-selector {
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: center;
}

.deck-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 2.5px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.deck-btn:hover .deck-back-preview {
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  transform: translateY(-2px);
}

.deck-btn.active .deck-back-preview {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent), 0 4px 16px rgba(0,0,0,0.15);
}

.deck-btn.active .deck-label { color: var(--accent); font-weight: 500; }

.deck-back-preview {
  width: 100%;
  aspect-ratio: 1980 / 1535;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg2);
  border: 2px solid var(--border);
  transition: all 0.2s ease;
}

.deck-back-preview img { width: 100%; height: 100%; object-fit: cover; }

.deck-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  transition: color 0.2s;
}

/* ── Mode Selector ── */
.mode-toggle {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.mode-toggle button {
  flex: 1;
  padding: 8px 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: all 0.2s;
  border-right: 1px solid var(--border);
}

.mode-toggle button:last-child { border-right: none; }
.mode-toggle button.active { background: var(--accent); color: white; font-weight: 500; }

/* ── Preset Selector ── */
#preset-selector { display: flex; flex-wrap: wrap; gap: 6px; }

.preset-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface2);
  font-size: 0.8rem;
  color: var(--text);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.preset-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.preset-btn.active { border-color: var(--accent); background: var(--accent); color: white; }

.preset-delete { font-size: 1rem; opacity: 0.6; margin-left: 2px; transition: opacity 0.2s; }
.preset-delete:hover { opacity: 1; }

/* ── Custom Preset ── */
.custom-preset-row { width: 100%; margin-top: 6px; }

.custom-preset-row summary {
  font-size: 0.76rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}
.custom-preset-row summary:hover { color: var(--accent); }

.custom-inputs { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

.custom-inputs label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.custom-inputs input[type="number"],
.custom-inputs input[type="text"] {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 0.82rem;
  color: var(--text);
}

.custom-inputs input[type="text"] { width: 100%; margin-top: 2px; }
.custom-inputs .custom-name-row { flex-direction: column; align-items: center; gap: 4px; }

.custom-btn-row { display: flex; gap: 6px; margin-top: 4px; }

.custom-btn-row button {
  flex: 1;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.2s;
}

#custom-apply { background: var(--accent); color: white; }
#custom-apply:hover { filter: brightness(1.1); }
#custom-save { border: 1px solid var(--accent); color: var(--accent); background: transparent; }
#custom-save:hover { background: var(--accent-light); }

/* ── Action Buttons ── */
.action-buttons {
  display: flex;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background: var(--surface);
}

.action-btn {
  flex: 1;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1.5px solid var(--border);
  color: var(--text);
  background: var(--surface2);
}

.action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
#btn-reset { color: #9B4040; border-color: #D4AAAA; }
#btn-reset:hover { background: rgba(155,64,64,0.1); border-color: #9B4040; }

/* ── Main Content ── */
#main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Board Area ── */
#board-area {
  flex: 1;
  padding: 20px;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Necesario para que el hijo pueda calcular su altura correctamente */
  min-height: 0;
}

/* ── Card Grid ── */
/*
  Estrategia: el tablero debe caber en la pantalla sin scroll.
  Las cartas son horizontales (ratio ~1.29:1).
  Usamos una variable CSS --cols y --rows seteadas por JS
  para calcular el tamaño máximo que cabe en el viewport disponible.

  Limitamos por ANCHO: cada col no puede superar (ancho_disponible / cols)
  Limitamos por ALTO:  cada fila (col_ancho / 1.29) * rows <= alto_disponible
  El CSS no puede hacer ambos cálculos juntos, así que usamos
  max-width + max-height en el board y dejamos que las celdas
  con aspect-ratio se ajusten solas via 1fr.
*/
#board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), 1fr);
  gap: clamp(3px, 0.6vw, 10px);
  /* Ancho: ocupa el espacio pero no más del disponible */
  width: 100%;
  max-width: calc(
    (min(
      /* Límite por ancho del área */
      (95vw - var(--sidebar-w, 280px)),
      /* Límite por alto del área: alto_carta = ancho_carta / 1.29, total_alto = alto_carta * rows */
      ((95vh - 40px) * 1.29 / var(--rows, 3) * var(--cols, 3))
    ))
  );
}

/* ── Card Cell — ratio 1980×1535 (horizontal) ── */
.card-cell {
  aspect-ratio: 1980 / 1535;
  perspective: 1200px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.97);
}

.card-cell.cell-enter {
  animation: cellReveal 0.35s ease forwards;
}

@keyframes cellReveal {
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Card Flip ── */
.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform var(--flip-duration) cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: var(--radius-sm);
}

.card-inner.is-flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}

.card-cell:hover .card-face { box-shadow: var(--shadow-lg); }

.card-face img { width: 100%; height: 100%; object-fit: contain; background: var(--bg2); }
.card-back { background: var(--bg2); }
.card-front { transform: rotateY(180deg); background: var(--surface); }

.placeholder-back {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #333));
}
.placeholder-front { background: var(--bg2); }

/* ── Empty Cell ── */
.empty-cell {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  aspect-ratio: 1980 / 1535;
}
.empty-cell:hover { border-color: var(--accent); }

.empty-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.empty-cell:hover .empty-placeholder { color: var(--accent); }
.plus-icon { font-size: 1.4rem; }
.empty-label { font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* ── Has card ── */
.has-card { position: relative; }

.remove-card-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
}
.has-card:hover .remove-card-btn { opacity: 1; }

/* ════════════════════════════════════════
   MODAL SLIDER — Modo Selección
════════════════════════════════════════ */
#card-selector-modal {
  position: fixed;
  inset: 0;
  background: rgba(20,15,10,0.75);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

#card-selector-modal.is-open { opacity: 1; pointer-events: all; }

/*
  El panel ocupa casi toda la pantalla (96vw × 92vh).
  El slider-body es flex:1 y tiene min-height:0 para que
  las cartas se dimensionen según el alto real disponible.
*/
.modal-panel {
  background: var(--surface);
  border-radius: var(--radius);
  width: min(1100px, 96vw);
  height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
  overflow: hidden;
}

#card-selector-modal.is-open .modal-panel {
  transform: translateY(0) scale(1);
}

.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--text);
}

.modal-header-right { display: flex; align-items: center; gap: 10px; }

.modal-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
}

#modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
#modal-close:hover { background: var(--accent); color: white; }

/* ── Slider body ── */
.slider-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  gap: 12px;
  min-height: 0;       /* clave para que flex calcule bien el alto */
  overflow: hidden;
}

.slider-nav {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  color: var(--text);
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  align-self: center;
}
.slider-nav:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.slider-nav:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Slider track ── */
.slider-track-wrap {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
}

.slider-track {
  display: flex;
  gap: 12px;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  align-items: center;
}

/* ── Slider Card ──
   La carta se dimensiona por ALTO: ocupa el alto disponible
   del slider-body menos padding. El ancho sale del aspect-ratio.
   Usamos height como base (la imagen es horizontal 1980×1535).
   La carta central escala 1.06x, las laterales son más pequeñas.
*/
.slider-card {
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s, opacity 0.25s;
  background: var(--bg2);
  aspect-ratio: 1980 / 1535;
  /* Alto: usa el espacio disponible. Header ~52px, footer ~60px, padding ~32px */
  height: clamp(120px, calc(92vh - 52px - 60px - 32px), 600px);
  width: auto;
}

.slider-card:hover:not(.in-use) {
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}

.slider-card.in-use { opacity: 0.35; cursor: not-allowed; }

.slider-card.center-card {
  transform: scale(1.06);
  box-shadow: 0 0 0 3px var(--accent), var(--shadow-lg);
  z-index: 2;
}

.slider-card.center-card:hover:not(.in-use) {
  transform: scale(1.06) translateY(-4px);
}

.slider-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg2);
  display: block;
}

.in-use-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 0.6rem;
  text-align: center;
  padding: 5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Slider footer ── */
.slider-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-shrink: 0;
}

.slider-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  max-width: 200px;
  overflow: hidden;
}

.slider-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: all 0.2s;
  flex-shrink: 0;
}

.slider-dot.active {
  background: var(--accent);
  transform: scale(1.4);
}

.slider-select-btn {
  padding: 8px 24px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}
.slider-select-btn:hover { filter: brightness(1.12); }
.slider-select-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ════════════════════════════════════════
   BUILD MODE — Armado del tablero
════════════════════════════════════════ */

/* Toolbar debajo del tablero */
#build-toolbar {
  display: none;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  flex-shrink: 0;
}

#build-toolbar.active { display: flex; }

.build-toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.build-toolbar-label {
  font-size: 0.63rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Paleta de mazos arrastrables */
#deck-palette {
  display: flex;
  gap: 12px;
  align-items: center;
  flex: 1;
}

#deck-palette.hidden { display: none; }

.palette-deck {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: grab;
  user-select: none;
}

.palette-deck img {
  height: 80px;
  aspect-ratio: 1980 / 1535;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  pointer-events: none;
}

.palette-deck:hover img {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.palette-deck.dragging img { opacity: 0.3; }

.palette-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
}

/* Ghost de arrastre */
.build-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  opacity: 0.88;
  height: 80px;
  aspect-ratio: 1980 / 1535;
  transform: rotate(2deg) scale(1.05);
  transition: transform 0.1s;
}

.build-drag-ghost img { width: 100%; height: 100%; object-fit: cover; }

/* Drop target highlight */
.card-cell.build-drop-target {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  background: var(--accent-light);
}

/* Celda asignada en diseño */
.build-assigned {
  cursor: default;
}

.build-cell-inner {
  width: 100%; height: 100%;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.build-dorso {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

.build-cell-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, transparent 50%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 6px;
  opacity: 0;
  transition: opacity 0.2s;
}

.build-assigned:hover .build-cell-overlay { opacity: 1; }

.build-deck-name {
  font-size: 0.6rem;
  font-weight: 500;
  color: white;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.build-cell-controls {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.cell-mode-btn {
  padding: 3px 6px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.15);
  color: white;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.cell-mode-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}

.cell-mode-btn:hover:not(.active) { background: rgba(255,255,255,0.3); }

.cell-remove-btn {
  padding: 3px 6px;
  border-radius: 4px;
  border: 1.5px solid rgba(255,255,255,0.3);
  background: rgba(180,50,50,0.5);
  color: white;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.cell-remove-btn:hover { background: rgba(180,50,50,0.85); }

/* Celda vacía en modo build */
.build-empty .empty-placeholder { color: var(--text-muted); }
.build-drop-target .empty-placeholder { color: var(--accent); }

.build-drop-icon { font-size: 1.4rem; }

/* Botones de fase */
.build-phase-btns { display: flex; gap: 8px; margin-left: auto; }

#btn-build-play, #btn-build-design {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s;
}

#btn-build-play {
  background: var(--accent);
  color: white;
  border: none;
}
#btn-build-play:hover { filter: brightness(1.1); }

#btn-build-design {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  background: transparent;
}
#btn-build-design:hover { background: var(--accent-light); }

.hidden { display: none !important; }

/* Legend */
.build-legend {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.legend-item { display: flex; align-items: center; gap: 4px; }


/* ── Confirm Dialog ── */
#confirm-dialog {
  position: fixed;
  inset: 0;
  background: rgba(20,15,10,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#confirm-dialog.is-open { opacity: 1; pointer-events: all; }

.dialog-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 300px;
}

.dialog-box p {
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 20px;
  color: var(--text);
}

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

.dialog-actions button {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

#confirm-yes { background: #9B4040; color: white; }
#confirm-yes:hover { filter: brightness(1.1); }
#confirm-no { border: 1.5px solid var(--border); color: var(--text); background: var(--surface2); }
#confirm-no:hover { border-color: var(--accent); color: var(--accent); }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 300;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Fullscreen ── */
body.is-fullscreen #sidebar { position: absolute; left: -100%; }
body.is-fullscreen #board-area { padding: 12px; }
body.is-fullscreen #board {
  max-width: calc(
    (min(
      99vw,
      ((99vh - 24px) * 1.29 / var(--rows, 3) * var(--cols, 3))
    ))
  );
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 50;
  }
  #sidebar.open { transform: translateX(0); }
  #board-area { padding: 12px; }

  .modal-panel { width: 100vw; height: 100dvh; border-radius: 0; }
  .slider-card { height: clamp(100px, calc(100dvh - 52px - 60px - 32px), 400px); }
}

/* ── Sidebar Collapse (desktop) ── */
#sidebar-collapse {
  position: fixed;
  top: 12px;
  left: calc(var(--sidebar-w) - 1px);
  z-index: 20;
  width: 22px;
  height: 36px;
  border-radius: 0 6px 6px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 2px 0 8px rgba(0,0,0,0.08);
  transition: left 0.35s ease, background 0.2s, color 0.2s;
}

#sidebar-collapse:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* When sidebar is collapsed */
#app.sidebar-collapsed #sidebar {
  width: 0;
  overflow: hidden;
  border-right: none;
}

#app.sidebar-collapsed #sidebar-collapse {
  left: 0;
  border-radius: 0 6px 6px 0;
}

/* Board max-width recalculation when collapsed */
#app.sidebar-collapsed #board {
  max-width: calc(
    min(
      95vw,
      ((95vh - 40px) * 1.29 / var(--rows, 3) * var(--cols, 3))
    )
  );
}

/* Sidebar transition */
#sidebar {
  transition: width 0.35s ease, transform 0.3s ease, background 0.3s;
}

/* Protect images from being saved */
img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: auto;
}

/* ── Sidebar Toggle (mobile) ── */
#sidebar-toggle {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  z-index: 60;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 1rem;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}



@media (max-width: 768px) {
  #sidebar-toggle { display: flex; }
  #sidebar-collapse { display: none; }
}