/* AyAyPotters — 3D world HUD styles */
:root {
  --ink: #5b4230;
  --outline: #8a6237;
  --cream: #fff9ee;
  --coral: #e2543e;
  --coral-deep: #c23f2e;
  --gold: #eebb52;
  --gold-deep: #cf9c2e;
  --night: #1b1440;
  --font-display: "Fredoka", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

button, a { touch-action: manipulation; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--night);
  font-family: var(--font-body);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.grabbing { cursor: grabbing; }

/* ---------- intro overlay ---------- */
.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)) 16px;
  background:
    radial-gradient(circle at 50% 15%, rgba(238, 187, 82, 0.16), transparent 45%),
    rgba(27, 20, 64, 0.94);
  transition: opacity 0.5s ease;
}
.intro-overlay.hidden { opacity: 0; pointer-events: none; }
.intro-card {
  margin: auto;
  flex-shrink: 0;
  width: min(480px, 94vw);
  background: var(--cream);
  border: 4px solid var(--outline);
  border-radius: 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  padding: clamp(20px, 5vw, 34px);
  text-align: center;
  color: var(--ink);
  animation: cardPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes cardPop {
  from { transform: translateY(40px) scale(0.8); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.intro-stars { color: var(--gold-deep); font-size: 1.2rem; margin-bottom: 6px; }
.intro-card h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 6vw, 2.1rem);
  margin-bottom: 4px;
}
.intro-tag {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--coral-deep);
  margin-bottom: 10px;
  font-size: clamp(0.9rem, 3vw, 1.05rem);
}
.intro-text { font-weight: 800; margin-bottom: 12px; }
.intro-howto {
  list-style: none;
  text-align: left;
  background: #fff;
  border: 3px dashed var(--outline);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.intro-howto li { font-weight: 800; font-size: clamp(0.9rem, 3vw, 1rem); margin: 6px 0; }
.enter-world-btn {
  width: 100%;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  color: #fff;
  background: linear-gradient(180deg, var(--coral) 0%, var(--coral-deep) 100%);
  border: 3px solid #8f2b1e;
  border-radius: 999px;
  padding: 16px;
  cursor: pointer;
  box-shadow: 0 6px 0 #8f2b1e;
  animation: pulseBtn 1.6s ease-in-out infinite;
}
.enter-world-btn:active { animation: none; transform: translateY(4px); box-shadow: 0 1px 0 #8f2b1e; }
@keyframes pulseBtn {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}

/* ---------- HUD ---------- */
.hud-top {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 10px;
  right: 10px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.hud-pill {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(0.82rem, 2.8vw, 1rem);
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--outline);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}
.hud-score.bump { animation: bump 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes bump { 50% { transform: scale(1.25) rotate(-3deg); } }
.hud-right {
  margin-left: auto;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.hud-btn {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  font-size: 1.25rem;
  background: var(--cream);
  border: 3px solid var(--outline);
  border-radius: 50%;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s;
}
.hud-btn:active { transform: translateY(3px); box-shadow: none; }

/* GOAL! flash */
.goal-flash {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  align-content: center;
  justify-items: center;
  gap: 4px;
  pointer-events: none;
  opacity: 0;
}
.goal-flash span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.8rem, 13vw, 6.5rem);
  color: #ffe9b0;
  letter-spacing: 0.04em;
  text-shadow: 0 5px 0 #c23f2e, 0 12px 34px rgba(0, 0, 0, 0.55);
  white-space: nowrap;
}
.goal-flash .siuu {
  font-size: clamp(1.6rem, 7vw, 3.4rem);
  color: #8ef0a0;
  text-shadow: 0 4px 0 #205c39, 0 10px 26px rgba(0, 0, 0, 0.55);
}
.goal-flash.show { animation: goalPop 1.25s cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes goalPop {
  0%   { opacity: 0; transform: scale(0.25) rotate(-8deg); }
  14%  { opacity: 1; transform: scale(1.15) rotate(3deg); }
  28%  { transform: scale(0.98) rotate(0deg); }
  75%  { opacity: 1; transform: scale(1.02); }
  100% { opacity: 0; transform: scale(1.08); }
}

/* toast */
.toast {
  position: fixed;
  top: max(70px, calc(env(safe-area-inset-top) + 62px));
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  z-index: 45;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1rem, 3.6vw, 1.3rem);
  color: var(--ink);
  background: var(--gold);
  border: 3px solid var(--outline);
  border-radius: 999px;
  padding: 12px 22px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 92vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- bottom HUD ---------- */
.hud-bottom {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 10px;
}
.house-row {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.house-btn {
  width: 48px;
  height: 48px;
  font-size: 1.3rem;
  border-radius: 50%;
  border: 3px solid var(--outline);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.15s;
  display: grid;
  place-items: center;
}
.house-btn:active { transform: translateY(3px); box-shadow: none; }
.house-btn.active { outline: 4px solid #fff; outline-offset: 1px; transform: scale(1.08); }
.house-btn.gry { background: linear-gradient(135deg, #c23f2e 50%, #eebb52 50%); }
.house-btn.sly { background: linear-gradient(135deg, #2f7d4f 50%, #cfd8d2 50%); }
.house-btn.rav { background: linear-gradient(135deg, #2f5d8a 50%, #cd9a5b 50%); }
.house-btn.huf { background: linear-gradient(135deg, #e0b135 50%, #4a423c 50%); }

.spell-bar {
  display: flex;
  gap: 8px;
  pointer-events: auto;
  flex-wrap: wrap;
  justify-content: center;
}
.spell-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 76px;
  font-family: var(--font-display);
  background: var(--cream);
  border: 3px solid var(--outline);
  border-radius: 18px;
  padding: 8px 12px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
.spell-btn:active { transform: translateY(4px); box-shadow: none; }
.spell-btn.active { background: var(--gold); outline: 3px solid #fff; }
.spell-btn .s-ico { font-size: 1.35rem; line-height: 1; }
.spell-btn .s-name { font-weight: 700; font-size: 0.78rem; color: var(--ink); }

.hint {
  pointer-events: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(0.78rem, 2.6vw, 0.95rem);
  color: rgba(255, 249, 238, 0.85);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  text-align: center;
}

@media (max-width: 640px) {
  .hud-title { display: none; }
  .hud-pill .pw { display: none; }
  .hud-pill { padding: 8px 11px; }
  .spell-btn { min-width: 64px; padding: 7px 8px; }
  .spell-btn .s-name { font-size: 0.7rem; }
}

@media (max-height: 700px) {
  .intro-card { padding: 16px; }
  .intro-card h1 { font-size: 1.35rem; }
  .intro-howto { padding: 10px 12px; margin-bottom: 12px; }
  .intro-howto li { margin: 4px 0; }
  .enter-world-btn { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
