:root {
  --cream: #FFF4C7;
  --honey: #FFC928;
  --orange: #FF8A00;
  --coral: #FF5C7A;
  --mint: #48D597;
  --cyan: #27D7E7;
  --purple: #8B5CF6;
  --ink: #1F1F29;
  --white: #FFFDF5;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background:
    radial-gradient(circle at 12% 18%, rgba(39,215,231,.18), transparent 42%),
    radial-gradient(circle at 88% 14%, rgba(255,92,122,.18), transparent 40%),
    radial-gradient(circle at 50% 110%, rgba(72,213,151,.22), transparent 55%),
    var(--cream);
  color: var(--ink);
  font-family: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
}
.pixel { image-rendering: pixelated; }
h1, h2, .title { font-weight: 800; letter-spacing: .5px; }

/* ---------- HOST canvas ---------- */
#host-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
#game { border-radius: 16px; overflow: hidden; box-shadow: 0 16px 0 rgba(31,31,41,.12), 0 26px 60px rgba(255,138,0,.22); border: 5px solid var(--ink); max-width: 100vw; max-height: 100vh; }

/* botones flotantes durante la partida */
.float-btns { position: fixed; top: 14px; right: 14px; display: flex; gap: 10px; z-index: 20; }
.float-btns.left { right: auto; left: 14px; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 14px; border: 3px solid var(--ink);
  background: var(--white); font-size: 22px; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 4px 0 var(--ink); transition: transform .05s;
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.hidden { display: none !important; }

/* ---------- LOBBY horizontal (dashboard) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(255,244,199,.78); backdrop-filter: blur(3px);
}
#lobby {
  display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; align-content: center;
  gap: clamp(14px, 3vw, 44px); padding: clamp(12px, 2.5vh, 30px) clamp(20px, 4vw, 64px);
  height: 100vh; overflow: hidden;
}
.lobby-left { display: flex; flex-direction: column; gap: clamp(6px, 1.2vh, 12px); min-width: 0; }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-row .bee { font-size: clamp(34px, 4.5vw, 56px); }
.brand { font-size: clamp(30px, 4.4vw, 54px); margin: 0; color: var(--orange); text-shadow: 3px 3px 0 var(--honey); line-height: 1; }
.sub { color: #7a6a3a; margin: 0; font-size: clamp(13px, 1.5vw, 17px); font-weight: 700; }

.quick { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0; }
.quick span { background: var(--white); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 10px; font-size: clamp(11px, 1.1vw, 13px); font-weight: 700; }

.section-title { font-size: clamp(12px, 1.3vw, 15px); font-weight: 800; color: var(--orange); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }

.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.mode-card {
  position: relative; background: var(--white); border: 3px solid var(--ink); border-radius: 14px;
  padding: 8px 8px 7px; cursor: pointer; text-align: left; box-shadow: 0 3px 0 var(--ink); transition: transform .05s;
}
.mode-card .ic { font-size: clamp(20px, 2.4vw, 28px); }
.mode-card .nm { font-weight: 800; font-size: clamp(12px, 1.2vw, 15px); }
.mode-card .ds { font-size: 10px; color: #8a7a4a; font-weight: 700; line-height: 1.1; }
.mode-card.active { background: var(--mint); }
.mode-card:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.mode-card.locked { opacity: .55; cursor: not-allowed; }
.mode-card.locked::after { content: "🔒 PRÓXIMAMENTE"; position: absolute; top: 6px; right: 6px; font-size: 8px; font-weight: 800; color: var(--purple); }

.diff { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.diff button {
  padding: 8px 4px; border-radius: 12px; border: 3px solid var(--ink); background: var(--white);
  color: var(--ink); font-weight: 800; cursor: pointer; font-size: clamp(11px, 1.1vw, 13px); box-shadow: 0 3px 0 var(--ink);
}
.diff button.active { background: var(--honey); }
.diff button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }

.btn {
  background: var(--honey); color: var(--ink); border: 4px solid var(--ink); border-radius: 16px;
  padding: 12px 30px; font-size: clamp(17px, 2vw, 24px); font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 0 var(--ink); transition: transform .05s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.alt { background: var(--cyan); }
.btn.ghost { background: var(--white); }
.btn.big { margin-top: 6px; align-self: flex-start; }

/* columna derecha (QR) */
.lobby-right { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr-card { background: var(--white); border: 5px solid var(--ink); border-radius: 22px; padding: clamp(12px, 2vh, 22px);
  box-shadow: 0 10px 0 rgba(31,31,41,.15), 0 24px 44px rgba(255,138,0,.18); text-align: center; }
#qrbox { background: #fff; padding: 10px; border-radius: 14px; display: inline-block; border: 4px solid var(--ink); }
#qrbox img, #qrbox canvas { width: clamp(150px, 22vh, 230px) !important; height: clamp(150px, 22vh, 230px) !important; }
.code { font-size: clamp(26px, 3vw, 36px); letter-spacing: 7px; color: var(--ink); margin: 10px 0 2px; font-weight: 800;
  background: var(--honey); display: inline-block; padding: 3px 16px; border-radius: 12px; border: 3px solid var(--ink); }
.hint { font-size: 12px; color: #8a7a4a; font-weight: 600; }
.status { margin-top: 8px; font-size: clamp(13px, 1.4vw, 16px); font-weight: 800; color: var(--coral); }
.status.ok { color: var(--mint); }
.right-actions { display: flex; gap: 10px; }

/* ---------- RESULTADOS ---------- */
.results-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; padding: 16px; }
.panel {
  background: var(--white); border: 5px solid var(--ink); border-radius: 26px; padding: 22px 30px; max-width: 620px; width: 100%;
  box-shadow: 0 12px 0 rgba(31,31,41,.15), 0 28px 50px rgba(255,138,0,.18); text-align: center;
}
.winner { font-size: clamp(28px, 4vw, 42px); margin: 0; color: var(--orange); text-shadow: 2px 2px 0 var(--honey); }
.medal { display: inline-block; margin: 8px 0; padding: 8px 18px; border-radius: 999px; border: 3px solid var(--ink);
  background: var(--purple); color: var(--white); font-weight: 800; font-size: clamp(15px, 1.8vw, 19px); }
.results-row { display: flex; justify-content: space-around; margin: 12px 0; gap: 8px; }
.results-row .cell { font-size: 13px; color: #7a6a3a; font-weight: 700; flex: 1;
  background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 8px 4px; }
.results-row .cell b { display: block; font-size: 26px; color: var(--ink); }
.you b { color: var(--orange); }
.bot b { color: var(--cyan); }
.phrase { font-style: italic; color: var(--purple); margin: 12px 6px 10px; font-size: clamp(15px, 1.7vw, 18px); font-weight: 700; }
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.row-btns .btn { padding: 11px 18px; font-size: 16px; }

/* ---------- CONTROLLER (movil tipo Switch) ---------- */
#ctrl { position: fixed; inset: 0; display: flex; flex-direction: column; padding: 10px; overscroll-behavior: none; touch-action: none; }
#join-form { flex: 1; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; }
.brand-sm { font-size: 34px; margin: 0; color: var(--orange); text-shadow: 2px 2px 0 var(--honey); font-weight: 800; }
#join-form input {
  font-size: 30px; letter-spacing: 8px; text-align: center; text-transform: uppercase;
  padding: 12px; width: 230px; border-radius: 14px; border: 4px solid var(--ink); background: var(--white); color: var(--ink); font-weight: 800;
}
#join-msg { font-size: 14px; color: var(--coral); font-weight: 700; min-height: 18px; }

.pad-top { display: flex; align-items: center; gap: 8px; }
.pad-top .miniscore { flex: 1; display: flex; gap: 6px; justify-content: center; }
.pad-top .miniscore div { background: var(--white); border: 3px solid var(--ink); border-radius: 12px; padding: 5px 9px; font-size: 11px; color: #7a6a3a; font-weight: 700; text-align: center; }
.pad-top .miniscore b { display: block; font-size: 18px; color: var(--ink); }
.small-btn { width: 46px; height: 46px; border-radius: 12px; border: 3px solid var(--ink); background: var(--white);
  font-size: 20px; display: grid; place-items: center; box-shadow: 0 3px 0 var(--ink); cursor: pointer; flex: none; }
.small-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.small-btn.exit { background: var(--coral); }

/* barra de riesgo en el movil */
.risk { height: 12px; border: 3px solid var(--ink); border-radius: 999px; background: var(--white); margin: 8px 2px 0; overflow: hidden; }
.risk > i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--mint), var(--honey), var(--coral)); transition: width .15s; }

.pad-main { flex: 1; display: flex; align-items: stretch; gap: 10px; margin-top: 8px; min-height: 0; }
#joyzone { flex: 1.2; position: relative; border-radius: 22px; border: 4px solid var(--ink);
  background: radial-gradient(circle at center, #fff 0%, var(--cream) 70%); touch-action: none; }
.joy-label { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px; color: #b09a5a; font-weight: 700; }
.abxy { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding-left: 2px; }
.gbtn {
  position: relative; border-radius: 50%; border: 4px solid var(--ink); font-size: 30px; font-weight: 900; color: var(--ink);
  aspect-ratio: 1/1; max-width: 120px; width: 100%; margin: 0 auto; display: grid; place-items: center;
  box-shadow: 0 6px 0 var(--ink); cursor: pointer; user-select: none; overflow: hidden;
}
.gbtn small { display: block; font-size: 11px; font-weight: 800; margin-top: -4px; }
.gbtn:active, .gbtn.pressed { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink); filter: brightness(1.15); }
.gbtn.a { background: var(--mint); }
.gbtn.b { background: var(--cyan); }
/* barrido de cooldown del boton B */
.gbtn .cd { position: absolute; inset: 0; background: rgba(31,31,41,.45); transform-origin: bottom; transform: scaleY(0); pointer-events: none; }
.gbtn.cooling .cd { transform: scaleY(1); transition: transform var(--cdms, 3000ms) linear; }
.pad-hint { text-align: center; font-size: 13px; color: #8a7a4a; font-weight: 700; padding: 7px 0 2px; }

.ctrl-howto { background: var(--white); border: 3px dashed var(--purple); border-radius: 14px; padding: 10px 12px; margin: 6px 0; text-align: left; }
.ctrl-howto li { font-size: 13px; color: #5a4d28; font-weight: 600; margin: 3px 0; list-style: none; }
.ctrl-howto b { color: var(--ink); }
.ctrl-howto ul { margin: 0; padding: 0; }

/* lobby en pantallas estrechas -> una columna */
@media (max-width: 820px) {
  #lobby { grid-template-columns: 1fr; gap: 12px; overflow-y: auto; }
  .btn.big { align-self: stretch; }
}
