html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: #8fd3e8; touch-action: none; user-select: none; -webkit-user-select: none; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* Name tags and emote bubbles, positioned from 3D each frame */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -100%);
  font: 600 12px/1 var(--sans); color: #fff; white-space: nowrap;
  background: rgba(20, 20, 24, .55); padding: 4px 8px; border-radius: 99px;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  will-change: transform;
}
.tag.me { background: rgba(20, 20, 24, .78); }
.bubble {
  position: absolute; left: 0; top: 0; font-size: 30px; line-height: 1;
  will-change: transform; animation: bubble 2.2s var(--ease) forwards;
}
@keyframes bubble {
  0% { opacity: 0; scale: .4; }
  12% { opacity: 1; scale: 1.15; }
  20% { scale: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; translate: 0 -24px; }
}

/* HUD */
.hud-top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 12px) 14px 0;
  pointer-events: none;
}
.pill {
  pointer-events: auto; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px 0 10px; border-radius: 99px;
  background: rgba(255, 255, 255, .82); color: #1b1b1d; text-decoration: none;
  font-size: 14px; font-weight: 600;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.pill .icon { width: 18px; height: 18px; }
.here { padding: 0 14px; max-width: 60vw; }
.here span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.here i { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #3fbf6f; box-shadow: 0 0 0 3px rgba(63, 191, 111, .25); }
.here.off i { background: #aaa; box-shadow: none; }

.hud-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 14px calc(env(safe-area-inset-bottom) + 16px);
  pointer-events: none;
}
.enter {
  pointer-events: auto; border: 0; border-radius: 16px; padding: 14px 22px;
  background: #1b1b1d; color: #fff; font: 600 16px var(--sans);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: rise .3s var(--ease);
}
.enter[hidden] { display: none; }
.enter small { display: block; font-weight: 500; font-size: 12px; opacity: .7; margin-top: 2px; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.emotes {
  pointer-events: auto; display: flex; gap: 4px; padding: 5px;
  border-radius: 99px; background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.emotes button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; font-size: 22px; transition: transform .1s, background .15s; }
.emotes button:active { transform: scale(.88); background: rgba(0, 0, 0, .06); }

.joy {
  position: fixed; z-index: 4; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%;
  background: rgba(255, 255, 255, .22); border: 2px solid rgba(255, 255, 255, .6); pointer-events: none;
}
.joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }

.hint {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 108px); max-width: calc(100vw - 32px); white-space: normal; text-align: center; transform: translateX(-50%); z-index: 5;
  background: rgba(20, 20, 24, .6); color: #fff; font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: 99px; pointer-events: none;
  transition: opacity .6s;
}
.hint.fade { opacity: 0; }

/* Intro + fallback cards */
.intro, .nogl {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(180deg, rgba(143, 211, 232, .55), rgba(143, 211, 232, .85));
  transition: opacity .5s;
}
.intro.gone { opacity: 0; pointer-events: none; }
.intro[hidden], .nogl[hidden] { display: none; }
.card {
  width: 100%; max-width: 380px; background: var(--bg-elev); color: var(--ink); border-radius: 22px;
  padding: 26px 22px 22px; text-align: center; box-shadow: 0 20px 60px rgba(0, 40, 60, .25);
}
.card .kicker { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.card h1 { margin: 4px 0 8px; font-family: var(--serif); font-weight: 400; font-size: 42px; letter-spacing: -.02em; line-height: 1; }
.card .lede { margin: 0 0 18px; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.card .small { margin: 14px 0 0; font-size: 12px; color: var(--ink-3); }
.card .btn { width: 100%; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 12px; }
.chip { border: 1px solid var(--border-strong); background: transparent; border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 500; }
.who-form { display: flex; gap: 8px; margin-bottom: 10px; }
.who-form .btn { width: auto; flex: none; }
.who-form input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--ink); font: inherit; font-size: 16px;
}
.link-btn { border: 0; background: none; padding: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- v2 HUD ---------- */
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.hud-row { display: flex; gap: 6px; pointer-events: auto; }
.pill.round { width: 38px; padding: 0; justify-content: center; border: 0; font-size: 17px; }
.pill.ducks { padding: 0 12px; font-size: 13px; }
.pill[hidden] { display: none; }
body:not(.playing) .hud-row, body:not(.playing) .emotes { visibility: hidden; }

.itoasts {
  position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 108px); z-index: 7;
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; padding: 0 16px;
}
.itoast {
  max-width: 420px; text-align: center; background: rgba(20, 20, 24, .78); color: #fff;
  font: 600 14px/1.4 var(--sans); padding: 9px 14px; border-radius: 14px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: tin .3s var(--ease);
}
.itoast.big { font-size: 18px; padding: 12px 18px; background: rgba(20, 20, 24, .88); }
.itoast.out { opacity: 0; transform: translateY(-6px); transition: opacity .35s, transform .35s; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px) scale(.96); } }
.bubble.small { font-size: 14px; font-weight: 700; background: #fff; color: #222; padding: 4px 8px; border-radius: 10px; font-family: var(--sans); }

.golf-panel {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 60px); transform: translateX(-50%); z-index: 6;
  display: flex; gap: 12px; align-items: baseline; white-space: nowrap;
  background: rgba(255, 255, 255, .9); color: #1b1b1d; padding: 8px 14px; border-radius: 14px;
  font: 500 13px var(--sans); box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.golf-panel b { font-weight: 700; font-size: 14px; }
.golf-panel[hidden] { display: none; }

.map { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(10, 30, 40, .45); padding: 16px; }
.map[hidden] { display: none; }
.map-card { background: var(--bg-elev); color: var(--ink); border-radius: 20px; padding: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.map-card p { margin: 2px 4px 10px; font-size: 13px; font-weight: 600; color: var(--ink-2); text-align: center; }
.map-card canvas { display: block; border-radius: 14px; touch-action: manipulation; }
.bubble.say { font-size: 14px; font-weight: 600; background: #fff; color: #222; padding: 6px 10px; border-radius: 12px; font-family: var(--sans); white-space: nowrap; }
@media (max-width: 640px) {
  .golf-panel { top: calc(env(safe-area-inset-top) + 108px); font-size: 12px; gap: 10px; padding: 7px 12px; max-width: calc(100vw - 28px); overflow: hidden; }
}
.pill.round.on { background: #f2a7b8; }
.enter { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* View controls: rotate and tilt, bottom-right */
.cam { position: fixed; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 96px); z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: auto; }
.cam button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .88); color: #1b1b1d; font-size: 22px; line-height: 1; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
.cam button:active { transform: scale(.92); }
.cam .cam-label { font-size: 14px; line-height: 1; margin-top: 2px; opacity: .85; }
.cam input[type="range"] { writing-mode: vertical-lr; direction: rtl; width: 32px; height: 120px; margin: 0; accent-color: #1b1b1d; background: rgba(255, 255, 255, .88); border-radius: 16px; padding: 10px 0; box-shadow: 0 2px 10px rgba(0, 0, 0, .12); touch-action: none; }
body:not(.playing) .cam { visibility: hidden; }
.cam input#camZoom { height: 96px; }
@media (max-width: 640px) { .cam { bottom: calc(env(safe-area-inset-bottom) + 170px); } .cam input[type="range"] { height: 84px; } .cam input#camZoom { height: 72px; } }
