/* QueBolá · Cliente */
:root {
  --bg: #f6f4ee;
  --ink: #1f2a44;
  --muted: #5b6478;
  --accent: #b3202b;
  --accent-dark: #7b1620;
  --card: #fff;
  --border: #e0dccf;
  --bubble-mine: #1f2a44;
  --bubble-mine-text: #fff;
  --bubble-them: #f0ebd9;
  --bubble-them-text: #1f2a44;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
}

input, button { font: inherit; }
input, button {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fdfbf6;
  color: var(--ink);
}
button { cursor: pointer; background: var(--accent); color: #fff; border-color: var(--accent-dark); }
button:hover { background: var(--accent-dark); }

.pantalla { width: 100%; height: 100%; display: flex; flex-direction: column; }
.error { color: var(--accent); margin-top: 10px; min-height: 20px; }
.small { font-size: 0.8em; color: var(--muted); }

/* Bienvenida */
#bienvenida { align-items: center; justify-content: center; padding: 24px; }
.caja {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px 24px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.caja h1 {
  font-size: 1.8em;
  margin-bottom: 6px;
  cursor: default;
  user-select: none;
}
.caja .lead { color: var(--muted); margin-bottom: 22px; }
#form-canjear { display: flex; flex-direction: column; gap: 10px; }
#codigo-input {
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 1.2em;
  letter-spacing: 0.05em;
}
.footer { margin-top: 22px; }

/* Chat */
#chat { background: var(--bg); }
#chat header {
  background: var(--ink);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 3px solid var(--accent);
}
#chat header h1 {
  font-size: 1em;
  font-weight: 700;
  flex: 1;
  cursor: pointer;
  user-select: none;
}
.status { font-size: 0.75em; color: #b6bdcc; }
.status.online { color: #6cd585; }
.status.offline { color: #ff8a8a; }
.panico {
  background: transparent;
  color: #ff8a8a;
  border: 1px solid #5a1818;
  font-size: 1.1em;
  padding: 4px 10px;
}
.panico:hover { background: var(--accent); color: #fff; }

#zona-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.msg {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
  animation: aparecer 0.18s ease;
}
@keyframes aparecer { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.msg.mio { align-self: flex-end; background: var(--bubble-mine); color: var(--bubble-mine-text); border-bottom-right-radius: 4px; }
.msg.suyo { align-self: flex-start; background: var(--bubble-them); color: var(--bubble-them-text); border-bottom-left-radius: 4px; }
.msg .ts { display: block; margin-top: 4px; font-size: 0.7em; opacity: 0.7; }

#form-msg {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
}
#msg-input {
  flex: 1;
  border-radius: 22px;
  padding: 10px 16px;
}
#form-msg button {
  border-radius: 50%;
  width: 44px; height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.info-pie {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--ink);
  color: #b6bdcc;
  font-size: 0.75em;
}
.info-pie #alias-pie { font-weight: 600; color: #fff; }

/* Modo pánico activo */
body.borrando { background: #000; }
body.borrando * { visibility: hidden; }

/* Toast simple */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 0.85em;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
}
.toast.visible { opacity: 1; }
