:root {
  --bg: #111318;
  --card: #1b1e26;
  --card2: #242834;
  --text: #f2f3f5;
  --muted: #9aa1ad;
  --accent: #ffb224;
  --accent2: #e5484d;
  --ok: #22c55e;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  height: 100%;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--accent2); font-weight: 600; }

.logo {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin: 0 0 4px;
}
.logo span { color: var(--accent); }
.cat-emoji { font-size: 2rem; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #201500;
  border: none;
  border-radius: var(--radius);
  padding: 12px 22px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: transform 0.08s ease, filter 0.12s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { filter: grayscale(0.8) brightness(0.7); cursor: default; }
.btn-big { font-size: 1.3rem; padding: 16px 28px; width: 100%; }

.banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  background: var(--accent2);
  color: #fff;
  font-weight: 700;
  text-align: center;
  padding: 8px;
  margin: 0;
}
.banner.reconnect { background: var(--accent); color: #201500; }

/* ---------- Landing ---------- */
.landing {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
}
.landing-card {
  background: var(--card);
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.tagline { color: var(--muted); margin: 0; }
.join-form { display: flex; gap: 10px; }
.join-form input {
  flex: 1;
  background: var(--card2);
  border: 2px solid #333a4a;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.2rem;
  text-align: center;
  letter-spacing: 4px;
  padding: 10px;
  min-width: 0;
}
.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }

/* ---------- Host ---------- */
body.host { overflow: hidden; }
#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  background: #000;
}
#game {
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 16 / 9;
  width: auto;
  height: auto;
  background: #15181f;
}
@media (min-aspect-ratio: 16/9) { #game { height: 100vh; } }
@media (max-aspect-ratio: 16/9) { #game { width: 100vw; } }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(13, 15, 19, 0.94);
  z-index: 10;
}
.lobby-grid {
  display: flex;
  gap: 56px;
  align-items: center;
  padding: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.lobby-left { text-align: center; }
.lobby-sub { color: var(--muted); margin: 2px 0 14px; }
#qr {
  width: min(300px, 60vw);
  height: min(300px, 60vw);
  border-radius: 12px;
  background: #fff;
  padding: 8px;
}
.join-url { color: var(--muted); font-size: 0.95rem; word-break: break-all; max-width: 320px; margin: 12px auto 0; }
.lobby-right { text-align: center; min-width: 320px; }
.code-label { color: var(--muted); margin: 0; font-size: 1.1rem; }
.code {
  font-size: clamp(70px, 12vw, 140px);
  font-weight: 900;
  letter-spacing: 12px;
  margin: 0 0 10px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.player-list {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 152px;
}
.player-list li {
  background: var(--card);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
}
.player-list .swatch { width: 22px; height: 22px; border-radius: 6px; }
.player-list .status { margin-left: auto; font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.player-list .status.ready { color: var(--ok); }
.player-list li.empty { color: #4a5160; font-weight: 600; justify-content: center; }
.countdown { font-size: 1.4rem; font-weight: 800; color: var(--ok); margin: 10px 0 0; }

.victory-card {
  text-align: center;
  background: var(--card);
  border-radius: 24px;
  padding: 40px 60px;
}
.victory-card h1 { font-size: 3rem; margin: 0 0 10px; }
#victory-stats { font-size: 1.3rem; color: var(--muted); margin: 0 0 24px; }

/* ---------- Controller ---------- */
body.controller {
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  height: 100dvh;
  overflow: hidden;
}
.scr {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}
#join-form { display: flex; flex-direction: column; gap: 14px; width: min(340px, 90vw); }
#join-form label { display: flex; flex-direction: column; gap: 6px; text-align: left; font-weight: 700; color: var(--muted); }
#join-form input {
  background: var(--card2);
  border: 2px solid #333a4a;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.4rem;
  padding: 12px;
  text-align: center;
}
#in-code { letter-spacing: 8px; font-variant-numeric: tabular-nums; }

.me { display: flex; flex-direction: column; align-items: center; gap: 2px; }
#my-cat { width: 120px; height: 120px; }
#me-name { font-size: 1.5rem; font-weight: 900; margin: 0; }
#scr-lobby .btn-big { width: min(340px, 90vw); }
#ready.on { background: var(--ok); color: #03200d; }

#scr-pad { padding: 0; gap: 0; justify-content: flex-start; }
#pad-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  font-weight: 800;
  background: var(--card);
}
#pad-swatch { width: 18px; height: 18px; border-radius: 5px; background: #666; }
#pad-level { margin-left: auto; font-size: 0.85rem; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.dot.off { background: var(--accent2); }
#fullscreen, #btn-pause {
  background: none; border: none; color: var(--muted);
  font-size: 1.3rem; cursor: pointer; padding: 2px 6px;
}

.banner-btn {
  margin-left: 10px;
  background: #fff;
  color: var(--accent2);
  border: none;
  border-radius: 8px;
  padding: 4px 12px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

/* Menú de pausa del control (overlay independiente de las pantallas) */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(13, 15, 19, 0.94);
  padding: 24px;
}
.menu-card {
  background: var(--card);
  border-radius: 24px;
  padding: 32px 28px;
  text-align: center;
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.menu-card h1 { margin: 0; font-size: 2rem; }
.menu-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }

#pad {
  flex: 1;
  width: 100%;
  display: flex;
  gap: 12px;
  padding: 14px;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
#pad-left { flex: 1.2; display: flex; gap: 12px; }
#pad-right { flex: 1; display: flex; }
.pad-btn {
  flex: 1;
  border: none;
  border-radius: 22px;
  background: var(--card2);
  color: var(--text);
  font-size: clamp(2rem, 8vw, 3.4rem);
  font-weight: 900;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.pad-btn.active, .pad-btn:active { background: #39415a; }
.pad-btn.jump { background: var(--accent); color: #201500; }
.pad-btn.jump.active { background: #ffc95e; }
.pad-btn small { font-size: 0.8rem; letter-spacing: 2px; }

.pad-toast {
  position: fixed;
  left: 50%;
  bottom: 30%;
  transform: translateX(-50%);
  background: rgba(20, 22, 28, 0.95);
  border: 2px solid var(--accent);
  padding: 10px 22px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1.1rem;
  z-index: 40;
  white-space: nowrap;
}
.pad-toast.death { border-color: var(--accent2); }
