* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: #111;
  color: #f2f2f2;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
/* Keep view sequencing: never let layout rules unhide screens */
[hidden] {
  display: none !important;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: #1a1a1a;
  border-bottom: 1px solid #2a2a2a;
}
.footer {
  border-bottom: 0;
  border-top: 1px solid #2a2a2a;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.bar-left { display: flex; align-items: baseline; gap: 0.6rem; min-width: 0; }
.bar-left span { color: #999; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-right { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.step-label { color: #888; font-size: 0.85rem; }

.screen {
  width: min(720px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 2.5rem;
}
.panel {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
  padding: 1.5rem 1.35rem 1.6rem;
}
.eyebrow {
  margin: 0 0 0.4rem;
  color: #c9a06a;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 600;
}
.panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.55rem;
  font-weight: 700;
}
.lede {
  margin: 0 0 1.25rem;
  color: #999;
  line-height: 1.45;
  font-size: 0.95rem;
}
.menu-hint {
  margin: -0.55rem 0 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(201, 160, 106, 0.35);
  background: rgba(201, 160, 106, 0.08);
  color: #e8dcc4;
  font-size: 0.88rem;
  line-height: 1.4;
}
.menu-hint strong {
  color: #c9a06a;
  font-weight: 650;
}

.lang-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.lang-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1.25rem 1rem;
  border-radius: 12px;
  border: 1px solid #333;
  background: #141414;
  color: #f2f2f2;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.lang-card:hover {
  border-color: #c9a06a;
  transform: translateY(-2px);
}
.lang-card .flag { font-size: 1.75rem; line-height: 1; }
.lang-card .lang-name { font-weight: 600; font-size: 1.05rem; }

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.15rem;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.guide-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  text-align: center;
  padding: 1rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #333;
  background: #141414;
  color: #f2f2f2;
  min-height: 0;
}
.guide-tile .tile-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
}
.guide-tile.is-ready {
  cursor: pointer;
  border-color: rgba(201, 160, 106, 0.55);
  transition: transform 0.15s ease, background 0.15s ease;
}
.guide-tile.is-ready:hover {
  background: #1c1914;
  transform: translateY(-2px);
}
.guide-tile.is-soon {
  opacity: 0.5;
  cursor: default;
}
.guide-tile .badge {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #c9a06a;
  border: 1px solid rgba(201, 160, 106, 0.4);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}
.guide-tile.is-soon .badge {
  color: #888;
  border-color: #444;
}
.goback { margin-top: 0.25rem; }

.orient-banner,
.rotate-hint {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0.75rem 0;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #1c1914;
  border: 1px solid rgba(201, 160, 106, 0.45);
  color: #e8dcc4;
}
.rotate-hint[hidden],
.orient-banner[hidden] { display: none !important; }
.rotate-hint-inner {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.rotate-hint-text {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
}
.phone-rotate {
  position: relative;
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}
.phone-frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 36px;
  margin: -18px 0 0 -11px;
  border: 2px solid #c9a06a;
  border-radius: 5px;
  background: rgba(201, 160, 106, 0.12);
  animation: phone-tilt 1.8s ease-in-out infinite;
  transform-origin: center center;
}
.phone-screen {
  position: absolute;
  inset: 4px 3px 6px;
  border-radius: 2px;
  background: rgba(201, 160, 106, 0.35);
}
.rotate-arrow {
  position: absolute;
  right: -2px;
  top: 2px;
  width: 28px;
  height: 28px;
  color: #c9a06a;
  animation: arrow-pulse 1.8s ease-in-out infinite;
}
@keyframes phone-tilt {
  0%, 15% { transform: rotate(0deg); }
  45%, 60% { transform: rotate(90deg); }
  85%, 100% { transform: rotate(0deg); }
}
@keyframes arrow-pulse {
  0%, 15% { opacity: 0.35; transform: scale(0.92); }
  45%, 60% { opacity: 1; transform: scale(1); }
  85%, 100% { opacity: 0.35; transform: scale(0.92); }
}
.orient-dismiss {
  border: 0;
  background: transparent;
  color: #aaa;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
  align-self: flex-start;
}

.stage-wrap {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 0.75rem;
  position: relative;
}
#view-guide.screen {
  width: min(1200px, 100%);
  padding: 0;
}
.stage {
  position: relative;
  background: #000;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  overflow: hidden;
}
.stage-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #000;
}
.stage-canvas {
  position: relative;
  width: 100%;
  transform-origin: 0 0;
  transition: transform 0.28s ease;
  line-height: 0;
}
.stage img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  pointer-events: none;
}
.hotspot {
  position: absolute;
  width: clamp(22px, 3vw, 32px);
  height: clamp(22px, 3vw, 32px);
  border-radius: 50%;
  border: 2px solid #0d9488;
  background: rgba(13, 148, 136, 0.5);
  transform: translate(-50%, -50%);
  cursor: pointer;
  z-index: 3;
  animation: pulse 1.4s ease infinite;
  /* Larger tap target without changing visual size much */
  touch-action: manipulation;
}
.hotspot::before {
  content: "";
  position: absolute;
  inset: -20px;
  border-radius: 50%;
}
.hotspot::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(13, 148, 136, 0.55);
  pointer-events: none;
}
.tip {
  position: absolute;
  z-index: 4;
  width: min(300px, calc(100% - 1.5rem));
  background: #fff;
  color: #222;
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  line-height: 1.35;
}
.tip h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 700;
}
.tip p {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: #444;
}
.tip p strong {
  color: #111;
  font-weight: 700;
}
.tip-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.next,
.home {
  border: 0;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  background: #c9a06a;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.prev {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  background: #f5f5f5;
  color: #444;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}
.prev:disabled {
  opacity: 0.4;
  cursor: default;
}
.ghost {
  border: 1px solid #333;
  background: transparent;
  color: #ddd;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.85rem;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(13, 148, 136, 0); }
}

/* —— Mobile: fit pickers + guide reading —— */
@media (max-width: 800px) {
  html, body {
    height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  .bar {
    padding: 0.55rem 0.75rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .bar-left span { font-size: 0.8rem; }

  .screen {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0.65rem 0.75rem 0.85rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
  }

  /* Language + guide menu: everything above the fold */
  #view-lang.screen:not([hidden]),
  #view-menu.screen:not([hidden]) {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 3.1rem);
    max-height: calc(100dvh - 3.1rem);
    overflow: hidden;
    box-sizing: border-box;
  }

  #view-lang .panel,
  #view-menu .panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.95rem 0.85rem 1rem;
    border-radius: 12px;
  }

  #view-lang .panel h1,
  #view-menu .panel h1 {
    font-size: 1.2rem;
    margin-bottom: 0.3rem;
    flex: 0 0 auto;
  }

  #view-lang .eyebrow {
    flex: 0 0 auto;
    margin-bottom: 0.25rem;
  }

  #view-lang .lede,
  #view-menu .lede {
    font-size: 0.82rem;
    margin-bottom: 0.55rem;
    flex: 0 0 auto;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  #view-menu .menu-hint {
    flex: 0 0 auto;
    margin: 0 0 0.65rem;
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
  }

  .lang-cards {
    grid-template-columns: 1fr 1fr;
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.55rem;
  }

  .lang-card {
    justify-content: center;
    min-height: 0;
    padding: 0.85rem 0.5rem;
    gap: 0.35rem;
    -webkit-tap-highlight-color: transparent;
  }

  .lang-card .flag { font-size: 1.45rem; }
  .lang-card .lang-name { font-size: 0.95rem; }

  /* 2×2 guide tiles always fill remaining viewport */
  #view-menu .guide-grid {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: none;
    aspect-ratio: auto;
    margin: 0 0 0.65rem;
    gap: 0.5rem;
  }

  #view-menu .guide-tile {
    padding: 0.55rem 0.4rem;
    gap: 0.35rem;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  #view-menu .guide-tile .tile-title {
    font-size: 0.86rem;
    line-height: 1.2;
  }

  #view-menu .guide-tile .badge {
    font-size: 0.62rem;
    padding: 0.15rem 0.45rem;
  }

  #view-menu .goback {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: 0;
    min-height: 40px;
    touch-action: manipulation;
  }

  .ghost,
  .next,
  .prev,
  .hotspot {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  #view-guide .stage-wrap {
    padding: 0.5rem 0.5rem 0;
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 7.5rem);
  }

  #view-guide .stage {
    border-radius: 8px;
    flex: 1 1 auto;
    min-height: 0;
  }

  /* Tip stays visible under the shot — no long scroll to find it */
  #view-guide .tip {
    position: relative;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100%;
    margin-top: 0.5rem;
    border-radius: 12px;
    box-shadow: none;
    flex: 0 0 auto;
  }

  #view-guide .stage-viewport {
    min-height: 0;
    height: 100%;
    max-height: none;
  }

  #view-guide.is-zoomed .stage-viewport {
    min-height: 0;
    max-height: none;
  }

  #view-guide .footer {
    position: sticky;
    bottom: 0;
    background: #1a1a1a;
    z-index: 5;
    gap: 0.35rem;
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
  }

  #view-guide .footer .ghost {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
    min-height: 36px;
  }

  #view-guide .footer a.ghost {
    max-width: 38%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 800px) and (hover: none) {
  .lang-card:hover,
  .guide-tile.is-ready:hover {
    transform: none;
  }

  .guide-tile.is-ready:active {
    background: #1c1914;
  }

  .lang-card:active {
    border-color: #c9a06a;
  }
}

/* Short phones: tighter menu copy so 2×2 stays fully visible */
@media (max-width: 800px) and (max-height: 700px) {
  #view-menu .lede,
  #view-lang .lede {
    display: none;
  }

  #view-menu .menu-hint {
    font-size: 0.74rem;
    padding: 0.45rem 0.55rem;
    margin-bottom: 0.5rem;
  }

  #view-lang .panel h1,
  #view-menu .panel h1 {
    font-size: 1.08rem;
  }

  #view-menu .guide-tile .tile-title {
    font-size: 0.8rem;
  }
}

/* Landscape phone: keep language/menu pickers on one screen */
@media (max-width: 800px) and (orientation: landscape) {
  .bar {
    padding-top: 0.35rem;
    padding-bottom: 0.35rem;
  }

  #view-lang.screen:not([hidden]),
  #view-menu.screen:not([hidden]) {
    height: calc(100dvh - 2.4rem);
    max-height: calc(100dvh - 2.4rem);
    padding: 0.3rem 0.5rem;
    overflow: hidden;
  }

  #view-lang .lede,
  #view-menu .lede,
  #view-lang .eyebrow,
  #view-menu .menu-hint {
    display: none;
  }

  #view-lang .panel,
  #view-menu .panel {
    padding: 0.45rem 0.55rem 0.5rem;
    min-height: 0;
    overflow: hidden;
  }

  #view-lang .panel h1,
  #view-menu .panel h1 {
    font-size: 0.92rem;
    margin-bottom: 0.35rem;
  }

  #view-menu .guide-grid {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    margin: 0 0 0.35rem;
    gap: 0.35rem;
  }

  #view-menu .guide-tile {
    padding: 0.25rem 0.35rem;
    gap: 0.2rem;
  }

  #view-menu .guide-tile .tile-title {
    font-size: 0.78rem;
    line-height: 1.15;
  }

  #view-menu .guide-tile .badge {
    font-size: 0.55rem;
    padding: 0.1rem 0.35rem;
  }

  #view-menu .goback {
    min-height: 32px;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
  }

  .lang-cards {
    gap: 0.35rem;
  }

  .lang-card {
    padding: 0.45rem 0.4rem;
  }

  .lang-card .flag { font-size: 1.2rem; }
  .lang-card .lang-name { font-size: 0.85rem; }
}

/* Portrait: tip overlays lower stage so it stays on-screen */
@media (max-width: 800px) and (orientation: portrait) {
  #view-guide.screen:not([hidden]) {
    width: 100%;
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding: 0;
  }

  #view-guide .rotate-hint {
    flex: 0 0 auto;
    margin: 0.4rem 0.5rem 0;
  }

  #view-guide .stage-wrap {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    padding: 0.4rem 0.5rem 0;
    touch-action: pan-y;
  }

  #view-guide .stage {
    height: 100%;
    max-height: 100%;
  }

  #view-guide .tip {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.45rem;
    top: auto !important;
    margin: 0;
    z-index: 6;
    width: auto;
    max-height: min(36vh, 220px);
    overflow-y: auto;
    padding: 0.7rem 0.8rem;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.97);
  }

  #view-guide .tip h2 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
  }

  #view-guide .tip p {
    font-size: 0.85rem;
    margin-bottom: 0.55rem;
  }

  #view-guide .footer {
    flex: 0 0 auto;
    position: relative;
    margin-top: 0;
  }
}

@media (max-width: 800px) and (orientation: landscape) {
  #view-guide .orient-banner { display: none !important; }

  #view-guide:not([hidden]) {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  #view-guide .stage-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: block;
    padding: 0.25rem 0.5rem 0;
    position: relative;
  }

  #view-guide .stage {
    max-height: calc(100dvh - 3.2rem);
    height: calc(100dvh - 3.2rem);
  }

  #view-guide .stage-viewport {
    height: 100%;
    max-height: none;
    min-height: 0;
  }

  /* Tip overlays upper-mid area of the shot (above screen midpoint) */
  #view-guide .tip {
    position: absolute !important;
    left: 4% !important;
    top: 12% !important;
    transform: none !important;
    width: min(340px, 52%) !important;
    max-height: calc(100dvh - 4.5rem);
    overflow-y: auto;
    margin: 0;
    padding: 0.45rem 0.7rem;
    z-index: 6;
    box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  }

  #view-guide .tip h2 {
    font-size: 0.88rem;
    margin-bottom: 0.15rem;
  }

  #view-guide .tip p {
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    line-height: 1.3;
  }

  #view-guide .tip-actions {
    gap: 0.35rem;
  }

  #view-guide .next,
  #view-guide .home,
  #view-guide .prev {
    padding: 0.3rem 0.65rem;
    font-size: 0.8rem;
  }

  #view-guide .footer {
    padding: 0.25rem 0.65rem;
    margin-top: 0;
    flex: 0 0 auto;
  }

  #view-guide .footer .ghost {
    padding: 0.28rem 0.55rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 801px) {
  .orient-banner { display: none !important; }
  #zoomToggle { display: none; }
}

.stage-viewport.nudge-landscape {
  outline: 2px solid rgba(201, 160, 106, 0.7);
  outline-offset: -2px;
  transition: outline-color 0.3s ease;
}

/* CSS landscape fallback when OS orientation.lock is unavailable */
body.css-landscape {
  overflow: hidden;
}
body.css-landscape .bar {
  position: fixed;
  z-index: 30;
}
body.css-landscape #view-guide {
  position: fixed;
  inset: 0;
  width: 100vh;
  height: 100vw;
  max-width: none;
  transform: rotate(90deg) translateY(-100%);
  transform-origin: top left;
  overflow: auto;
  background: #111;
  z-index: 20;
  padding: 0;
}
body.css-landscape #view-guide .orient-banner {
  display: flex !important;
}
body.css-landscape #view-guide .stage-viewport {
  min-height: min(42vw, 320px);
  max-height: 48vw;
}
body.css-landscape #view-guide .tip {
  position: relative;
  left: auto !important;
  top: auto !important;
  transform: none !important;
  width: auto;
  margin: 0.25rem 0.5rem;
  padding: 0.4rem 0.65rem;
}
body.css-landscape #view-guide .tip h2 {
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
}
body.css-landscape #view-guide .tip p {
  margin-bottom: 0.35rem;
  font-size: 0.78rem;
}
