/* Buscapina — estilos. Dos temas: "retro" (estilo escritorio 98) y "trading" (pantalla de broker). */

* { box-sizing: border-box; }
html, body { margin: 0; }

:root { --cell: 26px; --cols: 9; --gap: 0px; --chrome: 26px; }
body[data-theme="trading"] { --gap: 2px; --chrome: 34px; }

body[data-theme="retro"] {
  --bg: #0e7c78; --surface: #c3c3c3; --surface-2: #d6d3cc; --text: #111; --muted: #3b3b3b;
  --hi: #ffffff; --lo: #808080; --dk: #1e1e1e;
  --title-a: #0a2670; --title-b: #3b78c8; --title-fg: #fff;
  --cell-hidden: #c3c3c3; --cell-open: #bdbdbd; --cell-line: #8c8c8c; --cell-hover: #cfcfcf;
  --lcd-bg: #140000; --lcd-fg: #ff2626; --lcd-glow: rgba(255, 38, 38, .45);
  --n1: #0000f0; --n2: #007a00; --n3: #e00000; --n4: #00007b; --n5: #7b0000; --n6: #007b7b; --n7: #000; --n8: #6b6b6b;
  --up: #0b7d2a; --down: #c0151c;
  --tape-bg: #000; --tape-fg: #f2f2f2; --tape-sym: #ffd34d; --tape-up: #3ddc6b; --tape-down: #ff4d4d;
  --boom: #ff2b2b; --accent: #0a2670; --disc: #e3f3f2; --field: #fff;
  --font: Tahoma, Verdana, "Segoe UI", sans-serif;
  --mono: Consolas, "Courier New", monospace;
}

body[data-theme="trading"] {
  --bg: #070b10; --surface: #101821; --surface-2: #0c131b; --text: #d7dee7; --muted: #8a99ab;
  --hi: #263547; --lo: #18222e; --dk: #05080c;
  --title-a: #0f1a26; --title-b: #13283a; --title-fg: #9fe8c2;
  --cell-hidden: #1d2a3a; --cell-open: #0b1219; --cell-line: #18222e; --cell-hover: #2a3d54;
  --lcd-bg: #020604; --lcd-fg: #16e08a; --lcd-glow: rgba(22, 224, 138, .4);
  --n1: #4ea8ff; --n2: #16c784; --n3: #ff5b5b; --n4: #b18cff; --n5: #ffb020; --n6: #2fd4d4; --n7: #e6e6e6; --n8: #8a99ab;
  --up: #16c784; --down: #ea3943;
  --tape-bg: #05080c; --tape-fg: #d7dee7; --tape-sym: #9fe8c2; --tape-up: #16c784; --tape-down: #ea3943;
  --boom: #ea3943; --accent: #16c784; --disc: #6c7b8c; --field: #0c131b;
  --font: "Segoe UI", system-ui, sans-serif;
  --mono: Consolas, "SFMono-Regular", "Courier New", monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.4 var(--font);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- bordes en relieve ---------- */
.raised { border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi); }
.sunken { border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo); }
body[data-theme="trading"] .raised,
body[data-theme="trading"] .sunken { border: 1px solid var(--hi); border-radius: 6px; }

/* ---------- cinta de cotizaciones ---------- */
.tape {
  position: sticky; top: 0; z-index: 5;
  height: 28px; overflow: hidden; white-space: nowrap;
  background: var(--tape-bg); color: var(--tape-fg);
  font: 600 12px/28px var(--mono);
  border-bottom: 1px solid #222;
}
.tape-track { display: inline-block; animation: tape 70s linear infinite; }
.tape:hover .tape-track { animation-play-state: paused; }
.tk { margin-right: 30px; }
.tk b { color: var(--tape-sym); }
.tk i { font-style: normal; }
.tk i.up { color: var(--tape-up); }
.tk i.down { color: var(--tape-down); }
.tk i.flat { opacity: .7; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .tape-track { animation-duration: 300s; } }

/* ---------- ventana principal ---------- */
.app {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 20px 16px 140px;
}
.window {
  background: var(--surface);
  border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi);
  box-shadow: 1px 1px 0 var(--dk);
  padding: 3px;
}
body[data-theme="trading"] .window {
  border: 1px solid var(--hi); border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
  padding: 0; overflow: hidden;
}
.game {
  width: max(360px, calc(var(--cols) * var(--cell) + (var(--cols) - 1) * var(--gap) + var(--chrome)));
  max-width: 100%;
}
.game.shake { animation: shake .45s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); } 40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); } 80% { transform: translateX(4px); }
}

.titlebar {
  display: flex; align-items: center; gap: 8px;
  min-height: 26px; padding: 3px 4px 3px 6px;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: var(--title-fg); font-weight: 700;
}
.title-text { white-space: nowrap; }
.main-title { display: grid; grid-template-columns: 1fr auto 1fr; }
.main-title .title-text { letter-spacing: 2px; font-size: 14px; }
.title-buttons { margin-left: auto; display: flex; gap: 3px; flex: none; }
.tbtn {
  width: 26px; height: 22px; padding: 0; line-height: 1; font-size: 12px;
  background: var(--surface); color: var(--text);
  border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi);
}
.tbtn:active { border-color: var(--dk) var(--hi) var(--hi) var(--dk); }
body[data-theme="trading"] .tbtn { background: transparent; border: 1px solid var(--hi); border-radius: 5px; }

/* ---------- botones ---------- */
.btn {
  min-height: 30px; padding: 4px 10px; white-space: nowrap;
  background: var(--surface);
  border: 2px solid; border-color: var(--hi) var(--dk) var(--dk) var(--hi);
}
.btn:active, .btn.active, .btn[aria-pressed="true"] {
  border-color: var(--dk) var(--hi) var(--hi) var(--dk);
  background: var(--surface-2);
}
.btn.primary { font-weight: 700; outline: 1px solid var(--dk); }
.btn:focus-visible, .tbtn:focus-visible, .face:focus-visible { outline: 2px dotted var(--text); outline-offset: 1px; }
body[data-theme="trading"] .btn { border: 1px solid var(--hi); border-radius: 6px; background: #162230; }
body[data-theme="trading"] .btn.active,
body[data-theme="trading"] .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: rgba(22, 199, 132, .08); }
body[data-theme="trading"] .btn.primary { background: var(--accent); color: #03140b; border-color: var(--accent); outline: none; }

.menubar { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 4px; }
body[data-theme="trading"] .menubar { padding: 8px; }
.levels, .tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.menu-label { font-weight: 700; margin-right: 2px; }

/* ---------- panel con contadores ---------- */
.panel {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 4px 6px; padding: 6px 8px;
}
body[data-theme="trading"] .panel { margin: 0 8px 8px; }
.lcd-box { text-align: center; }
.lcd-box small { display: block; margin-top: 2px; font-size: 10px; color: var(--muted); }
.lcd {
  min-width: 66px; padding: 3px 6px; text-align: center;
  font: 700 26px/1 var(--mono); letter-spacing: 2px;
  color: var(--lcd-fg); background: var(--lcd-bg);
  text-shadow: 0 0 6px var(--lcd-glow);
  border: 1px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo);
}
body[data-theme="trading"] .lcd { border: 1px solid var(--hi); border-radius: 4px; }
.lcd.urgent { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .25; } }
.face {
  width: 46px; height: 46px; padding: 0;
  display: grid; place-items: center;
  font-size: 27px; line-height: 1;
  background: var(--surface);
}
.face:active { border-color: var(--dk) var(--hi) var(--hi) var(--dk); }
body[data-theme="trading"] .face { background: #162230; border-radius: 50%; }

/* ---------- tablero ---------- */
.board-wrap { margin: 0 4px 6px; overflow: auto; max-width: 100%; }
body[data-theme="trading"] .board-wrap { margin: 0 8px 8px; padding: 4px; }
.board {
  display: grid; width: max-content; margin: 0 auto;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.board { gap: var(--gap); }
.cell {
  width: var(--cell); height: var(--cell);
  display: grid; place-items: center; overflow: hidden;
  font: 700 calc(var(--cell) * .58)/1 var(--font);
  cursor: default;
}
.cell.flag, .cell.question, .cell.mine, .cell.wrong { font-size: calc(var(--cell) * .56); }
.n1 { color: var(--n1); } .n2 { color: var(--n2); } .n3 { color: var(--n3); } .n4 { color: var(--n4); }
.n5 { color: var(--n5); } .n6 { color: var(--n6); } .n7 { color: var(--n7); } .n8 { color: var(--n8); }

body[data-theme="retro"] .cell {
  background: var(--cell-hidden);
  border: max(2px, calc(var(--cell) * .11)) solid;
  border-color: var(--hi) var(--lo) var(--lo) var(--hi);
}
body[data-theme="retro"] .cell.open,
body[data-theme="retro"] .cell.down {
  background: var(--cell-open);
  border-width: 1px 0 0 1px; border-color: var(--cell-line);
}

body[data-theme="trading"] .cell {
  background: var(--cell-hidden);
  border: 1px solid #2a3b50; border-radius: 3px;
  font-family: var(--mono);
}
body[data-theme="trading"] .cell:not(.open):hover { background: var(--cell-hover); }
body[data-theme="trading"] .cell.open,
body[data-theme="trading"] .cell.down { background: var(--cell-open); border-color: var(--cell-line); }

.cell.boom { background: var(--boom) !important; }
.cell.wrong { background: #ffd5d5 !important; }
body[data-theme="trading"] .cell.wrong { background: #3a1518 !important; }

/* ---------- barra de estado ---------- */
.statusbar { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px 2px; }
body[data-theme="trading"] .statusbar { padding: 0 8px 8px; }
.sb {
  flex: 1 1 auto; min-width: 0; padding: 2px 6px; font-size: 12px;
  border: 1px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo);
}
body[data-theme="trading"] .sb { border: 1px solid var(--hi); border-radius: 4px; font-family: var(--mono); }
.up { color: var(--up); }
.down { color: var(--down); }

.disclaimer { max-width: 640px; margin: 0; text-align: center; font-size: 11px; color: var(--disc); }

/* ---------- tuits ---------- */
.tweets {
  position: fixed; right: 16px; bottom: 16px; z-index: 20;
  width: min(360px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.tweet {
  display: flex; gap: 10px; padding: 10px 12px;
  background: #fff; color: #0f1419;
  border: 1px solid #cfd9de; border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  font: 14px/1.35 "Segoe UI", system-ui, sans-serif;
  text-align: left;
}
body[data-theme="trading"] .tweet { background: #15202b; color: #e7e9ea; border-color: #2f3b47; }
.tweet.toast { pointer-events: auto; cursor: pointer; animation: slideIn .25s ease-out; transition: opacity .35s, transform .35s; }
.tweet.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes slideIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.avatar {
  position: relative; overflow: hidden;
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
}
/* la foto tapa las iniciales; si no carga, se ven las iniciales */
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tweet { position: relative; padding-right: 40px; }
.tw-body { min-width: 0; }
.tw-head { margin-bottom: 2px; }
.tw-handle { color: #536471; font-size: 13px; }
body[data-theme="trading"] .tw-handle { color: #8b98a5; }
.tw-text { overflow-wrap: anywhere; }
.tw-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tw-moment {
  padding: 0 6px; font-size: 11px; font-weight: 700;
  color: #fff; border-radius: 999px;
}
.tw-start { background: #0969da; }
.tw-cascade { background: #1a7f37; }
.tw-lose { background: #cf222e; }
.tw-win { background: #bf8700; }
.tw-timeout { background: #6e7781; }
.tw-idle { background: #8250df; }
/* sticker grande y torcido en la esquina del tuit */
.tw-sticker {
  position: absolute; top: -10px; right: -6px;
  font-size: 30px; line-height: 1;
  transform: rotate(12deg);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35));
  animation: stickerPop .45s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes stickerPop { from { transform: scale(0) rotate(-40deg); } to { transform: scale(1) rotate(12deg); } }

/* ---------- ventanas emergentes ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(0, 0, 0, .45);
}
.overlay[hidden] { display: none; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal-body { padding: 14px 16px 16px; overflow: auto; }
.modal-body h3 { margin: 16px 0 6px; font-size: 14px; }
.modal-body p { margin: 0 0 10px; }
.modal-body ul { margin: 0 0 10px; padding-left: 20px; }
.lead { font-size: 14px; }
.note { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }

input {
  font: inherit; padding: 4px 6px; max-width: 100%;
  background: var(--field); color: var(--text);
  border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo);
}
body[data-theme="trading"] input { border: 1px solid var(--hi); border-radius: 6px; }

.rank-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.rank-table td, .rank-table th { padding: 4px 6px; border-bottom: 1px solid var(--lo); text-align: left; }

.rank-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px;
  margin-top: 14px; padding: 10px;
  border: 2px solid; border-color: var(--lo) var(--hi) var(--hi) var(--lo);
}
body[data-theme="trading"] .rank-form { border: 1px solid var(--accent); border-radius: 8px; }
.rank-form label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.rank-table .rk-name { overflow-wrap: anywhere; }
.empty { padding: 12px 0; color: var(--muted); }

.legend { display: grid; grid-template-columns: 30px 1fr; gap: 6px 8px; align-items: center; margin-bottom: 10px; }
.legend .ico { text-align: center; font-size: 18px; }
kbd {
  padding: 0 4px; font: 12px var(--mono);
  border: 1px solid var(--lo); border-radius: 3px; background: var(--surface-2);
}

@media (max-width: 480px) {
  .app { padding-top: 12px; }
  .lcd { font-size: 22px; min-width: 56px; }
}
