:root {
  --bg: #fff6e5;
  --ink: #1f1b16;
  --muted: #6e6558;
  --card: #ffffff;
  --line: #eadfca;
  --yellow: #ffc233;
  --coral: #ff5e5b;
  --green: #1fa463;
  --green-soft: #dcf5e7;
  --coral-soft: #ffe3e2;
  --whatsapp: #25d366;
  --display: "Baloo 2", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.screen { display: none; flex-direction: column; gap: 16px; }
.screen.active { display: flex; }

h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.1; }
h2 { font-size: 1.35rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* Marca */
.brand { text-align: center; padding-top: 24px; }
.brand.small { padding-top: 4px; }
.logo { font-size: 3.6rem; font-weight: 800; letter-spacing: -1px; }
.squiggle { width: 200px; height: 22px; margin: -6px auto 0; display: block; }
.squiggle path { fill: none; stroke: var(--coral); stroke-width: 5; stroke-linecap: round; }
.tagline { margin-top: 12px; font-size: 1.15rem; color: var(--muted); }
.mini-logo { font-family: var(--display); font-weight: 800; font-size: 1.3rem; }

/* Controles */
.input {
  width: 100%;
  font: inherit;
  font-size: 1.15rem;
  padding: 14px 16px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
}
.input:focus { outline: 3px solid var(--yellow); outline-offset: 2px; }

.btn {
  display: block;
  width: 100%;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.2rem;
  text-align: center;
  text-decoration: none;
  color: var(--ink);
  padding: 12px 18px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 60ms ease, box-shadow 60ms ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn-primary { background: var(--yellow); }
.btn-whatsapp { background: var(--whatsapp); }
.btn-small { font-size: 1rem; padding: 8px 12px; box-shadow: 0 3px 0 var(--ink); }

.error { color: #b42318; font-weight: 600; }

.invite {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--card);
  border: 2px dashed var(--coral);
  border-radius: 16px;
  padding: 12px 16px;
  text-align: center;
}
.invite strong { font-family: var(--display); font-size: 1.3rem; }

.how { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; color: var(--muted); }
.how li { display: flex; gap: 12px; align-items: flex-start; }
.how span {
  flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--display);
  font-weight: 700;
  display: grid; place-items: center;
}

/* Tarjetas y listas */
.card { background: var(--card); border: 2px solid var(--ink); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.room-code b { font-family: var(--display); font-size: 1.2rem; letter-spacing: 2px; }

.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player-list li { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; }
.avatar {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
}
.tag { font-size: 0.8rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.offline { opacity: 0.45; }

.demo-badge { text-align: center; font-size: 0.85rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; padding: 6px; }

/* Ronda */
.game { gap: 12px; }
.round-label { font-family: var(--display); font-weight: 700; color: var(--muted); }
.timer {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.4rem;
  min-width: 64px;
  text-align: center;
  padding: 2px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--card);
}
.timer.hurry { background: var(--coral); color: #fff; }

.word-box { text-align: center; }
.word-hint { display: block; color: var(--muted); font-weight: 600; }
.word { font-family: var(--display); font-weight: 800; font-size: 2.4rem; line-height: 1; }

.board-wrap { position: relative; width: min(100%, calc(100dvh - 330px)); min-width: 240px; margin: 0 auto; }
.board {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 20px;
  touch-action: none;
  cursor: crosshair;
}
.board-overlay {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: rgba(255, 246, 229, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 16px;
}
.board-overlay.win { background: rgba(220, 245, 231, 0.92); }
.board-overlay.miss { background: rgba(255, 227, 226, 0.9); }
.board-overlay.miss .overlay-big { font-size: 2.3rem; }
.board-overlay.miss .overlay-small { color: var(--ink); font-size: 1.15rem; }
.overlay-big { font-family: var(--display); font-weight: 800; font-size: 3rem; line-height: 1; }
.overlay-small { font-size: 1.05rem; color: var(--muted); font-weight: 600; }

.ai-line { display: flex; align-items: center; gap: 8px; min-height: 36px; flex-wrap: wrap; justify-content: center; }
.ai-label { font-weight: 700; color: var(--muted); }
.guesses { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip {
  font-family: var(--display);
  font-weight: 700;
  padding: 2px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--card);
}
.chip.old { text-decoration: line-through; opacity: 0.5; border-color: var(--line); }
.chip.ok { background: var(--green); color: #fff; border-color: var(--green); }
.chip.warn { background: var(--coral-soft); border-color: var(--coral); }
.muted-chip { color: var(--muted); border-color: var(--line); }

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.status-strip { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.status-strip li {
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
}
.status-strip li.done { background: var(--green-soft); border-color: var(--green); font-weight: 700; }

/* Revelación */
.reveal-head { text-align: center; display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.reveal-head h2 { font-size: 2rem; line-height: 1.3; }
.highlight { display: inline-block; background: var(--yellow); padding: 0 10px; border-radius: 10px; line-height: 1.25; }
.reveal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.reveal-card { background: var(--card); border: 2px solid var(--ink); border-radius: 16px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.reveal-card.winner { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.reveal-card img, .reveal-card .blank { width: 100%; aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: block; }
.reveal-card .blank { display: grid; place-items: center; color: var(--muted); font-size: 0.9rem; }
.reveal-card .bot-art { font-size: 3.5rem; background: var(--bg); }
.pitch { font-family: var(--display); font-weight: 700; font-size: 1.2rem; line-height: 1.3; white-space: pre-line; }
.reveal-name { font-family: var(--display); font-weight: 700; font-size: 1.1rem; display: flex; justify-content: space-between; gap: 6px; }
.reveal-status { font-size: 0.9rem; color: var(--muted); }
.reveal-status.ok { color: var(--green); font-weight: 700; }
.points { color: var(--green); }

/* Final */
.final-title { font-size: 2.4rem; margin-top: 8px; }
.ranking { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ranking li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 10px 14px;
  font-size: 1.1rem;
}
.ranking li:first-child { background: var(--yellow); }
.ranking .pos { font-family: var(--display); font-weight: 800; font-size: 1.4rem; width: 32px; }
.ranking .name { flex: 1; font-weight: 700; }
.ranking .meta { color: var(--muted); font-size: 0.95rem; }
.ranking .score { font-family: var(--display); font-weight: 800; min-width: 40px; text-align: right; }
.ranking li.me { box-shadow: 0 0 0 3px var(--coral); }

.small { font-size: 0.9rem; }
.status-strip li.hint { background: none; border-style: dashed; color: var(--muted); }

/* Vista previa de la tarjeta */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(31, 27, 22, 0.7);
  display: grid;
  place-items: center;
  padding: 16px;
}
.dialog[hidden] { display: none; }
.dialog-box {
  width: min(100%, 420px);
  max-height: 100%;
  overflow: auto;
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card-image { width: 100%; max-height: 62dvh; object-fit: contain; border-radius: 12px; }

/* Avisos */
.connection {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  background: var(--ink);
  color: var(--bg);
  text-align: center;
  font-weight: 700;
  padding: 6px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  z-index: 10;
  max-width: calc(100% - 32px);
}
