html { scroll-behavior: smooth; }

body {
  /* Sfondo elegante a strati: gradiente + texture sottile */
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(201,169,97,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 100% 60% at 50% 100%, rgba(201,169,97,0.03) 0%, transparent 60%),
    #0a0a0a;
}

/* ============================================================
   Tastiera
   ============================================================ */

.key {
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.key:focus-visible {
  outline: 2px solid #c9a961;
  outline-offset: -3px;
}

/* Tasti bianchi */
.key-white {
  background: linear-gradient(180deg, #f6f1e6 0%, #f1ead9 65%, #e1d8c0 100%);
  border-left: 1px solid #6a5d3f;
  border-right: 1px solid #2a2418;
  border-top: 1px solid #d8cfb6;
  border-bottom: 6px solid #2a2418;
  border-radius: 0 0 6px 6px;
  box-shadow:
    inset 0 -8px 18px -8px rgba(85, 70, 38, 0.45),
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 4px 0 rgba(0,0,0,0.4),
    0 12px 24px -8px rgba(0,0,0,0.6);
  transition: transform 80ms ease-out, box-shadow 80ms ease-out, background 200ms ease;
  position: relative;
}
.key-white:first-child { border-top-left-radius: 4px; }
.key-white:last-child { border-top-right-radius: 4px; }

.key-white:hover {
  background: linear-gradient(180deg, #fbf6ec 0%, #f4ede0 65%, #e6ddc6 100%);
}
.key-white.is-pressed,
.key-white:active {
  background: linear-gradient(180deg, #e2dac4 0%, #d8d0b8 70%, #c9c0a4 100%);
  transform: translateY(2px);
  border-bottom-width: 3px;
  box-shadow:
    inset 0 -4px 12px -6px rgba(85, 70, 38, 0.6),
    inset 0 2px 8px rgba(85, 70, 38, 0.3),
    0 1px 0 rgba(0,0,0,0.4),
    0 4px 12px -4px rgba(0,0,0,0.5);
}

/* Tasti neri */
.key-black {
  height: 62%;
  background: linear-gradient(180deg, #2a2a2a 0%, #1a1a1a 50%, #0a0a0a 100%);
  border-left: 1px solid #444;
  border-right: 1px solid #000;
  border-top: 1px solid #555;
  border-bottom: 4px solid #000;
  border-radius: 0 0 4px 4px;
  box-shadow:
    inset 0 -3px 6px -2px rgba(255,255,255,0.08),
    inset 0 -10px 20px -10px rgba(255,200,100,0.15),
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 4px 8px rgba(0,0,0,0.7);
  z-index: 10;
  transition: transform 80ms ease-out, box-shadow 80ms ease-out, background 200ms ease;
}
.key-black:hover {
  background: linear-gradient(180deg, #353535 0%, #222 50%, #0e0e0e 100%);
}
.key-black.is-pressed,
.key-black:active {
  background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 50%, #000 100%);
  transform: translateY(2px);
  border-bottom-width: 2px;
  box-shadow:
    inset 0 -2px 4px rgba(255,200,100,0.2),
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 1px 4px rgba(0,0,0,0.7);
}

/* Glow oro quando attivo */
.key-white.is-pressed .key-label,
.key-white.is-active .key-label {
  color: #8a6f2c;
}
.key-black.is-pressed .key-label-black,
.key-black.is-active .key-label-black {
  color: #e0c585;
  text-shadow: 0 0 8px rgba(201, 169, 97, 0.6);
}

.key-label, .key-label-black {
  pointer-events: none;
}

/* ============================================================
   Pannello (modale di sezione)
   ============================================================ */

.panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  pointer-events: none;
}
.panel.is-open { pointer-events: auto; }
.panel.hidden { display: none; }

.panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10,10,10,0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 350ms ease;
}
.panel.is-open .panel-backdrop { opacity: 1; }

.panel-card {
  position: relative;
  width: 100%;
  max-width: 720px;
  height: 100%;
  background: linear-gradient(180deg, #141414 0%, #0a0a0a 100%);
  border-left: 1px solid rgba(201,169,97,0.25);
  padding: clamp(2rem, 4vw, 3.5rem) clamp(1.5rem, 4vw, 3rem);
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 450ms cubic-bezier(.2,.85,.25,1);
  display: flex;
  flex-direction: column;
}
.panel.is-open .panel-card { transform: translateX(0); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.panel-close {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(245, 240, 232, 0.15);
  border-radius: 50%;
  color: #f5f0e8;
  background: transparent;
  transition: all 180ms ease;
  cursor: pointer;
}
.panel-close:hover {
  border-color: #c9a961;
  color: #c9a961;
  transform: rotate(90deg);
}

.panel-body {
  margin-top: 1.5rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: rgba(245, 240, 232, 0.78);
}
.panel-body .lede {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  line-height: 1.45;
  color: #f5f0e8;
  font-style: italic;
  margin-bottom: 1.25rem;
  position: relative;
  padding-left: 1rem;
}
.panel-body .lede::before {
  content: '';
  position: absolute;
  left: 0; top: 0.4rem; bottom: 0.4rem;
  width: 2px;
  background: #c9a961;
}
.panel-body p { margin-bottom: 1rem; }
.panel-body .muted { color: rgba(245, 240, 232, 0.5); }
.panel-body a {
  color: #e0c585;
  text-decoration: underline;
  text-decoration-color: rgba(201,169,97,0.4);
  text-underline-offset: 3px;
  transition: color 200ms ease;
}
.panel-body a:hover { color: #c9a961; }

.panel-body .quote {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-left: 2px solid #c9a961;
  font-family: 'Playfair Display', serif;
  font-style: italic;
  color: #f5f0e8;
  font-size: 1.25rem;
}

.panel-body .simple {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.panel-body .simple li {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(245,240,232,0.08);
}
.panel-body .simple.no-bullet li { border: none; padding: 0.35rem 0; }
.panel-body .simple li::before { content: '· '; color: #c9a961; }
.panel-body .simple.no-bullet li::before { content: ''; }
.panel-body .simple strong { color: #f5f0e8; }

.panel-body .cta {
  display: inline-flex;
  align-items: center;
  padding: 0.85rem 1.75rem;
  background: #c9a961;
  color: #0a0a0a;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  text-decoration: none;
  margin-top: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background 200ms ease;
}
.panel-body .cta:hover { background: #e0c585; color: #0a0a0a; }

/* Form contatti */
.contact-grid { display: grid; gap: 2rem; }
@media (min-width: 768px) {
  .contact-grid { grid-template-columns: 1fr 1.3fr; gap: 3rem; }
}
.contact-form { display: flex; flex-direction: column; gap: 1rem; }
.contact-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(201,169,97,0.85);
  font-family: 'Inter', system-ui, sans-serif;
}
.contact-form input,
.contact-form select,
.contact-form textarea {
  background: #1f1f1f;
  border: 1px solid rgba(245,240,232,0.15);
  color: #f5f0e8;
  padding: 0.75rem 0.9rem;
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  transition: border-color 180ms ease;
}
.contact-form input:focus,
.contact-form select:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: #c9a961;
}
.contact-form textarea { resize: vertical; min-height: 120px; }
.contact-form .err {
  color: #fca5a5;
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.contact-form .form-error-global {
  background: rgba(127, 29, 29, 0.25);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  text-transform: none;
  letter-spacing: 0;
}
.contact-form button.cta {
  align-self: flex-start;
  margin-top: 0.5rem;
}

/* ============================================================
   Stage / intro / hint
   ============================================================ */

#stage { min-height: 100vh; }

#intro {
  transition: opacity 400ms ease, transform 400ms ease;
}
body.has-played #intro {
  opacity: 0.35;
  transform: translateY(-8px);
}

@media (max-width: 767px) {
  #stage { padding-top: 7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .panel-card, .panel-backdrop, .key-white, .key-black, #intro { transition: none !important; }
  .panel-close:hover { transform: none; }
}
