* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #a8def0; touch-action: none; overscroll-behavior: none; }
body { font-family: "Segoe UI", system-ui, sans-serif; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
/* Explicit position+z-index (not just document order) so the WebGL canvas can't
   get compositor-promoted above the DOM UI on mobile/VR browsers — some
   Chromium-based browsers (Quest Browser included) hoist a canvas onto its own
   hardware surface that ignores normal paint order once WebXR is in play. */
canvas { display: block; touch-action: none; position: fixed; inset: 0; z-index: 0; }

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#topbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(46, 36, 28, 0.72); color: #fdf3e3;
  padding: 8px 20px; border-radius: 999px; font-size: 15px; font-weight: 600;
  letter-spacing: 0.3px; white-space: nowrap;
  box-shadow: 0 3px 12px rgba(0,0,0,0.25);
}

#stamina-wrap {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%);
  width: 220px; height: 12px; border-radius: 999px;
  background: rgba(46, 36, 28, 0.6); overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
#stamina-fill { height: 100%; width: 100%; background: #8ed86f; border-radius: 999px; transition: width 0.25s; }

#hotbar {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px;
}
.slot {
  position: relative; width: 54px; height: 54px; border-radius: 14px;
  background: rgba(46, 36, 28, 0.68); border: 2px solid rgba(253, 243, 227, 0.25);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
}
.slot.active { border-color: #ffd97a; background: rgba(84, 62, 38, 0.85); transform: translateY(-4px); }
.slot .key {
  position: absolute; top: 2px; left: 6px; font-size: 10px; color: #fdf3e3aa; font-weight: 700;
}
.slot .count {
  position: absolute; bottom: 1px; right: 5px; font-size: 11px; color: #ffd97a; font-weight: 700;
}

#prompt {
  position: absolute; bottom: 92px; left: 50%; transform: translateX(-50%) translateY(6px);
  background: rgba(46, 36, 28, 0.8); color: #ffe9c4; padding: 8px 18px;
  border-radius: 999px; font-size: 15px; font-weight: 600; opacity: 0;
  transition: opacity 0.15s, transform 0.15s; white-space: nowrap;
}
#prompt.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#toasts {
  position: absolute; top: 90px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
}
.toast {
  background: rgba(253, 243, 227, 0.94); color: #4a3826; padding: 8px 18px;
  border-radius: 14px; font-size: 14px; font-weight: 600; max-width: 480px; text-align: center;
  opacity: 0; transform: translateY(-8px); transition: all 0.3s;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.toast.show { opacity: 1; transform: translateY(0); }

#help {
  position: absolute; bottom: 8px; left: 12px;
  color: rgba(255,255,255,0.75); font-size: 12px; text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

#shop {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95);
  width: 380px; max-height: 80vh; overflow-y: auto;
  background: rgba(253, 243, 227, 0.97); border-radius: 20px; padding: 22px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: all 0.2s;
}
#shop.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
#shop h2 { color: #4a3826; font-size: 20px; margin-bottom: 4px; }
#shop .coins { color: #b0812e; font-weight: 700; margin-bottom: 10px; }
#shop .shop-section {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px;
  color: #9a8468; font-weight: 700; margin: 12px 0 6px;
}
#shop .goods { font-size: 13px; color: #6b5844; margin-bottom: 8px; }
#shop .tabs { display: flex; gap: 6px; margin: 10px 0 4px; }
#shop button.tab {
  flex: 1; margin: 0; padding: 8px 4px; text-align: center; font-size: 13px;
  background: #e6d8be; color: #7a6849;
}
#shop button.tab.on { background: #4a3826; color: #fdf3e3; }
#shop button.tab:hover:not(.on) { background: #dcccae; }
#shop .swatches { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 8px; }
#shop button.chip {
  width: 38px; height: 38px; margin: 0; padding: 0; flex: none;
  border-radius: 10px; border: 3px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18);
}
#shop button.chip.on { border-color: #4a3826; transform: scale(1.06); }
#shop button.chip:hover { border-color: #b0a189; }
#shop .goods.warn { color: #a8562f; font-weight: 600; }
#shop .goods.locked { opacity: 0.55; margin-bottom: 4px; }
#shop .rehome {
  float: right; color: #4a7a3a; font-weight: 700; font-size: 12px;
  background: #dfeccd; padding: 2px 8px; border-radius: 8px;
}
#shop button:disabled .rehome { background: #e4ddcd; color: #97907f; }
#shop .breed {
  font-size: 13px; color: #4a3826; padding: 5px 4px;
  border-bottom: 1px solid rgba(122, 104, 73, 0.14);
}
#shop .breed.unknown { color: #9a8f80; font-style: italic; }
#shop .sw {
  display: inline-block; width: 15px; height: 15px; border-radius: 4px;
  margin-right: 8px; vertical-align: -2px; border: 1px solid rgba(0,0,0,0.18);
}
#shop button {
  display: block; width: 100%; margin: 5px 0; padding: 10px 14px;
  border: none; border-radius: 12px; background: #f0e2c8; color: #4a3826;
  font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
  font-family: inherit; transition: background 0.12s;
}
#shop button:hover:not(:disabled) { background: #ffd97a; }
#shop button:disabled { opacity: 0.45; cursor: default; }
#shop button .own { color: #9a8468; font-weight: 500; font-size: 12px; }

#touch-ui { display: none; }
body.touch #touch-ui { display: block; }
body.touch #help { display: none; }
body.touch #hotbar { bottom: 26px; }
.slot { pointer-events: auto; }

/* Floating stick: rests bottom-left as a hint, springs to wherever you touch
   in the left half of the screen. Purely visual — the canvas handles input. */
#joy {
  position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px;
  border-radius: 50%; background: rgba(46, 36, 28, 0.28);
  border: 2px solid rgba(253, 243, 227, 0.28);
  pointer-events: none; opacity: 0.38;
  transition: opacity 0.12s;
}
#joy.on { opacity: 1; background: rgba(46, 36, 28, 0.42); border-color: rgba(253, 243, 227, 0.5); }
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px;
  margin: -29px 0 0 -29px; border-radius: 50%;
  background: rgba(253, 243, 227, 0.85); box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
#btn-use, #btn-act, #btn-rot, #btn-done {
  position: absolute; right: 30px; width: 68px; height: 68px; border-radius: 50%;
  background: rgba(46, 36, 28, 0.55); border: 2px solid rgba(253, 243, 227, 0.4);
  align-items: center; justify-content: center; font-size: 30px;
  pointer-events: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
#btn-use, #btn-act { display: flex; }
#btn-use { bottom: 118px; }
#btn-act { bottom: 34px; right: 116px; }
#btn-rot, #btn-done { display: none; }
body.touch.decorating #btn-rot { display: flex; bottom: 202px; }
body.touch.decorating #btn-done { display: flex; bottom: 118px; right: 116px; font-size: 26px; }
#btn-use:active, #btn-act:active, #btn-rot:active, #btn-done:active {
  background: rgba(84, 62, 38, 0.85); transform: scale(0.94);
}

#mode {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%);
  background: rgba(224, 138, 90, 0.92); color: #fff6e8;
  padding: 5px 16px; border-radius: 999px; font-size: 13px; font-weight: 700;
  letter-spacing: 0.4px; opacity: 0; transition: opacity 0.2s; white-space: nowrap;
}
body.decorating #mode { opacity: 1; }

#sound-toggle {
  position: absolute; top: 12px; right: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(46, 36, 28, 0.6); border: 2px solid rgba(253, 243, 227, 0.28);
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  pointer-events: auto; cursor: pointer; user-select: none;
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
}
#sound-toggle:active { transform: scale(0.93); }
#sound-toggle.off { opacity: 0.5; }

#cam-orbit {
  position: absolute; top: 60px; right: 14px;
  display: flex; gap: 8px; pointer-events: none;
}
.cam-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(46, 36, 28, 0.55); border: 2px solid rgba(253, 243, 227, 0.26);
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  color: #fdf3e3; pointer-events: auto; cursor: pointer; user-select: none;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  touch-action: none;
}
.cam-btn:active, .cam-btn.pressed { background: rgba(84, 62, 38, 0.85); transform: scale(0.92); }

#coma {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(28, 24, 44, 0.72); color: #e9e2f5;
  padding: 14px 28px; border-radius: 18px; font-size: 15px; font-weight: 600;
  letter-spacing: 0.3px; text-align: center; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity 0.5s;
  box-shadow: 0 8px 28px rgba(0,0,0,0.3);
}
body.comatose #coma { opacity: 1; }
body.comatose canvas { filter: saturate(0.55) brightness(0.8); transition: filter 0.6s; }

/* furniture strip replaces the hotbar while decorating */
.slot.furn {
  width: auto; min-width: 78px; max-width: 130px; height: 54px; padding: 0 10px 0 14px;
  font-size: 12px; font-weight: 600; color: #fdf3e3; text-align: center; line-height: 1.15;
}
.slot.furn .fname { display: block; }
.empty-strip {
  background: rgba(46, 36, 28, 0.68); color: #fdf3e3cc; padding: 10px 18px;
  border-radius: 14px; font-size: 13px;
}

#fade {
  position: absolute; inset: 0; background: #0c0a14;
  display: flex; align-items: center; justify-content: center;
  color: #fdf3e3; font-size: 22px; font-weight: 600;
  opacity: 0; transition: opacity 0.8s; pointer-events: none;
}
#fade.show { opacity: 1; }

body.mainmenu #hud { display: none; }

#pause-btn {
  position: absolute; top: 12px; left: 14px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(46, 36, 28, 0.6); border: 2px solid rgba(253, 243, 227, 0.28);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  pointer-events: auto; cursor: pointer; user-select: none;
  box-shadow: 0 3px 10px rgba(0,0,0,0.22);
}
#pause-btn:active { transform: scale(0.93); }

#vr-button {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  padding: 10px 22px; border-radius: 22px;
  background: rgba(46, 36, 28, 0.72); border: 2px solid rgba(253, 243, 227, 0.3);
  color: #fdf3e3; font: 700 13px/1 system-ui, sans-serif; letter-spacing: 0.04em;
  cursor: pointer; user-select: none; z-index: 30;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
#vr-button:disabled { opacity: 0.5; cursor: default; }
#vr-button:active:not(:disabled) { transform: translateX(-50%) scale(0.95); }

.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 16, 12, 0.55);
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }

/* Title screen: a slim card tucked in the corner so the cinematic scene reads
   as the main event, not just a backdrop behind a big centred dialog. */
#main-menu {
  align-items: flex-start; justify-content: flex-end;
  background: transparent; padding: 22px;
}
#main-menu .menu-card {
  width: 210px; padding: 18px 16px;
}
#main-menu .menu-card h1 { font-size: 19px; }
#main-menu .menu-tag { font-size: 10.5px; margin-bottom: 14px; }
#main-menu .menu-btn { font-size: 13px; padding: 10px 12px; }
.menu-card {
  width: 340px; max-width: 88vw; max-height: 82vh; overflow-y: auto;
  background: rgba(253, 243, 227, 0.97); border-radius: 20px; padding: 26px 24px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.4); text-align: center;
}
.menu-card h1 { color: #4a3826; font-size: 26px; margin-bottom: 4px; }
.menu-card h2 { color: #4a3826; font-size: 20px; margin-bottom: 14px; }
.menu-tag { color: #9a8468; font-size: 13px; margin-bottom: 20px; font-style: italic; }
.menu-btn {
  display: block; width: 100%; margin: 8px 0 0; padding: 12px 16px;
  border: none; border-radius: 14px; background: #e6d8be; color: #4a3826;
  font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background 0.12s, transform 0.1s;
}
.menu-btn:hover { background: #ddceac; }
.menu-btn:active { transform: scale(0.97); }
.menu-btn.primary { background: #ffd97a; }
.menu-btn.opt.on { background: #4a3826; color: #fdf3e3; }
.menu-btn.opt.on:hover { background: #4a3826; }
.menu-section {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px;
  color: #9a8468; font-weight: 700; margin: 14px 0 8px; text-align: left;
}
.menu-card > .menu-section:first-of-type { margin-top: 4px; }
.menu-btn.primary:hover { background: #ffcf5c; }
.howto-list {
  list-style: none; text-align: left; margin: 4px 0 18px; padding: 0;
  color: #5c4a36; font-size: 13.5px; line-height: 1.7;
}
.howto-list li { margin-bottom: 6px; }
