/* Hero Quest online: usa i colori del sito (chiaro/scuro) */
.hq { display: grid; gap: 1rem; }
.hq .card { padding: 1rem 1.2rem; }
.hq label { display: block; margin: .6rem 0 .2rem; font-weight: 600; }
.hq input, .hq select {
  font: inherit; padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); max-width: 100%;
}
.hq-login { max-width: 24rem; }
.hq-login button { margin-top: .9rem; }
.hq-bar { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: space-between; align-items: center; }
.hq-notice { margin: 0; padding: .6rem .9rem; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 600; }
.hq-code { text-transform: uppercase; letter-spacing: .12em; width: 8rem; }
strong.hq-code { width: auto; }
.hq-rooms, .hq-users, .hq-heroes { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.hq-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .6rem; }
.hq-secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; min-height: 1.4rem; }
.hq-pick { display: flex; flex-wrap: wrap; gap: .5rem; margin: .5rem 0; }

.hq-play { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 1rem; align-items: start; }
.hq-board {
  display: grid; grid-template-columns: repeat(var(--w), minmax(0, 1fr)); gap: 1px; padding: 2px;
  background: var(--border); border-radius: 8px; width: 100%; max-width: 60rem;
}
.hq-cell {
  aspect-ratio: 1; padding: 0; border: 0; border-radius: 0; display: grid; place-items: center;
  font: 700 clamp(.6rem, 1.8vw, 1rem)/1 var(--font); color: var(--text); background: var(--surface);
}
button.hq-cell { cursor: pointer; }
.hq-panel { display: grid; gap: .7rem; }
.hq-panel p, .hq-panel ul, .hq-panel ol { margin: 0; }
.hq-heroes .dead { text-decoration: line-through; opacity: .6; }
.hq-controls { display: flex; flex-wrap: wrap; gap: .4rem; }
.hq-controls p { flex-basis: 100%; }
.hq-log { padding-left: 1.2rem; max-height: 14rem; overflow: auto; font-size: .88rem; color: var(--muted); }
.hq-win { font-weight: 800; font-size: 1.2rem; }
.hq-disclaimer { max-width: 44rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

@media (max-width: 52rem) {
  .hq-play { grid-template-columns: 1fr; }
}

.hq-rules { margin-top: 1rem; padding: .8rem 1.2rem; }
.hq-rules summary { cursor: pointer; }
.hq-rules ul { margin: .8rem 0; padding-left: 1.2rem; }
.hq-tables { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.hq-tables table { border-collapse: collapse; font-size: .9rem; }
.hq-tables caption { text-align: left; font-weight: 700; margin-bottom: .3rem; }
.hq-tables th, .hq-tables td { text-align: left; padding: .25rem .8rem .25rem 0; border-bottom: 1px solid var(--border); }
.hq-tabs { display: flex; flex-wrap: wrap; gap: .4rem; }
.hq textarea { font: inherit; padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--text); width: 100%; }
.hq-users h3, #hq-admin h3 { margin: 1rem 0 .4rem; }
.hq-side { display: grid; gap: 1rem; align-content: start; }
.hq-cell.picked { outline: 3px solid var(--star); outline-offset: -3px; }
.hq-dice, .hq-tools, .hq-say { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.hq-say input { flex: 1; min-width: 8rem; }
.hq-card { padding: .6rem .8rem; border-radius: 8px; border: 2px solid var(--star); background: var(--surface-2); }
.hq-card p { margin: .3rem 0 0; }
.hq-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 .2rem; }
.hq-num { width: 5rem; }
.hq-heroes li { display: grid; gap: .3rem; }
.hq-master h3 { margin: 0; }

/* ---- pixel art ---- */
.hq-board { image-rendering: pixelated; background: #0c0b10; padding: 3px; gap: 0; border: 3px solid #4a4658; border-radius: 2px; box-shadow: 4px 4px 0 #0c0b10; }
.hq-cell { background-size: 100% 100%; background-repeat: no-repeat; image-rendering: pixelated; position: relative; overflow: hidden; }
.hq-sprite { display: block; width: 100%; height: 100%; image-rendering: pixelated; object-fit: contain; pointer-events: none; }
.hq-cell.ghost .hq-sprite { opacity: .55; }
.hq-cell.reach::after { content: ""; position: absolute; inset: 0; background: rgb(94 200 216 / 38%); box-shadow: inset 0 0 0 2px #5ec8d8; pointer-events: none; }
.hq-cell.cur::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px #f1c40f; z-index: 1; pointer-events: none; animation: hq-blink 1s steps(2) infinite; }
.hq-cell.picked::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 3px #c0392b; z-index: 1; pointer-events: none; }
@keyframes hq-blink { 50% { opacity: .3; } }
button.hq-cell:hover::after { content: ""; position: absolute; inset: 0; background: rgb(255 255 255 / 22%); }

/* ---- a gioco aperto: il menu del sito sparisce e il dungeon prende tutta la pagina ---- */
body.hq-full {
  --bg: #17161c; --surface: #25232d; --surface-2: #1d1c24; --text: #f2efe6; --muted: #b3ad9b; --border: #4a4658;
  --accent: #5ec8d8; --accent-strong: #5ec8d8; --accent-soft: #2c3a44; --on-accent: #17161c; --star: #f1c40f; --ok: #6fcf86;
  background: #17161c; color: var(--text);
}
body.hq-full .site-header, body.hq-full .site-footer, body.hq-full .skip, body.hq-full .page-head,
body.hq-full .hq-rules, body.hq-full .hq-disclaimer, body.hq-full .hq-bar { display: none; }
body.hq-full main.wrap { max-width: none; width: 100%; margin: 0; padding: .6rem; }
body.hq-full .card { border-radius: 2px; border: 2px solid #4a4658; box-shadow: 4px 4px 0 #0c0b10; background: var(--surface); }
body.hq-full .btn { border-radius: 2px; border: 2px solid #0c0b10; background: #3a374a; color: var(--text); box-shadow: inset -2px -2px 0 rgb(0 0 0 / 35%), inset 2px 2px 0 rgb(255 255 255 / 12%); }
body.hq-full .btn.ghost { background: #2b2937; }
body.hq-full .btn:hover { background: #4a4658; }
body.hq-full .hq-board { width: min(100%, calc((100dvh - 1.4rem) * var(--w) / var(--h))); max-width: none; }
body.hq-full .hq-play { grid-template-columns: minmax(0, 1fr) 21rem; }
body.hq-full h2, body.hq-full h3, body.hq-full strong { letter-spacing: .02em; }
.hq-menu-btn { display: none; position: fixed; z-index: 60; top: .5rem; left: .5rem; width: 2.6rem; height: 2.6rem; font-size: 1.4rem; line-height: 1; cursor: pointer;
  background: #3a374a; color: #f2efe6; border: 2px solid #0c0b10; border-radius: 2px; box-shadow: 3px 3px 0 #0c0b10; }
body.hq-full .hq-menu-btn { display: block; }
.hq-menu { position: fixed; z-index: 59; top: 3.4rem; left: .5rem; width: min(20rem, calc(100vw - 1rem)); display: grid; gap: .6rem; padding: .9rem;
  background: #25232d; color: #f2efe6; border: 2px solid #4a4658; box-shadow: 4px 4px 0 #0c0b10; }
.hq-menu[hidden] { display: none; }
.hq-menu a.btn { text-align: center; text-decoration: none; }
body.hq-full .hq-play { padding-top: 0; }
body.hq-full .hq-board { margin-left: 3.2rem; width: min(calc(100% - 3.2rem), calc((100dvh - 1.4rem) * var(--w) / var(--h))); }

/* ---- dadi animati ---- */
.hq-dice-ov { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgb(12 11 16 / 55%); cursor: pointer; }
.hq-dice-box { display: grid; gap: .8rem; padding: 1.2rem 1.6rem; background: #25232d; color: #f2efe6; border: 3px solid #4a4658; box-shadow: 6px 6px 0 #0c0b10; text-align: center; max-width: 92vw; }
.hq-dice-row { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; padding: .7rem 0; }
.hq-die { width: 4.2rem; height: 4.2rem; image-rendering: pixelated; }
.hq-die.rolling { animation: hq-tumble .38s linear infinite; }
.hq-die.land { animation: hq-land .3s ease-out; }
@keyframes hq-tumble { 0% { transform: translateY(0) rotate(0); } 25% { transform: translateY(-14px) rotate(90deg); } 50% { transform: translateY(0) rotate(180deg); } 75% { transform: translateY(-8px) rotate(270deg); } 100% { transform: translateY(0) rotate(360deg); } }
@keyframes hq-land { 0% { transform: scale(1.35); } 60% { transform: scale(.92); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .hq-die.rolling, .hq-die.land, .hq-cell.cur::before { animation: none; } }
@media (max-width: 52rem) {
  body.hq-full .hq-play { grid-template-columns: 1fr; }
  body.hq-full .hq-board { margin-left: 0; margin-top: 3rem; width: 100%; }
}
.hq-boardwrap { overflow-x: auto; min-width: 0; }
@media (max-width: 52rem) {
  .hq-board { min-width: calc(var(--w) * 24px); }
  body.hq-full .hq-board { min-width: calc(var(--w) * 24px); }
}

/* griglia ben visibile: i personaggi si muovono casella per casella */
.hq-cell { box-shadow: inset 0 0 0 1px rgb(12 11 16 / 55%), inset 1px 1px 0 rgb(255 255 255 / 14%); }
.hq-cell.t-hall, .hq-cell.t-room, .hq-cell.t-dooropen { box-shadow: inset 0 0 0 1px rgb(12 11 16 / 70%), inset 2px 2px 0 rgb(255 255 255 / 22%), inset -2px -2px 0 rgb(0 0 0 / 14%); }
.hq-cell.t-wall, .hq-cell.t-fog { box-shadow: inset 0 0 0 1px rgb(12 11 16 / 35%); }

/* ---- sezioni a scomparsa, zoom, suggerimenti ---- */
.hq { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.hq-sec { border-top: 1px solid var(--border); padding-top: .4rem; }
.hq-sec > summary { cursor: pointer; font-weight: 700; padding: .35rem 0; }
.hq-sec[open] > summary { margin-bottom: .4rem; }
.hq-turn { font-weight: 700; }
.hq-mapcol { min-width: 0; display: grid; gap: .4rem; align-content: start; }
.hq-zoom { display: flex; gap: .35rem; justify-content: flex-end; }
.hq-hint { position: fixed; z-index: 57; left: 50%; transform: translateX(-50%); top: .6rem; max-width: calc(100vw - 1rem); padding: .55rem .8rem;
  background: #f1c40f; color: #17161c; border: 2px solid #0c0b10; box-shadow: 3px 3px 0 #0c0b10; font-weight: 700; display: flex; gap: .6rem; align-items: center; }
.hq-hint .btn { color: #f2efe6; }
.hq-top { display: none; }
body.hq-full .hq-board { margin-left: 0; }
body.hq-full .hq-play { padding-left: 3.2rem; }
body.hq-full .hq-board { width: auto; }

@media (max-width: 52rem) {
  .hq input, .hq select, .hq textarea { font-size: 16px; }
  .hq .btn.small { min-height: 2.6rem; padding: .45rem .8rem; font-size: .95rem; }
  body.hq-full main.wrap { padding: .4rem .4rem 7rem; }
  body.hq-full .hq-play { padding-left: 0; grid-template-columns: 1fr; gap: .6rem; }
  body.hq-full .hq-mapcol { margin-top: 3.2rem; }
  body.hq-full .hq-boardwrap { max-height: 56dvh; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; border: 2px solid #4a4658; }
  body.hq-full .hq-board { min-width: 0; margin: 0; border: 0; box-shadow: none; }
  .hq-top { display: flex; align-items: center; position: fixed; z-index: 55; top: .5rem; left: 3.6rem; right: .5rem; height: 2.6rem; padding: 0 .7rem;
    font-size: .92rem; font-weight: 700; background: #25232d; color: #f2efe6; border: 2px solid #4a4658; box-shadow: 3px 3px 0 #0c0b10; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  body:not(.hq-full) .hq-top { display: none; }
  .hq-hint { top: 3.5rem; left: .5rem; right: .5rem; transform: none; max-width: none; justify-content: space-between; }
  /* comandi del turno sempre a portata di pollice, in fondo allo schermo */
  body.hq-full .hq-controls { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: .5rem .5rem calc(.5rem + env(safe-area-inset-bottom));
    background: #25232d; border-top: 3px solid #4a4658; box-shadow: 0 -4px 0 #0c0b10; max-height: 45dvh; overflow-y: auto; }
  body.hq-full .hq-controls .btn { flex: 1 1 8rem; min-height: 2.9rem; font-size: 1rem; }
  body.hq-full .hq-controls p { flex-basis: 100%; margin: 0; }
  .hq-dice-ov { padding: .5rem; }
  .hq-die { width: 3.4rem; height: 3.4rem; }
  .hq-menu { top: 3.4rem; }
}

/* ---- editor visuale (archivio e missioni) ---- */
.hq-fld { display: grid; gap: .2rem; margin: .5rem 0; font-weight: 600; }
.hq-fld small { font-weight: 400; }
.hq-editor { display: grid; gap: .6rem; margin: .4rem 0 1rem; }
.hq-list { display: grid; gap: .5rem; }
.hq-eff { display: grid; gap: .4rem; padding: .6rem .7rem; border: 2px solid #4a4658; background: var(--surface-2); }
.hq-eff-top { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.hq-eff-top > select, .hq-eff-top > input[type="text"] { flex: 1 1 12rem; }
.hq-eff-body { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.hq-tgt .hq-fld { margin: 0; display: flex; gap: .3rem; align-items: center; font-weight: 400; }
.hq-chk { display: flex; gap: .4rem; align-items: center; font-weight: 400; }
.hq-qed h3 { margin: 1.2rem 0 .4rem; }
.hq-edit-wrap { overflow: auto; max-height: 70dvh; border: 2px solid #4a4658; }
.hq-edit-board { margin: 0; }
.hq-edit-board .hq-cell { cursor: crosshair; }
.hq-letter { position: absolute; inset: 0; display: grid; place-items: center; font: 700 .7rem/1 monospace; color: rgb(23 22 28 / 55%); pointer-events: none; }
.hq-star { position: absolute; inset: 0; display: grid; place-items: center; font-size: .9rem; pointer-events: none; }
.hq-json { width: 100%; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; }

/* ---- animazioni: respiro dei personaggi, barre della salute, effetti sulla mappa ---- */
.hq-cell { overflow: visible; }
.hq-sprite.bob { animation: hq-bob 1.1s steps(2) infinite; animation-delay: var(--d, 0s); }
@keyframes hq-bob { 0%, 49% { transform: translateY(0); } 50%, 100% { transform: translateY(-6%); } }
.hq-sprite.shake { animation: hq-shake .35s linear 1; }
@keyframes hq-shake { 0% { transform: translateX(0); filter: brightness(2.4) saturate(0); } 25% { transform: translateX(-12%); } 50% { transform: translateX(10%); filter: none; } 75% { transform: translateX(-6%); } 100% { transform: translateX(0); } }
.hq-hp { position: absolute; left: 12%; right: 12%; bottom: 3%; height: 11%; min-height: 3px; max-height: 5px; background: #0c0b10; border: 1px solid #0c0b10; pointer-events: none; z-index: 2; }
.hq-hp > i { display: block; height: 100%; background: #6fcf86; }
.hq-stat { position: absolute; top: 0; right: 1px; font-size: .62rem; line-height: 1; z-index: 3; pointer-events: none; }
.hq-fx { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; font: 700 clamp(.7rem, 1.6vw, 1.05rem)/1 var(--font); text-shadow: 0 0 2px #0c0b10, 1px 1px 0 #0c0b10, -1px -1px 0 #0c0b10;
  color: #fff; pointer-events: none; animation: hq-float 1.1s ease-out forwards; }
.hq-fx-hit { color: #ff6b5e; }
.hq-fx-heal { color: #6fcf86; }
.hq-fx-gold { color: #f1c40f; }
.hq-fx-death { font-size: 1.3rem; animation-duration: 1.4s; }
@keyframes hq-float { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { transform: translateY(-4px) scale(1.25); opacity: 1; } 100% { transform: translateY(-26px) scale(1); opacity: 0; } }
.hq-toast { position: fixed; z-index: 90; top: 4.2rem; left: 50%; transform: translateX(-50%); padding: .6rem 1.2rem; background: #f1c40f; color: #17161c; font-weight: 800;
  border: 3px solid #0c0b10; box-shadow: 4px 4px 0 #0c0b10; animation: hq-pop .35s ease-out; }
@keyframes hq-pop { 0% { transform: translateX(-50%) scale(.6); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hq-sprite.bob, .hq-sprite.shake, .hq-fx, .hq-toast { animation: none; } }

.hq-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.hq-table th, .hq-table td { text-align: left; padding: .35rem .6rem .35rem 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.hq-table th { color: var(--muted); font-weight: 600; }
section.card:has(.hq-table) { overflow-x: auto; }
.hq-statlist { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .4rem .9rem; }
.hq-statlist strong { font-size: 1.1rem; }
.hq-dice-txt { font-size: .85rem; color: #d9d4c5; min-height: 1.2rem; }
.hq-mini-die { width: 1.6rem; height: 1.6rem; image-rendering: pixelated; vertical-align: middle; }
.hq-faces { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-top: .8rem; }
.hq-hist { display: grid; gap: .3rem; margin-top: .6rem; max-height: 22rem; overflow: auto; }
.hq-hist-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .25rem 0; border-bottom: 1px solid var(--border); }
.hq-hist-dice { display: inline-flex; gap: 2px; }
.hq-noanim *, .hq-noanim *::before, .hq-noanim *::after { animation: none !important; }
.hq-settings select { max-width: 16rem; }
.hq-settings .hq-die { width: 3rem; height: 3rem; }
.hq-menu .hq-settings { box-shadow: none; border: 0; padding: .4rem 0; background: transparent; }
.hq-menu .hq-settings h2 { display: none; }

/* prima dell'accesso nella pagina c'è solo il riquadro di login */
body:not(.hq-authed) .page-head, body:not(.hq-authed) .hq-rules, body:not(.hq-authed) .hq-disclaimer { display: none; }

.hq-chat { list-style: none; margin: 0 0 .5rem; padding: 0; display: grid; gap: .25rem; max-height: 11rem; overflow: auto; font-size: .92rem; }
@media (max-width: 52rem) {
  /* spazio sotto la pagina pari all'altezza dei comandi fissi in basso (misurata dal gioco): niente resta coperto */
  body.hq-full main.wrap { padding-bottom: calc(var(--hq-bottom, 7rem) + env(safe-area-inset-bottom)); }
  body.hq-full .hq-controls { max-height: 34dvh; }
  .hq-toast { max-width: calc(100vw - 1rem); }
}
