/* ============================================================
   BUSCAMINAS POWER · ventana, paneles, HUD y diálogos clásicos
   ============================================================ */

.app {
  position: relative;
  z-index: 2;
  width: min(1400px, calc(100% - 24px));
  margin: 12px auto;
  padding: 0;
  border: 3px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  background: var(--face);
  box-shadow: 2px 2px 0 var(--black);
}

/* ---------------- barra de título ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  padding: 3px 4px;
  border-bottom: 1px solid var(--black);
  background: linear-gradient(90deg, var(--title), var(--title-2));
  color: var(--white);
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border: 2px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  background: var(--face);
  color: var(--black);
  box-shadow: 1px 1px 0 var(--black);
}

.brand-mark::after {
  display: none;
}

.brand-mark svg {
  width: 16px;
  height: 16px;
  filter: none;
}

.brand-copy {
  min-width: 0;
}

.brand-copy .eyebrow {
  display: none;
}

.brand h1 {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--white);
  font-size: 12px;
  letter-spacing: 0;
  white-space: nowrap;
}

.brand h1 span {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  color: #ffff80;
  font-size: 1em;
  letter-spacing: 0;
  text-shadow: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: none;
}

.top-actions .icon-btn,
.top-actions .ghost-btn {
  width: 22px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  font-size: 11px;
}

.top-actions .ghost-btn span {
  display: none;
}

.top-actions .coin-chip {
  height: 20px;
  min-height: 20px;
  padding: 0 4px;
  font-size: 10px;
}

.top-actions .coin-chip .icon {
  color: var(--amber);
  font-size: 11px;
}

.contracts-panel { margin-top: 7px; padding: 7px; border: 2px solid; border-color: var(--white) var(--dark) var(--dark) var(--white); background: var(--face); }
.contracts-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; color: var(--title); }
.contracts-head { cursor: pointer; min-height: 28px; align-items: center; }
.contracts-head strong::before { content: "▸ "; }
details[open] > .contracts-head strong::before { content: "▾ "; }
.contracts-panel p { margin: 4px 0; color: var(--muted); font-size: 11px; }
.contracts-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.contract { display: flex; justify-content: space-between; gap: 4px; padding: 5px; border: 1px solid; border-color: var(--dark) var(--white) var(--white) var(--dark); font-size: 11px; }
.contract b { color: #805800; white-space: nowrap; }
.contract.is-complete b { color: #006400; }
@media (max-width: 760px) { .contracts-list { grid-template-columns: 1fr; } .contract { min-height: 30px; align-items: center; } }

/* El tablero es la acción principal; el historial sigue disponible desde la barra de título. */
.intel-panel { display: none; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .extractor-button, .extractor-upgrade { white-space: normal; overflow-wrap: anywhere; padding: 4px 6px; }
  .toolbar-actions { display: flex; gap: 6px; }
  .toolbar-actions .chip-btn { min-width: 0; }
}

/* Estación de clics: una acción principal y una inversión visible. */
.extractor { display: grid; grid-template-columns: minmax(150px, 1fr) auto auto auto minmax(95px, 140px); align-items: center; gap: 8px; padding: 7px; margin: 0 0 7px; border: 2px solid; border-color: var(--white) var(--dark) var(--dark) var(--white); background: #d4d0c8; }
.extractor-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.extractor-copy strong { color: #000080; font-size: 11px; }
.extractor-copy span { font-size: 11px; }
.extractor-hint { color: #404040; }
.extractor-button { min-height: 36px; min-width: 130px; font-weight: 700; }
.extractor-upgrade, .extractor-activate { min-height: 36px; }
.extractor-charge { display: flex; flex-direction: column; gap: 4px; font-size: 10px; font-weight: 700; }
.extractor-charge span { display: flex; justify-content: space-between; gap: 8px; }
.extractor-track { height: 12px; border: 2px solid; border-color: var(--dark) var(--white) var(--white) var(--dark); background: #fff; }
.extractor-track i { display: block; width: 0; height: 100%; background: #000080; }
@media (max-width: 760px) {
  .extractor { grid-template-columns: 1fr 1fr; }
  .extractor-copy, .extractor-charge, .extractor-upgrade { grid-column: 1 / -1; }
  .extractor-button, .extractor-upgrade, .extractor-activate { min-height: 44px; min-width: 0; }
}
.core-panel > .panel-sub, .core-bot-hint { display: none; }
.core-summary { cursor: pointer; list-style: none; }
.core-summary::-webkit-details-marker { display: none; }
.core-summary h2::before { content: "▸ "; }
.core-panel[open] .core-summary h2::before { content: "▾ "; }
.core-panel[open] .core-stats { margin-top: 8px; }
.power-card { cursor: pointer; }
.power-card:focus-visible { outline: 2px solid #000080; outline-offset: -4px; }
.network-panel { margin: 8px 0; padding: 8px; border: 2px solid; border-color: var(--white) var(--dark) var(--dark) var(--white); background: var(--face); }
.network-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px; color: var(--title); }
.network-panel p { margin-top: 5px; font-size: 11px; }
.network-bar { height: 12px; margin-top: 6px; border: 2px solid; border-color: var(--dark) var(--white) var(--white) var(--dark); background: #fff; }
.network-bar span { display: block; height: 100%; width: 0; background: #000080; transition: width 0.2s ease; }

.coin-chip.is-bump {
  animation: coinBump 0.35s ease-out;
}

@keyframes coinBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.18); filter: drop-shadow(0 0 4px #ffcc00); }
  100% { transform: scale(1); filter: none; }
}

/* ---------------- estructura ---------------- */

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  padding: 8px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.panel {
  position: relative;
  padding: 8px;
  border: 2px solid;
  border-color: var(--white) var(--shadow) var(--shadow) var(--white);
  background: var(--face);
  box-shadow: 1px 1px 0 var(--black);
  overflow: hidden;
}

.panel::before {
  display: none;
}

.powers-panel,
.core-panel,
.intel-panel {
  padding: 8px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.panel-head h2 {
  margin-top: 1px;
  color: var(--black);
  font-size: 12px;
  letter-spacing: 0;
}

.panel-sub {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.panel-sub kbd {
  min-width: 14px;
  height: 14px;
  font-size: 10px;
}

.charge-total {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
}

.charge-total .icon {
  color: var(--amber);
  font-size: 10px;
}

/* ---------------- historial rápido ---------------- */

.mini-stats {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr 0.85fr;
  gap: 4px;
  margin-top: 8px;
}

.mini-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 4px 5px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.mini-stat strong {
  overflow: hidden;
  color: var(--title);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-stat:nth-child(2) strong {
  color: var(--mint);
}

.mini-stat:nth-child(3) strong {
  color: var(--amber);
}

.mini-stat span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  line-height: 1.2;
  text-transform: uppercase;
}

.intel-tip {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 8px;
  padding: 5px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.tip-dot {
  width: 6px;
  height: 6px;
  flex: none;
  margin-top: 3px;
  background: var(--title);
  animation: dotPulse 2s ease-in-out infinite;
}

.intel-tip p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

/* ---------------- zona de juego ---------------- */

.game-shell {
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.touch-tools { display: none; align-items: center; gap: 6px; }
.touch-tool { min-height: 44px; min-width: 84px; padding: 0 12px; border: 2px solid; border-color: var(--white) var(--dark) var(--dark) var(--white); background: var(--face); color: var(--black); font-weight: 700; }
.touch-tool.is-active { border-color: var(--dark) var(--white) var(--white) var(--dark); background: #e5e5e5; outline: 2px solid #000080; outline-offset: -4px; }
@media (max-width: 760px), (pointer: coarse) {
  .touch-tools { display: flex; flex-wrap: wrap; width: 100%; order: 3; }
  .touch-tools span { font-weight: 700; }
  .touch-tool { flex: 1; }
  .field input { font-size: 16px; }
}

.difficulty {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
  overflow-x: auto;
  scrollbar-width: none;
}

.difficulty::-webkit-scrollbar {
  display: none;
}

.diff-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 7px;
  border: 2px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  background: var(--face);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  white-space: nowrap;
}

.diff-btn:hover {
  background: #d4d4d4;
}

.diff-btn:active {
  border-color: var(--dark) var(--white) var(--white) var(--dark);
  box-shadow: 1px 1px 0 var(--white) inset;
}

.diff-btn.is-active {
  border-color: var(--dark) var(--white) var(--white) var(--dark);
  background: #b0b0b0;
  box-shadow: 1px 1px 0 var(--white) inset;
  font-weight: 700;
}

.diff-dot {
  display: none;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.toolbar-options { position: relative; }
.toolbar-options summary { display: flex; align-items: center; justify-content: center; min-height: 24px; padding: 0 8px; border: 2px solid; border-color: var(--white) var(--dark) var(--dark) var(--white); background: var(--face); cursor: pointer; list-style: none; }
.toolbar-options summary::-webkit-details-marker { display: none; }
.toolbar-options summary::after { content: " ▾"; }
.toolbar-options-menu { position: absolute; right: 0; top: 100%; z-index: 30; padding: 4px; background: var(--face); border: 2px solid; border-color: var(--white) var(--dark) var(--dark) var(--white); box-shadow: 1px 1px var(--black); }
.toolbar-options-menu .chip-btn { white-space: nowrap; }
@media (max-width: 760px) {
  .toolbar-options { flex: 1; }
  .toolbar-options summary { min-height: 44px; }
  .toolbar-options-menu { min-width: 100%; }
  .toolbar-options-menu .chip-btn { width: 100%; }
}

.toolbar-actions .chip-btn {
  min-height: 24px;
}

/* ---------------- tablero personalizado ---------------- */

.custom-panel {
  margin-bottom: 6px;
  padding: 6px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
  animation: panelIn 0.15s ease;
}

.custom-fields {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 64px;
}

.field > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.field input {
  width: 72px;
  height: 22px;
  padding: 0 4px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  border-radius: 0;
  background: var(--white);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  outline: none;
}

.field input:focus {
  outline: 1px dotted var(--black);
  outline-offset: -4px;
}

.field--mines input {
  width: 80px;
}

.field-x {
  display: grid;
  place-items: center;
  height: 22px;
  color: var(--muted);
}

.custom-hint {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

/* ---------------- marco del juego ---------------- */

.game-panel {
  position: relative;
  padding: 6px;
  border: 2px solid;
  border-color: var(--white) var(--shadow) var(--shadow) var(--white);
  background: var(--face);
  box-shadow: 1px 1px 0 var(--black);
}

.game-panel::before {
  display: none;
}

.hud {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  padding: 4px 6px 18px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.hud-stat--right {
  align-items: flex-end;
  text-align: right;
}

.hud-label {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--black);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hud-label .icon {
  color: var(--black);
  font-size: 11px;
}

.digital {
  display: inline-block;
  min-width: 54px;
  padding: 0 4px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--led-bg);
  color: var(--led);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  line-height: 1.1;
  text-align: center;
  text-shadow: none;
}

.hud-stat--right .digital {
  color: var(--led);
  text-shadow: none;
}

.hud-record {
  position: absolute;
  left: 50%;
  bottom: 2px;
  max-width: 200px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translateX(-50%);
}

.hud-record.has-record {
  color: var(--amber);
  text-shadow: none;
}

.face-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  border-radius: 0;
  background: var(--face);
  box-shadow: 1px 1px 0 var(--black);
  color: var(--black);
}

.face-btn::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid var(--black);
  border-radius: 50%;
  background: #ffff00;
}

.face-btn::after {
  display: none;
}

.face-btn:hover {
  background: #d4d4d4;
}

.face-btn:active {
  border-color: var(--dark) var(--white) var(--white) var(--dark);
  box-shadow: 1px 1px 0 var(--white) inset;
  transform: translate(1px, 1px);
}

.face-btn.is-focus {
  background: #b0b0b0;
}

.face-btn.is-dead {
  background: #ffcccc;
  animation: faceShake 0.35s ease-in-out;
}

.face-btn.is-win {
  background: #ccffcc;
  animation: faceWin 0.35s ease;
}

.face-icon {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  color: var(--black);
  filter: none;
}

/* ---------------- tablero ---------------- */

.board-frame {
  position: relative;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 3px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
  overflow: hidden;
}

.board-frame::after {
  display: none;
}

.frame-corner {
  display: none;
}

.board-viewport {
  display: flex;
  justify-content: flex-start;
  max-height: min(62vh, 760px);
  overflow: auto;
  border: 0;
  background: var(--face);
  overscroll-behavior: contain;
}

.board-viewport > .board {
  margin: 0 auto;
}

/* ---------------- escudo ---------------- */

.shield-hud {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 4px;
  border: 2px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  border-radius: 0;
  background: var(--face);
  box-shadow: 1px 1px 0 var(--black);
  color: var(--black);
  animation: shieldIn 0.15s ease;
}

.shield-hud .icon {
  color: var(--mint);
  font-size: 11px;
  filter: none;
}

.shield-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.shield-pips {
  display: flex;
  gap: 2px;
  margin-left: 1px;
}

.shield-pips i {
  width: 5px;
  height: 10px;
  border: 1px solid var(--black);
  border-radius: 0;
  background: var(--mint);
  box-shadow: none;
}

.shield-pips i.is-spent {
  background: transparent;
  opacity: 1;
  transform: none;
}

/* ---------------- aviso de congelación ---------------- */

.freeze-banner {
  position: absolute;
  left: 50%;
  bottom: 8px;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 16px);
  padding: 3px 6px;
  border: 2px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  border-radius: 0;
  background: var(--face);
  box-shadow: 1px 1px 0 var(--black);
  color: var(--black);
  font-size: 11px;
  transform: translateX(-50%);
  animation: bannerIn 0.15s ease;
}

.freeze-banner .icon {
  color: var(--blue);
  font-size: 13px;
  animation: snowSpin 9s linear infinite;
}

.freeze-banner-title {
  color: var(--black);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.freeze-banner kbd {
  font-size: 10px;
}

.freeze-banner-copy {
  color: var(--muted);
  font-size: 10px;
}

.freeze-banner-timer {
  min-width: 30px;
  color: var(--black);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-align: right;
  text-shadow: none;
}

.freeze-banner-meter {
  width: 44px;
  height: 6px;
  overflow: hidden;
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  border-radius: 0;
  background: var(--white);
}

.freeze-banner-meter i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: var(--blue);
  box-shadow: none;
  transform-origin: left center;
  transition: transform 0.08s linear;
}

.freeze-banner.is-holding {
  background: #c0ffff;
}

.freeze-banner.is-holding .icon {
  animation-duration: 1.4s;
}

.freeze-banner.is-hammer {
  background: #ffffcc;
}

.freeze-banner.is-hammer .icon {
  color: var(--amber);
  animation: hammerReady 1.1s ease-in-out infinite;
}

.freeze-banner.is-hammer .freeze-banner-title,
.freeze-banner.is-hammer .freeze-banner-timer {
  color: var(--black);
  text-shadow: none;
}

.freeze-banner.is-hammer .freeze-banner-meter {
  background: var(--white);
}

.freeze-banner.is-hammer .freeze-banner-meter i {
  background: var(--amber);
}

/* ---------------- barra de estado ---------------- */

.status-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 3px 2px 0;
}

.status-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 0;
  background: var(--mint);
  animation: dotPulse 2s ease-in-out infinite;
}

.status-dot.is-warn {
  background: var(--amber);
}

.status-dot.is-danger {
  background: var(--red);
}

.status-dot.is-scan {
  background: var(--title);
}

.status-dot.is-ice {
  background: var(--blue);
}

#statusText {
  overflow: hidden;
  color: var(--black);
  font-size: 11px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.controls-hint {
  margin-left: auto;
  flex: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  white-space: nowrap;
}

/* ---------------- pie ---------------- */

.footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  padding: 3px 6px;
  border-top: 1px solid var(--shadow);
  background: var(--face);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.footer-sep {
  width: 1px;
  height: 12px;
  background: var(--shadow);
}

.footer-right {
  margin-left: auto;
}

/* ---------------- diálogos ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: 22px;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.12s ease, visibility 0.12s;
}

.modal.is-open {
  visibility: visible;
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 660px);
  max-height: calc(100dvh - 44px);
  overflow: auto;
  padding: 0 10px 10px;
  border: 3px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  border-radius: 0;
  background: var(--face);
  box-shadow: 2px 2px 0 var(--black);
  transform: none;
  transition: none;
}

.modal.is-open .modal-card {
  transform: none;
}

.modal-card--help {
  width: min(100%, 780px);
}

.modal-card--records {
  width: min(100%, 820px);
}

.modal-card--result {
  width: min(100%, 520px);
  padding: 28px 10px 10px;
  text-align: center;
}

.modal-card--result::before {
  content: "Resultado";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 20px;
  padding: 3px 8px;
  background: linear-gradient(90deg, var(--title), var(--title-2));
  color: var(--white);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
}

.modal-card::-webkit-scrollbar {
  width: 16px;
}

.modal-close {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 16px;
  height: 14px;
  border: 1px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  border-radius: 0;
  background: var(--face);
  color: var(--black);
  font-size: 11px;
  box-shadow: none;
}

.modal-close:hover {
  background: #d4d4d4;
  color: var(--black);
  border-color: var(--white) var(--dark) var(--dark) var(--white);
}

.modal-head {
  margin: 0 -10px 10px;
  padding: 4px 26px 4px 8px;
  background: linear-gradient(90deg, var(--title), var(--title-2));
  color: var(--white);
}

.modal-head .kicker {
  display: none;
}

.modal-head h2 {
  margin: 0;
  color: var(--white);
  font-size: 12px;
  letter-spacing: 0;
}

.modal-sub {
  margin-top: 2px;
  color: #e0e0ff;
  font-size: 11px;
  line-height: 1.3;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 10px;
}

.modal-actions--between {
  justify-content: space-between;
}

.modal-actions--stack {
  flex-direction: column;
  gap: 4px;
}

.modal-actions--stack .primary-btn,
.modal-actions--stack .ghost-btn {
  width: 100%;
}

/* ---------------- ayuda ---------------- */

.help-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 8px;
}

.help-block {
  padding: 8px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.help-block h3,
.help-powers h3 {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
  color: var(--black);
  font-size: 11px;
  letter-spacing: 0;
}

.help-num {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 16px;
  border: 1px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  background: var(--face);
  color: var(--black);
  font-size: 10px;
  letter-spacing: 0;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-list li {
  position: relative;
  padding-left: 10px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.help-list li::before {
  content: "•";
  position: absolute;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  color: var(--black);
}

.help-list b {
  color: var(--black);
  font-weight: 700;
}

.key-table {
  display: flex;
  flex-direction: column;
}

.key-table > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 3px 0;
  border-bottom: 1px dotted var(--shadow);
  color: var(--muted);
  font-size: 11px;
}

.key-table > div:last-child {
  border-bottom: 0;
}

.key-table kbd {
  height: 15px;
  font-size: 10px;
}

.help-powers {
  margin-top: 10px;
}

.help-power-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.help-power-grid article {
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.help-power-grid article > .icon {
  flex: none;
  margin-top: 1px;
  color: var(--title);
  font-size: 17px;
}

.help-power-grid article:nth-child(2) > .icon {
  color: var(--amber);
}

.help-power-grid article:nth-child(3) > .icon {
  color: var(--mint);
}

.help-power-grid article:nth-child(4) > .icon {
  color: var(--blue);
}

.help-power-grid h4 {
  margin-bottom: 2px;
  color: var(--black);
  font-size: 10px;
  letter-spacing: 0;
}

.help-power-grid p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.help-power-grid b {
  color: var(--black);
  font-weight: 700;
}

/* ---------------- récords ---------------- */

.records-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}

.rec-stat {
  padding: 5px 6px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.rec-stat strong {
  display: block;
  color: var(--title);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.15;
}

.rec-stat:nth-child(2) strong {
  color: var(--mint);
}

.rec-stat:nth-child(3) strong {
  color: var(--amber);
}

.rec-stat:nth-child(4) strong {
  color: var(--violet);
}

.rec-stat span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.records-subtitle {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 10px 0 5px;
  color: var(--black);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.records-subtitle .icon {
  color: var(--amber);
  font-size: 12px;
}

.best-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.best-card {
  position: relative;
  padding: 6px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.best-card.is-empty {
  opacity: 0.55;
}

.best-card .best-mode {
  display: block;
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.best-card strong {
  display: block;
  color: var(--title);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0;
}

.best-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.history-wrap {
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--white);
  overflow: hidden;
}

.history-head,
.history-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.5fr) 0.8fr 0.75fr 1fr 0.65fr;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
}

.history-head {
  border-bottom: 1px solid var(--shadow);
  background: var(--face);
  color: var(--black);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.history-list {
  max-height: 230px;
  overflow: auto;
}

.history-row {
  border-bottom: 1px solid var(--face-light);
  color: var(--black);
  font-size: 11px;
}

.history-row:last-child {
  border-bottom: 0;
}

.history-row:hover {
  background: var(--title);
  color: var(--white);
}

.history-mode {
  overflow: hidden;
  color: var(--black);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-mode small {
  display: block;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 400;
}

.history-result {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.history-result.is-win {
  color: var(--mint);
}

.history-result.is-lose {
  color: var(--red);
}

.history-time {
  color: var(--black);
  font-family: var(--font-body);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.history-date {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.history-powers {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  white-space: nowrap;
}

.history-row:hover .history-mode,
.history-row:hover .history-mode small,
.history-row:hover .history-time,
.history-row:hover .history-date,
.history-row:hover .history-powers {
  color: var(--white);
}

.history-row:hover .history-result.is-win {
  color: #80ff80;
}

.history-row:hover .history-result.is-lose {
  color: #ff8080;
}

.history-empty {
  padding: 18px 10px;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

/* ---------------- resultado ---------------- */

.result-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 8px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  border-radius: 0;
  background: var(--face);
  box-shadow: none;
  color: var(--red);
  font-size: 24px;
}

.result-emblem.is-win {
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: #ccffcc;
  box-shadow: none;
  color: var(--mint);
}

.result-emblem.is-win .icon {
  animation: trophyPop 0.4s ease;
}

.modal-card--result .kicker {
  color: var(--muted);
}

.modal-card--result.is-win .kicker {
  color: var(--mint);
}

.modal-card--result h2 {
  margin: 3px 0 4px;
  color: var(--black);
  font-size: 16px;
}

.result-time-wrap {
  position: relative;
  margin: 10px 0 8px;
  padding: 6px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.result-time-label {
  display: block;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.result-time {
  display: block;
  margin-top: 3px;
  padding: 0 4px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--led-bg);
  color: var(--led);
  font-family: "Consolas", "Courier New", monospace;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  line-height: 1.15;
  text-shadow: none;
}

.new-record {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 5px;
  padding: 2px 5px;
  border: 2px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  border-radius: 0;
  background: #ffffcc;
  color: var(--black);
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  animation: recordPulse 1.6s ease-in-out infinite;
}

.new-record .icon {
  font-size: 10px;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.result-detail {
  padding: 4px;
  border: 2px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  background: var(--face);
}

.result-detail strong {
  display: block;
  overflow: hidden;
  color: var(--black);
  font-family: var(--font-body);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-detail span {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}

/* ---------------- avisos ---------------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 500;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 4px;
  width: min(92vw, 460px);
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 8px;
  border: 2px solid;
  border-color: var(--white) var(--dark) var(--dark) var(--white);
  border-radius: 0;
  background: var(--face);
  box-shadow: 1px 1px 0 var(--black);
  color: var(--black);
  font-size: 10px;
  line-height: 1.3;
  animation: toastIn 0.15s ease;
}

.toast.is-out {
  animation: toastOut 0.15s ease forwards;
}

.toast-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border: 1px solid;
  border-color: var(--shadow) var(--white) var(--white) var(--shadow);
  border-radius: 0;
  background: var(--face);
  color: var(--title);
  font-size: 11px;
}

.toast.is-warn .toast-icon {
  color: var(--amber);
}

.toast.is-danger .toast-icon {
  color: var(--red);
}

.toast.is-success .toast-icon {
  color: var(--mint);
}

/* ---------------- efectos ---------------- */

.fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 350;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 340;
  background: var(--white);
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* ---------------- animaciones ---------------- */

@keyframes dotPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@keyframes faceShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

@keyframes faceWin {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes shieldIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes bannerIn {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes snowSpin {
  to { transform: rotate(360deg); }
}

@keyframes panelIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes trophyPop {
  0% { transform: scale(0.8); }
  100% { transform: scale(1); }
}

@keyframes recordPulse {
  0%, 100% { background: #ffffcc; }
  50% { background: #ffff00; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* ---------------- adaptación ---------------- */

@media (max-width: 1240px) {
  .app {
    width: calc(100% - 16px);
  }

  .layout {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 6px;
    padding: 6px;
  }

  .controls-hint {
    display: none;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .game-shell {
    order: 1;
  }

  .sidebar {
    order: 2;
    display: grid;
    grid-template-columns: 1fr;
  }

  .powers-panel {
    order: 1;
  }

  .intel-panel {
    order: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 10px;
  }

  .intel-panel .panel-head {
    align-items: center;
  }

  .intel-panel .panel-sub,
  .intel-panel .intel-tip {
    display: none;
  }

  .mini-stats {
    margin-top: 0;
    min-width: 320px;
  }

  .power-list {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .board-viewport {
    max-height: 64vh;
  }
}

@media (max-width: 760px) {
  .app {
    width: 100%;
    margin: 0;
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .topbar {
    gap: 6px;
    padding: 2px 3px;
  }

  .brand {
    gap: 4px;
  }

  .brand-mark {
    width: 20px;
    height: 20px;
  }

  .brand-mark svg {
    width: 14px;
    height: 14px;
  }

  .brand h1 {
    font-size: 11px;
  }

  .top-actions {
    gap: 2px;
  }

  .top-actions .icon-btn,
  .top-actions .ghost-btn {
    width: 20px;
    height: 20px;
    min-height: 20px;
  }

  .top-actions .coin-chip {
    height: 20px;
    min-height: 20px;
    padding: 0 3px;
  }

  .layout {
    padding: 4px;
    gap: 6px;
  }

  .toolbar {
    gap: 4px;
  }

  .difficulty {
    width: 100%;
    order: 1;
  }

  .diff-btn {
    flex: 1;
    justify-content: center;
    padding: 0 4px;
    font-size: 11px;
  }

  .toolbar-actions {
    order: 2;
    width: 100%;
  }

  .toolbar-actions .chip-btn {
    flex: 1;
    justify-content: center;
  }

  .game-panel {
    padding: 4px;
  }

  .hud {
    gap: 4px;
    padding: 3px 4px 16px;
  }

  .digital {
    min-width: 46px;
    font-size: 18px;
  }

  .hud-label {
    font-size: 10px;
  }

  .face-btn {
    width: 30px;
    height: 30px;
  }

  .face-btn::before {
    width: 20px;
    height: 20px;
  }

  .face-icon {
    width: 20px;
    height: 20px;
  }

  .board-frame {
    padding: 2px;
  }

  .board-viewport {
    max-height: 58vh;
  }

  .status-bar {
    padding-top: 4px;
  }

  #statusText {
    font-size: 10px;
  }

  .footer {
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 10px;
  }

  .footer-right,
  .footer-sep {
    display: none;
  }

  .power-list {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .intel-panel {
    display: none;
  }

  .custom-fields {
    gap: 4px;
  }

  .field {
    min-width: 0;
    flex: 1;
  }

  .field input,
  .field--mines input {
    width: 100%;
  }

  .custom-fields .primary-btn {
    width: 100%;
  }

  .field-x {
    display: none;
  }

  .modal {
    padding: 8px;
  }

  .modal-card {
    max-height: calc(100dvh - 16px);
  }

  .modal-head {
    padding-right: 24px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  .help-power-grid {
    grid-template-columns: 1fr;
  }

  .records-summary,
  .best-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .history-head,
  .history-row {
    grid-template-columns: minmax(100px, 1.4fr) 0.75fr 0.7fr 0.9fr;
    gap: 4px;
    padding: 3px 5px;
  }

  .history-powers {
    display: none;
  }

  .history-head span:last-child {
    display: none;
  }

  .result-details {
    gap: 4px;
  }

  .freeze-banner {
    gap: 3px;
    padding: 2px 4px;
    font-size: 10px;
    bottom: 5px;
  }

  .freeze-banner .freeze-banner-title {
    display: none;
  }

  .freeze-banner kbd {
    display: none;
  }

  .toasts {
    bottom: 8px;
  }
}

@media (max-width: 420px) {
  .brand h1 {
    font-size: 10px;
  }

  .brand-mark {
    width: 18px;
    height: 18px;
  }

  .top-actions .icon-btn {
    display: none;
  }

  .top-actions .coin-chip {
    padding: 0 2px;
    font-size: 11px;
  }

  #recordsBtn {
    display: none;
  }

  .power-list {
    grid-template-columns: 1fr !important;
  }

  .diff-btn {
    font-size: 10px;
    letter-spacing: 0;
  }

  .hud-record {
    font-size: 10px;
  }

  .result-details {
    grid-template-columns: 1fr;
  }
}

/* Controles t?ctiles conservando el relieve cl?sico. */
@media (max-width: 760px) {
  .topbar { min-height: 44px; padding: 3px 5px; }
  .top-actions .icon-btn, .top-actions .ghost-btn {
    display: inline-flex; width: 36px; height: 38px; min-height: 38px;
  }
  .top-actions .coin-chip { min-height: 38px; height: 38px; padding: 0 6px; }
  .diff-btn, .toolbar-actions .chip-btn, .view-tab, .hq-tab,
  .modal-close, .modal-actions button, .hq-panel-head button { min-height: 44px; }
  .face-btn { width: 44px; height: 44px; }
  .modal { padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
}
@media (max-width: 420px) {
  #recordsBtn { display: inline-flex; }
  .power-list { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 6px; }
}

.intel-panel { display: none; }
@media (max-width: 980px) {
  .powers-panel { order: 0; }
  .core-panel { order: 1; }
}

/* La vista de bots tiene sus propios controles; el arsenal pertenece a Mi partida. */
body.is-spectating .layout { grid-template-columns: minmax(0, 1fr); }
body.is-spectating .sidebar { display: none; }
body.is-spectating .game-shell { width: min(100%, 1200px); margin-inline: auto; }

/* Un solo aviso, fijo y fuera de la zona de juego. */
.toasts { left: auto; right: max(12px, env(safe-area-inset-right)); top: max(4px, env(safe-area-inset-top)); bottom: auto; width: min(340px, calc(100vw - 24px)); align-items: flex-end; transform: none; }
.toast { font-size: 12px; line-height: 1.35; padding: 7px 10px; animation: toastFade 0.12s ease; }
.toast--warn { border-left: 4px solid #a55a00; }
.toast--danger { border-left: 4px solid #b00000; }
.toast--success { border-left: 4px solid #008000; }
@keyframes toastFade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 760px) { .toasts { left: auto; right: 8px; bottom: auto; top: max(4px, env(safe-area-inset-top)); width: min(300px, calc(100vw - 16px)); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
