:root {
  --bg: #0f1410;
  --panel: #18211b;
  --panel2: #1f2b23;
  --line: #2c3a30;
  --text: #e6efe8;
  --muted: #93a89a;
  --accent: #2ee27a;
  --accent-d: #1f7a4d;
  --warn: #ffd23f;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, sans-serif;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}

.appbar {
  display: flex; align-items: center; gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 14px 8px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.appbar strong { display: block; font-size: 15px; }
.appbar span { display: block; font-size: 11px; color: var(--muted); }

main { flex: 1; overflow: hidden; position: relative; }
.screen { position: absolute; inset: 0; overflow-y: auto; display: none; }
.screen.active { display: block; }
.pad { padding: 12px; padding-bottom: 24px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px; margin-bottom: 12px;
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.fit { width: 100%; height: auto; border-radius: 10px; display: block; }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--panel2);
  color: var(--text); border-radius: 10px; padding: 11px 14px; font-size: 14px;
  font-weight: 600; cursor: pointer; flex: 1;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent-d); border-color: var(--accent-d); color: #f1fff6; }
.btn.primary:disabled { opacity: .4; }
.btn.block { display: block; width: 100%; text-align: center; }
.row { display: flex; gap: 8px; margin-top: 10px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 4px; }
.grid2 label, .slider { display: flex; flex-direction: column; font-size: 12.5px; color: var(--muted); gap: 4px; }
.grid2 input { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 9px; font-size: 16px; }
.slider { margin-top: 12px; }
.slider input { accent-color: var(--accent); }

.canvas-box { background: #0a0d0b; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 8px; }
.canvas-box canvas { width: 100%; height: auto; display: block; }

.banner {
  margin: 12px 0 0; padding: 9px 11px; font-size: 12px;
  background: rgba(255,210,63,.1); border: 1px solid rgba(255,210,63,.35);
  border-radius: 9px; color: #f3e2a8;
}

/* Visor */
.toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--panel); border-bottom: 1px solid var(--line); }
.chip { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; }
.chip.on { background: var(--accent-d); color: #f1fff6; border-color: var(--accent-d); }
.readout { margin-left: auto; font-size: 12.5px; color: var(--accent); font-weight: 600; }
.canvas-stage { position: absolute; inset: 49px 0 0 0; touch-action: none; background: #0a0d0b; }
#screen-view .canvas-stage canvas { width: 100%; height: 100%; display: block; }
.empty { padding: 30px 20px; text-align: center; color: var(--muted); }

/* Clasificar */
.results { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.piece-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.pnum { width: 26px; height: 26px; flex: none; display: grid; place-items: center; background: var(--panel2); border-radius: 7px; font-weight: 700; font-size: 13px; }
.swatch { width: 26px; height: 26px; flex: none; border-radius: 6px; border: 1px solid rgba(255,255,255,.2); }
.pzone { font-size: 18px; font-weight: 800; color: var(--accent); min-width: 44px; }
.pmeta { font-size: 12px; color: var(--muted); margin-left: auto; text-align: right; }

/* Progreso */
.zone-grid { display: grid; gap: 3px; padding: 4px; }
.zone-cell { aspect-ratio: 1; border: 1px solid rgba(0,0,0,.3); border-radius: 4px; padding: 0; position: relative; cursor: pointer; }
.zone-cell.done::after { content: '✓'; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.55); color: var(--accent); font-weight: 800; border-radius: 4px; }

/* Tabbar */
.tabbar { display: flex; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 4px 10px; font-size: 11px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabbar button span { font-size: 19px; }
.tabbar button.active { color: var(--accent); }
