/* La Piazza — HUD + dialogue overlay. Warm Italian palette over the 3D canvas. */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  background: #87b8d8;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
  font-family: 'Baloo 2', sans-serif;
}
#scene { position: fixed; inset: 0; display: block; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud-title {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  font-family: 'Press Start 2P', monospace; font-size: 13px; color: #fff;
  text-shadow: 0 2px 0 rgba(0,0,0,0.45); letter-spacing: 1px;
  background: rgba(42,26,16,0.65); padding: 10px 16px; border-radius: 10px;
  border: 2px solid rgba(201,162,39,0.7);
  transition: opacity 1s ease;
  white-space: nowrap;
}
#hud-frasario {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 14px;
  font-family: 'Press Start 2P', monospace; font-size: 12px; color: #ffe27a;
  background: rgba(42,26,16,0.75); padding: 9px 12px; border-radius: 10px;
  border: 2px solid rgba(201,162,39,0.5);
}
#mute-btn {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px;
  pointer-events: auto; width: 42px; height: 42px; font-size: 20px;
  background: rgba(42,26,16,0.75); color: #fff; border: 2px solid rgba(255,235,200,0.3);
  border-radius: 10px; cursor: pointer;
}
#hud-hint {
  position: absolute; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%;
  transform: translateX(-50%);
  font-size: 14px; font-weight: 700; color: rgba(255,255,255,0.92);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
  background: rgba(0,0,0,0.28); padding: 6px 14px; border-radius: 999px;
  white-space: nowrap;
}

/* ---------- proximity prompt ---------- */
#talk-prompt {
  position: fixed; left: 50%; bottom: 22%; transform: translateX(-50%);
  z-index: 11; text-align: center; color: #fff;
  font-family: 'Press Start 2P', monospace; font-size: 12px; line-height: 1.9;
  background: rgba(42,26,16,0.85); border: 2px solid #c9a227;
  padding: 12px 18px; border-radius: 12px;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4);
  animation: bob 1.1s ease-in-out infinite;
}
#talk-prompt b { color: #8fe0a0; }
#talk-btn {
  position: fixed; right: 20px; bottom: max(96px, calc(env(safe-area-inset-bottom) + 84px));
  z-index: 12; font-family: 'Press Start 2P', monospace; font-size: 14px;
  background: #2ec07a; color: #fff; border: 3px solid rgba(255,255,255,0.4);
  border-radius: 16px; padding: 18px 20px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  animation: bob 1.1s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
#talk-prompt.hidden, #talk-btn.hidden { display: none; }

/* ---------- virtual joystick ---------- */
#joystick {
  position: fixed; left: 26px; bottom: max(26px, calc(env(safe-area-inset-bottom) + 14px));
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.35);
  z-index: 12; touch-action: none;
}
#stick {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: rgba(255,255,255,0.55); border: 2px solid rgba(0,0,0,0.15);
}
#joystick.hidden { display: none; }

/* ---------- dialogue overlay ---------- */
.hidden { display: none !important; }
#dialogue {
  position: fixed; inset: 0; z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; justify-content: flex-end;
}
#figura-wrap {
  position: absolute; top: max(12px, env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%); width: min(88vw, 560px); pointer-events: none;
}
#figura-bar {
  position: relative; height: 16px; border-radius: 8px;
  background: linear-gradient(90deg, #c0392b, #c9a227, #2ec07a);
  border: 2px solid rgba(0,0,0,0.35); box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
#figura-marker {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 18px; text-shadow: 0 2px 2px rgba(0,0,0,0.6);
  transition: left 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#figura-labels {
  display: flex; justify-content: space-between; margin-top: 3px;
  font-family: 'Press Start 2P', monospace; font-size: 8px;
}
#figura-labels span:first-child { color: #ffb3a7; }
#figura-labels span:last-child { color: #a7e8c3; }

#dlg-panel {
  pointer-events: auto;
  background: rgba(26,16,10,0.96);
  border-top: 3px solid #c9a227;
  padding: 14px 18px calc(max(14px, env(safe-area-inset-bottom)) + 8px);
  max-height: 62vh; overflow-y: auto;
}
#dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
#dlg-speaker { font-family: 'Press Start 2P', monospace; font-size: 12px; color: #c9a227; }
#dlg-tools button {
  font-family: 'Press Start 2P', monospace; font-size: 11px; margin-left: 8px;
  background: #2a1a10; color: #8fe0a0; border: 1px solid rgba(201,162,39,0.5);
  border-radius: 8px; padding: 6px 9px; cursor: pointer;
}
#dlg-line { font-size: 21px; font-weight: 800; color: #ffe9c2; line-height: 1.3; }
#dlg-en-text { font-size: 14px; font-style: italic; color: #c9a26a; margin-top: 4px; min-height: 0; }
#dlg-choices { margin-top: 12px; display: flex; flex-direction: column; gap: 9px; }
.dlg-choice {
  text-align: left; font-family: 'Baloo 2', sans-serif; font-size: 17px; font-weight: 700;
  color: #ffe9c2; background: #2a1a10; border: 2px solid rgba(201,162,39,0.55);
  border-radius: 12px; padding: 12px 14px; cursor: pointer;
  opacity: 0; transform: translateY(14px);
  animation: choiceIn 0.24s ease-out forwards;
}
.dlg-choice:hover { border-color: #ffe27a; }
@keyframes choiceIn { to { opacity: 1; transform: translateY(0); } }

/* ---------- outcome / result card ---------- */
#card {
  position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,0.82);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#card-inner { max-width: 620px; width: 100%; text-align: center; }
#card-react { font-size: 22px; font-weight: 800; color: #ffe9c2; line-height: 1.35; }
#card-react-en { font-size: 14px; font-style: italic; color: #c9a26a; margin-top: 8px; }
#card-verdict { font-family: 'Press Start 2P', monospace; font-size: 17px; margin-top: 18px; }
#card-tip { font-size: 17px; font-weight: 600; color: #f4ede0; line-height: 1.45; margin-top: 14px; }
#card-phrase {
  display: inline-block; margin-top: 16px; font-size: 15px; font-weight: 800; color: #ffe27a;
  background: #3a2214; border-radius: 10px; padding: 9px 14px;
}
#card-btn {
  display: block; margin: 26px auto 0; font-family: 'Press Start 2P', monospace;
  font-size: 14px; color: #fff; background: #2ec07a; border: none; border-radius: 12px;
  padding: 15px 22px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,0.3);
}
#card-btn.retry { background: #c0392b; }

#loading {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: #87b8d8; color: #2a1a10;
  font-family: 'Press Start 2P', monospace; font-size: 14px;
  transition: opacity 0.5s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; display: flex !important; }
