/* VIA GUBBIO 6 — layout stile Game Boy */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: #2c2137;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#gb {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#screen-wrap {
  position: relative;
  line-height: 0;
  border: 6px solid #1a1a1a;
  border-radius: 8px;
  background: #1a1a1a;
  box-shadow: 0 8px 30px rgba(0,0,0,.6);
}

canvas#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
  background: #0f0f1a;
}

#audio-btn {
  position: absolute;
  top: 4px; right: 4px;
  z-index: 5;
  background: rgba(26,26,26,.55);
  color: #f5f0e8;
  border: 1px solid #f5f0e8;
  border-radius: 4px;
  font-size: 14px;
  padding: 3px 5px;
  cursor: pointer;
  line-height: 1;
}

/* ---------- Controlli touch ---------- */
#controls {
  display: none;
  width: 100%;
  max-width: 480px;
  justify-content: space-between;
  align-items: center;
  padding: 0 26px;
}
body.touch #controls { display: flex; }

#dpad {
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
}
#d-up    { grid-area: 1 / 2; border-radius: 10px 10px 0 0; }
#d-left  { grid-area: 2 / 1; border-radius: 10px 0 0 10px; }
#d-right { grid-area: 2 / 3; border-radius: 0 10px 10px 0; }
#d-down  { grid-area: 3 / 2; border-radius: 0 0 10px 10px; }

.dbtn, #abtn {
  background: #1a1a1a;
  color: #888;
  border: 2px solid #000;
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
}
.dbtn:active, #abtn:active { background: #3a3a3a; color: #fff; }

#abtn {
  width: 74px; height: 74px;
  border-radius: 50%;
  background: #a02040;
  color: #fff;
  font-size: 24px;
  box-shadow: 0 4px 0 #601020;
}
#abtn:active { background: #c03050; transform: translateY(2px); box-shadow: 0 2px 0 #601020; }

/* ---------- Overlay rotazione ---------- */
#rotate-overlay {
  display: none;
  position: fixed; inset: 0;
  background: #1a1a1a;
  color: #f5f0e8;
  z-index: 100;
  text-align: center;
  font-size: 14px;
  line-height: 2;
  align-items: center;
  justify-content: center;
}
@media (orientation: landscape) and (pointer: coarse) and (max-height: 500px) {
  #rotate-overlay { display: flex; }
}

/* ---------- Blocco mobile: apri da PC ---------- */
#pc-only {
  display: none;
  position: fixed; inset: 0;
  background: #1a1a1a;
  color: #f5f0e8;
  z-index: 200;
  text-align: center;
  font-size: 15px;
  line-height: 2.2;
  padding: 24px;
  align-items: center;
  justify-content: center;
}
body.is-mobile #pc-only { display: flex; }

/* ---------- Schermata regalo ---------- */
.hidden { display: none !important; }

#gift {
  position: absolute; inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 15, 26, .55);
  line-height: normal;
  animation: gift-in 1s ease-out;
}
@keyframes gift-in { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }

#gift-box {
  background: #f5f0e8;
  color: #1a1a1a;
  border: 3px solid #1a1a1a;
  outline: 3px solid #f5f0e8;
  outline-offset: 2px;
  border-radius: 4px;
  padding: 14px 12px;
  width: 92%;
  max-width: 330px;
  text-align: center;
  font-size: 9px;
  line-height: 1.8;
  user-select: text;
  -webkit-user-select: text;
}
.gift-title { font-size: 11px; color: #b5651d; margin-bottom: 8px; }
#gift-box p { margin: 6px 0; }
#gift-link {
  display: inline-block;
  margin: 6px 0;
  color: #d63031;
  font-size: 11px;
  text-decoration: underline;
}
#gift-code-row {
  margin: 8px 0;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
#gift-code {
  background: #1a1a1a;
  color: #f4d03f;
  padding: 6px 8px;
  letter-spacing: 1px;
  font-size: 10px;
  user-select: all;
  -webkit-user-select: all;
}
#gift-joke {
  font-size: 8px;
  line-height: 1.6;
  color: #8b6f47;
  background: #efe7d8;
  border: 1px dashed #b5651d;
  padding: 6px 7px;
  margin: 8px 0;
  text-align: left;
}
#gift-question { font-size: 9px; line-height: 1.7; margin: 8px 0 6px; }
#gift-answer {
  font-family: inherit;
  font-size: 9px;
  width: 92%;
  padding: 7px 6px;
  margin: 4px 0 8px;
  border: 2px solid #1a1a1a;
  background: #fff;
  color: #1a1a1a;
  text-align: center;
}
#gift-answer:focus { outline: 2px solid #b5651d; }
#gift-unlock {
  font-family: inherit;
  font-size: 8px;
  background: #b5651d;
  color: #fff;
  border: 2px solid #1a1a1a;
  padding: 7px 8px;
  cursor: pointer;
}
#gift-unlock:active { transform: translateY(1px); }
#gift-error { color: #d63031; margin-top: 8px; }
#copy-btn, #replay-btn {
  font-family: inherit;
  font-size: 8px;
  background: #d63031;
  color: #fff;
  border: 2px solid #1a1a1a;
  padding: 6px 8px;
  cursor: pointer;
}
#copy-btn:active, #replay-btn:active { transform: translateY(1px); }
#replay-btn { margin-top: 8px; background: #8b6f47; }
.gift-sign { color: #555; }
