/* ==========================================================================
   Ahorcado Online — estilo "cuaderno": hoja cuadriculada + trazos a mano
   ========================================================================== */
:root {
  --paper: #fffdf6;
  --card: #fffefa;
  --grid: rgba(70, 130, 200, .15);
  --ink: #2b2a33;
  --ink-soft: #66636f;
  --blue: #2f6fd1;
  --red: #e04848;
  --green: #2f9e44;
  --orange: #f08c2e;
  --yellow: #ffe46b;
  --hl: rgba(255, 226, 92, .8);
  --hl-blue: rgba(120, 190, 255, .45);
  --hl-green: rgba(120, 220, 140, .5);
  --hl-red: rgba(255, 130, 130, .35);

  /* bordes irregulares, como dibujados a mano */
  --r-big: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --r-alt: 18px 225px 18px 255px / 255px 18px 225px 18px;
  --r-sm: 14px 6px 12px 5px / 5px 12px 6px 14px;
  --r-sm2: 6px 14px 5px 12px / 12px 5px 14px 6px;
  --line: 2.5px solid var(--ink);
  --shadow: 3px 4px 0 var(--ink);
  --shadow-sm: 2px 3px 0 var(--ink);

  --font: 'Patrick Hand', 'Comic Sans MS', 'Segoe Print', 'Chalkboard SE', cursive;
  --title: 'Caveat Brush', 'Patrick Hand', 'Comic Sans MS', cursive;
  --tap: 50px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

html, body { margin: 0; }
body {
  min-height: 100dvh;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2 { margin: 0 0 .5rem; line-height: 1.1; font-family: var(--title); font-weight: 400; }
h1 { font-size: 2.3rem; }
h2 { font-size: 1.6rem; }
p { margin: .35rem 0; }
.muted { color: var(--ink-soft); }
.small { font-size: .95rem; }
.center { text-align: center; }
b { font-weight: 700; }

/* marcatextos */
.hl { background: linear-gradient(transparent 50%, var(--hl) 50%, var(--hl) 88%, transparent 88%); padding: 0 .15em; }

/* ---------- Barra superior ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: rgba(255, 253, 246, .92);
  backdrop-filter: blur(6px);
  border-bottom: 2.5px dashed var(--ink);
}
.brand { font-family: var(--title); font-size: 1.75rem; line-height: 1; }
.brand span { font-family: var(--font); font-size: 1rem; margin-left: 6px; color: var(--blue); }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  position: relative;
  min-width: 44px; height: 44px; padding: 0 8px;
  border: var(--line); border-radius: var(--r-sm); background: #fff; color: var(--ink);
  font-size: 1.2rem; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform .08s, box-shadow .08s;
}
.icon-btn:active { transform: translate(2px, 3px); box-shadow: none; }
.room-badge {
  height: 44px; padding: 0 12px; cursor: pointer;
  border: var(--line); border-radius: var(--r-sm2); background: var(--yellow); color: var(--ink);
  font-family: var(--title); font-size: 1.25rem; letter-spacing: 2px; box-shadow: var(--shadow-sm);
}

.container { max-width: 680px; margin: 0 auto; padding: 18px 16px 100px; }
.screen { display: flex; flex-direction: column; gap: 16px; animation: fadeIn .25s ease; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* ---------- Tarjetas de papel ---------- */
.card {
  position: relative;
  background: var(--card);
  border: var(--line);
  border-radius: var(--r-big);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.card:nth-of-type(even) { border-radius: var(--r-alt); }
/* cinta adhesiva */
.card.taped::before {
  content: ""; position: absolute; top: -14px; left: 50%; width: 110px; height: 26px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(255, 226, 92, .55);
  border-left: 1px dashed rgba(0,0,0,.12); border-right: 1px dashed rgba(0,0,0,.12);
  pointer-events: none;
}

/* ---------- Campos y botones ---------- */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 1.1rem; }
input[type="text"] {
  width: 100%; min-height: var(--tap);
  padding: 8px 14px;
  border: var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink);
  font-family: var(--font); font-size: 1.2rem; outline: none;
}
input[type="text"]::placeholder { color: #a8a5b0; }
input[type="text"]:focus { border-color: var(--blue); box-shadow: 3px 3px 0 var(--hl-blue); }
.code-input { text-align: center; letter-spacing: 10px; font-family: var(--title) !important; font-size: 1.9rem !important; }

.btn {
  min-height: var(--tap); padding: 8px 16px;
  border: var(--line); border-radius: var(--r-sm);
  background: #fff; color: var(--ink);
  font-family: var(--title); font-size: 1.3rem; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .08s ease, box-shadow .08s ease, background .15s;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { background: #fff8d6; }
.btn:active:not(:disabled) { transform: translate(2px, 3px); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--yellow); }
.btn.primary:hover:not(:disabled) { background: #ffd93b; }
.btn.outline { background: transparent; border-style: dashed; color: var(--blue); border-color: var(--blue); box-shadow: none; }
.btn.outline:hover:not(:disabled) { background: var(--hl-blue); }
.btn.big { min-height: 58px; font-size: 1.5rem; width: 100%; }
.btn.danger { color: var(--red); border-color: var(--red); box-shadow: 2px 3px 0 var(--red); }
.row { display: flex; gap: 12px; }
.row > .btn { flex: 1; }

.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); margin: 4px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 2px dashed var(--ink-soft); opacity: .6; }

.msg { min-height: 1.3em; text-align: center; color: var(--red); margin: 0; font-size: 1.1rem; }
.msg.info { color: var(--blue); }

/* ---------- Inicio ---------- */
.hero { text-align: center; }
.hero-art { width: 130px; height: 150px; }
.ink path, .ink circle, .gallows path {
  fill: none; stroke: var(--ink); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round;
  filter: url(#pencil);
}
.hero-man { animation: swing 3s ease-in-out infinite; transform-origin: 135px 15px; }
.hero-man circle[r="1.5"] { fill: var(--ink); stroke-width: 2; }
.hero-man path:nth-last-child(3) { stroke-width: 3; }

/* ---------- Lobby ---------- */
.code-card { text-align: center; }
.big-code {
  font-family: var(--title);
  font-size: clamp(3rem, 15vw, 4.6rem); letter-spacing: .18em; padding-left: .18em;
  line-height: 1.05; color: var(--blue);
}
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.player {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-bottom: 2px dashed rgba(43,42,51,.25);
}
.player:last-child { border-bottom: 0; }
.avatar {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border: var(--line); border-radius: 50% 45% 52% 48% / 48% 52% 45% 50%;
  font-family: var(--title); font-size: 1.3rem; color: var(--ink);
}
.pname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.2rem; }
.pname small { color: var(--ink-soft); }
.tag { font-size: .95rem; padding: 0 8px; white-space: nowrap; }
.tag.host { background: linear-gradient(transparent 40%, var(--hl) 40%, var(--hl) 90%, transparent 90%); }
.kick-btn { min-height: 38px; padding: 2px 10px; font-size: 1.05rem; }

.label { margin: 6px 0 0; font-size: 1.15rem; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg button {
  min-height: 50px; padding: 6px;
  border: 2px solid var(--ink); border-radius: var(--r-sm2);
  background: #fff; color: var(--ink-soft);
  font-family: var(--title); font-size: 1.3rem; cursor: pointer;
  transition: transform .1s, background .15s;
}
.seg button:nth-child(2) { border-radius: var(--r-sm); }
.seg button.active { background: var(--yellow); color: var(--ink); box-shadow: var(--shadow-sm); transform: rotate(-1deg); }
.settings-view { margin: 0; font-size: 1.2rem; }

/* ---------- Juego ---------- */
.game-top { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.game-left, .game-right { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* marcador: tira horizontal deslizable en móvil */
.scoreboard {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 8px;
  scroll-snap-type: x proximity; scrollbar-width: thin;
}
.chip {
  flex: none; scroll-snap-align: start;
  display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 6px;
  background: #fff; border: 2px solid var(--ink); border-radius: var(--r-sm);
  min-width: 0; max-width: 190px; position: relative;
  transition: transform .2s;
}
.chip:nth-child(even) { border-radius: var(--r-sm2); }
.chip .avatar { width: 32px; height: 32px; font-size: 1.1rem; border-width: 2px; }
.chip .info { min-width: 0; display: flex; flex-direction: column; line-height: 1.05; }
.chip .nm { font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip .sc { font-family: var(--title); font-size: 1.15rem; color: var(--blue); }
.chip .role { font-size: 1.05rem; }
.chip.turn { background: var(--hl); box-shadow: var(--shadow-sm); transform: rotate(-1.5deg); animation: wiggle 1.4s ease-in-out infinite; }
.chip.chooser { border-style: dashed; border-color: var(--orange); }
.chip.spectator { opacity: .5; }
.chip.me .nm { text-decoration: underline 2px rgba(47,111,209,.7); text-underline-offset: 3px; }
.chip.kickable { cursor: pointer; }

.round-info { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 1.15rem; }
#round-label { font-family: var(--title); font-size: 1.4rem; }

.stage { display: grid; grid-template-columns: minmax(120px, 46%) 1fr; gap: 10px; align-items: center; padding: 12px; }
.hangman { width: 100%; max-height: 210px; overflow: visible; }
.part {
  fill: none; stroke: var(--ink); stroke-width: 5.5; stroke-linecap: round;
  stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0;
  filter: url(#pencil);
}
.part.on { stroke-dashoffset: 0; opacity: 1; transition: stroke-dashoffset .55s ease-out, opacity .1s; }
.hangman.dead .part { stroke: var(--red); }
.face line { stroke: var(--red); stroke-width: 3; stroke-linecap: round; opacity: 0; transition: opacity .4s .3s; }
.hangman.dead .face line { opacity: 1; }
.hangman.shake { animation: shake .4s ease; }

.stage-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hint { font-size: 1.1rem; word-break: break-word; padding: 2px 4px; }
.hint b { background: linear-gradient(transparent 45%, var(--hl-blue) 45%, var(--hl-blue) 92%, transparent 92%); font-weight: 400; }
.errors { font-size: 1.15rem; }
.errors span { font-family: var(--title); font-size: 1.6rem; color: var(--red); }
.wrong-letters { display: flex; flex-wrap: wrap; gap: 2px 8px; min-height: 1.6em; }
.wrong-letters span { font-family: var(--title); font-size: 1.5rem; color: var(--red); text-decoration: line-through 2px; }

.pattern {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 12px 22px;
  padding: 10px 4px; min-height: 70px;
}
.pattern .word { display: inline-flex; gap: 6px; }
.slot {
  width: clamp(24px, 7.6vw, 44px); height: clamp(38px, 11vw, 58px);
  display: grid; place-items: end center; padding-bottom: 2px;
  font-family: var(--title); font-size: clamp(1.7rem, 8.4vw, 2.7rem); line-height: 1;
  border-bottom: 3px solid var(--ink);
  border-radius: 0 0 40% 20% / 0 0 4px 3px;
}
.slot:nth-child(odd) { transform: rotate(-1deg); }
.slot.hit { color: var(--blue); }
.slot.hit.new { animation: pop .4s ease; }
.slot.secret { color: rgba(43,42,51,.28); }
.slot.missed { color: var(--red); }
.slot.sep { border-bottom-color: transparent; width: auto; min-width: 12px; }

.status {
  text-align: center; font-family: var(--title); font-size: 1.55rem; line-height: 1.15;
  padding: 6px 10px;
}
.status.myturn {
  background: var(--hl); border: var(--line); border-radius: var(--r-alt); box-shadow: var(--shadow-sm);
  transform: rotate(-1deg); animation: popIn .3s ease;
}
.status:empty { display: none; }
.last-action { text-align: center; color: var(--ink-soft); font-size: 1.1rem; min-height: 1.3em; word-break: break-word; }

.secret-box { text-align: center; padding: 8px 12px; border: 2.5px dashed var(--orange); border-radius: var(--r-sm); background: #fff; font-size: 1.15rem; }
.secret-box b { font-family: var(--title); font-weight: 400; font-size: 1.5rem; letter-spacing: 2px; color: var(--orange); word-break: break-word; }

#panel-play { display: flex; flex-direction: column; gap: 14px; }
.keyboard { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.key {
  min-height: 50px; padding: 0;
  border: 2px solid var(--ink); border-radius: var(--r-sm);
  background: #fff; color: var(--ink);
  font-family: var(--title); font-size: 1.55rem; line-height: 1;
  cursor: pointer; touch-action: manipulation;
  transition: transform .08s, background .15s, box-shadow .08s;
}
.key:nth-child(3n) { border-radius: var(--r-sm2); }
.key:nth-child(4n+1) { border-radius: 10px 4px 12px 6px / 6px 12px 4px 10px; }
.keyboard.active .key:not(:disabled) { box-shadow: var(--shadow-sm); }
.keyboard.active .key:not(:disabled):hover { background: #fff8d6; }
.key:active:not(:disabled) { transform: translate(2px, 3px); box-shadow: none !important; background: var(--yellow); }
.key:disabled { cursor: default; }
.keyboard:not(.active) .key:not(.hit):not(.miss) { opacity: .55; }
.key.hit { background: var(--hl-green); color: var(--green); border-color: var(--green); }
.key.miss { color: var(--red); border-color: rgba(224,72,72,.5); background: #fff; text-decoration: line-through 2px; opacity: .55; }

.result { text-align: center; animation: popIn .3s ease; }
.result h2 { font-size: 2.1rem; }
.result b { font-family: var(--title); font-weight: 400; font-size: 1.7rem; letter-spacing: 2px; color: var(--blue); word-break: break-word; }

/* ---------- Podio ---------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin-top: 8px; }
.podium .place { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; min-width: 0; }
.podium .place .nm { font-size: 1.15rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .block {
  width: 100%; display: grid; place-items: center; font-size: 1.8rem;
  border: var(--line); border-bottom: 0; border-radius: 12px 6px 0 0 / 8px 12px 0 0;
  animation: grow .6s ease both; transform-origin: bottom;
}
/* sombreado a lápiz (rayado) */
.podium .p1 .block { height: 130px; background: repeating-linear-gradient(-45deg, var(--yellow) 0 6px, #fff6c4 6px 12px); }
.podium .p2 .block { height: 95px; background: repeating-linear-gradient(-45deg, #cfd6e3 0 6px, #f1f4f9 6px 12px); animation-delay: .15s; }
.podium .p3 .block { height: 70px; background: repeating-linear-gradient(-45deg, #ffc48a 0 6px, #ffeedd 6px 12px); animation-delay: .3s; }
.final-list { margin: 6px 0; padding-left: 1.6rem; font-size: 1.2rem; }
.final-list li { padding: 2px 0; }
.final-list li span { color: var(--ink-soft); }

/* ---------- Chat (hoja de libreta rayada) ---------- */
.badge {
  position: absolute; top: -6px; right: -6px; min-width: 24px; height: 24px; padding: 0 6px;
  border: 2px solid var(--ink); border-radius: 50%; background: var(--red); color: #fff;
  font-family: var(--font); font-size: .95rem; display: grid; place-items: center;
}
.chat {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: min(72dvh, 540px); display: flex; flex-direction: column;
  background: #fff;
  border-top: var(--line); border-radius: 22px 22px 0 0;
  box-shadow: 0 -6px 0 rgba(43,42,51,.12);
  animation: slideUp .2s ease;
  padding-bottom: env(safe-area-inset-bottom);
}
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 8px 18px; border-bottom: 2.5px dashed var(--ink); }
.chat-head b { font-family: var(--title); font-weight: 400; font-size: 1.5rem; }
.chat-log {
  list-style: none; margin: 0; padding: 4px 14px 4px 46px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column;
  background:
    linear-gradient(90deg, transparent 34px, rgba(224,72,72,.45) 34px, rgba(224,72,72,.45) 36px, transparent 36px),
    repeating-linear-gradient(#fff 0 27px, rgba(70,130,200,.28) 27px 28px);
  background-attachment: local;
  line-height: 28px;
}
.chat-log li { word-break: break-word; font-size: 1.1rem; }
.chat-log li.sys { color: var(--ink-soft); font-size: 1rem; }
.chat-log .who {
  margin-right: 6px;
  background: linear-gradient(transparent 50%, var(--c, var(--hl)) 50%, var(--c, var(--hl)) 90%, transparent 90%);
}
.chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 2.5px dashed var(--ink); }
.chat-form input { flex: 1; }

/* ---------- Modal / avisos (post-it) ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(43,42,51,.35); display: grid; place-items: center; padding: 16px; animation: fadeIn .15s; }
.modal-box {
  width: 100%; max-width: 440px; background: var(--card);
  border: var(--line); border-radius: var(--r-big); box-shadow: 5px 6px 0 var(--ink);
  padding: 20px; display: flex; flex-direction: column; gap: 12px; animation: popIn .2s ease;
}

.toasts {
  position: fixed; top: calc(74px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(92vw, 400px); pointer-events: none;
}
.toast {
  background: #fff3a8; color: var(--ink);
  padding: 10px 16px; font-size: 1.1rem; text-align: center; word-break: break-word;
  box-shadow: 2px 4px 8px rgba(0,0,0,.18);
  border-radius: 2px 2px 14px 2px;
  transform: rotate(-1.2deg);
  animation: toastIn .25s ease;
}
.toast:nth-child(even) { transform: rotate(1deg); background: #c9f0ff; }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .3s; }

/* ---------- Animaciones ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.94) rotate(-2deg); } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) rotate(-3deg); } }
@keyframes pop { 0% { transform: scale(.3) rotate(-12deg); } 70% { transform: scale(1.3) rotate(4deg); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-6px) rotate(-2deg); } 40% { transform: translateX(6px) rotate(2deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }
@keyframes wiggle { 0%,100% { transform: rotate(-1.5deg); } 50% { transform: rotate(1.5deg); } }
@keyframes swing { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ==========================================================================
   Distribución responsive
   ========================================================================== */

/* Móvil: todo compacto para que el teclado quepa sin hacer scroll */
@media (max-width: 759px) {
  body.in-room .brand { display: none; }
  body.in-room .top-actions { flex: 1; }
  body.in-room .room-badge { margin-right: auto; }
  .container { padding-top: 12px; }
  .game { gap: 10px; }
  .game-top, .game-left, .game-right { gap: 8px; }
  .scoreboard { padding-bottom: 4px; }
  .chip { padding: 3px 8px 3px 4px; }
  .chip .avatar { width: 28px; height: 28px; font-size: 1rem; }
  .round-info { font-size: 1.05rem; }
  #round-label { font-size: 1.25rem; }
  .stage { padding: 8px 12px; grid-template-columns: minmax(100px, 40%) 1fr; }
  .hangman { max-height: 150px; }
  .pattern { padding: 4px; min-height: 56px; gap: 8px 18px; }
  .status { font-size: 1.35rem; padding: 4px 8px; }
  .last-action { font-size: 1rem; }
  .btn.big { min-height: 52px; font-size: 1.35rem; }
  #panel-play { gap: 10px; }
}

/* Móvil pequeño */
@media (max-width: 380px) {
  body { font-size: 17px; }
  .container { padding-left: 12px; padding-right: 12px; }
  .keyboard { gap: 4px; }
  .key { min-height: 46px; font-size: 1.35rem; }
  .brand span { display: none; }
}

/* Tablet / PC: más espacio y columnas */
@media (min-width: 760px) {
  body::before { /* línea roja de margen del cuaderno */
    content: ""; position: fixed; top: 0; bottom: 0; left: 56px; width: 2px;
    background: rgba(224, 72, 72, .35); pointer-events: none; z-index: 0;
  }
  .topbar, .container { position: relative; z-index: 1; }
  .topbar { padding-left: 76px; }
  .container { max-width: 1080px; padding: 28px 28px 100px 84px; }

  /* Inicio: dibujo a la izquierda, formulario a la derecha */
  .home { display: grid; grid-template-columns: 1fr minmax(340px, 420px); gap: 40px; align-items: center; min-height: calc(100dvh - 160px); }
  .home .hero { text-align: left; }
  .home .hero-art { width: 200px; height: 230px; }
  .home h1 { font-size: 3.4rem; }
  .home .hero p { font-size: 1.3rem; max-width: 26ch; }

  /* Lobby: dos columnas */
  .lobby { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }

  /* Juego: dibujo a la izquierda, zona de juego a la derecha */
  .game {
    display: grid;
    grid-template-columns: minmax(260px, 5fr) 7fr;
    grid-template-areas: "top top" "left right";
    gap: 18px 28px; align-items: start;
  }
  .game-top { grid-area: top; }
  .game-left { grid-area: left; position: sticky; top: 84px; }
  .game-right { grid-area: right; }
  .stage { grid-template-columns: 1fr; padding: 16px; }
  .hangman { max-height: 300px; }
  .scoreboard { flex-wrap: wrap; overflow: visible; }
  .round-info { font-size: 1.25rem; }
  .key { min-height: 58px; font-size: 1.8rem; }
  .keyboard { gap: 8px; }
  .chat { left: auto; right: 16px; bottom: 16px; width: 380px; border: var(--line); border-radius: var(--r-big); box-shadow: var(--shadow); }
}

/* PC ancho: el chat queda fijo como columna lateral */
@media (min-width: 1180px) {
  body.in-room { padding-right: 360px; }
  body.in-room .chat[hidden],
  body.in-room .chat {
    display: flex !important;
    top: 0; right: 0; bottom: 0; left: auto; width: 360px; height: auto;
    border: 0; border-left: var(--line); border-radius: 0; box-shadow: none; animation: none;
    z-index: 25;
  }
  body.in-room #btn-chat-close, body.in-room #btn-chat { display: none !important; }
  body.in-room .toasts { left: calc(50% - 180px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .part.on { stroke-dashoffset: 0; }
}
