/* =========================================================
   LETSCAPE THEME — style.css (drop-in)
   Look: dark / neon / suspense, readable, accessible.
   ========================================================= */

/* ---------- Reset / Base ---------- */
:root {
  --bg0: #07070a;
  --bg1: #0c0d12;
  --panel: #10121a;
  --panel2: #0d0f16;
  --ink: #e8e9f0;
  --muted: #a8acbf;

  /* --accent:#00f5d4;     neon cyan (Old) */
  /* --accent2:#ff3b7a;    neon pink (Old) */

  --accent: #00e5ff;
  /* Neon Cyan/Blue */
  --accent2: #a855f7;
  /* Neon Purple */
  --warn: #ffcc00;
  --danger: #ff2f2f;

  --line: rgba(255, 255, 255, .08);
  --shadow: 0 16px 45px rgba(0, 0, 0, .60);

  --radius: 18px;
  --radius2: 12px;

  --glow: 0 0 16px rgba(0, 229, 255, 0.45), 0 0 45px rgba(0, 229, 255, 0.15);
  --glow2: 0 0 16px rgba(168, 85, 247, 0.45), 0 0 45px rgba(168, 85, 247, 0.15);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 10% 10%, rgba(0, 229, 255, 0.12), transparent 55%),
    radial-gradient(900px 600px at 90% 25%, rgba(168, 85, 247, 0.12), transparent 55%),
    radial-gradient(700px 500px at 50% 110%, rgba(168, 85, 247, 0.08), transparent 65%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  overflow-x: hidden;
}

/* Subtle film grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .08;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='260' height='260' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  background-size: 260px 260px;
}

/* Subtle scanlines */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .07;
  background: repeating-linear-gradient(to bottom,
      rgba(255, 255, 255, .06),
      rgba(255, 255, 255, .06) 1px,
      transparent 1px,
      transparent 3px);
  mix-blend-mode: soft-light;
}

/* ---------- Layout Helpers ---------- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

/* ---------- Typography ---------- */
h1,
h2,
h3 {
  margin: 0 0 12px 0;
  letter-spacing: .4px;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35), 0 0 30px rgba(0, 245, 212, .10);
}

h2 {
  font-size: clamp(18px, 2.2vw, 26px);
  opacity: .95;
}

p {
  color: var(--muted);
  margin: 10px 0;
}

b,
strong {
  color: var(--ink);
}

code,
pre {
  font-family: var(--mono);
  color: #dffbf7;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- Top “HUD” header feel ---------- */
header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: linear-gradient(180deg, rgba(8, 9, 12, .86), rgba(8, 9, 12, .35));
  border-bottom: 1px solid var(--line);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
}

header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
}

header .brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: var(--glow);
}

header nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

header nav a {
  color: rgba(232, 233, 240, .9);
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
}

header nav a:hover {
  border-color: rgba(0, 245, 212, .25);
  background: rgba(0, 245, 212, .06);
  text-decoration: none;
}

/* ---------- Cards / Panels ---------- */
.card {
  background: linear-gradient(180deg, rgba(16, 18, 26, .92), rgba(10, 12, 18, .92));
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

/* Neon edge */
.card::before {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: calc(var(--radius) + 2px);
  background: radial-gradient(450px 150px at 10% 0%, rgba(0, 245, 212, .18), transparent 60%),
    radial-gradient(450px 150px at 90% 0%, rgba(255, 59, 122, .14), transparent 60%);
  opacity: .9;
  pointer-events: none;
  mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  -webkit-mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  padding: 2px;
  box-sizing: border-box;
}

/* Inner */
.card>* {
  position: relative;
  z-index: 1;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .10);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .03));
  color: rgba(232, 233, 240, .95);
  text-decoration: none;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: .2px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
  transition: transform .12s ease, border-color .18s ease, box-shadow .18s ease, background .18s ease, opacity .18s ease;
  line-height: 1;
  vertical-align: middle;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 245, 212, .32);
  box-shadow: 0 14px 35px rgba(0, 0, 0, .45), var(--glow);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0px);
}

.btn-primary {
  border-color: rgba(0, 245, 212, .35);
  background:
    radial-gradient(120px 40px at 20% 0%, rgba(0, 245, 212, .30), transparent 70%),
    linear-gradient(180deg, rgba(0, 245, 212, .18), rgba(255, 255, 255, .04));
  box-shadow: 0 16px 38px rgba(0, 0, 0, .45), var(--glow);
}

.btn-primary:hover {
  border-color: rgba(0, 245, 212, .55);
}

.btn-danger {
  border-color: rgba(255, 47, 47, .35);
  background:
    radial-gradient(120px 40px at 20% 0%, rgba(255, 47, 47, .25), transparent 70%),
    linear-gradient(180deg, rgba(255, 47, 47, .14), rgba(255, 255, 255, .03));
}

.btn-danger:hover {
  border-color: rgba(255, 47, 47, .58);
  box-shadow: 0 14px 35px rgba(0, 0, 0, .45), 0 0 16px rgba(255, 47, 47, .25);
}

button.btn {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
}

button.btn:disabled,
a.btn[aria-disabled="true"] {
  opacity: .45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ---------- Forms ---------- */
label {
  color: rgba(232, 233, 240, .9);
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(8, 10, 15, .75);
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2);
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}

input::placeholder,
textarea::placeholder {
  color: rgba(168, 172, 191, .7);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 245, 212, .45);
  box-shadow: 0 0 0 3px rgba(0, 245, 212, .12), var(--glow);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .10);
}

.table th,
.table td {
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.table th {
  text-align: left;
  font-size: .95rem;
  color: rgba(232, 233, 240, .92);
  background: rgba(0, 245, 212, .06);
}

.table tr:hover td {
  background: rgba(255, 255, 255, .02);
}

/* ---------- Badges / pills ---------- */
.badge,
code {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .04);
  font-size: .9rem;
}

/* ---------- Notes / alerts ---------- */
.note {
  color: rgba(168, 172, 191, .9);
  font-size: .95rem;
}

.flash {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .03);
  margin: 10px 0;
}

.flash.success {
  border-color: rgba(0, 245, 212, .28);
  background: rgba(0, 245, 212, .07);
}

.flash.error {
  border-color: rgba(255, 47, 47, .28);
  background: rgba(255, 47, 47, .06);
}

.flash.warn {
  border-color: rgba(255, 204, 0, .28);
  background: rgba(255, 204, 0, .06);
}

/* ---------- Puzzle overlay look ---------- */
.overlay {
  margin: 10px 0 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px dashed rgba(0, 245, 212, .25);
  background:
    radial-gradient(250px 120px at 20% 10%, rgba(0, 245, 212, .12), transparent 60%),
    rgba(0, 0, 0, .18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2);
}

.overlay p {
  margin: 6px 0;
  color: rgba(232, 233, 240, .9);
}

.overlay em {
  color: rgba(168, 172, 191, .9);
}

/* ---------- Details / Summary ---------- */
details {
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, .03);
}

summary {
  cursor: pointer;
  color: rgba(232, 233, 240, .92);
  font-weight: 600;
}

details[open] {
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}

/* ---------- “Timer / urgency” subtle pulse ---------- */
.pulse {
  position: relative;
}

.pulse::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  border: 1px solid rgba(255, 59, 122, .35);
  opacity: .35;
  animation: pulse 2.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {

  0%,
  100% {
    opacity: .16;
    box-shadow: none;
  }

  50% {
    opacity: .45;
    box-shadow: var(--glow2);
  }
}

/* ---------- Small utilities ---------- */
hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, .10);
  margin: 14px 0;
}

kbd {
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .05);
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 680px) {
  .container {
    padding: 14px;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

  header .container {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  body::before,
  body::after {
    display: none;
  }
}

/* =========================================================
   CONTROL ROOM HEADER (HUD)
   ========================================================= */
.hud {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(180deg, rgba(8, 9, 12, .88), rgba(8, 9, 12, .45));
  border-bottom: 1px solid rgba(255, 255, 255, .10);
  backdrop-filter: blur(10px);
}

.hud__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hud__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(232, 233, 240, .95);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: .6px;
  text-transform: uppercase;
}

/* === HUD LOGO IMAGING === */
header.hud .hud__brand .hud__logo,
.hud__logo {
  display: block !important;
  width: 42px !important;
  height: 42px !important;
  background: transparent !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  border: none !important;
  padding: 0 !important;
}

header.hud .hud__brand .hud__logo img,
.hud__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(0, 229, 255, 0.6));
  transition: transform .25s ease, filter .25s ease;
}

/* Hover effect */
header.hud .hud__brand:hover .hud__logo img {
  transform: scale(1.1) rotate(-3deg);
  filter: drop-shadow(0 0 12px rgba(0, 229, 255, 1));
}

/* Disable old SVG styles */
header.hud .hud__brand .hud__logo svg.puzzle-icon,
.puzzle-icon,
.ico svg {
  display: none !important;
}

/* Mobile header */
@media (max-width: 820px) {
  .hud__inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .hud__nav {
    justify-content: flex-start;
  }
}


/* =========================================================
   STUDENT UI — Terminal / Access
   (Usa queste classi nei template studenti)
   ========================================================= */
.student-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: 18px;
}

.terminal {
  background: linear-gradient(180deg, rgba(7, 9, 12, .92), rgba(10, 12, 18, .92));
  border: 1px solid rgba(0, 245, 212, .18);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 30px rgba(0, 245, 212, .10);
  overflow: hidden;
}

.terminal__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(0, 245, 212, .06);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.terminal__lights {
  display: flex;
  gap: 6px;
}

.terminal__lights span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
}

.terminal__lights span:nth-child(1) {
  background: rgba(255, 59, 122, .55);
}

.terminal__lights span:nth-child(2) {
  background: rgba(255, 204, 0, .55);
}

.terminal__lights span:nth-child(3) {
  background: rgba(0, 245, 212, .55);
}

.terminal__title {
  font-family: var(--mono);
  font-size: .9rem;
  color: rgba(232, 233, 240, .92);
  opacity: .95;
}

.terminal__body {
  padding: 16px;
  font-family: var(--mono);
  color: rgba(232, 233, 240, .92);
}

.terminal__line {
  opacity: .9;
  margin: 0 0 10px 0;
}

.terminal__line .prompt {
  color: var(--accent);
}

.terminal__line .warn {
  color: var(--warn);
}

.terminal__line .danger {
  color: var(--danger);
}

.student-form {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.student-form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 700px) {
  .student-form .row {
    grid-template-columns: 1fr;
  }
}

.student-form input {
  font-family: var(--mono);
}

/* Pannello gioco studenti: status/timer */
.hud-panels {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 12px;
  margin: 12px 0;
}

@media (max-width: 900px) {
  .hud-panels {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: linear-gradient(180deg, rgba(16, 18, 26, .92), rgba(10, 12, 18, .92));
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 18px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, .55);
  padding: 14px;
}

.panel h3 {
  margin: 0 0 8px 0;
  font-size: 1.1rem;
}

.panel .big {
  font-family: var(--mono);
  font-size: 1.35rem;
  letter-spacing: .6px;
  color: rgba(232, 233, 240, .96);
}

.panel .muted {
  color: rgba(168, 172, 191, .9);
}

.answer-box {
  margin-top: 12px;
  background: rgba(0, 0, 0, .18);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 18px;
  padding: 12px;
}

.answer-box label {
  font-family: var(--mono);
  font-weight: 700;
}

.answer-box input {
  margin-top: 8px;
  font-family: var(--mono);
}

.answer-box .btn {
  width: 100%;
  margin-top: 10px;
}

/* Messaggi feedback */
.toast-ok {
  border: 1px solid rgba(0, 245, 212, .22);
  background: rgba(0, 245, 212, .07);
  padding: 10px 12px;
  border-radius: 14px;
  margin-top: 10px;
}

.toast-bad {
  border: 1px solid rgba(255, 47, 47, .22);
  background: rgba(255, 47, 47, .06);
  padding: 10px 12px;
  border-radius: 14px;
  margin-top: 10px;
}

.is-disabled {
  opacity: .55;
  cursor: not-allowed;
}

/* Glitch leggero (solo durante join) */
body.joining .terminal__title {
  animation: glitch 700ms steps(2, end) 1;
}

body.denied .terminal {
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 30px rgba(255, 47, 47, .18);
  border-color: rgba(255, 47, 47, .28);
}

@keyframes glitch {
  0% {
    transform: translateX(0);
    text-shadow: none;
  }

  25% {
    transform: translateX(-1px);
    text-shadow: 2px 0 rgba(255, 59, 122, .35);
  }

  50% {
    transform: translateX(1px);
    text-shadow: -2px 0 rgba(0, 245, 212, .35);
  }

  75% {
    transform: translateX(-1px);
    text-shadow: 2px 0 rgba(255, 59, 122, .25);
  }

  100% {
    transform: translateX(0);
    text-shadow: none;
  }
}

body.joining .terminal__title {
  animation: glitch 700ms steps(2, end) 1;
}

body.denied .terminal {
  border-color: rgba(255, 47, 47, .28);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 30px rgba(255, 47, 47, .18);
}

/* === HUD LOGO: hard reset per evitare differenze tra pagine === */
header.hud .hud__brand .hud__logo {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 38px !important;
  height: 38px !important;
  border-radius: 10px !important;
  background: rgba(34, 197, 94, 0.08) !important;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.25) !important;
  line-height: 1 !important;
  padding: 0 !important;
}

header.hud .hud__brand .hud__logo svg.puzzle-icon {
  display: block !important;
  width: 28px !important;
  /* più grande */
  height: 28px !important;
  /* più grande */
  margin: 0 !important;
  padding: 0 !important;
  transform: rotate(45deg) !important;
  transform-origin: 50% 50% !important;
  filter: drop-shadow(0 0 7px rgba(34, 197, 94, 0.75)) !important;
  transition: transform .25s ease, filter .25s ease !important;
}

/* hover coerente */
header.hud .hud__brand:hover .hud__logo svg.puzzle-icon {
  transform: rotate(45deg) scale(1.12) !important;
  filter: drop-shadow(0 0 11px rgba(34, 197, 94, 0.95)) !important;
}

.pill {
  display: inline-block;
  padding: .25rem .55rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  margin: .15rem .25rem .15rem 0;
  font-size: .9rem;
  white-space: nowrap;
}

.pill--running {
  box-shadow: 0 0 0 1px rgba(0, 255, 160, .25), 0 0 22px rgba(0, 255, 160, .12);
}

.pill--ended {
  opacity: .9;
}

.pill--idle {
  opacity: .8;
}

.inline-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.inline-form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inline-form label {
  font-size: .9rem;
  opacity: .8;
}

.inline-form input,
.inline-form select {
  min-height: 42px;
}

/* Badge giocatori in lobby docente */
.badge-player {
  background: linear-gradient(180deg,
      rgba(0, 255, 170, 0.22),
      rgba(0, 180, 140, 0.18));
  color: #eafff7;
  border: 1px solid rgba(0, 255, 170, 0.45);
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  transition: all 0.15s ease;
}

.badge-player:hover {
  background: linear-gradient(180deg,
      rgba(0, 255, 170, 0.35),
      rgba(0, 180, 140, 0.28));
  border-color: rgba(0, 255, 170, 0.75);
  box-shadow: 0 0 0 2px rgba(0, 255, 170, 0.15),
    0 0 14px rgba(0, 255, 170, 0.35);
  transform: translateY(-1px);
}

.badge-player:active {
  transform: translateY(0);
  box-shadow: 0 0 8px rgba(0, 255, 170, 0.3);
}

/* --- Play header: più evidente --- */
.student-shell .desktop-only h2 {
  font-size: 2.0rem !important;
  line-height: 1.15 !important;
  letter-spacing: 0.5px;
}

.student-shell .desktop-only>div {
  font-size: 1.05rem !important;
  opacity: 1 !important;
}

/* Chip compagni */
/* Chip compagni (desktop + mobile) */
#teammates .teammate-chip,
#mobTeammates .teammate-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 600;
  font-size: 0.95rem;
}

#teammates .teammate-chip--muted,
#mobTeammates .teammate-chip--muted {
  opacity: 0.6;
  font-weight: 500;
}

/* Mobile: un filo più piccoli */
#mobTeammates .teammate-chip {
  font-size: 0.85rem;
  padding: 2px 8px;
}

/* =========================================================
   PLAY VIEW — Distinzione PUZZLE vs CHAT
   ========================================================= */

.terminal--chat {
  border-color: rgba(192, 132, 252, 0.40);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 30px rgba(192, 132, 252, .14);
}

.terminal--chat .terminal__top {
  background: rgba(192, 132, 252, 0.08);
}

.terminal--chat .terminal__title {
  letter-spacing: 0.6px;
}

/* =========================================================
   PUZZLE: stile dedicato per differenziarlo nettamente dalla chat
   ========================================================= */
.terminal--puzzle {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6), 0 0 34px rgba(56, 189, 248, .18);
}

.terminal--puzzle .terminal__top {
  background: rgba(56, 189, 248, 0.10);
}

.terminal--puzzle .terminal__title {
  letter-spacing: 0.7px;
}

.terminal--puzzle .terminal__title::before {
  content: "🧩 ";
}

/* =========================================================
   RUSH TIME blink (timer rosso lampeggiante)
   ========================================================= */
.pulse-fast {
  animation: rushPulse 2.2s ease-in-out infinite;
}

@media (max-width: 767px),
(hover: none) and (pointer: coarse) {
  .pulse-fast {
    animation-duration: 1.8s;
  }
}

@keyframes rushPulse {

  0%,
  100% {
    opacity: 1;
    text-shadow: 0 0 6px rgba(255, 0, 0, 0.25);
  }

  50% {
    opacity: 0.45;
    text-shadow: 0 0 18px rgba(255, 0, 0, 0.95);
  }
}

/* =========================================================
   Clue share button (invio indizi in chat)
   ========================================================= */

/* Base button */
.clue-share-btn {
  border: 1px solid rgba(192, 132, 252, 0.45);
  background: rgba(192, 132, 252, 0.15);
  color: #f5d0fe;

  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: 24px;
  min-width: 24px;
  padding: 0 8px;
  border-radius: 999px;

  cursor: pointer;
  font-family: var(--mono);
  font-weight: 900;
  line-height: 1;
}

.clue-share-btn:hover {
  background: rgba(192, 132, 252, 0.25);
}

/* Per-box: il contenitore dell'indizio ospita il pulsante */
.clue-item {
  position: relative;
  line-height: 1.1;
  padding-right: 40px;
  /* spazio per l'icona */
}

/* Pulsante dentro il singolo box-indizio (in alto a destra) */
.clue-share-btn--item {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 60;

  height: 28px;
  min-width: 28px;
  padding: 0 8px;
}

.clue-item--legacy {
  padding-right: 34px;
}

/* === CLUE GRID (indizi): 2 colonne su desktop, 1 su mobile stretto === */
.clue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

/* evita che i box “sfondino” e forzino a capo strano */
.clue-grid>* {
  min-width: 0;
}

@media (max-width: 560px) {
  .clue-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   CLUE ITEMS: evita wrapping precoce (mobile) + bottone 💬 non “mangia” larghezza
   ========================================================= */

.clue-item {
  position: relative;
  /* ok anche se il bottone era absolute */
  min-width: 0;
  /* fondamentale per grid/flex dentro layout stretti */
  padding-right: 10px !important;
  /* NON riservare 40px fissi */
}

/* Layout interno: contenuto a sinistra, bottone a destra SOLO nella prima riga */
.clue-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-auto-rows: min-content;
  column-gap: 10px;
  row-gap: 2px;
}

/* Bottone share: niente absolute => non restringe il testo */
.clue-item .clue-share-btn--item {
  position: static !important;
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: start;
  margin: 0 !important;
}

/* Pnum e cipher stanno a sinistra */
.clue-item .clue-pnum,
.clue-item .clue-cipher {
  grid-column: 1;
}

/* Il testo dell’indizio prende tutta la riga sotto (larghezza piena) */
.clue-item .clue-text {
  grid-column: 1 / -1;
  white-space: normal !important;
  word-break: normal !important;
  overflow-wrap: break-word !important;
  /* non “anywhere”, evita righe da 1 lettera */
}

/* Anche per legacy extraBox (se dentro c’è testo senza classi) */
.clue-item--legacy {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 10px;
}

/* =========================================================
   Letscape (messaggi di sistema) — blu/ciano
   ========================================================= */
[data-sender="LETSCAPE"] {
  border: 1px solid rgba(56, 189, 248, 0.55) !important;
  background: rgba(56, 189, 248, 0.12) !important;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.18);
}

[data-sender="LETSCAPE"] .chat-msg__head b {
  color: rgba(125, 211, 252, 1);
  letter-spacing: 0.3px;
}

[data-sender="LETSCAPE"] .chat-msg__head span {
  opacity: 0.8;
}

/* =========================================================
   MASTER DASHBOARD TOP LAYOUT (40% / 60%) + scroll "Partite recenti"
   ========================================================= */

.master-dashboard-top {
  display: grid;
  grid-template-columns: 40% 60%;
  gap: 18px;
  align-items: stretch;
  /* la card di destra si allunga come la colonna sinistra */
}

.master-dashboard-left {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
}

/* Card "Partite recenti" deve usare flex per far scrollare solo il contenuto */
.master-dashboard-recent {
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* fondamentale per overflow in grid */
}

.master-dashboard-recent__scroll {
  flex: 1 1 auto;
  min-height: 0;
  /* fondamentale per overflow */
  overflow-y: auto;
  padding-right: 6px;
  /* spazio per scrollbar */
}

/* lista più compatta */
.master-dashboard-recent__scroll ul {
  margin: 0;
  padding-left: 18px;
}

/* Responsive: su mobile una colonna */
@media (max-width: 900px) {
  .master-dashboard-top {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   MASTER DASHBOARD: allineamento in basso perfetto (right spans 2 rows)
   ========================================================= */

.master-dashboard-top {
  display: grid;
  grid-template-columns: 40% 60%;
  grid-template-rows: auto auto;
  /* due righe: card1 e card2 */
  gap: 18px;
  align-items: stretch;
}

/* La colonna sinistra non serve più come flex per l'allineamento:
   la usiamo come "contenitore trasparente" e posizioniamo le due card nelle 2 righe */
.master-dashboard-left {
  display: contents;
  /* importante: i figli diventano grid-items della master-dashboard-top */
}

/* prima card sinistra => riga 1 colonna 1 */
.master-dashboard-left>.card:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

/* seconda card sinistra => riga 2 colonna 1 */
.master-dashboard-left>.card:nth-child(2) {
  grid-column: 1;
  grid-row: 2;
}

/* Partite recenti a destra => occupa entrambe le righe */
.master-dashboard-recent {
  grid-column: 2;
  grid-row: 1 / span 2;

  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* Scroll interno che prende tutto lo spazio rimanente */
.master-dashboard-recent__scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

/* Responsive: su mobile torna “normale” */
@media (max-width: 900px) {
  .master-dashboard-top {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .master-dashboard-left {
    display: block;
    /* annulla contents */
  }

  .master-dashboard-recent {
    grid-column: auto;
    grid-row: auto;
    height: auto;
  }
}

/* =========================
   Toast overlay (global)
   ========================= */
.toast-stack {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: min(460px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  /* lascia cliccare sotto, eccetto sui toast */
}

.toast-stack .toast {
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .30);
  animation: toastIn .14s ease-out;
}

.toast-stack .toast.toast-hide {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .16s ease, transform .16s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* HUD Fixes for Profile/Logout */
.hud__right {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.hud__pill {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  color: rgba(232, 233, 240, .9);
  padding: 6px 12px;
  border-radius: 99px;
  /* Pill shape */
  border: 1px solid rgba(255, 255, 255, 0.08);
  /* Subtle border */
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.04);
  transition: all 0.2s ease;
}

.hud__pill:hover {
  border-color: var(--accent);
  background: rgba(0, 229, 255, 0.1);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
  transform: translateY(-1px);
}

.hud__pill .ico {
  display: flex !important;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
  min-width: 20px;
  /* Force reservation */
}

.hud__pill .ico svg {
  width: 18px;
  height: 18px;
  min-width: 18px;
  /* Force size */
  min-height: 18px;
  stroke: #ffffff !important;
  /* Force visibility */
  stroke-width: 2px !important;
  fill: none !important;
}

/* Specifico per Logout: rosso */
.hud__pill[href*="logout"]:hover {
  border-color: var(--danger, #ff2f2f);
  background: rgba(255, 47, 47, 0.15);
  box-shadow: 0 0 12px rgba(255, 47, 47, 0.3);
}