html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  background: transparent;
  font-family: -apple-system, system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif;
}



:root{
  --vvw: 100vw;
  --vvh: 100vh;
  --panelH: calc(var(--vvh) * 0.34);
  --kbd: 0px;
}

#arjs-video{
  position: fixed;
  left: 0;
  top: 0;
  width: var(--vvw);
  height: var(--vvh);
  object-fit: cover;
  z-index: 0;
}

#ar-scene{
  position: fixed;
  left: 0;
  top: 0;
  width: var(--vvw);
  height: var(--vvh);
  pointer-events: none;
  z-index: 1;
}


#hud {
  position: fixed;
  inset: 0;
  height: var(--vvh);
  pointer-events: none;
  z-index: 2;
}

#design-icon {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  opacity: 0.9;
  pointer-events: none;
  z-index: 2;
}


#hint {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(64px + env(safe-area-inset-bottom));
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  text-shadow: 0 1px 6px rgba(0,0,0,0.8);
}

#bubble {
  position: absolute;
  width: fit-content;
  max-width: min(340px, 82vw);
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bubble-bg, rgba(196, 255, 210, 0.72));
  color: #111;
  font-size: 14px;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  transform: translate(-50%, -100%);
  pointer-events: none;
  overflow: visible;
}

#bubble .bubble-content{
  max-height: min(40vh, 320px);
  overflow-y: auto;
  word-break: break-word;
}

#bubble::after {
  content: "";
  position: absolute;
  display: block;
  left: 20%;
  bottom: -18px;
  width: 34px;
  height: 18px;
  background: var(--bubble-bg, rgba(196, 255, 210, 0.72));
  -webkit-clip-path: polygon(0 0, 100% 0, 58% 0, 50% 100%, 42% 0);
  clip-path: polygon(0 0, 100% 0, 58% 0, 50% 100%, 42% 0);
}

.hidden { display: none; }


#bubble[data-mood="neutral"] { --bubble-bg: rgba(196, 255, 210, 0.72); }
#bubble[data-mood="happy"]   { --bubble-bg: rgba(210, 255, 220, 0.78); }
#bubble[data-mood="angry"]   { --bubble-bg: rgba(255, 215, 215, 0.78); }
#bubble[data-mood="sad"]     { --bubble-bg: rgba(200, 235, 255, 0.78); }
#bubble[data-mood="surprised"] { --bubble-bg: rgba(225, 215, 255, 0.78); }


:root{
  --vvh: 100vh;     /* JSで上書きされる */
  --panelH: calc(var(--vvh) * 0.34);   /* 好みで調整。まずは34% */
  --kbd: 0px;
}

html, body{
  height: var(--vvh);
}
#ar-scene{
  height: var(--vvh);
}

/* ここが大事：panelは bottom固定 */
/* stage は panel を除いた高さ */
#stage{
  position: absolute;
  left: 0; right: 0; top: 0;
  height: calc(var(--vvh) - var(--panelH));
}

#panel{
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--panelH);
  display: flex;
  flex-direction: column;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255,255,255,0.12);
  pointer-events: auto;
}

#log{
  flex: 1;
  overflow: auto;
  overflow-x: hidden;
  padding: 10px 12px;
  color: #fff;
  font-size: 14px;
}

.msg{
  margin: 6px 0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.badge{
  font-size: 12px;
  opacity: 0.75;
  min-width: 2.8em;
}
.text{
  white-space: pre-wrap;
  line-height: 1.35;
}

#chatbar{
  display: flex;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
  pointer-events: auto;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
}

#q{
  flex: 1;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 16px;
}

#send{
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 16px;
}

/* 吹き出しは上ステージ内に表示される想定 */
#bubble{ pointer-events: none; }

/* 感情エフェクト（絵文字） */
#fx{
  position: absolute;
  font-size: 28px;
  transform: translate(-50%, -120%);
  text-shadow: 0 8px 18px rgba(0,0,0,0.35);
  pointer-events: none;
}

#flowers{
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.flower{
  position: absolute;
  left: 0;
  top: 0;
  font-size: var(--size, 18px);
  transform: translate(-50%, -50%) scale(0.85);
  opacity: 0;
  animation: flower-float var(--dur, 1.4s) ease-in-out forwards;
  text-shadow: 0 6px 14px rgba(0,0,0,0.2);
}

@keyframes flower-float{
  0%{
    opacity: 0;
    transform: translate(-50%, -50%) translate(0, 0) scale(0.85);
  }
  20%{
    opacity: 0.9;
  }
  100%{
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--dx, 0px), var(--dy, -26px)) scale(1);
  }
}

#face{
  position: absolute;
  font-size: 20px;
  transform: translate(-50%, -120%);
  text-shadow: 0 8px 18px rgba(0,0,0,0.35);
  pointer-events: none;
  opacity: 0.9;
}

#new-chat{
  position: absolute;
  right: 16px;
  bottom: calc(var(--panelH) + 16px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  box-shadow: 0 10px 20px rgba(0,0,0,0.25);
  pointer-events: auto;
}

#new-chat .paw{
  font-size: 16px;
  line-height: 1;
}

#new-chat:active{
  transform: translateY(1px);
}


.arjs-permission-ui,
.arjs-permission-ui * {
  pointer-events: auto !important;
  z-index: 99999 !important;
}


html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
}

a-scene,
#a-scene,
.a-scene,
.a-canvas,
.a-canvas-container,
canvas,
video {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  width: var(--vvw) !important;
  height: var(--vvh) !important;
}

#arjs-video,
video {
  object-fit: cover !important;
}

#a-scene,
.a-scene,
.a-canvas,
.a-canvas-container,
canvas {
  background: transparent !important;
}