:root {
  --ink: #17312e;
  --paper: #f8f5eb;
  --gold: #f1d998;
  --glass: rgba(20, 42, 42, .89);
  --safe-top: 0px;
  color-scheme: light;
}

body, #app { touch-action: auto; }
body { font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif; }
#app { left: 0; width: 100%; transform: none; box-shadow: none; }
#world { touch-action: none; cursor: grab; }
#world:active { cursor: grabbing; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #b07d20; outline-offset: 3px; }
.web-mouse, .focus-control:not(.open), .bird-info:not(.open),
.photo-preview:not(.open), .achievements-panel:not(.open) { visibility: hidden; }
.web-mouse { display: none; }
.web-control-note { display: none; }
#app:has(.start-screen:not(.hidden)) > :is(#world, .session-hud, .observation-card, .scene-zoom-hud) { visibility: hidden; }
.scene-zoom-hud .scope-focals button.active { color: var(--ink); background: var(--gold); }

/* Entry screen */
.start-screen {
  place-items: center;
  min-height: 100%;
  background-position: 63% center;
}
.start-screen::before {
  background:
    linear-gradient(0deg, rgba(13, 30, 29, .86), transparent 32%),
    linear-gradient(92deg, rgba(14, 34, 34, .94) 0%, rgba(23, 53, 53, .83) 35%, rgba(38, 75, 70, .27) 82%);
}
.start-content {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(24px, 6vw, 100px);
  width: min(100%, 1420px);
  max-width: none;
  padding: clamp(28px, 5.8vw, 96px);
  text-align: left;
}
.start-title {
  margin: 0 0 clamp(16px, 4dvh, 34px);
  color: #fff9e9;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  font-size: clamp(50px, 6.4vw, 100px);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: .045em;
}
.start-title span { display: block; margin-top: 10px; font-size: .77em; white-space: nowrap; }
.start-actions { display: flex; flex-wrap: wrap; gap: 9px; max-width: none; margin: 0; }
.start-actions button { min-height: 49px; padding: 0 17px; border-radius: 9px; white-space: nowrap; }
.start-actions .play-btn { padding-inline: 19px; color: var(--ink); background: var(--gold); }
.start-actions .guide-btn { color: #f6f5e9; background: rgba(14, 35, 34, .36); border-color: rgba(249, 246, 229, .37); }
.start-actions .play-btn:hover { background: #ffe7a8; }
.start-actions .guide-btn:hover { background: rgba(248, 246, 229, .22); }
.start-hero.no-overlay { position: relative; display: grid; justify-items: center; gap: 9px; width: 100%; height: auto; margin: 0; overflow: visible; }
.web-hero-optics {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 475px, 57dvh);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 249, 220, .58);
  border-radius: 50%;
  background: radial-gradient(circle at 53% 44%, rgba(255, 250, 213, .24), rgba(30, 67, 65, .15) 72%);
  box-shadow: 0 0 0 9px rgba(246, 243, 216, .08);
}
.web-hero-optics::after {
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 249, 220, .28);
  border-radius: inherit;
  content: '';
  pointer-events: none;
}
.start-hero img { width: 92%; height: 82%; filter: drop-shadow(0 20px 19px rgba(12, 28, 27, .36)); }
.start-hero figcaption {
  display: grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  justify-content: center;
  gap: 3px 9px;
  margin-top: 12px;
  color: #fff9e9;
  text-align: center;
  text-shadow: 0 1px 5px #132e2e;
}
.start-hero figcaption strong {
  font: 600 18px/1.4 "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  letter-spacing: .04em;
}
.start-hero figcaption span { color: var(--gold); font: 600 13px/1.4 Inter, system-ui, sans-serif; }
.start-hero figcaption i { grid-column: 1 / -1; font: italic 16px/1.35 Georgia, serif; }

.web-notice {
  width: min(560px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: clamp(20px, 4vw, 32px);
  border: 1px solid rgba(23, 49, 46, .2);
  border-radius: 18px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 22px 66px #091c1b51;
  font-size: 14px;
  line-height: 1.7;
}
.web-notice::backdrop { background: rgba(7, 22, 23, .68); }
.web-notice h2 { margin: 0 0 16px; font-size: 23px; line-height: 1.25; }
.web-notice h3 { margin: 16px 0 4px; font-size: 15px; }
.web-notice p { margin: 0 0 10px; }
.web-notice ul { margin: 0 0 14px; padding-left: 1.35em; }
.web-notice a { color: #226361; font-weight: 700; overflow-wrap: anywhere; }
.web-notice-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.web-notice-actions button { min-height: 42px; padding: 0 16px; border-radius: 9px; }
.web-notice-dismiss { color: var(--ink); background: #e6ebe1; }

/* Overlays use the available space without stretching phone panels. */
.date-dialog, .session-complete { width: min(440px, calc(100% - 32px)); padding: 25px; background: var(--ink); }
.date-dialog h2, .session-complete h2 { margin-top: 0; }
.field-guide-page, .bird-profile-page { background: var(--paper); }
.guide-page-head, .field-guide-page .guide-page-head {
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 16px max(16px, calc((100% - 1300px) / 2));
}
.field-guide-page .guide-page-head > div { grid-column: 2; }
.field-guide-page .guide-page-head .page-back { position: static; transform: none; }
.guide-page-head h2 { margin: 0; font-size: clamp(20px, 2vw, 32px); }
.guide-page-head p { font-size: 12px; }
.field-guide-page .guide-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(43%, 168px), 1fr));
  width: min(100%, 1340px);
  margin-inline: auto;
  padding: 20px;
}
.field-guide-page .guide-item { padding: 10px; border: 1px solid rgba(34, 79, 73, .09); }
.field-guide-page .guide-item > img { height: 92px; }
.field-guide-page .guide-item-title b { font-size: 14px; }
.field-guide-page .guide-item-title em { font-size: 10px; }
.field-guide-page .guide-item dt { font-size: 9px; }
.field-guide-page .guide-item dd { font-size: 10px; }
.bird-profile-content { width: min(100%, 960px); margin-inline: auto; }
.profile-hero img { height: clamp(140px, 28vh, 280px); }
.profile-variants img { height: clamp(70px, 14vh, 140px); }
.profile-variants figcaption { font-size: 11px; }
.photo-preview, .achievements-panel {
  top: 50%; left: 50%; right: auto; bottom: auto;
  width: min(880px, calc(100% - 26px));
  max-height: calc(100% - 32px);
  padding: clamp(14px, 2.2vw, 26px);
  background: var(--paper);
  touch-action: pan-y;
  transform: translate(-50%, calc(-50% + 16px));
}
.photo-preview.open, .achievements-panel.open { transform: translate(-50%, -50%); }
#app:has(.photo-preview.open, .achievements-panel.open)::after {
  position: absolute; inset: 0; z-index: 109; content: '';
  background: rgba(13, 30, 29, .52);
}
.achievements-panel { width: min(560px, calc(100% - 26px)); }
.achievements-panel .achievement-item { min-height: 70px; padding: 14px; }
.sheet-head h2 { margin-top: 0; }
.photo-preview img { height: auto; max-height: 66dvh; background: var(--ink); }
.photo-actions { grid-template-columns: 1fr 1fr; }
.photo-actions button { min-height: 42px; font-size: 13px; }
.photo-preview { width: min(420px, calc(100% - 26px)); text-align: center; }
.photo-preview .sheet-head { justify-content: center; }
.photo-preview img { width: auto; max-width: 100%; margin-inline: auto; }

.session-hud {
  top: max(12px, env(safe-area-inset-top));
  left: 50%; right: auto;
  width: max-content;
  padding: 7px 9px;
  border-radius: 14px;
  background: var(--glass);
  transform: translateX(-50%);
}
.session-heading { grid-template-columns: 32px auto 32px; gap: 8px; }
.session-center { display: flex; align-items: center; gap: 8px; width: auto; }
.session-center .session-date, .session-weather { margin: 0; font-size: 12px; }
.session-center [data-session-time] { width: auto; font-size: 24px; }
.session-center > * { white-space: nowrap; }
.session-weather { padding: 4px 6px; border-radius: 6px; color: var(--gold); background: #f1d99818; }
.observation-card {
  left: 50%; right: auto;
  width: max-content;
  max-width: calc(100% - 20px);
  transform: translateX(-50%);
}
.tool-row { display: grid; grid-template-columns: repeat(3, auto); }
.tool-row > button:not(.camera-shutter) { min-width: 71px; }

@media (min-width: 700px) {
  .observation-card {
    bottom: 20px;
    padding: 7px; border-radius: 16px;
    background: var(--glass); border: 1px solid #ffffff28;
  }
  .tool-row { align-items: center; gap: 7px; }
  .tool-row button { min-width: 71px; min-height: 46px; font-size: 11px; }
  .tool-row .camera-shutter { min-width: 46px; min-height: 46px; width: 46px; height: 46px; margin: 0; }
  .scene-zoom-hud { bottom: 86px; padding: 5px; background: var(--glass); }
  .scene-zoom-hud button { min-width: 49px; height: 38px; font-size: 13px; }
  .focus-control, #app.info-open .focus-control.open { bottom: 144px; width: min(360px, 38vw); }
  .focus-control > span, .focus-control button { font-size: 11px; }
  .scope-hud { gap: 10px; padding: 7px 13px; font-size: 12px; }
  .scope-hud b, .scope-hud small { font-size: inherit; }
}

@media (min-width: 900px) {
  .bird-info, .bird-info.compact-result, .bird-info.compact-result.has-banding {
    left: auto; right: 20px; bottom: 95px;
    width: clamp(248px, 23vw, 340px);
    height: auto !important;
    max-height: calc(100% - 120px);
    padding: 15px !important;
    overflow: auto;
    color: var(--ink); background: var(--paper);
  }
  .bird-info:not(.open) { transform: translateX(calc(100% + 22px)); }
  .bird-info-header, .bird-info.compact-result .bird-info-header { grid-template-columns: 76px minmax(0, 1fr) auto; gap: 9px; }
  .bird-info-identity h2, .bird-info.compact-result .bird-info-identity h2 { font-size: 19px; }
  .bird-info-identity span, .bird-info-identity small { font-size: 10px; }
  .bird-info.unidentified .bird-info-content { display: none; }
  .bird-info.compact-result .bird-info-content,
  .bird-info.compact-result.has-banding .bird-info-content {
    position: static;
    margin-top: 10px;
    padding: 0;
  }
  .bird-info.compact-result .bird-info-content dl div { padding: 6px 7px; }
  .bird-info.compact-result .bird-info-content dt { font-size: 9px; }
  .bird-info.compact-result .bird-info-content dd { font-size: 11px; }
}

@media (pointer: fine) {
  .web-mouse { display: revert; visibility: visible; }
  .web-touch { display: none; }
}

@media (min-width: 1100px) and (pointer: fine) {
  .web-control-note {
    position: absolute; z-index: 3; left: 20px; bottom: 23px;
    display: block; margin: 0; padding: 10px 12px;
    border-radius: 8px; color: #f4f0df; background: var(--glass);
    font-size: 12px; pointer-events: none;
  }
  .web-control-note span { margin-inline: 3px; color: var(--gold); }
  #app:has(.scope-ring.open, .start-screen:not(.hidden)) .web-control-note { display: none; }
}

@media (max-width: 720px) {
  .start-screen { background-position: 60% center; }
  .start-screen::before { background: linear-gradient(165deg, #152f2de8, #214a48a8 55%, #132e2ee8); }
  .start-content { grid-template-columns: 1fr; gap: 24px; padding: 26px 24px; }
  .web-intro { width: min(100%, 450px); margin-inline: auto; }
  .start-title { font-size: clamp(42px, 12vw, 67px); }
  .start-title span { margin-top: 4px; }
  .start-actions button { padding-inline: 11px; }
  .start-actions .play-btn { padding-inline: 13px; }
  .web-hero-optics { width: min(68vw, 34dvh, 240px); }
  .start-hero figcaption { margin-top: 4px; }
}

@media (max-height: 540px) and (min-width: 721px) {
  .start-content { padding-block: 20px; }
  .start-title { font-size: clamp(42px, 11dvh, 60px); }
}

@media (max-height: 520px) {
  .observation-card { bottom: max(6px, env(safe-area-inset-bottom)); padding: 3px 6px; }
  .tool-row .camera-shutter { width: 42px; height: 42px; min-width: 42px; min-height: 42px; margin: 0; }
  .tool-row button { min-height: 40px; }
  .tool-row button:not(.camera-shutter) span { width: 20px; height: 20px; margin-bottom: 2px; }
  .scene-zoom-hud { bottom: calc(max(6px, env(safe-area-inset-bottom)) + 52px); padding: 4px; }
  .scene-zoom-hud button { height: 30px; }
  .focus-control, #app.info-open .focus-control.open { bottom: calc(max(6px, env(safe-area-inset-bottom)) + 94px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
