:root {
  --ui-fg: #f3f6fa;
  --ui-border: rgba(255, 255, 255, 0.28);
  --ui-bg: rgba(20, 24, 30, 0.62);
  --ui-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
  --ui-outline: 1px solid rgba(255, 255, 255, 0.2);
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "MS Pゴシック", sans-serif;
  background: #000;
  color: var(--ui-fg);
}

#arScene {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#cameraFeed {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background: #000;
}

#markerLayer {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.screen-marker {
  position: absolute;
  left: 0;
  top: 0;
  display: inline-flex;
  align-items: flex-start;
  gap: 0.3em;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85), 0 0 10px rgba(0, 0, 0, 0.45);
  line-height: 1;
  font-weight: 700;
}

.screen-marker.selected {
  filter: drop-shadow(0 0 10px rgba(255, 192, 90, 0.95));
  transform: translate(-50%, -50%) scale(1.08);
}

.screen-marker-icon {
  width: 1em;
  height: 1em;
  display: block;
  flex: 0 0 auto;
  border-radius: 2px;
  align-self: flex-start;
  margin-top: 0;
}

.screen-marker-label {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 0 0 auto;
  min-width: 7em;
  line-height: 1.15;
  max-width: 14em;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: normal;
  line-break: strict;
}

.screen-marker-title {
  display: block;
}

.screen-marker-distance {
  display: block;
  margin-top: 0.1em;
  font-size: 0.8em;
  opacity: 0.9;
}

.overlay {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 4;
  pointer-events: none;
}

#centerPanel {
  inset: 0;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#centerPanel.hidden {
  display: none;
}

#launchCard {
  width: min(88vw, 420px);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(10, 12, 16, 0.52), rgba(8, 10, 14, 0.42));
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.28),
    0 0 44px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 12px;
  pointer-events: auto;
  text-align: center;
}

#launchTitle {
  margin: 0 0 6px 0;
  font-size: 16px;
  line-height: 1.4;
  font-weight: 700;
}

#launchStatus {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  color: #ffcc73;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  white-space: pre-line;
  word-break: break-word;
}

#launchLoading {
  display: none;
  width: 54px;
  height: 54px;
  margin: 2px auto 10px auto;
  object-fit: contain;
}

#centerPanel.is-loading #launchLoading {
  display: block;
}

#centerPanel.is-loading #startButton {
  opacity: 0.75;
  pointer-events: none;
}

#startButton {
  margin-top: 10px;
  border: 1px solid rgba(255, 211, 145, 0.95);
  border-radius: 10px;
  background: linear-gradient(165deg, rgba(235, 167, 82, 0.95), rgba(185, 112, 42, 0.92));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 228, 180, 0.2) inset;
  color: #fff;
  height: 38px;
  min-width: 120px;
  padding: 0 18px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#statusStrip {
  top: calc(8px + env(safe-area-inset-top));
  left: 8px;
  right: auto;
  width: min(78vw, 360px);
  min-height: 32px;
  padding: 0;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}

#statusText {
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.95);
  text-align: left;
  white-space: pre-line;
  max-width: 100%;
}

#compassStrip {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 5;
  pointer-events: none;
  display: flex;
  justify-content: center;
}

#compassViewport {
  position: relative;
  width: min(92vw, 560px);
  height: 28px;
  overflow: hidden;
}

#compassTrack {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  will-change: transform;
}

.compass-mark {
  position: absolute;
  top: 0;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.14);
}

.compass-mark.major {
  background: rgba(255, 255, 255, 0.24);
}

.compass-label {
  position: absolute;
  top: 6px;
  transform: translateX(-50%);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  color: #eaf6ff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  letter-spacing: 0.14em;
}

.compass-label.cardinal {
  color: #eaf6ff;
}

#compassCenterLine {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-50%);
  background: rgba(255, 96, 96, 0.95);
}

#modal-container {
  position: fixed;
  z-index: 6;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.82);
  padding: 0;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 220ms ease, visibility 220ms ease;
}

#modal-container.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#modal-content {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  border-radius: 0;
  border: none;
  background: rgba(16, 19, 24, 0.98);
  color: #fff;
  box-shadow: none;
  padding:
    calc(12px + env(safe-area-inset-top))
    14px
    calc(14px + env(safe-area-inset-bottom))
    14px;
  box-sizing: border-box;
  transform: translateY(12px);
  opacity: 0.85;
  transition: transform 220ms ease, opacity 220ms ease;
}

#modal-container.visible #modal-content {
  transform: translateY(0);
  opacity: 1;
}

#modal-close-button {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  color: transparent;
  font-size: 0;
  line-height: 0;
  cursor: pointer;
  user-select: none;
  z-index: 20;
  width: 32px;
  height: 32px;
  display: block;
  box-sizing: border-box;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center center;
  background-size: 100% 100%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='48' fill='%23000'/><path d='M30 30 L70 70 M70 30 L30 70' stroke='%23fff' stroke-width='12' stroke-linecap='round'/></svg>");
  border: none;
  box-shadow: none;
  padding: 0;
}

#modal-title {
  margin: 28px 0 10px 0;
  padding: 0 64px;
  box-sizing: border-box;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

#modal-meta {
  margin: 0 0 8px 0;
  font-size: 13px;
  opacity: 0.9;
  text-align: right;
}

#modal-body {
  font-size: 17.5px;
  line-height: 1.6;
}

#modal-body img {
  max-width: 100%;
  height: auto;
}

#modal-body .modal-main-photo {
  margin: 0 0 10px 0;
}

#modal-body .modal-main-photo img {
  width: 100%;
  max-height: 52vh;
  object-fit: contain;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

#modal-body .photographer {
  margin: -2px 0 8px 0;
  font-size: 0.75em;
  text-align: center;
}

#modal-container.is-testimony:not(.is-video-shogen) #modal-content {
  background: #f8f6f2;
  color: #111;
}

#modal-container.is-photo #modal-content {
  background: rgba(16, 19, 24, 0.98);
  color: #fff;
}

#modal-container.is-photo #modal-title,
#modal-container.is-photo #modal-meta,
#modal-container.is-photo #modal-body {
  color: #fff;
}

#modal-container.is-testimony:not(.is-video-shogen) #modal-title,
#modal-container.is-testimony:not(.is-video-shogen) #modal-meta,
#modal-container.is-testimony:not(.is-video-shogen) #modal-body {
  color: #111;
  font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", "MS PMincho", serif;
}

#modal-container.is-testimony:not(.is-video-shogen) #modal-close-button {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='48' fill='%23000'/><path d='M30 30 L70 70 M70 30 L30 70' stroke='%23fff' stroke-width='12' stroke-linecap='round'/></svg>");
}

#modal-container:not(.is-testimony) #modal-close-button,
#modal-container.is-video-shogen #modal-close-button {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='48' fill='%23fff'/><path d='M30 30 L70 70 M70 30 L30 70' stroke='%23000' stroke-width='12' stroke-linecap='round'/></svg>");
}

#modal-container.is-testimony:not(.is-video-shogen) #modal-body a {
  color: #1a4db3;
}

#modal-container.is-testimony #modal-body p.image {
  text-align: center;
}

#modal-container.is-testimony #modal-body p.image img {
  display: inline-block;
  max-width: min(72vw, 260px);
  height: auto;
}

#modal-container.is-testimony #modal-body .exp_head .faceImage {
  text-align: center;
  margin: 0 0 6px 0;
}

#modal-container.is-testimony #modal-body .exp_head .faceImage img {
  display: inline-block;
}

#modal-container.is-testimony #modal-body .exp_head h1 {
  text-align: center;
  font-size: 1.1em;
  line-height: 1.35;
}

#modal-container.is-testimony #modal-body h1 {
  text-align: center !important;
  margin-left: auto;
  margin-right: auto;
}

#modal-container.is-testimony #modal-body .exp_head .nameAndLocation {
  display: block;
  text-align: center;
  font-size: 0.78em;
  line-height: 1.45;
}

#modal-container.is-testimony #modal-body .exp_content p {
  text-align: justify;
  text-justify: inter-ideograph;
}

#modal-container.is-testimony #modal-body p.body {
  font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
  text-align: justify;
  text-justify: inter-ideograph;
  line-height: 1.5;
}

#modal-body p.photograph_text {
  font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
}

#modal-container.is-testimony #modal-body p.subject {
  text-align: center;
  font-weight: 700;
  font-size: 1.25em;
  line-height: 1.4;
}

#modal-container.is-testimony #modal-body h2 {
  text-align: center;
  font-size: 0.95em;
  line-height: 1.35;
}

#modal-container.is-testimony #modal-body .my_wish {
  text-align: left;
}

#modal-container.is-testimony #modal-body .my_wish p {
  text-align: left;
}

#modal-container.is-testimony #modal-body .reference,
#modal-container.is-testimony #modal-body p.reference {
  text-align: center;
  font-size: calc(0.72em + 2pt);
  opacity: 0.88;
}

#modal-container.is-testimony #modal-body .pub_date {
  text-align: center;
  font-size: 0.82em;
  line-height: 1.4;
}

#modal-body iframe,
#modal-body video {
  max-width: 100%;
}

#modal-body .video,
#modal-body .balloon,
#modal-body .shogen,
#modal-body p.image {
  width: 100%;
  max-width: 100%;
}

#modal-body iframe {
  display: block;
  width: 100% !important;
  max-width: none;
  height: auto !important;
  aspect-ratio: 16 / 9;
  border: 0;
}

#buttonMap {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: 8px;
  z-index: 5;
  opacity: 0.95;
  pointer-events: auto;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-bg);
  box-shadow: var(--ui-shadow);
  color: var(--ui-fg);
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 32px;
  text-decoration: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#debugSwitchWrap {
  position: fixed;
  top: calc(44px + env(safe-area-inset-top));
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 5;
  opacity: 0.95;
  pointer-events: auto;
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  background: var(--ui-bg);
  box-shadow: var(--ui-shadow);
  color: var(--ui-fg);
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#debugSwitchLabel {
  color: var(--ui-fg);
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}

.debug-switch {
  position: relative;
  width: 34px;
  height: 18px;
  display: inline-block;
}

.debug-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.debug-slider {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  transition: background 180ms ease;
  cursor: pointer;
}

.debug-slider::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #fff;
  transition: transform 180ms ease;
}

.debug-switch input:checked + .debug-slider {
  background: rgba(80, 170, 255, 0.88);
}

.debug-switch input:checked + .debug-slider::before {
  transform: translateX(16px);
}
