/* DSK Palabras — style.css — mobile-first */
:root {
  --bg:         #0d0f0e;
  --bg2:        #141716;
  --bg3:        #1c201e;
  --border:     #263030;
  --border-hi:  #3a4f4a;
  --text:       #c8d8d2;
  --text-dim:   #576860;
  --text-hi:    #eaf5f0;
  --accent:     #00e5a0;
  --accent2:    #00b07a;
  --accent-dim: #003d2a;
  --green:      #538d4e;
  --green-hi:   #6aaf62;
  --yellow:     #b59f3b;
  --yellow-hi:  #d4bc44;
  --grey:       #3a3a3c;
  --grey-hi:    #818184;
  --red:        #e05a5a;
  --radius:     10px;
  --radius-sm:  6px;
  --font-mono:  'Share Tech Mono', monospace;
  --font-ui:    'Rajdhani', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
  /* Evitar zoom con dos dedos en Safari */
  touch-action: pan-x pan-y;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom, 16px);
  overscroll-behavior-y: contain;
  /* Evitar selección de texto accidental */
  -webkit-user-select: none;
  user-select: none;
  /* Evitar menú contextual largo en móvil */
  -webkit-touch-callout: none;
}

/* ── BANNER ACTUALIZACIÓN ────────────────────────────── */
#updateBanner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem;
  background: var(--accent-dim); border-bottom: 1px solid var(--accent2);
  padding: 0.6rem 1rem;
  font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent);
  position: sticky; top: 0; z-index: 200;
}
#updateBanner button {
  background: var(--accent); color: var(--bg);
  border: none; border-radius: var(--radius-sm);
  padding: 0.3rem 0.8rem; font-family: var(--font-mono);
  font-size: 0.75rem; cursor: pointer; white-space: nowrap;
  touch-action: manipulation;
}

/* ── SPINNER ─────────────────────────────────────────── */
.spinner-overlay {
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,0.72);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.spinner-box {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  background: var(--bg2); border: 1px solid var(--border-hi);
  border-radius: var(--radius); padding: 2rem 2.5rem;
}
.spinner-ring {
  width: 48px; height: 48px;
  border: 4px solid var(--border-hi);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-msg {
  font-family: var(--font-mono); font-size: 0.85rem;
  color: var(--accent); letter-spacing: 0.06em;
  text-align: center; max-width: 200px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── HEADER ──────────────────────────────────────────── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 1rem 1rem;
  position: sticky; top: 0; z-index: 100;
  padding-top: max(1.1rem, env(safe-area-inset-top));
}
.header-inner {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 0.35rem;
}
.header-logo { width: 52px; height: 52px; border-radius: 10px; }
h1 {
  font-family: var(--font-mono); font-size: 1.6rem;
  color: var(--text-hi); font-weight: normal;
  letter-spacing: 0.1em; text-align: center;
}
h1 .blink { color: var(--accent); animation: blink 1.1s step-end infinite; }
h1 .accent { color: var(--accent); }
@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0;} }
.subtitle {
  font-family: var(--font-mono); font-size: 0.68rem;
  color: var(--text-dim); text-align: center;
}

/* ── MAIN / CARDS ────────────────────────────────────── */
main {
  display: flex; flex-direction: column; gap: 0.75rem;
  padding: 0.75rem;
  max-width: 520px; margin: 0 auto;
}

.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex; flex-direction: column; gap: 0.75rem;
}

.card-title {
  font-family: var(--font-mono); font-size: 0.78rem;
  letter-spacing: 0.1em; color: var(--accent);
  display: flex; align-items: center; gap: 0.5rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;
  flex-wrap: wrap;
}
.step {
  background: var(--accent-dim); color: var(--accent);
  font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 3px;
}
.hint-inline { color: var(--text-dim); font-size: 0.65rem; text-transform: none; }

/* ── UPLOAD ──────────────────────────────────────────── */
.upload-zone {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0.4rem;
  border: 2px dashed var(--border-hi); border-radius: var(--radius);
  padding: 1.5rem 1rem; cursor: pointer;
  background: var(--bg3); transition: border-color 0.2s, background 0.2s;
  touch-action: manipulation;
}
.upload-zone:active { border-color: var(--accent); background: var(--accent-dim); }
.upload-icon { font-size: 2rem; }
.upload-text { font-weight: 700; font-size: 0.95rem; color: var(--text-hi); }
.upload-hint { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-dim); }

/* Miniatura */
#thumbWrap { display: flex; align-items: center; gap: 0.75rem; }
#gameCanvas { height: 80px; width: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); background: #000; }
.thumb-label { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-dim); }

/* ── BOTONES ─────────────────────────────────────────── */
.btn-primary {
  background: var(--accent-dim); color: var(--accent);
  border: 1px solid var(--accent2); border-radius: var(--radius-sm);
  padding: 0.8rem; font-family: var(--font-mono);
  font-size: 0.95rem; letter-spacing: 0.1em;
  cursor: pointer; width: 100%; touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
}
.btn-primary:active:not(:disabled) { background: var(--accent); color: var(--bg); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg3); color: var(--accent);
  border: 1px solid var(--accent2); border-radius: var(--radius-sm);
  padding: 0.65rem; font-family: var(--font-mono);
  font-size: 0.82rem; letter-spacing: 0.08em;
  cursor: pointer; width: 100%; touch-action: manipulation;
  transition: background 0.15s;
}
.btn-secondary:active { background: var(--accent); color: var(--bg); }

.btn-sm {
  background: var(--bg3); color: var(--text);
  border: 1px solid var(--border-hi); border-radius: var(--radius-sm);
  padding: 0.45rem 0.85rem; font-family: var(--font-mono);
  font-size: 0.75rem; cursor: pointer; touch-action: manipulation;
  transition: border-color 0.15s, color 0.15s;
}
.btn-sm:active:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn-sm:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── STATUS BAR ──────────────────────────────────────── */
.status-bar {
  font-family: var(--font-mono); font-size: 0.72rem;
  color: var(--text-dim); border-left: 2px solid var(--border-hi);
  padding-left: 0.6rem; min-height: 1.2rem; line-height: 1.4;
}
.status-bar.active { color: var(--accent); border-left-color: var(--accent); }
.status-bar.error  { color: var(--red);   border-left-color: var(--red); }
.status-bar.ok     { color: var(--green-hi); border-left-color: var(--green-hi); }

/* ── LEYENDA ─────────────────────────────────────────── */
.grid-legend { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.leg {
  font-family: var(--font-mono); font-size: 0.7rem;
  padding: 0.2rem 0.6rem; border-radius: 4px; color: #fff;
}
.leg.green  { background: var(--green); }
.leg.yellow { background: var(--yellow); }
.leg.grey   { background: var(--grey); color: var(--grey-hi); }

/* ── CUADRÍCULA EDITABLE ─────────────────────────────── */
#editableGrid { display: flex; flex-direction: column; gap: 6px; }

.grid-row { display: flex; align-items: center; gap: 5px; }

.row-num {
  font-family: var(--font-mono); font-size: 0.65rem;
  color: var(--text-dim); min-width: 1.1rem; text-align: right;
}

.grid-cell {
  flex: 1; aspect-ratio: 1;
  max-width: 62px; min-width: 42px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none;
  border: 2px solid transparent;
  transition: transform 0.1s, filter 0.1s;
  position: relative;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.grid-cell:active { transform: scale(0.93); filter: brightness(1.2); }

.grid-cell.green  { background: var(--green); }
.grid-cell.yellow { background: var(--yellow); }
.grid-cell.grey   { background: var(--grey); }
.grid-cell.empty  { background: var(--bg3); border: 2px dashed var(--border-hi); }

.cell-letter {
  font-family: var(--font-mono); font-size: 1.25rem;
  font-weight: bold; color: #fff; pointer-events: none;
  line-height: 1;
}
.grid-cell.empty .cell-letter { color: var(--text-dim); }

.row-del {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 0.9rem; padding: 0.3rem;
  touch-action: manipulation; line-height: 1;
  border-radius: 4px;
}
.row-del:active { color: var(--red); }

.btn-add-row {
  background: var(--bg3); color: var(--text-dim);
  border: 1px dashed var(--border-hi); border-radius: var(--radius-sm);
  padding: 0.5rem; font-family: var(--font-mono); font-size: 0.75rem;
  cursor: pointer; width: 100%; margin-top: 2px;
  touch-action: manipulation;
}
.btn-add-row:active { color: var(--accent); border-color: var(--accent); }

/* ── RESULTADOS ──────────────────────────────────────── */
.results-meta {
  font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-dim);
}
.results-list {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.word-chip {
  font-family: var(--font-mono); font-size: 0.85rem;
  padding: 0.3rem 0.65rem; border-radius: 5px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); display: flex; align-items: center; gap: 0.35rem;
  cursor: default;
}
.word-chip .rank { font-size: 0.62rem; color: var(--text-dim); }
.word-chip.top1 { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); font-size: 1rem; padding: 0.4rem 0.8rem; }
.word-chip.top3 { border-color: var(--green-hi); }

.placeholder-text { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-dim); }

/* ── DICCIONARIO COLAPSABLE ──────────────────────────── */
.card-dict { gap: 0; }
.toggle-dict { cursor: pointer; user-select: none; touch-action: manipulation; border-bottom: none; padding-bottom: 0; }
.toggle-dict.open { border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 0.75rem; }
.dict-arrow { margin-left: auto; color: var(--text-dim); font-size: 0.7rem; transition: transform 0.2s; }
.dict-arrow.open { transform: rotate(180deg); }
#dictPanel { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.75rem; }
#dictPanel.hidden { display: none; }

.dict-status { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.4rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.green  { background: var(--green-hi); }
.dot.yellow { background: var(--yellow-hi); }
.dot.grey   { background: var(--grey-hi); }
.dict-actions { display: flex; gap: 0.5rem; }

/* ── MODAL IMAGEN ────────────────────────────────────── */
.img-modal-box {
  position: relative;
  max-width: 96vw; max-height: 90dvh;
  display: flex; align-items: center; justify-content: center;
}
.img-modal-box img {
  max-width: 96vw; max-height: 88dvh;
  border-radius: var(--radius);
  border: 1px solid var(--border-hi);
  object-fit: contain;
}
.img-modal-close {
  position: absolute; top: -14px; right: -14px;
  background: var(--bg2); border: 1px solid var(--border-hi);
  color: var(--text); border-radius: 50%;
  width: 32px; height: 32px; font-size: 0.85rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.img-modal-close:active { background: var(--red); color: #fff; }

.thumb-clickable { cursor: zoom-in; }
.thumb-zoom { font-size: 1rem; color: var(--text-dim); }

/* ── MODAL EDITAR LETRA ──────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 8000;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
  backdrop-filter: blur(3px);
}
.modal-box {
  background: var(--bg2); border: 1px solid var(--border-hi);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem 1.25rem 2rem;
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 1rem;
}
.modal-title { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent); letter-spacing: 0.1em; }
.letter-input {
  background: var(--bg3); border: 2px solid var(--accent);
  border-radius: var(--radius-sm); color: var(--text-hi);
  font-family: var(--font-mono); font-size: 2rem;
  text-align: center; text-transform: uppercase;
  padding: 0.5rem; width: 100%; outline: none;
}
.modal-actions { display: flex; gap: 0.75rem; }
.modal-actions .btn-primary { flex: 1; }
.modal-actions .btn-sm { flex: 1; padding: 0.8rem; }

/* ── DESKTOP ADAPTATION ──────────────────────────────── */
@media (min-width: 600px) {
  main { padding: 1.25rem; max-width: 600px; }
  .grid-cell { max-width: 72px; }
  .cell-letter { font-size: 1.4rem; }
  .modal { align-items: center; padding: 1rem; }
  .modal-box { border-radius: var(--radius); }
  h1 { font-size: 1.3rem; }
}

/* ── FOOTER ──────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1rem 1rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}
footer a {
  color: var(--accent);
  text-decoration: none;
  -webkit-user-select: none;
  user-select: none;
}
footer a:active { opacity: 0.7; }

/* ── PREVENIR SELECCIÓN Y MENÚ CONTEXTUAL ────────────── */
/* Solo en elementos interactivos de la app, no en el footer link */
.grid-cell, .word-chip, .card-title, .grid-legend,
.upload-zone, .btn-primary, .btn-secondary, .btn-sm,
.btn-add-row, .btn-reprocess, .row-del, .results-list,
.results-meta, .dict-status, .status-bar, header, .spinner-msg {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ── PALABRAS INICIALES ──────────────────────────────── */
.card-starters { gap: 0.75rem; }

.btn-starter-pack {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  width: 100%;
  touch-action: manipulation;
  transition: background 0.15s, color 0.15s;
  -webkit-user-select: none; user-select: none;
}
.btn-starter-pack:active {
  background: var(--accent);
  color: var(--bg);
}

.starter-hint {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.starter-words {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.starter-word {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  background: var(--bg3);
  border: 1px solid var(--border-hi);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  -webkit-user-select: none; user-select: none;
}
.starter-word:active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── MODAL CONFIRMACIÓN ──────────────────────────────── */
.confirm-msg {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.4;
}
