:root{
  --bg:#1f1f1f;
  --panel:#1f1f1f;
  --line:rgba(255,255,255,.16);
  --text:#f5f7fb;
  --muted:rgba(245,247,251,.68);
  --accent:#f6ff4b;
  --shadow:0 20px 60px rgba(0,0,0,.6);
}

*{box-sizing:border-box;margin:0;padding:0}
html,body{
  width:100%;
  height:100%;
  overflow:hidden;
  background:var(--bg);
  font-family:'Inter',system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--text);
}

#gameContainer{
  position:relative;
  width:100vw;
  height:100vh;
}

#gameCanvas{
  width:100vw;
  height:100vh;
  display:block;
}

/* HUD */
#hud{
  position:absolute;
  top:0;
  left:0;
  width:100%;
  padding:12px 16px 0;
  z-index:20;
  display:flex;
  flex-direction:column;
  gap:6px;
  pointer-events:none;
}

/* pill istruzioni (desktop) */
.hintCard{
  padding:8px 12px;
  border-radius:999px;
  color:var(--muted);
  font-size:.8rem;
  line-height:1.4;
  max-width:260px;
  background:var(--panel);
  border:1px solid var(--line);
  pointer-events:auto;
  text-align:right;
  opacity: 0.3;
}

.hudBottomRow{
  display:flex;
  justify-content:center;
  align-items:center;
  margin-top:0;
}

/* tabellone */
.scoreStrip{
  display:inline-flex;
  align-items:stretch;
  gap:8px;
  padding:6px 8px;
  border-radius:18px;
  background:var(--panel);
  border:1px solid var(--line);
  pointer-events:auto;
}

.scoreCard{
  min-width:90px;
  padding:6px 10px;
  border-radius:16px;
  text-align:center;
  background:#111;
}

.scoreLabel{
  color:var(--muted);
  font-size:.68rem;
  letter-spacing:.18em;
  text-transform:uppercase;
  margin-bottom:2px;
}

.scoreValue{
  font-size:1.4rem;
  font-weight:800;
  color:var(--accent);
  line-height:1;
}

/* Overlay start/game over */
#overlay{
  position:absolute;
  inset:0;
  z-index:50;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(31,31,31,.96);
  transition:opacity .2s ease, visibility .2s ease;
}

#overlay.hidden{
  opacity:0;
  visibility:hidden;
}

.panel{
  width:min(820px, calc(100vw - 32px));
  border-radius:20px;
  border:1px solid var(--line);
  background:var(--panel);
  box-shadow:var(--shadow);
  padding:22px 24px;
  text-align:left;
}

.panelGrid{
  display:grid;
  grid-template-columns:1.3fr .9fr;
  gap:18px;
}

.kicker{
  font-size:.78rem;
  letter-spacing:.22em;
  text-transform:uppercase;
  color:var(--muted);
  margin-bottom:6px;
}

.panel h2{
  font-size:clamp(1.7rem,4vw,3rem);
  line-height:1.05;
  font-weight:800;
  margin-bottom:10px;
}

.panel p{
  color:var(--muted);
  font-size:.95rem;
  line-height:1.6;
}

.panel .small{
  margin-top:4px;
  font-size:.8rem;
  letter-spacing:-0.05em;
  text-transform:uppercase;
  color:rgba(255,255,255,.5);
  color: var(--accent);
}

.actions{
  display:flex;
  flex-direction:column;
  gap:8px;
  align-items:stretch;
  justify-content:center;
}

button{
  appearance:none;
  border:none;
  cursor:pointer;
  font-family:inherit;
  font-weight:700;
  letter-spacing:.14em;
  text-transform:uppercase;
  padding:12px 16px;
  border-radius:999px;
  transition:transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s ease;
}

.primary{
  background:var(--accent);
  color:#111;
  box-shadow:0 8px 14px rgba(0,0,0,.6);
}

.secondary{
  background:var(--accent);
  color:#111;
  border:1px solid var(--line);
}

button:hover{
  transform:translateY(-5px) !important;
}
button:active{
  transform:translateY(0);
}

/* footer pill */
#footerHint{
  position:absolute;
  left:0;
  right:0;
  bottom:10px;
  z-index:20;
  display:flex;
  justify-content:center;
  pointer-events:none;
}

.footerPill{
  background:var(--panel);
  border:1px solid var(--line);
  color:var(--muted);
  padding:6px 12px;
  border-radius:999px;
  font-size:.75rem;
  pointer-events:auto;
}

/* overlay orientazione mobile */
#orientationOverlay{
  position:absolute;
  inset:0;
  z-index:60;
  background:rgba(31,31,31,.96);
  display:none;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:24px;
}

#orientationOverlay .box{
  border-radius:18px;
  border:1px solid var(--line);
  background:var(--panel);
  padding:16px 18px;
  max-width:320px;
  margin:auto;
}

#orientationOverlay h3{
  font-size:1.1rem;
  margin-bottom:6px;
}

#orientationOverlay p{
  font-size:.9rem;
  color:var(--muted);
}

/* box istruzioni solo mobile dopo start */
#mobileInstructions{
  position:absolute;
  left:50%;
  transform:translateX(-50%);
  bottom:10px;
  z-index:22;
  background:var(--panel);
  border-radius:999px;
  border:1px solid var(--line);
  padding:6px 6px 6px 14px;
  font-size:1rem;
  color:var(--muted);
  display:none;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  text-align:left;
  width:auto;
  max-width:min(72%, 460px);
}

.homeBtn{
  flex-shrink:0;
  background:var(--accent);
  color:#111;
  text-decoration:none;
  font-weight:700;
  font-size:.85rem;
  letter-spacing:.1em;
  text-transform:uppercase;
  padding:6px 14px;
  border-radius:999px;
  pointer-events:auto;
  transition:transform .15s ease;
}
.homeBtn:active{ transform:translateY(1px); }

/* mobile (in base alla larghezza) */
@media (max-width: 820px){
  #hud{
    padding:8px 8px 0;
  }
  .hintCard{
    display:none;
  }
  .scoreStrip{
    padding:4px 6px;
  }
  .scoreCard{
    padding:4px 8px;
    min-width:70px;
  }
  .scoreLabel{
    font-size:.62rem;
    letter-spacing:.16em;
  }
  .scoreValue{
    font-size:1.15rem;
  }
  .panelGrid{
    grid-template-columns:1fr;
  }
  .panel{
    padding:16px 14px;
  }
  #mobileInstructions{
    font-size:.5rem;
    flex-wrap:nowrap;
    white-space:nowrap;
    width:auto;
    max-width:calc(100vw - 24px);
  }
  #mobileInstructions span{
    overflow:hidden;
    text-overflow:ellipsis;
  }
  .homeBtn{
    font-size:.5rem;
    white-space:nowrap;
  }
}
