/* "Tú eres la CPU": layered on top of ../assets/style.css (theme variables, reset, skip link). */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.game-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--header-height);
  padding: 0 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}
.game-brand { font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.game-top-links { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; white-space: nowrap; }
.theme-btn,
.link-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  padding: 0.3rem 0.6rem;
}
.link-btn:hover,
.theme-btn:hover { color: var(--accent); border-color: var(--accent); }

.game-main {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}
.game-main:focus { outline: none; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 4px;
  padding: 0.05em 0.3em;
}

/* ---------- Home ---------- */
.game-hero h1 { font-size: 1.9rem; margin-bottom: 0.5rem; }
.game-hero p { color: var(--text-secondary); max-width: 65ch; }
.how-to {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
  font-size: 0.85rem;
}
.how-to li {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  color: var(--text-secondary);
}
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.pattern-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-margin-top: calc(var(--header-height) + 1rem);
}
.pattern-card.is-highlighted { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.pattern-card header { display: flex; gap: 0.75rem; align-items: center; }
.pattern-icon { font-size: 1.8rem; }
.pattern-card h2 { font-size: 1.1rem; }
.pattern-days { font-size: 0.8rem; color: var(--text-muted); }
.pattern-card > p { font-size: 0.92rem; color: var(--text-secondary); }
.level-list { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; margin-top: auto; }
.level-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
}
.level-btn:hover { border-color: var(--accent); }
.level-stars { color: var(--warning); white-space: nowrap; letter-spacing: 1px; }

/* ---------- Level ---------- */
.level-nav { margin-bottom: 1rem; }
.level-kicker { font-size: 0.85rem; color: var(--text-muted); }
.level-head h1 { font-size: 1.45rem; margin: 0.15rem 0 0.6rem; }
.progress {
  height: 8px;
  background: var(--bg-surface);
  border-radius: 999px;
  overflow: hidden;
}
.progress span { display: block; height: 100%; background: var(--accent); transition: width 0.2s ease; }
.level-meta { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.35rem; }

.intro-card,
.end-card,
.decision {
  margin-top: 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.1rem;
}
.intro-card p { margin-bottom: 1rem; }

.board { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.25rem; }
.panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.75rem;
  overflow-x: auto;
}
.panel-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 0.5rem; }
.panel-note { color: var(--text-secondary); font-size: 0.92rem; }
.empty { color: var(--text-muted); font-size: 0.85rem; }

/* Arrays and bars */
.cells { list-style: none; display: flex; gap: 0.35rem; min-width: min-content; }
.cell { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 0.15rem; min-width: 1.9rem; max-width: 3.6rem; }
.cell-box {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.6rem;
  padding: 0 0.3rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-surface);
  font-family: var(--font-mono);
  font-weight: 600;
}
@media (max-width: 480px) {
  .cell-box { font-size: 0.85rem; min-height: 2.2rem; padding: 0 0.15rem; }
  .game-brand { font-size: 0.9rem; }
}
@media (max-width: 420px) {
  .game-top { padding: 0 0.75rem; }
  .hide-narrow { display: none; }
}
@media (max-width: 340px) {
  .brand-name { display: none; }
}
.cells-bars .cell-box { height: 7rem; align-items: flex-end; border-style: dashed; background: transparent; }
.cells-bars .bar {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  max-height: calc(100% - 6px);
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 4px 4px 2px 2px;
}
.cells-bars .cell-val { position: relative; margin-bottom: 0.2rem; }
.cell-idx { font-size: 0.7rem; color: var(--text-muted); font-family: var(--font-mono); }
.cell-ptrs { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 1.1rem; }
.ptr {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 0 0.25rem;
}
.cell.is-dim .cell-box { opacity: 0.35; }
.cell.is-active .cell-box { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.cell.is-mid .cell-box { border-color: var(--warning); background: var(--warning-bg); }
.cell.is-found .cell-box { border-color: var(--success); background: var(--success-bg); }
.cell.is-bad .cell-box { border-color: var(--danger); background: var(--danger-bg); }

/* Grid */
.grid-wrap { overflow-x: auto; }
.grid { border-collapse: collapse; font-family: var(--font-mono); font-size: 0.9rem; }
.grid th, .grid td { border: 1px solid var(--border-color); padding: 0.35rem 0.55rem; text-align: center; min-width: 2.2rem; }
.grid th { color: var(--text-muted); font-weight: 500; }
.grid td.is-active { outline: 3px solid var(--accent); outline-offset: -3px; background: var(--accent-glow); }
.grid td.is-mid { background: var(--warning-bg); }
.grid td.is-found { background: var(--success-bg); }
.grid td.is-bad { background: var(--danger-bg); }
.grid td.is-dim { opacity: 0.4; }

/* Stack and queue */
.stack, .queue { list-style: none; display: flex; gap: 0.35rem; font-family: var(--font-mono); }
.stack { flex-direction: column-reverse; align-items: flex-start; }
.stack li, .queue li {
  border: 2px solid var(--border-color);
  background: var(--bg-surface);
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
}
.stack li:last-child { border-color: var(--accent); }
.stack li:last-child::after { content: '  ← tope'; color: var(--text-muted); font-size: 0.75rem; }
.queue li:first-child { border-color: var(--accent); }
.queue li:first-child::before { content: 'frente → '; color: var(--text-muted); font-size: 0.75rem; }

/* Graph */
.graph { width: 100%; max-width: 520px; display: block; margin: 0 auto; }
.graph .edges line { stroke: var(--text-muted); stroke-width: 0.6; }
.graph marker path { fill: var(--text-muted); }
.graph .node circle { fill: var(--bg-surface); stroke: var(--border-color); stroke-width: 0.8; }
.graph .node text { fill: var(--text-primary); font-size: 5px; text-anchor: middle; font-family: var(--font-mono); font-weight: 700; }
.graph .node.is-active circle { stroke: var(--accent); stroke-width: 1.4; fill: var(--accent-glow); }
.graph .node.is-mid circle { stroke: var(--warning); fill: var(--warning-bg); }
.graph .node.is-found circle { stroke: var(--success); fill: var(--success-bg); }
.graph .node.is-bad circle { stroke: var(--danger); fill: var(--danger-bg); }
.graph .node.is-dim { opacity: 0.45; }

/* Variables */
.vars { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.vars div {
  display: flex;
  gap: 0.4rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}
.vars dt { color: var(--text-muted); }
.vars dd { font-weight: 700; }

/* Decision */
.decision h2 { font-size: 1.1rem; margin-bottom: 0.8rem; }
.decision h2:focus { outline: none; }
.choices { display: grid; gap: 0.5rem; }
.choice-btn,
.primary-btn,
.secondary-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 10px;
  min-height: 48px;
  padding: 0.65rem 0.9rem;
}
.choice-btn {
  text-align: left;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
}
.choice-btn:hover:not(:disabled) { border-color: var(--accent); }
.choice-btn.is-wrong { border-color: var(--danger); background: var(--danger-bg); text-decoration: line-through; opacity: 0.75; cursor: not-allowed; }
.primary-btn { background: var(--accent); border: 2px solid var(--accent); color: #fff; font-weight: 700; }
[data-theme="dark"] .primary-btn,
:root:not([data-theme]) .primary-btn { color: #0b0f19; }
.secondary-btn { background: transparent; border: 2px solid var(--border-color); color: var(--text-primary); }

.feedback { margin-top: 0.8rem; }
.fb { border-radius: 10px; padding: 0.7rem 0.9rem; font-size: 0.95rem; }
.fb-wrong { background: var(--danger-bg); border: 1px solid var(--danger); }
.fb-right { background: var(--success-bg); border: 1px solid var(--success); margin-top: 1rem; }

/* End */
.end-card { text-align: center; }
.end-card h2:focus { outline: none; }
.end-stars { font-size: 2.4rem; color: var(--warning); letter-spacing: 4px; }
.outro { margin: 0.75rem auto; max-width: 60ch; color: var(--text-secondary); }
.review-note { font-size: 0.9rem; }
.traps { text-align: left; margin: 1rem auto; max-width: 60ch; }
.traps summary { cursor: pointer; font-weight: 600; }
.traps ul { margin: 0.5rem 0 0 1.2rem; display: grid; gap: 0.4rem; font-size: 0.9rem; }
.end-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1rem; }

@media (min-width: 640px) {
  .choices { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .progress span { transition: none; }
}
.choice-btn code,
.decision h2 code { white-space: nowrap; }
code { overflow-wrap: anywhere; }
