/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #fff;
  color: #222;
  overflow: hidden;
  font-family: 'Patrick Hand', 'Comic Sans MS', 'Segoe Print', cursive;
}

button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: none; -webkit-user-drag: none; user-select: none; }

/* ---------- Lienzo ---------- */
#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;          /* evita que el dedo haga scroll mientras dibujás */
  cursor: default;
}
body.drawing[data-tool="mano"]  #stage { cursor: grab; }
body.drawing[data-tool="mano"].panning #stage { cursor: grabbing; }
body.drawing[data-tool="lapiz"] #stage,
body.drawing[data-tool="goma"]  #stage { cursor: crosshair; }

/* ---------- Logo ---------- */
#logo {
  position: fixed; top: 36px; left: 4px; margin: 0; z-index: 30;
  pointer-events: none;
}

/* ---------- Menú ---------- */
#menu {
  position: fixed; left: 4px; bottom: 6px; z-index: 30;
}
#menu ul { list-style: none; margin: 0; padding: 0; }
#menu li { margin: 4px 0; }
#menu li:last-child { margin-bottom: 0; }   /* la fila de "top 10" apoya en el borde de abajo */
#menu button {
  background: none; border: 0; padding: 4px 6px;
  transition: transform .15s ease, opacity .15s ease;
  opacity: .85;
}
#menu button:hover, #menu button:focus-visible { transform: translateX(4px); opacity: 1; outline: none; }
body.drawing #menu [data-action="crear"] { opacity: .4; pointer-events: none; }

/* ---------- Toolbar ---------- */
#toolbar {
  position: fixed; top: 40px; right: 6px; z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  opacity: 0; pointer-events: none; transform: translateX(20px);
  transition: opacity .25s ease, transform .25s ease;
}
body.drawing #toolbar { opacity: 1; pointer-events: auto; transform: none; }

#toolbar { --t: 1; }   /* escala de la toolbar: 1 en la compu, menos en celulares (ver abajo) */
#toolbar .tool,
#toolbar .action {
  background: none; border: 0; padding: 0; width: calc(46px * var(--t));
  transition: background .12s ease;
}
#toolbar .tool img, #toolbar .action img { width: 100%; height: auto; }
#toolbar .tool:hover,
#toolbar .action:hover { background: rgba(0, 0, 0, .05); }
#toolbar .tool.active { background: rgba(0, 0, 0, .13); }

.trazo { position: relative; width: calc(46px * var(--t)); height: calc(120px * var(--t)); margin-top: calc(14px * var(--t)); }
.trazo > img { width: 100%; height: 100%; }
.trazo .brush {
  position: absolute; left: 0; width: 100%;
  background: none; border: 0; padding: 0;
}
.trazo .brush:hover { background: rgba(0, 0, 0, .05); }
.trazo .brush.active { background: rgba(0, 0, 0, .13); }

.pill {
  padding: 4px 10px; min-width: 90px;
  font-size: 18px; line-height: 1.1; white-space: nowrap;
  background: #fff; border: 2px solid #222;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  transition: transform .12s ease, background .12s ease;
}
.pill:hover { transform: rotate(-1.5deg) scale(1.04); background: #f4f4f4; }
.pill.primary { background: #222; color: #fff; }
.pill.primary:hover { background: #000; }
.pill:disabled { opacity: .35; pointer-events: none; }

/* ---------- Deshacer / Listo (abajo al centro) ---------- */
#actions {
  position: fixed; left: 50%; bottom: 6px; z-index: 30;
  height: 36px;                      /* el JS lo iguala a la fila de "top 10" */
  display: flex; align-items: center; gap: 14px;
  transform: translateX(calc(-50% + 20px));
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
body.drawing #actions { opacity: 1; pointer-events: auto; transform: translateX(-50%); }

/* ---------- Redes ---------- */
#social {
  position: fixed; right: 6px; bottom: 6px; z-index: 30;
  display: flex; gap: 8px; align-items: flex-end;
}
#social button { display: block; padding: 0; background: none; border: 0; opacity: .8; transition: transform .15s ease, opacity .15s ease; }
#social button:hover { opacity: 1; transform: translateY(-3px) rotate(-3deg); }

/* ---------- Vistas (Galería / Top 10) ---------- */
.view {
  position: fixed; inset: 0; z-index: 20;
  background: #fff; overflow-y: auto;
  padding: 90px 24px 120px;
}
.view[hidden] { display: none; }
.view header { display: flex; justify-content: center; margin: 0 0 40px; }
.view-title {
  margin: 0; font-weight: normal; font-size: 144px; line-height: 1;   /* antes 48px */
  font-family: inherit; color: #222;
}
.view .close {
  position: fixed; top: 10px; right: 14px; z-index: 31;
  width: 44px; height: 44px; font-size: 34px; line-height: 1;
  background: none; border: 0;
}
.grid {
  max-width: 1100px; margin: 0 auto;
  display: grid; gap: 28px 24px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.grid .empty { grid-column: 1 / -1; text-align: center; font-size: 22px; opacity: .6; padding: 40px 0; }

.card { margin: 0; position: relative; }
.card .frame {
  border: 2px solid #222; background: #fff;
  border-radius: 6px 3px 7px 3px / 3px 7px 3px 6px;
  padding: 6px;
  transition: transform .15s ease;
}
.card:hover .frame { transform: rotate(-.8deg) scale(1.02); }
.card img { width: 100%; height: auto; }
.card figcaption {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 8px; font-size: 20px;
}
.card .rank { font-size: 34px; line-height: 1; opacity: .7; }
.heart {
  background: none; border: 0; padding: 2px 6px; font-size: 22px;
  display: inline-flex; gap: 6px; align-items: center;
}
.heart .h { display: inline-block; transition: transform .15s ease; }
.heart:hover .h { transform: scale(1.25); }
.heart.voted .h { color: #c0392b; }

/* ---------- Aviso ---------- */
#toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 40;
  transform: translate(-50%, 20px);
  background: #222; color: #fff; padding: 8px 18px; border-radius: 20px;
  font-size: 20px; opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Moderador ---------- */
#admin-bar {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 35;
  display: flex; align-items: center; gap: 10px;
  background: #222; color: #fff; padding: 3px 6px 3px 14px; border-radius: 22px; font-size: 18px;
}
#admin-bar[hidden] { display: none; }
#admin-bar .pill { min-width: 0; padding: 0 10px; font-size: 16px; color: #222; }

.modal {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .92); padding: 20px;
}
.modal[hidden] { display: none; }
.modal form {
  width: min(340px, 100%); background: #fff; padding: 22px 22px 18px;
  border: 2px solid #222; border-radius: 6px 3px 7px 3px / 3px 7px 3px 6px;
  display: flex; flex-direction: column; gap: 12px;
}
.modal h3 { margin: 0 0 2px; font-weight: normal; font-size: 34px; line-height: 1; }
.modal input {
  font: inherit; font-size: 22px; padding: 6px 10px; border: 2px solid #222; border-radius: 6px; background: #fff;
  width: 100%;
}
.modal .err { margin: 0; min-height: 1.2em; color: #c0392b; font-size: 18px; }
.modal .row { display: flex; justify-content: flex-end; gap: 12px; }
.card .side { display: inline-flex; align-items: center; gap: 8px; }
.pill.del { min-width: 0; padding: 0 10px; font-size: 16px; }

/* ---------- Pantallas chicas (celulares, en vertical y en horizontal) ---------- */
/* El lienzo ya se achica solo (ver computeScale en app.js). Acá se achica la interfaz. */
@media (max-width: 900px), (max-height: 560px) {
  #logo { top: 34px; left: 4px; }
  #logo img { width: 104px; height: auto; }
  #menu { left: 2px; bottom: 4px; }
  #menu li { margin: 2px 0; }
  #menu img { zoom: .78; }
  #social { right: 4px; bottom: 4px; }
  #social img { width: 30px; height: 30px; }
  #toolbar { --t: .8; top: 38px; right: 4px; }
  .pill { font-size: 16px; padding: 3px 9px; min-width: 0; }
  #actions { gap: 10px; }
  .view { padding: 70px 14px 100px; }
  .view-title { font-size: 100px; }   /* antes 38px; más grande no entra "galería" en una pantalla angosta */
}
@media (max-height: 430px) {
  #toolbar { --t: .66; }
  .view { padding-top: 50px; }
  .view-title { font-size: 72px; }
}
@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 18px 12px; }
}
