/* CRUCIGO · BEEHIVE
   Telefono (390×844): tutto in una schermata — gradi, striscia delle trovate, parola, alveare, tasti.
   L'elenco delle trovate si apre a tendina SOPRA l'alveare (non spinge giù niente).
   Da 880px: due colonne — a sinistra parola + alveare + tasti, a destra gradi + elenco sempre aperto. */
.bh { position: relative; max-width: 520px; margin: 0 auto; }
.bh-gioco { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "capo" "lato" "scrivi" "favo" "tasti"; grid-template-rows: auto auto auto 1fr auto;
  /* alto quanto lo schermo meno testata e margini: lo spazio in più va attorno all'alveare e i tasti
     restano in basso, sotto il pollice */
  min-height: calc(100dvh - 112px - env(safe-area-inset-bottom)); }
.bh-capo { grid-area: capo; display: flex; gap: 8px; align-items: stretch; }
.bh-lato { grid-area: lato; position: relative; }
.bh-scrivi { grid-area: scrivi; position: relative; padding-top: 34px; }
.bh-favo { grid-area: favo; justify-self: center; align-self: center; }
.bh-tasti { grid-area: tasti; }

/* ---- gradi: nome, punti e la scala dei nove gradi ---- */
.bh-voto { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 7px 12px 6px; text-align: left; cursor: pointer;
  border: 2px solid var(--inchiostro, #151311); border-radius: 12px; background: var(--foglio, #fff); color: var(--inchiostro, #151311);
  box-shadow: 0 3px 0 var(--inchiostro, #151311); font: inherit; -webkit-tap-highlight-color: transparent; }
.bh-voto:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--inchiostro, #151311); }
.bh-voto__riga { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bh-voto__nome { font: 700 19px/1.1 var(--stampa, Georgia, serif); letter-spacing: -.01em; }
.bh-voto__punti { font-size: 15px; white-space: nowrap; }
.bh-voto__manca { font: 500 12px/1.2 var(--testo, system-ui); color: var(--grafite, #5E5A54); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bh-scala { position: relative; display: block; height: 16px; margin: 3px 7px 1px; }
.bh-scala i { position: absolute; display: block; font-style: normal; }
.bh-scala__linea { left: 0; right: 0; top: 50%; height: 2px; margin-top: -1px; background: var(--riga, rgba(21,19,17,.16)); }
.bh-scala__linea i { left: 0; top: 0; bottom: 0; background: var(--inchiostro, #151311); transition: width .35s ease-out; }
.bh-scala__p { top: 50%; width: 9px; height: 9px; margin: -6.5px 0 0 -6.5px; border: 2px solid var(--inchiostro, #151311); border-radius: 50%; background: var(--foglio, #fff); }
.bh-scala__p.pieno { background: var(--inchiostro, #151311); }
/* il traguardo della giornata: un rombo */
.bh-scala__p.fatto { border-radius: 2px; transform: rotate(45deg); }
.bh-scala__p.qui { width: 13px; height: 13px; margin: -8.5px 0 0 -8.5px; background: var(--g); }
.bh-aiuto { flex: none; min-width: 70px; min-height: 0; padding: 0 10px; font-size: 14px; }

/* ---- la striscia delle trovate (telefono) e l'elenco ---- */
.bh-striscia { width: 100%; min-height: 46px; display: flex; align-items: center; gap: 10px; padding: 0 10px 0 12px; cursor: pointer;
  border: 2px solid var(--inchiostro, #151311); border-radius: 12px; background: var(--foglio, #fff); color: var(--inchiostro, #151311);
  font: inherit; text-align: left; -webkit-tap-highlight-color: transparent; }
.bh-striscia__conto { flex: none; font: 500 14px/1 var(--testo, system-ui); }
.bh-striscia__conto b { font: 400 17px/1 var(--macchina, monospace); }
.bh-striscia__ultime { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font: 400 15px/1 var(--macchina, monospace); color: var(--grafite, #5E5A54); word-spacing: .2em; }
.bh-striscia svg { flex: none; width: 22px; height: 22px; transition: transform .2s; }
.bh-striscia[aria-expanded="true"] svg { transform: rotate(180deg); }
.bh-elenco { display: none; }
.bh.aperto .bh-elenco { display: block; position: absolute; z-index: 6; left: 0; right: 0; top: calc(100% + 6px);
  height: min(62dvh, 470px); overflow: auto; overscroll-behavior: contain; padding: 10px 14px 12px; box-sizing: border-box;
  border: 2px solid var(--inchiostro, #151311); border-radius: 12px; background: var(--foglio, #fff); box-shadow: 0 4px 0 var(--inchiostro, #151311); }
.bh-elenco ul { margin: 0; padding: 0; list-style: none; columns: 2; column-gap: 18px; }
.bh-elenco li { break-inside: avoid; padding: 6px 0 5px; border-bottom: 1px solid var(--riga, rgba(21,19,17,.16)); font: 400 17px/1.15 var(--macchina, monospace); }
.bh-elenco li.pang, .bh-ieri li.pang { font-weight: 700; color: var(--inchiostro, #151311); text-decoration: underline; text-decoration-color: var(--g); text-decoration-thickness: .28em; text-underline-offset: -.08em; text-decoration-skip-ink: none; }
.bh-elenco li.rara { font-style: italic; color: var(--grafite, #5E5A54); }
.bh-elenco li.nuova { animation: bh-nuova 1.2s ease-out; }
@keyframes bh-nuova { 0% { background: var(--g); } 100% { background: transparent; } }
.bh-legenda { margin: 10px 0 0; font-size: 13px; }
.bh-legenda:empty { display: none; }

/* ---- la parola che si compone, e il messaggio sopra ---- */
.bh-parola { min-height: 50px; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; padding: 0 4px;
  font-size: clamp(26px, 8.4vw, 36px); line-height: 1; letter-spacing: .06em; overflow-wrap: anywhere; }
.bh-parola span { padding-top: .08em; }
.bh-parola .c { box-shadow: inset 0 -.26em 0 var(--g); }
.bh-parola .fuori { color: var(--grafite, #5E5A54); opacity: .45; }
.bh-cursore { display: inline-block; width: 2px; height: .95em; margin-left: 3px; background: var(--inchiostro, #151311); animation: bh-cursore 1.05s steps(1) infinite; }
.bh-parola.vuota .bh-cursore { margin-left: 0; }
@keyframes bh-cursore { 50% { opacity: 0; } }
.bh-parola.no { animation: bh-no .36s ease-in-out; }
@keyframes bh-no { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-9px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.bh-msg { position: absolute; left: 50%; top: 0; z-index: 4; margin: 0; padding: 7px 13px; transform: translate(-50%, 6px); opacity: 0; pointer-events: none; white-space: nowrap;
  border: 2px solid var(--inchiostro, #151311); border-radius: 999px; background: var(--inchiostro, #151311); color: var(--carta, #FBF9F4);
  font: 700 14px/1 var(--testo, system-ui); transition: opacity .15s, transform .15s; }
.bh-msg.su { opacity: 1; transform: translate(-50%, 0); }
.bh.aperto .bh-msg { opacity: 0; }
.bh-msg--si, .bh-msg--rara { background: var(--foglio, #fff); color: var(--inchiostro, #151311); }
.bh-msg--rara { font-style: italic; }
.bh-msg--pang, .bh-msg--grado { background: var(--g); color: var(--su-colore, #151311); box-shadow: 0 3px 0 var(--inchiostro, #151311); }

/* ---- l'alveare ---- */
.bh-favo { width: min(100%, 380px, calc((100dvh - 420px) * .95)); min-width: 236px; height: auto; display: block; overflow: visible;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.bh-cella { cursor: pointer; outline: none; }
.bh-cella__ombra { fill: var(--inchiostro, #151311); }
.bh-cella__faccia { fill: var(--foglio, #fff); stroke: var(--inchiostro, #151311); stroke-width: 2.5px; stroke-linejoin: round; transition: fill .12s; }
.bh-cella--centro .bh-cella__faccia { fill: var(--g); }
.bh-cella__l { font-family: var(--macchina, "Special Elite", monospace); font-size: 44px; fill: var(--inchiostro, #151311); pointer-events: none; }
.bh-cella--centro .bh-cella__l { fill: var(--su-colore, #151311); }
.bh-cella__su { transition: transform .08s; }
.bh-cella.giu .bh-cella__su { transform: translateY(3px); }
@media (hover: hover) { .bh-cella:hover .bh-cella__faccia { fill: color-mix(in oklab, var(--g) 22%, var(--foglio, #fff)); } .bh-cella--centro:hover .bh-cella__faccia { fill: color-mix(in oklab, var(--g) 85%, var(--inchiostro, #151311)); } }
.bh-favo.gira .bh-cella:not(.bh-cella--centro) .bh-cella__su { animation: bh-gira .32s ease-out; }
@keyframes bh-gira { 0% { opacity: 1; } 35% { opacity: 0; } 100% { opacity: 1; } }

/* ---- i tasti ---- */
.bh-tasti { display: grid; grid-template-columns: 1fr 64px 1fr; gap: 10px; }
.bh-tasti .g-tasto { min-height: 50px; padding: 0 8px; }
.bh-mescola svg { width: 24px; height: 24px; }

/* ---- desktop: alveare a sinistra, gradi + elenco a destra ---- */
@media (min-width: 880px) {
  .bh { max-width: 1000px; }
  .bh-gioco { min-height: 0; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 44px; row-gap: 14px;
    grid-template-areas: "scrivi capo" "favo lato" "tasti lato"; grid-template-rows: auto 1fr auto; }
  .bh-scrivi { align-self: end; padding-top: 38px; }
  .bh-favo { width: min(100%, 430px, calc(100dvh - 330px)); align-self: center; }
  .bh-tasti { width: min(100%, 430px); justify-self: center; }
  .bh-lato { display: flex; flex-direction: column; min-height: 0; }
  .bh-striscia { pointer-events: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; border-bottom-width: 1px; }
  .bh-striscia svg, .bh-striscia__ultime { display: none; }
  .bh-elenco, .bh.aperto .bh-elenco { display: block; position: static; flex: 1; height: auto; min-height: 260px; max-height: calc(100dvh - 300px); overflow: auto;
    padding: 10px 16px 14px; border: 2px solid var(--inchiostro, #151311); border-top: 0; border-radius: 0 0 12px 12px; background: var(--foglio, #fff); box-shadow: 0 4px 0 var(--inchiostro, #151311); }
  .bh-elenco ul { columns: 3; }
  .bh-voto__nome { font-size: 22px; }
  .bh-parola { min-height: 64px; font-size: 40px; }
}

/* ---- INSIEME (c/r-beehive.js): nell'elenco ogni parola porta, a destra, l'iniziale di chi l'ha trovata;
   in stanza c'è la barra in più sotto la testata: alveare, tasti ed elenco devono stare ancora nello schermo ---- */
body.g--insieme .bh-elenco li { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.bh-elenco .bh-w { min-width: 0; overflow-wrap: anywhere; }
/* la sottolineatura del pangramma va sulla parola, non sull'iniziale accanto */
body.g--insieme .bh-elenco li.pang { text-decoration: none; }
body.g--insieme .bh-elenco li.pang .bh-w { text-decoration: underline; text-decoration-color: var(--g); text-decoration-thickness: .28em; text-underline-offset: -.08em; text-decoration-skip-ink: none; }
.bh-elenco li .ins-p--mini { width: 18px; height: 18px; font-size: 10px; font-weight: 700; font-style: normal; box-shadow: none; text-decoration: none; }
body.g--insieme .bh-gioco { min-height: calc(100dvh - 112px - var(--ins-h, 48px) - env(safe-area-inset-bottom)); }
body.g--insieme .bh-favo { width: min(100%, 380px, calc((100dvh - 420px - var(--ins-h, 48px)) * .95)); }
body.g--insieme .bh.aperto .bh-elenco { height: min(calc(62dvh - var(--ins-h, 48px)), 470px); }
@media (min-width: 880px) {
  body.g--insieme .bh-gioco { min-height: 0; }
  body.g--insieme .bh-favo { width: min(100%, 430px, calc(100dvh - 330px - var(--ins-h, 48px))); }
  body.g--insieme .bh-elenco, body.g--insieme .bh.aperto .bh-elenco { height: auto; max-height: calc(100dvh - 300px - var(--ins-h, 48px)); }
}

/* le parole in corso degli altri (terzo giro, owner 16 nov: «c'è troppo spazio»): stanno NELLA fascia che c'è già
   sopra la mia parola (quella del messaggio «Ottima +2»), attaccate alla mia: in stanza non costano un pixel in più e
   l'alveare non si sposta quando compaiono. Una riga sola, CENTRATA; se non ci stanno si stringono (g-beehive.js:
   misura e passa a lettere più piccole, poi alle sole ultime lettere) e solo alla fine scorre, restando centrata.
   Quando arriva un mio messaggio la riga si fa da parte per un attimo (stanno nello stesso posto). */
.bh-altri { display: none; }
.bh--ins .bh-altri { position: absolute; left: 0; right: 0; top: 0; height: 34px; display: flex; align-items: center; gap: 6px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; transition: opacity .15s; }
.bh--ins .bh-altri::-webkit-scrollbar { display: none; }
.bh--ins .bh-scrivi:has(.bh-msg.su) .bh-altri { opacity: 0; }
.bh-altro:first-child { margin-left: auto; }
.bh-altro:last-child { margin-right: auto; }
.bh-altro { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 26px; box-sizing: border-box; padding: 0 9px 0 2px;
  border: 1.5px solid color-mix(in oklab, var(--p, #5E5A54) 80%, var(--inchiostro, #151311)); border-radius: 999px;
  background: color-mix(in oklab, var(--p, #5E5A54) 9%, var(--foglio, #fff)); color: color-mix(in oklab, var(--p, #5E5A54) 55%, var(--inchiostro, #151311)); }
.bh-altro .ins-p--mini { box-shadow: none; }
.bh-altro b { font: 400 15px/1 var(--macchina, monospace); letter-spacing: .05em; padding-top: 2px; white-space: nowrap; }
.bh-altro b .c { box-shadow: inset 0 -.24em 0 var(--g); }
.bh-altro b .fuori { opacity: .45; }
.bh-altro b i { font-style: normal; opacity: .5; letter-spacing: 0; }
.bh-altro__cur { width: 1.5px; height: 14px; margin-left: -2px; background: currentColor; animation: bh-cursore 1.05s steps(1) infinite; }
/* in tanti: pillole più strette */
.bh-altri.stretti { gap: 4px; }
.bh-altri.stretti .bh-altro { gap: 3px; padding-right: 6px; }
.bh-altri.stretti .bh-altro b { font-size: 13px; letter-spacing: .02em; }
.bh-altri.stretti .ins-p--mini { width: 17px; height: 17px; font-size: 9px; }
@media (min-width: 880px) { .bh--ins .bh-altri { height: 38px; } }
/* l'esagono toccato da un altro: un battito nel suo colore */
.bh-cella.batte .bh-cella__faccia { animation: bh-batte .6s ease-out; }
@keyframes bh-batte { 0%, 30% { stroke: var(--batte, var(--inchiostro, #151311)); stroke-width: 9px; } 100% { stroke-width: 2.5px; } }
/* il tasto «Aiuto» porta i tondi di chi l'ha guardato */
.bh--ins .bh-aiuto { display: grid; place-items: center; align-content: center; gap: 4px; }
.bh--ins .bh-aiuto .ins-voti { justify-content: center; }
@media (prefers-reduced-motion: reduce) { .bh-altro__cur, .bh-cella.batte .bh-cella__faccia { animation: none; } }

/* ---- fogli: gradi, aiuto, parole di ieri ---- */
.bh-gradi { margin: 4px 0 12px; padding: 0; list-style: none; }
.bh-gradi li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 10px; border-bottom: 1px solid var(--riga, rgba(21,19,17,.16)); color: var(--grafite, #5E5A54); }
.bh-gradi li span:first-child { display: grid; gap: 2px; }
.bh-gradi b { font: 700 17px/1.15 var(--stampa, Georgia, serif); }
.bh-gradi em { font: 700 10.5px/1 var(--testo, system-ui); font-style: normal; letter-spacing: .08em; text-transform: uppercase; color: var(--inchiostro, #151311); }
.bh-gradi small { font: 400 13.5px/1.3 var(--testo, system-ui); }
.bh-gradi .dato { font-size: 17px; }
.bh-gradi li.pieno { color: var(--inchiostro, #151311); }
.bh-gradi li.qui { background: color-mix(in oklab, var(--g) 40%, var(--foglio, #fff)); border-radius: 10px; border-bottom-color: transparent; }
.bh-tab-box { overflow-x: auto; margin: 6px 0 12px; }
.bh-tab { width: 100%; border-collapse: collapse; font: 400 15px/1 var(--macchina, monospace); }
.bh-tab th, .bh-tab td { min-width: 30px; height: 32px; padding: 0 4px; text-align: center; border: 1px solid var(--riga, rgba(21,19,17,.16)); }
.bh-tab thead th { font: 700 12px/1 var(--testo, system-ui); color: var(--grafite, #5E5A54); }
.bh-tab tbody th { font-weight: 400; background: color-mix(in oklab, var(--g) 30%, var(--foglio, #fff)); }
.bh-tab td.zero { color: var(--grafite, #5E5A54); opacity: .4; }
.bh-tab .s, .bh-tab tr.s td, .bh-tab tr.s th { font-weight: 700; background: var(--carta-2, #F1EDE3); }
.bh-due { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.bh-due small { flex-basis: 100%; font: 700 11px/1 var(--testo, system-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--grafite, #5E5A54); }
.bh-due span { padding: 6px 8px 5px; border: 1.5px solid var(--inchiostro, #151311); border-radius: 8px; font-size: 14px; }
.bh-due b { font-weight: 400; color: var(--grafite, #5E5A54); }
.bh-ieri { margin: 6px 0 0; padding: 0; list-style: none; columns: 3 7em; column-gap: 14px; font: 400 15px/1.2 var(--macchina, monospace); }
.bh-ieri li { break-inside: avoid; padding: 3px 0; color: var(--grafite, #5E5A54); }
.bh-ieri li.mia { color: var(--inchiostro, #151311); text-decoration: underline; text-decoration-color: var(--g); text-decoration-thickness: 3px; }

@media (prefers-reduced-motion: reduce) {
  .bh-parola.no, .bh-favo.gira .bh-cella__su, .bh-elenco li.nuova, .bh-cursore { animation: none; }
  .bh-scala__linea i, .bh-msg, .bh-cella__su { transition: none; }
}
