:root {
  --navy: #071b3d;
  --blue: #0d3970;
  --blue2: #174f8e;
  --gold: #f2c14e;
  --green: #43b96a;
  --red: #ec6c70;
  --ink: #10264b;
  --paper: #f7f6ef;
  --line: #2d6bb2;
  --muted: #dbe8f8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: #f3f5fb;
  color: #17223b;
  font-family: Tahoma, Arial, sans-serif;
}

.cr-asteroides-wrap {
  max-width: 1500px;
  margin: 8px auto;
  padding: 0 10px;
}

.cr-asteroides-card {
  overflow: hidden;
  border: 1px solid #dce3f2;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 10px 30px rgba(32, 56, 100, .12);
  color: var(--ink);
}

.cr-asteroides-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 9px 16px;
  background: linear-gradient(135deg, #152b55, #315c98);
  border-bottom: 3px solid var(--gold);
}

.eyebrow {
  margin: 0 0 5px;
  color: #b9d7ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .12em;
}

.cr-asteroides-head h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1;
}

.subtitulo {
  margin: 8px 0 0;
  color: #dce8ff;
  font-size: 12px;
}

.cr-asteroides-controls {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto auto;
  align-items: end;
  gap: 8px;
  min-width: 275px;
}

.cr-asteroides-controls label {
  grid-column: 1 / -1;
  color: #d8e9ff;
  font-size: 12px;
  font-weight: 700;
}

.cr-asteroides-controls select,
.cr-asteroides-controls button,
.records-panel button {
  border: 0;
  border-radius: 8px;
  padding: 7px 9px;
  font: inherit;
  font-weight: 800;
}

.cr-asteroides-controls select {
  min-width: 0;
  background: #fff;
  color: var(--ink);
}

button { cursor: pointer; }

.cr-asteroides-controls button:first-of-type {
  background: var(--green);
  color: #fff;
}

.cr-asteroides-controls button:last-of-type {
  background: #f2f6fc;
  color: var(--ink);
}

button:focus,
input:focus,
select:focus,
canvas:focus {
  outline: 3px solid #ffd45c;
  outline-offset: 2px;
}

.estado {
  padding: 6px 16px;
  background: #eef4ff;
  color: #214978;
  font-size: 14px;
  font-weight: 700;
}

.resumen-final {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px;
  background: #fff5cf;
  border-bottom: 1px solid #e8c657;
  color: #664d00;
}

.resumen-final strong { font-size: 18px; }
.resumen-final span { font-size: 14px; }

.cr-asteroides-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 5px 12px;
}

.panel-mision {
  padding: 7px;
  border: 1px solid #c8d7e8;
  border-radius: 13px;
  background: #f7fbff;
  box-shadow: 0 4px 12px rgba(27, 64, 111, .08);
}

.panel-mision-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.panel-mision-col {
  min-width: 0;
}

.panel-mision-col-mision,
.panel-mision-col-mision .mision-box {
  height: 100%;
}

.mision-box {
  padding: 8px;
  border-radius: 11px;
  background: linear-gradient(150deg, #103d78, #08234c);
  color: #fff;
}

.panel-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
}

.mision-box strong {
  display: block;
  color: #fff;
  font-size: 14px;
  line-height: 1.25;
}

.mision-box p {
  margin: 7px 0 6px;
  padding: 7px 6px;
  border: 1px dashed var(--gold);
  border-radius: 8px;
  background: rgba(0, 0, 0, .17);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
}

.mision-box small {
  display: block;
  color: #dceaff;
  line-height: 1.2;
}

.records-panel {
  display: grid;
  gap: 2px;
  margin-top: 0;
}

.records-panel label {
  color: #294b79;
  font-size: 10px;
  font-weight: 800;
}

.records-panel input {
  width: 100%;
  min-height: 25px;
  padding: 4px 7px;
  border: 1px solid #a8bfdc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
}

.records-panel button {
  margin-top: 4px;
  padding: 5px 6px;
  background: #194b89;
  color: #fff;
  font-size: 11px;
}

.records-estado {
  min-height: 18px;
  margin-top: 2px;
  color: #2c4e78;
  font-size: 12px;
}

.ranking {
  margin: 0;
  padding-left: 22px;
  color: #284b79;
  font-size: 12px;
  line-height: 1.5;
}

.panel-mision h2 {
  margin: 8px 0 4px;
  color: #1a4274;
  font-size: 14px;
}

.instrucciones {
  margin: 0;
  padding-left: 17px;
  color: #345375;
  font-size: 10px;
  line-height: 1.2;
}

.zona-juego {
  min-width: 0;
}

.juego-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 188px 156px;
  align-items: start;
  gap: 10px;
}

.campo-columna { min-width: 0; }

#campo {
  display: block;
  width: 100%;
  height: 408px;
  min-height: 408px;
  border: 3px solid #245b98;
  border-radius: 13px;
  background: #061735;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), 0 5px 14px rgba(0, 0, 0, .22);
  touch-action: none;
}

.panel-auxiliar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 8px;
}

.feedback {
  min-height: 58px;
  margin: 0;
  padding: 10px 11px;
  border: 1px solid #c8d7e8;
  border-radius: 9px;
  background: #eef5fd;
  color: #244c79;
  font-size: 14px;
  font-weight: 800;
}

.feedback.ok {
  border-color: #72c689;
  background: #eaf8ed;
  color: #17602f;
}

.feedback.error {
  border-color: #e79a9b;
  background: #fff0f0;
  color: #8d2e32;
}

.aux-card {
  padding: 8px 9px;
  border: 1px solid #c8d7e8;
  border-radius: 9px;
  background: #f7fbff;
  color: #345375;
  font-size: 11px;
  line-height: 1.2;
}

.aux-card strong {
  display: block;
  margin-bottom: 4px;
  color: #1a4274;
  font-size: 12px;
}

.aux-card p { margin: 3px 0; }

.movil-controles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 0;
}

.movil-controles button {
  min-width: 48px;
  min-height: 40px;
  border: 1px solid #557ca7;
  border-radius: 8px;
  background: #113e76;
  color: #fff;
  font: inherit;
  font-weight: 900;
}

.movil-controles button:nth-child(2) {
  min-width: 104px;
  background: #197746;
}

.leyenda,
.nota {
  margin: 5px 0 0;
  color: #5b6f88;
  font-size: 11px;
  text-align: center;
}

.marcador {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: center;
  gap: 0;
  min-height: 126px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 9px;
  background: #082653;
  color: #dceaff;
  font-size: 12px;
}

.marcador span {
  display: flex;
  min-height: 63px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-right: 1px solid rgba(220, 234, 255, .22);
  border-bottom: 1px solid rgba(220, 234, 255, .22);
  text-align: center;
}

.marcador span:nth-child(2n) { border-right: 0; }
.marcador span:nth-child(n + 3) { border-bottom: 0; }
.marcador strong {
  color: var(--gold);
  font-size: 17px;
}

.nota {
  padding: 0 20px 18px;
  font-size: 11px;
}

code { font-family: Consolas, monospace; }

@media (max-width: 1080px) {
  .juego-grid { grid-template-columns: minmax(0, 1fr) 176px 140px; }
  .cr-asteroides-layout { grid-template-columns: 300px minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .cr-asteroides-head {
    align-items: stretch;
    flex-direction: column;
  }
  .cr-asteroides-controls { min-width: 0; }
  .cr-asteroides-layout { grid-template-columns: 1fr; }
  .panel-mision-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .panel-mision { order: 2; }
  .zona-juego { order: 1; }
  .juego-grid { grid-template-columns: minmax(0, 1fr) minmax(150px, .34fr); }
  .marcador {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 560px) {
  .cr-asteroides-wrap { padding: 8px; }
  .cr-asteroides-head { padding: 17px; }
  .cr-asteroides-controls { grid-template-columns: 1fr 1fr; }
  .cr-asteroides-controls select { grid-column: 1 / -1; }
  .cr-asteroides-controls button { width: 100%; }
  .cr-asteroides-layout { gap: 10px; padding: 10px; }
  .juego-grid { grid-template-columns: 1fr; }
  .panel-mision-grid { grid-template-columns: 1fr; }
  .panel-auxiliar { display: grid; grid-template-columns: 1fr 1fr; }
  .panel-auxiliar .feedback,
  .panel-auxiliar .movil-controles,
  .panel-auxiliar .leyenda { grid-column: 1 / -1; }
  .marcador {
    grid-column: auto;
    grid-row: auto;
    min-height: 104px;
  }
  .marcador span { min-height: 52px; }
  #campo {
    height: 280px;
    min-height: 280px;
  }
  .mision-box p { font-size: 15px; }
  .subtitulo { font-size: 13px; }
}
