#po-cat-room * {
  box-sizing: border-box;
}
#po-cat-room {
  margin: 0;
  background: #d9d5ce;
  color: #272721;
  font:
    12px/1.6 Arial,
    sans-serif;
}
#po-cat-room #scene {
  position: fixed;
  left: 0;
  top: 50%;
  width: 100vw;
  height: min(84vh, 66.5vw);
  transform: translateY(-50%);
  touch-action: none;
  cursor: grab;
}
#po-cat-room #scene:active {
  cursor: grabbing;
}
#po-cat-room canvas {
  display: block;
}
#po-cat-room .room-title {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  pointer-events: none;
  background: linear-gradient(#f3eee0a0, transparent);
}
#po-cat-room .room-title a {
  pointer-events: auto;
  color: inherit;
  text-decoration: none;
}
#po-cat-room .room-title span {
  font:
    italic 18px Georgia,
    serif;
}
#po-cat-room .room-controls {
  position: fixed;
  bottom: 20px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  pointer-events: none;
}
#po-cat-room .room-controls p {
  margin: 0;
  padding: 9px 13px;
  background: #f7f3e7df;
  border-radius: 8px;
  font-size: 10px;
}
#po-cat-room nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  pointer-events: auto;
}
#po-cat-room button {
  border: 1px solid #bcb6a8;
  background: #faf7eeed;
  color: #33352f;
  border-radius: 0;
  padding: 11px 15px;
  cursor: pointer;
}
#po-cat-room button:hover {
  background: white;
}
#po-cat-room dialog {
  border: 0;
  border-radius: 10px;
  max-width: 94vw;
  padding: 12px;
  background: #f6f2e9;
}
#po-cat-room dialog::backdrop {
  background: #181714bf;
}
#po-cat-room dialog img {
  display: block;
  max-width: 88vw;
  max-height: 78vh;
}
#po-cat-room dialog button {
  display: block;
  margin: 10px 0 0 auto;
}
@media (max-width: 600px) {
  #po-cat-room .room-title {
    padding: 15px;
  }
  #po-cat-room .room-controls {
    bottom: 14px;
    left: 12px;
    right: 12px;
    align-items: center;
    flex-direction: column;
  }
  #po-cat-room button {
    padding: 9px 12px;
    font-size: 11px;
  }
  #po-cat-room .room-controls p {
    font-size: 9px;
  }
}
#po-cat-room #forward-cue {
  position: fixed;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 12px 24px;
  background: #161b1980;
  border: 1px solid #ffffff50;
  color: #fff8e8;
  border-radius: 0;
  text-shadow: 0 1px 4px #0008;
}
#po-cat-room #forward-cue[hidden] {
  display: none;
}
#po-cat-room #forward-cue .chevron {
  display: block;
  width: 15px;
  height: 15px;
  border-top: 2px solid currentColor;
  border-left: 2px solid currentColor;
  transform: rotate(45deg);
  animation: forward-pulse 1.8s infinite ease-in-out;
}
#po-cat-room #forward-cue .chevron:nth-child(2) {
  animation-delay: 0.2s;
  margin-top: -3px;
}
#po-cat-room #forward-cue .cue-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  margin-top: 5px;
}
@keyframes forward-pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: translateY(5px) rotate(45deg);
  }
  50% {
    opacity: 1;
    transform: translateY(-4px) rotate(45deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  #po-cat-room #forward-cue .chevron {
    animation: none;
  }
}
@media (max-width: 600px) {
  #po-cat-room #forward-cue {
    bottom: 25%;
    padding: 10px 19px;
  }
}

/* Shared-header page layout */
#po-cat-room {
  position: relative;
  margin-top: var(--room-header-gap, var(--shared-header-height, 144px));
  height: max(880px, calc(100vh - var(--shared-header-height, 144px)));
  overflow: hidden;
  isolation: isolate;
  background: #e8e5de;
}
#po-cat-room .room-title {
  position: absolute;
  inset: 0 0 auto;
  height: 145px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  padding: 14px clamp(24px, 7vw, 160px);
  background: none;
  z-index: 2;
  pointer-events: none;
}
#po-cat-room .room-page-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: auto;
}
#po-cat-room .room-page-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 34px;
  padding: 6px 16px;
  border: 1px solid #242822;
  border-radius: 0;
  background: #242822;
  color: #fff;
  font:
    700 13px/1.4 "Yu Gothic",
    Meiryo,
    sans-serif;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition:
    background 0.2s,
    color 0.2s;
}
#po-cat-room .room-page-nav a + a {
  background: #fff;
  color: #242822;
}
#po-cat-room .room-page-nav a:hover {
  background: #b5a278;
  color: #171a16;
}
#po-cat-room .room-page-nav a:focus-visible {
  outline: 3px solid #997b37;
  outline-offset: 3px;
}
#po-cat-room .room-title div {
  width: auto;
  margin: 0;
  padding: 0;
  border: 0;
  text-align: left;
}
#po-cat-room .room-title h1 {
  margin: 0;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: clamp(15px, 1.25vw, 21px);
  white-space: nowrap;
  font-weight: 800;
  line-height: 1.35;
  letter-spacing: 0.015em;
  color: #242822;
}
#po-cat-room .room-title p {
  margin: 5px 0 0;
  font:
    italic 26px/1.15 Georgia,
    "Times New Roman",
    serif;
  letter-spacing: 0.015em;
  color: #373c33;
}
#po-cat-room #scene {
  position: absolute;
  top: 145px;
  left: 0;
  width: 100%;
  height: calc(100% - 255px);
  transform: none;
}
#po-cat-room canvas {
  width: 100%;
  height: 100%;
}
#po-cat-room .room-controls {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 20px;
  height: auto;
  min-height: 0;
  padding: 0;
  background: transparent;
}
#po-cat-room #forward-cue {
  position: absolute;
  bottom: 25%;
}
@media (max-width: 600px) {
  #po-cat-room {
    height: max(850px, calc(100dvh - var(--shared-header-height, 144px)));
  }
  #po-cat-room .room-title {
    height: 170px;
    gap: 10px;
    padding: 14px 20px;
  }
  #po-cat-room .room-title h1 {
    font-size: clamp(12px, 3.3vw, 18px);
  }
  #po-cat-room #scene {
    top: 170px;
    height: calc(100% - 350px);
  }
  #po-cat-room .room-controls {
    left: 12px;
    right: 12px;
  }
  #po-cat-room #forward-cue {
    bottom: 30%;
  }
}

/* スマホは共通ヘッダー直下に横並びナビと短いタイトルを配置。 */
.room-mobile-move { display: none; }
@media (max-width: 600px) {
  #po-cat-room .room-title { height: 108px; padding: 8px 12px; gap: 7px; }
  #po-cat-room .room-page-nav { flex-wrap: nowrap; width: 100%; gap: 6px; }
  #po-cat-room .room-page-nav a { min-width: 0; min-height: 32px; padding: 5px 8px; gap: 5px; font-size: 11px; letter-spacing: 0; white-space: nowrap; }
  #po-cat-room .room-page-nav a + a { flex: 1; }
  #po-cat-room .room-title p { font-size: 23px; margin-top: 3px; }
  #po-cat-room #scene { top: 108px; height: calc(100% - 288px); }
  #po-cat-room .room-mobile-move { display: flex; position: absolute; z-index: 4; top: 465px; right: 12px; gap: 6px; }
  #po-cat-room .room-mobile-move button { border: 1px solid #aaa; border-radius: 0; background: #fffffff0; color: #242822; padding: 9px 13px; font-size: 13px; min-height: 44px; touch-action: manipulation; }
}

/* コンパクトなボタンと、少しゆとりのある上余白。 */
@media (max-width: 600px) {
  #po-cat-room .room-title { height: 108px; padding: 14px 12px 7px; gap: 6px; }
  #po-cat-room .room-page-nav a { min-height: 27px; padding: 3px 8px; }
  #po-cat-room #forward-cue { top: 390px; bottom: auto; padding: 7px 12px; }
  #po-cat-room #forward-cue .chevron { width: 10px; height: 10px; }
  #po-cat-room #forward-cue .cue-label { font-size: 9px; margin-top: 3px; }
}

/* 猫への導線と、片手で使える移動・回転操作。 */
@media (max-width: 600px) {
  #po-cat-room .room-mobile-move { top: auto; bottom: 190px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; }
  #po-cat-room .room-mobile-move button { min-height: 34px; padding: 5px 8px; font-size: 11px; }
  #po-cat-room #mobile-cat-view { grid-column: 1 / -1; background: #242822ed; color: white; }
  #po-cat-room #forward-cue { top: auto; bottom: 200px; left: 25%; }
}

/* スマホの初期画面内に、軽量な一列の操作バーを収める。 */
@media (max-width: 600px) {
  #po-cat-room { height: calc(100svh - var(--shared-header-height, 70px)); min-height: 420px; }
  #po-cat-room #scene { top: 108px; height: calc(100% - 108px); }
  #po-cat-room .room-mobile-move { top: auto; bottom: calc(44px + env(safe-area-inset-bottom, 0px)); left: 50%; right: auto; transform: translateX(-50%); display: flex; gap: 0; padding: 3px; border: 1px solid #ffffff60; background: #202722df; backdrop-filter: blur(8px); }
  #po-cat-room .room-mobile-move button { display: grid; place-items: center; width: 42px; height: 40px; min-height: 40px; padding: 0; border: 0; background: transparent; color: #f7f4e9; font: 22px/1 Arial,sans-serif; }
  #po-cat-room .room-mobile-move button:active { background: #ffffff30; }
  #po-cat-room .room-mobile-move button:focus-visible { outline: 1px solid #fff; outline-offset: -3px; }
  #po-cat-room .room-mobile-move button:nth-child(2),
  #po-cat-room .room-mobile-move button:nth-child(6) { border-left: 1px solid #ffffff35; }
  #po-cat-room #forward-cue { left: 50%; top: auto; bottom: calc(106px + env(safe-area-inset-bottom, 0px)); padding: 6px 10px; }
  #po-cat-room .room-controls { bottom: calc(7px + env(safe-area-inset-bottom, 0px)); left: 8px; right: 8px; pointer-events: none; }
  #po-cat-room .room-controls nav { display: none; }
  #po-cat-room .room-controls p { margin: 0; padding: 4px 6px; font-size: 9px; line-height: 1.4; background: #e8e5ded9; text-align: center; }
}

@media (max-width:600px) { #po-cat-room .room-mobile-move { width: max-content; max-width: calc(100% - 24px); flex-wrap: nowrap; } #po-cat-room .room-mobile-move button { flex: 0 0 40px; } }


/* Mobile joystick: quiet translucent disc with a draggable central thumb. */
@media (max-width: 600px) {
  #po-cat-room .room-mobile-move {
    display: block; position: absolute; top: auto; left: auto; right: 18px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    width: 96px; height: 96px; padding: 0; transform: none;
    border: 0; background: transparent; backdrop-filter: none;
  }
  #po-cat-room .room-mobile-move #room-joystick {
    display: block; position: relative; width: 96px; height: 96px;
    min-height: 96px; padding: 0; border: 1px solid #99999970;
    border-radius: 50%; background: #ffffff30; touch-action: none;
    user-select: none; cursor: grab;
  }
  #po-cat-room .room-mobile-move #room-joystick:active { cursor: grabbing; }
  #po-cat-room .room-joystick-knob {
    position: absolute; left: 32px; top: 32px; width: 30px; height: 30px;
    box-sizing: border-box; border: 1px solid #999999bb;
    border-radius: 50%; background: #ffffffb3; pointer-events: none;
  }
  #po-cat-room #forward-cue { bottom: calc(44px + env(safe-area-inset-bottom, 0px)); }
}
