/* Mesa de juego — sistema visual.
   Tapete azul noche para lo publico; papel claro para lo privado de cada uno.
   Lo memorable: la estanteria de cajas de juego (lomos con el color de cada juego).
   Tipos: Big Shoulders Display (lomos y titulares) y Atkinson Hyperlegible (lectura). */

:root {
  --night: #17153b;
  --surface: #221f4d;
  --surface-2: #2c2860;
  --line: #433e86;
  --text: #f2eee3;
  --muted: #b5afd6;
  --paper: #f2eee3;
  --paper-edge: #d9d2bf;
  --ink: #1d1a33;
  --ink-muted: #5b5670;
  --lamp: #f2c14e;
  --danger: #ff8a7a;
  --ok: #7fd1a8;
  --game: var(--lamp);

  --cronica: #9e2b25;
  --notario: #c9962b;
  --ciudad: #3fa7a0;
  --prueba: #8c86c9;

  --display: 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, sans-serif;
  --shadow: 5px 5px 0 rgba(6, 5, 24, .55);
  --radius: 6px;
  --gap: 14px;
}

[data-game='cronica'] { --game: var(--cronica); }
[data-game='notario'] { --game: var(--notario); }
[data-game='ciudad'] { --game: var(--ciudad); }
[data-game='prueba'] { --game: var(--prueba); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--night);
  color: var(--text);
  font: 17px/1.5 var(--body);
}
main { width: min(720px, 100%); margin: 0 auto; padding: 16px 16px 96px; }
main.wide { width: min(1080px, 100%); }

h1, h2, h3 { font-family: var(--display); line-height: 1.02; margin: 0 0 .35em; letter-spacing: .005em; }
h1 { font-size: clamp(56px, 13vw, 112px); font-weight: 900; }
h2 { font-size: 30px; font-weight: 800; }
h3 { font-size: 21px; font-weight: 800; margin-top: .6em; }
p { margin: .4em 0 .8em; max-width: 62ch; }
a { color: var(--lamp); text-underline-offset: 3px; }
ul { padding-left: 20px; margin: .3em 0 .8em; }
li { margin: .3em 0; }
.small { font-size: 14px; }
.dim { color: var(--muted); }
.paper .dim, .paper.dim { color: var(--ink-muted); }

/* ---------- controles ---------- */
button, select, input {
  font: inherit;
  color: inherit;
  border-radius: var(--radius);
}
button {
  cursor: pointer;
  padding: 11px 16px;
  background: transparent;
  border: 2px solid var(--line);
  color: var(--text);
  transition: transform .08s ease, box-shadow .08s ease, border-color .15s;
}
button:hover { border-color: var(--muted); }
button.p, .btn-p {
  background: var(--lamp);
  border-color: var(--lamp);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 3px 3px 0 rgba(6, 5, 24, .6);
}
button.p:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(6, 5, 24, .6); }
button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.small, .small button { padding: 7px 11px; }
.big { font-family: var(--display); font-size: 40px; font-weight: 900; padding: 26px; width: 100%; }
input, select {
  width: 100%;
  padding: 11px 12px;
  background: var(--night);
  border: 2px solid var(--line);
  color: var(--text);
}
input::placeholder { color: var(--muted); }
:focus-visible { outline: 3px solid var(--lamp); outline-offset: 2px; }
label { display: block; }
input[type='checkbox'] { width: auto; accent-color: var(--lamp); }

/* ---------- superficies ---------- */
.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: var(--gap) 0;
}
.card.root { border-color: var(--game); }
.paper {
  background: var(--paper);
  color: var(--ink);
  border: 0;
  border-radius: 3px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin: var(--gap) 0;
}
.paper button { color: var(--ink); border-color: var(--paper-edge); }
.paper button.p { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.paper input, .paper select { background: #fff; color: var(--ink); border-color: var(--paper-edge); }
.paper a { color: var(--ink); }
.card.paper { border: 0; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badge {
  display: inline-block;
  font-size: 13px;
  padding: 2px 9px;
  border-radius: 99px;
  border: 1.5px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.badge.r { border-color: var(--game); color: var(--text); background: color-mix(in srgb, var(--game) 30%, transparent); }
.paper .badge { border-color: var(--paper-edge); color: var(--ink-muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #5d588f; margin-right: 8px; vertical-align: middle; }
.dot.on { background: var(--ok); }
.pl { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.pl:last-child { border-bottom: 0; }
.paper .pl { border-color: var(--paper-edge); }
.clue {
  border-left: 4px solid var(--game);
  padding: 8px 12px;
  margin: 10px 0;
  background: color-mix(in srgb, var(--game) 10%, transparent);
  border-radius: 0 4px 4px 0;
}
table { width: 100%; border-collapse: collapse; font-size: 15px; }
td, th { text-align: left; padding: 7px 5px; border-bottom: 1px solid var(--line); vertical-align: top; }
.paper td, .paper th { border-color: var(--paper-edge); }
th { font-weight: 700; color: var(--muted); }
details > summary { cursor: pointer; color: var(--muted); padding: 4px 0; }
details[open] > summary { margin-bottom: 8px; }
.paper details > summary { color: var(--ink-muted); }

/* ---------- cabecera de la mesa ---------- */
.masthead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0 4px; }
.masthead .brand { font-family: var(--display); font-weight: 900; font-size: 30px; text-decoration: none; color: var(--text); }
.masthead .who { font-size: 15px; color: var(--muted); text-align: right; }
.masthead .who b { color: var(--text); }
.seats { font-family: var(--display); font-weight: 800; font-size: 20px; color: var(--muted); }

/* ---------- la estanteria ---------- */
.shelf { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; padding-right: 22px; }
.box {
  --tone: var(--game);
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
  width: 100%;
  min-height: 92px;
  padding: 14px 18px;
  background: var(--tone);
  color: #fff;
  border: 0;
  border-radius: 4px;
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(255, 255, 255, .14);
  text-align: left;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1), filter .2s;
}
.box::before {
  /* canto de la tapa: la linea que separa tapa y fondo de una caja de carton */
  content: '';
  position: absolute;
  left: 0; right: 0; top: 12px;
  border-top: 2px solid rgba(0, 0, 0, .22);
}
.box .box-title { font-family: var(--display); font-weight: 900; font-size: clamp(34px, 9vw, 52px); line-height: .9; }
.box .box-blurb { display: block; font-size: 14px; margin-top: 6px; opacity: .9; max-width: 44ch; }
.box .box-count { font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1; text-align: right; }
.box .box-count span { display: block; font-family: var(--body); font-weight: 400; font-size: 12px; opacity: .85; }
.box[data-game='cronica'] { --tone: var(--cronica); }
.box[data-game='notario'] { --tone: var(--notario); color: #1d1405; }
.box[data-game='ciudad'] { --tone: var(--ciudad); color: #06201e; }
.box[data-game='prueba'] { --tone: var(--prueba); color: #15122e; }
.box.out { transform: translateX(22px); }
.box:disabled { filter: saturate(.25) brightness(.7); opacity: 1; }
.box .stamp {
  position: absolute;
  right: 14px; top: 22px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 15px;
  padding: 1px 8px;
  border: 2px solid currentColor;
  border-radius: 3px;
  transform: rotate(-4deg);
}
@media (min-width: 900px) {
  .shelf.spines { flex-direction: row; align-items: flex-end; height: 460px; padding: 0; gap: 12px; }
  .shelf.spines .box {
    width: 100px; min-height: 0; height: 100%;
    grid-template-columns: 1fr; grid-template-rows: 1fr auto;
    padding: 18px 10px;
  }
  .shelf.spines .box:nth-child(2) { height: 92%; }
  .shelf.spines .box:nth-child(3) { height: 97%; }
  .shelf.spines .box:nth-child(4) { height: 86%; }
  .shelf.spines .box .box-title { writing-mode: vertical-rl; transform: rotate(180deg); font-size: 50px; white-space: nowrap; }
  .shelf.spines .box .box-blurb { display: none; }
  .shelf.spines .box::before { top: 0; bottom: 0; left: 12px; right: auto; border-top: 0; border-left: 2px solid rgba(0, 0, 0, .22); }
  .shelf.spines .box.out { transform: translateY(-22px); }
}

/* La tapa: ficha del juego elegido, que sale de la caja */
.lid {
  position: relative;
  margin: -4px 22px 18px 0;
  padding: 18px 18px 16px;
  background: var(--paper);
  color: var(--ink);
  border-top: 8px solid var(--game);
  border-radius: 3px;
  box-shadow: var(--shadow);
  animation: lid-open .32s cubic-bezier(.2, .8, .2, 1);
}
.lid h2 { font-size: 40px; font-weight: 900; }
.lid p { color: var(--ink); }
.lid .dim { color: var(--ink-muted); }
.lid button { color: var(--ink); border-color: var(--paper-edge); }
.lid button.p { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.lid h3 { color: var(--ink); }
.rules { margin-top: 10px; border-top: 1px solid var(--paper-edge); padding-top: 6px; }
@keyframes lid-open { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- portada ---------- */
.home { display: grid; gap: 18px; padding-top: 4vh; }
.home h1 { margin-bottom: 0; }
.home .lede { font-size: 20px; max-width: 40ch; }
.join { display: flex; gap: 10px; max-width: 460px; }
.join input { font-family: var(--display); font-size: 28px; font-weight: 800; text-transform: uppercase; padding: 8px 12px; }
@media (min-width: 900px) {
  .home { grid-template-columns: 1fr 1fr; align-items: end; gap: 48px; padding-top: 8vh; }
}

/* ---------- paneles de root y maestro ---------- */
.share { display: flex; gap: 8px; align-items: center; background: var(--night); border: 2px dashed var(--line); border-radius: var(--radius); padding: 8px 8px 8px 12px; }
.share code { flex: 1; overflow-wrap: anywhere; font-size: 14px; color: var(--text); }
.paper .share { background: #fff; border-color: var(--paper-edge); }
.paper .share code { color: var(--ink); }
.fresh { border-color: var(--lamp); }
.meter { height: 8px; border-radius: 99px; background: var(--night); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; background: var(--ok); }
.meter.full i { background: var(--danger); }

/* ---------- avisos ---------- */
#toast {
  position: fixed;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 24px));
  padding: 12px 16px;
  background: var(--paper);
  color: var(--ink);
  border-left: 6px solid var(--game);
  border-radius: 3px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 10;
}
.empty { text-align: center; padding: 30px 10px; }
.empty h2 { font-size: 44px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
