:root {
  --ink: #17213a;
  --paper: rgba(255, 255, 255, 0.93);
  --pink: #ff65ba;
  --pink-dark: #c73d91;
  --blue: #5cc8ff;
  --yellow: #ffd75a;
  --shadow: 0 18px 0 rgba(20, 35, 65, 0.18), 0 24px 42px rgba(12, 25, 48, 0.28);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  background: #62c8ff;
  color: var(--ink);
  user-select: none;
}
button, input { font: inherit; }
button { cursor: pointer; }

#app { width: 100%; height: 100%; position: relative; }
#gameCanvas { width: 100%; height: 100%; display: block; background: linear-gradient(#5dc9ff, #dff8ff); }

.screen {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.96);
  width: min(92vw, 760px);
  max-height: 92vh;
  overflow-y: auto;
  padding: clamp(22px, 4vw, 42px);
  border: 5px solid rgba(255,255,255,.95);
  border-radius: 34px;
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
  backdrop-filter: blur(14px);
}
.screen.active { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.screen h2 { margin: 0 0 10px; font-size: clamp(28px, 5vw, 44px); }
.screen p { line-height: 1.45; }

.logo-wrap { margin: -8px auto 12px; transform: rotate(-1deg); }
.logo-small, .logo-big, .logo-story {
  display: block;
  font-weight: 1000;
  line-height: .82;
  letter-spacing: -0.06em;
  -webkit-text-stroke: clamp(2px, .45vw, 5px) #17213a;
  paint-order: stroke fill;
  text-shadow: 0 8px 0 #17213a, 0 14px 18px rgba(23,33,58,.28);
}
.logo-small { font-size: clamp(42px, 8vw, 76px); color: #fff; }
.logo-big { font-size: clamp(56px, 12vw, 110px); color: #ff9fdb; }
.logo-story { margin-top: 18px; font-size: clamp(22px, 4vw, 36px); color: #ffe478; letter-spacing: .04em; }
.tagline { font-size: clamp(15px, 2.5vw, 21px); margin: 24px auto; max-width: 590px; }
.legal-note { opacity: .64; font-size: 12px; margin: 22px auto 0; max-width: 620px; }

.menu-grid { display: grid; gap: 13px; max-width: 460px; margin: auto; }
.big-btn, .back-btn, .count-btn {
  border: 0;
  border-radius: 18px;
  font-weight: 900;
  color: var(--ink);
  padding: 15px 22px;
  transition: transform .1s ease, filter .1s ease;
  box-shadow: 0 7px 0 rgba(23,33,58,.25);
}
.big-btn:hover, .back-btn:hover, .count-btn:hover { transform: translateY(-2px); filter: brightness(1.04); }
.big-btn:active, .back-btn:active, .count-btn:active { transform: translateY(5px); box-shadow: 0 2px 0 rgba(23,33,58,.25); }
.big-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.primary { background: linear-gradient(#ff91d3, #ff5eb5); color: #fff; text-shadow: 0 2px 0 #9c2f70; }
.secondary { background: linear-gradient(#7dd8ff, #43b9f4); color: #fff; text-shadow: 0 2px 0 #277aa5; }
.ghost, .back-btn { background: #e8eef7; }
.back-btn { padding: 12px 18px; }
.row { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 25px; }

.player-count { display: flex; justify-content: center; gap: 12px; margin: 24px 0; }
.count-btn { width: 62px; height: 62px; font-size: 24px; background: #e8eef7; }
.count-btn.selected { background: var(--yellow); transform: translateY(-4px); }
.character-strip { display: flex; min-height: 115px; align-items: end; justify-content: center; gap: 6px; }
.mini-bunny { width: 75px; height: 104px; position: relative; filter: drop-shadow(0 8px 4px rgba(0,0,0,.18)); }
.mini-bunny .body { position: absolute; left: 15px; top: 31px; width: 48px; height: 67px; border-radius: 46% 46% 40% 40%; background: var(--c); border: 3px solid rgba(23,33,58,.5); }
.mini-bunny .ear { position: absolute; top: 2px; width: 17px; height: 46px; border-radius: 70% 70% 35% 35%; background: var(--c); border: 3px solid rgba(23,33,58,.5); }
.mini-bunny .ear.a { left: 20px; transform: rotate(-8deg); }
.mini-bunny .ear.b { right: 17px; transform: rotate(8deg); }
.mini-bunny .face { position: absolute; left: 25px; top: 42px; width: 30px; height: 24px; background: #f6dcc9; border-radius: 48%; border: 2px solid var(--ink); }
.mini-bunny .face::after { content: "• ᴗ •"; position: absolute; inset: 1px 0; font-size: 11px; }

.field-row { display: grid; grid-template-columns: 115px 1fr; gap: 14px; align-items: center; margin: 14px auto; max-width: 470px; text-align: left; }
.field-row label { font-weight: 900; }
.field-row input, .join-box input {
  width: 100%;
  border: 3px solid #c9d6e8;
  background: white;
  border-radius: 15px;
  padding: 13px 15px;
  outline: none;
}
.field-row input:focus, .join-box input:focus { border-color: var(--blue); }
#playerColor { height: 52px; padding: 5px; }
.online-actions { display: grid; gap: 15px; max-width: 470px; margin: 22px auto; }
.join-box { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
#roomCodeInput { text-transform: uppercase; font-size: 21px; font-weight: 1000; letter-spacing: .12em; text-align: center; }
.error { min-height: 24px; color: #d31d52; font-weight: 800; }

#roomCodeText { color: var(--pink-dark); letter-spacing: .12em; }
.lobby-players { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 12px; margin: 22px 0; }
.lobby-card { border: 3px solid #d9e3f0; border-radius: 20px; padding: 15px; background: #fff; }
.lobby-avatar { width: 54px; height: 54px; border-radius: 50%; margin: auto auto 8px; border: 4px solid var(--ink); background: var(--c); box-shadow: inset 0 -8px 0 rgba(0,0,0,.1); }
.lobby-card b { display: block; overflow: hidden; text-overflow: ellipsis; }
.lobby-card small { opacity: .62; }
.waiting { font-weight: 800; opacity: .7; }

.controls-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.controls-grid article { display: grid; gap: 7px; background: #eef4fb; border-radius: 18px; padding: 16px; text-align: left; }
.controls-grid b { font-size: 18px; color: var(--pink-dark); }

.hud {
  position: absolute;
  inset: 16px 18px auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  color: white;
  pointer-events: none;
  text-shadow: 0 3px 0 rgba(23,33,58,.55);
}
.hud-left, .hud-right, .hud-center {
  background: rgba(23,33,58,.56);
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 16px;
  padding: 10px 14px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0,0,0,.16);
}
.hud-left { display: grid; }
.hud-left strong { font-size: 18px; }
.hud-left span { font-size: 12px; opacity: .85; }
.hud-center { text-align: center; font-weight: 900; }
.hud-right { justify-self: end; display: flex; align-items: center; gap: 12px; }
#pauseBtn { pointer-events: auto; width: 38px; height: 38px; border: 0; border-radius: 12px; font-weight: 1000; color: var(--ink); }
.hidden { display: none !important; }

.modal { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(9,16,33,.45); backdrop-filter: blur(7px); z-index: 20; }
.modal-card { min-width: min(90vw, 420px); display: grid; gap: 14px; padding: 30px; background: white; border: 5px solid rgba(255,255,255,.8); border-radius: 28px; box-shadow: var(--shadow); text-align: center; }
.modal-card h2 { margin: 0 0 5px; font-size: 42px; }

.message-overlay { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; color: white; text-shadow: 0 5px 0 #17213a, 0 8px 22px rgba(0,0,0,.35); z-index: 15; }
.message-title { font-size: clamp(38px, 8vw, 86px); font-weight: 1000; transform: rotate(-2deg); }
.message-body { font-size: clamp(16px, 3vw, 26px); font-weight: 900; margin-top: 12px; }

.touch-controls { position: absolute; inset: auto 12px 18px; display: flex; justify-content: space-between; align-items: end; z-index: 10; pointer-events: none; }
.touch-left, .touch-right { display: flex; gap: 10px; align-items: end; }
.touch-controls button { pointer-events: auto; width: 72px; height: 72px; border-radius: 50%; border: 3px solid rgba(255,255,255,.85); background: rgba(23,33,58,.66); color: white; font-weight: 1000; box-shadow: 0 7px 18px rgba(0,0,0,.2); touch-action: none; }
.touch-controls .grab-touch { width: 80px; height: 80px; background: rgba(73,164,255,.82); }
.touch-controls .jump-touch { width: 88px; height: 88px; background: rgba(255,82,172,.82); }

@media (max-width: 700px) {
  .screen { border-radius: 24px; padding: 22px 18px; }
  .controls-grid { grid-template-columns: 1fr; }
  .hud { inset: 8px 8px auto; grid-template-columns: 1fr auto; }
  .hud-center { display: none; }
  .hud-left, .hud-right { padding: 8px 10px; }
  .join-box { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; gap: 6px; }
}

.online-note {
  margin-top: -0.3rem;
  opacity: 0.82;
  font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   Selector de los cuatro conejos personalizados
   -------------------------------------------------------------------------- */
.character-strip {
  display: grid;
  min-height: 0;
  gap: 12px;
  align-items: stretch;
  justify-content: stretch;
  margin: 18px auto 0;
  max-width: 680px;
}

.player-skin-row {
  display: grid;
  grid-template-columns: 105px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 3px solid #dbe5f1;
  border-radius: 20px;
  background: rgba(255,255,255,.78);
}

.player-skin-label {
  font-weight: 1000;
  text-align: left;
}

.skin-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.skin-option {
  position: relative;
  min-width: 0;
  height: 88px;
  padding: 0;
  overflow: hidden;
  border: 3px solid #cbd8e8;
  border-radius: 17px;
  background-color: var(--c, #e8eef7);
  background-image: var(--skin-image, none);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  box-shadow: 0 5px 0 rgba(23,33,58,.2);
  transition: transform .1s ease, border-color .1s ease, filter .1s ease;
}

.skin-option:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.skin-option.selected {
  border-color: #ffbf2f;
  box-shadow: 0 5px 0 #c98900, 0 0 0 4px rgba(255,215,90,.35);
  transform: translateY(-3px);
}

.skin-option span {
  position: absolute;
  inset: auto 4px 4px;
  padding: 3px 5px;
  border-radius: 8px;
  background: rgba(23,33,58,.72);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  text-shadow: 0 1px 0 #000;
}

.skin-field-row {
  align-items: start;
}

.online-skin-picker {
  width: 100%;
}

.online-skin-picker .skin-option {
  height: 100px;
}

.lobby-avatar {
  width: 72px;
  height: 82px;
  border-radius: 18px;
  background-color: var(--c);
  background-image: var(--skin-image, none);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

@media (max-width: 560px) {
  .player-skin-row {
    grid-template-columns: 1fr;
  }

  .player-skin-label {
    text-align: center;
  }

  .skin-option {
    height: 74px;
  }

  .skin-option span {
    display: none;
  }
}

@media (max-width: 560px) {
  .touch-controls { inset: auto 7px 10px; }
  .touch-left, .touch-right { gap: 6px; }
  .touch-controls button { width: 58px; height: 58px; font-size: 11px; }
  .touch-controls .grab-touch { width: 64px; height: 64px; }
  .touch-controls .jump-touch { width: 70px; height: 70px; }
}
