/* 3D Hardware Stage & CSS3DRenderer Overlay Styles */
.viewport {
  position: relative;
  margin: 6px auto 0;
  user-select: none;
  -webkit-user-select: none;
}

body.webgl-3d .viewport {
  touch-action: none;
}

#duo-3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
  cursor: grab;
}

#duo-3d-canvas:active {
  cursor: grabbing;
}

#duo-css3d-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.console-3d-carrier {
  width: 600px;
  height: 658px;
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

body.webgl-3d .console {
  position: absolute;
  left: 0;
  top: 0;
  width: 600px;
  height: 658px;
  transform: none !important;
  transform-origin: 50% 50% !important;
  filter: none !important;
  pointer-events: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Make 2D CSS shell parts transparent so the 3D WebGL enclosure renders the hardware */
body.webgl-3d .lid,
body.webgl-3d .base {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  pointer-events: none;
}

body.webgl-3d .hinge,
body.webgl-3d .camera-dot,
body.webgl-3d .speaker,
body.webgl-3d .circle-pad,
body.webgl-3d .c-stick,
body.webgl-3d .brand,
body.webgl-3d .power-led {
  background: transparent !important;
  box-shadow: none !important;
  border-color: transparent !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

body.webgl-3d .dpad:after,
body.webgl-3d .start-select button:before {
  display: none !important;
}

body.webgl-3d .dpad {
  filter: none !important;
  pointer-events: none;
}

/* Keep hardware buttons interactive as transparent hit targets aligned over 3D buttons */
body.webgl-3d .dpad button,
body.webgl-3d .abxy button,
body.webgl-3d .start-select button,
body.webgl-3d .home {
  pointer-events: auto;
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: transparent !important;
}

body.webgl-3d .dpad button:focus-visible,
body.webgl-3d .abxy button:focus-visible,
body.webgl-3d .start-select button:focus-visible,
body.webgl-3d .home:focus-visible {
  outline: 2px solid #4d9aff;
  outline-offset: 2px;
}

/* Live DOM screens sit cleanly inside the 3D recessed display bezels */
body.webgl-3d .top-screen,
body.webgl-3d .bottom-screen {
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.55) !important;
  border: 1px solid rgba(8, 10, 14, 0.9) !important;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

body.webgl-3d .top-screen {
  pointer-events: none;
}

body.webgl-3d .bottom-screen {
  pointer-events: auto;
}

/* Page chrome: one title row and one menu. The 3D console is the page. */
html, body { overscroll-behavior: none; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
header {
  padding: 14px 16px 4px;
}
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 auto;
}
/* not enough room to keep the title centred: title left, buttons right */
@media (max-width: 1023px) {
  .topbar { justify-content: space-between; }
  .topbar-actions { position: static; transform: none; flex-shrink: 0; }
}
.topbar h1 {
  margin: 0;
  white-space: nowrap;
}
.h1-sub {
  font-weight: 300;
  color: #8c9294;
}
.tagline {
  margin: 4px 0 0;
}
.tagline .prototype-tag {
  margin-left: 6px;
}
main.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 10px;
}

.topbar-actions {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-button,
.stage-menu > summary {
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 0.5px rgba(30, 36, 40, 0.14), 0 2px 8px rgba(30, 36, 40, 0.08);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  color: #1d1d1f;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 160ms ease, transform 160ms ease;
}
.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  padding: 0;
}
.icon-button:active,
.stage-menu > summary:active { transform: scale(0.94); }
.rotate-glyph {
  width: 19px;
  height: 19px;
  transition: transform 260ms ease;
}
.icon-button[aria-pressed="true"] { background: rgba(255, 255, 255, 0.96); }
a.icon-button { color: #1d1d1f; text-decoration: none; }
.social-glyph { width: 15px; height: 15px; }
.lang-menu > summary { gap: 5px; padding: 0 11px; }
.lang-menu .lang-glyph { flex: 0 0 17px; width: 17px; height: 17px; color: currentColor; }
.lang-code { font-size: 12px; font-weight: 600; letter-spacing: 0.2px; }
.menu-panel.lang-panel { width: 184px; }
.topbar-divider { width: 1px; height: 18px; margin: 0 2px; background: rgba(30, 36, 40, 0.16); }
.icon-button[aria-pressed="true"] .rotate-glyph { transform: rotate(90deg); }

.stage-menu {
  position: relative;
  text-align: left;
}
.stage-menu > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 500;
}
.stage-menu > summary::-webkit-details-marker { display: none; }
.stage-menu > summary { white-space: nowrap; outline: none; }
.stage-menu > summary:focus-visible { outline: 2px solid #398cec; outline-offset: 2px; }
.stage-menu[open] > summary { background: rgba(255, 255, 255, 0.96); }
.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 13px;
  height: 1.5px;
  border-radius: 1px;
  background: currentColor;
}
.menu-icon { position: relative; }
.menu-icon::before,
.menu-icon::after {
  content: '';
  position: absolute;
  left: 0;
}
.menu-icon::before { top: -4.5px; }
.menu-icon::after { top: 4.5px; }

/* iOS-style pull-down menu */
.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 252px;
  max-width: calc(100vw - 20px);
  max-height: calc(100dvh - 80px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 14px;
  background: rgba(246, 246, 248, 0.76);
  box-shadow: 0 12px 40px rgba(20, 24, 28, 0.2), 0 0 0 0.5px rgba(20, 24, 28, 0.12);
  backdrop-filter: blur(30px) saturate(1.8);
  -webkit-backdrop-filter: blur(30px) saturate(1.8);
  color: #1d1d1f;
  font-size: 14px;
  line-height: 1.25;
  transform-origin: top right;
  animation: menu-in 180ms cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes menu-in {
  from { opacity: 0; transform: scale(0.92); }
}
.menu-view[hidden] { display: none; }
.menu-group + .menu-group,
.view-3d-controls + .menu-group,
.menu-back + .menu-group,
.menu-back + .help {
  border-top: 0.5px solid rgba(60, 60, 67, 0.22);
}
.menu-item,
.menu-back {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.menu-item:hover,
.menu-back:hover { background: rgba(60, 60, 67, 0.08); }
.menu-item:active,
.menu-back:active { background: rgba(60, 60, 67, 0.16); }
.menu-item:focus-visible,
.menu-back:focus-visible,
.segmented button:focus-visible {
  outline: 2px solid #398cec;
  outline-offset: -2px;
}
.menu-glyph {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  color: #3c3c43;
}
.menu-item-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: break-word;
}
.menu-value {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(60, 60, 67, 0.6);
}
.menu-check,
.menu-chevron {
  flex: 0 0 14px;
  height: 14px;
  position: relative;
}
.menu-check::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 0;
  width: 5px;
  height: 10px;
  border: solid #1d1d1f;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  visibility: hidden;
}
[aria-pressed="true"] > .menu-check::after { visibility: visible; }
.menu-chevron::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 3px;
  width: 7px;
  height: 7px;
  border: solid rgba(60, 60, 67, 0.45);
  border-width: 1.8px 1.8px 0 0;
  transform: rotate(45deg);
}
.menu-back {
  font-weight: 600;
  gap: 8px;
}
.menu-back .menu-chevron::after {
  left: 5px;
  border-color: currentColor;
  transform: rotate(-135deg);
}
#language-list .menu-item { padding-left: 22px; }
.menu-panel .help {
  max-width: none;
  margin: 0;
  padding: 12px 16px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: #3c3c43;
}
.menu-credit {
  padding: 10px 14px 12px;
  border-top: 0.5px solid rgba(60, 60, 67, 0.22);
  font-size: 12px;
  color: rgba(60, 60, 67, 0.6);
}
.menu-credit a { color: #0a64d8; text-decoration: none; }
.menu-credit a:hover { text-decoration: underline; }

/* View presets: iOS segmented control */
.view-3d-controls {
  display: block;
  padding: 10px;
}
.view-3d-controls[hidden] { display: none; }
.segmented {
  display: flex;
  padding: 2px;
  border-radius: 9px;
  background: rgba(118, 118, 128, 0.16);
}
.segmented button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 30px;
  margin: 0;
  padding: 5px 4px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  overflow-wrap: break-word;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.segmented button[aria-pressed="true"] {
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04);
}
@media (prefers-reduced-motion: reduce) {
  .menu-panel { animation: none; }
}

.stage-3d-hint {
  margin: 10px auto 0;
  padding: 5px 13px;
  width: max-content;
  max-width: calc(100vw - 32px);
  border-radius: 999px;
  background: rgba(24, 27, 32, 0.72);
  color: #f3f5f7;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  transition: opacity 600ms ease;
}
.stage-3d-hint.is-faded { opacity: 0; }
body.recording .stage-3d-hint { display: none; }

@media (max-width: 700px) {
  .topbar h1 { line-height: 1.1; }
  .topbar h1 .h1-sub { display: block; font-size: 0.78em; }
}
@media (max-width: 620px) {
  header { padding: 10px 10px 2px; }
  .topbar { justify-content: space-between; }
  .topbar { gap: 8px; }
  .topbar h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: clamp(16px, 4.6vw, 19px); letter-spacing: -0.6px; }
  .topbar-actions { position: static; flex-shrink: 0; transform: none; gap: 6px; }
  .stage-menu > summary { gap: 6px; padding: 0 11px; }
  .tagline { font-size: 11px; line-height: 1.6; text-align: left; }
  .tagline .prototype-tag { font-size: 9px; padding: 2px 5px; letter-spacing: 0.3px; margin-left: 5px; }
  .stage-3d-hint { font-size: 11px; }
}
@media (max-width: 620px) {
  .lang-menu > summary { width: 34px; padding: 0; justify-content: center; }
  .lang-menu .lang-code { display: none; }
  /* the language list opens from the right edge of the button group, like Menu */
  .topbar-actions { position: relative; }
  .lang-menu { position: static; }
}
@media (max-width: 380px) {
  .topbar h1 { font-size: 16px; }
  .stage-menu > summary .menu-text { display: none; }
  .stage-menu > summary { width: 34px; padding: 0; justify-content: center; }
  .topbar-divider { display: none; }
  .topbar-actions { gap: 4px; }
}
