/* Golden Hour game layer: HUD, cards, photo mode, share view. Author: Ejaz Ahmed. */

#ui {
  --g-ink: #0d0a1a;
  --g-pink: #ff3d9a;
  --g-teal: #22e0d0;
  --g-amber: #ffb347;
  --g-glass: rgba(13, 10, 26, 0.62);
  --g-line: rgba(255, 255, 255, 0.18);
  --g-display: "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", system-ui, sans-serif;
  --g-text: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --g-top: calc(10px + env(safe-area-inset-top, 0px));
  --g-left: calc(10px + env(safe-area-inset-left, 0px));
  --g-right: calc(10px + env(safe-area-inset-right, 0px));
  --g-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  font-family: var(--g-text);
  color: #fff;
}
#ui [hidden] { display: none !important; }
#ui *, #ui *::before, #ui *::after { box-sizing: border-box; }
#ui p, #ui h2 { margin: 0; }
#ui button { font-family: inherit; cursor: pointer; pointer-events: auto; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#ui button:focus-visible { outline: 3px solid var(--g-teal); outline-offset: 2px; }
#ui button:disabled { opacity: 0.55; cursor: default; }

/* ---------- Buttons ---------- */
.g-btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--g-line);
  background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 15px; font-weight: 700; letter-spacing: 0.02em;
  transition: transform 0.12s ease, background 0.12s ease;
}
.g-btn:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.18); }
.g-btn.g-primary { border: 0; color: var(--g-ink); background: linear-gradient(135deg, var(--g-amber), var(--g-pink)); }
.g-icon-btn {
  width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border-radius: 50%;
  border: 1px solid var(--g-line); background: var(--g-glass); color: #fff;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.g-icon-btn:active { background: rgba(255, 255, 255, 0.2); }
.g-stack { display: grid; gap: 10px; margin-top: 18px; }
.g-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- HUD ---------- */
.g-hud { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.g-map-wrap {
  position: absolute; top: var(--g-top); left: var(--g-left); width: 96px; height: 96px; border-radius: 50%;
  overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.4); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}
.g-map { display: block; width: 100%; height: 100%; }
.g-top-right {
  position: absolute; top: var(--g-top); right: var(--g-right); display: flex; flex-direction: column;
  align-items: flex-end; gap: 8px;
}
.g-btns, .g-readouts { display: flex; gap: 8px; justify-content: flex-end; }
.g-timer, .g-speed {
  min-height: 40px; padding: 0 12px; display: flex; align-items: baseline; gap: 4px; border-radius: 12px;
  background: var(--g-glass); border: 1px solid var(--g-line); line-height: 40px;
  font-family: var(--g-display); font-weight: 800; font-variant-numeric: tabular-nums;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
/* The colour is set from script: amber, turning pink over the last seconds as the sun reaches the horizon. */
.g-timer { font-size: 28px; color: var(--g-amber); letter-spacing: 0.03em; }
.g-timer.g-urgent { border-color: var(--g-pink); animation: g-beat 0.5s ease-in-out infinite alternate; }
.g-speed b { font-size: 24px; min-width: 2ch; text-align: right; }
.g-speed span { font: 600 11px var(--g-text); letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.8; }

/* Full objective: open for a few seconds after a change, then it collapses to the chip. Tap to dismiss. */
.g-objective {
  position: absolute; top: calc(var(--g-top) + 108px); left: 50%; transform: translateX(-50%);
  width: min(92vw, 440px); padding: 10px 14px 12px; text-align: center; border-radius: 16px;
  background: var(--g-glass); border: 1px solid var(--g-line); pointer-events: auto; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  animation: g-in 0.25s ease both;
}
/* Collapsed objective: one line by the mini-map (under it on narrow screens, beside it from 700 px). */
#ui .g-objchip {
  position: absolute; top: calc(var(--g-top) + 104px); left: var(--g-left); max-width: calc(100vw - 20px);
  min-height: 30px; padding: 0 12px; display: flex; align-items: center; gap: 8px; border-radius: 999px;
  background: var(--g-glass); border: 1px solid var(--g-line); color: #fff; white-space: nowrap;
  font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
/* A taller invisible hit area keeps the small chip easy to tap. */
.g-objchip::after { content: ""; position: absolute; inset: -8px -4px; }
.g-mini-name { overflow: hidden; text-overflow: ellipsis; }
.g-mini-progress { color: var(--g-amber); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

/* Screen-edge arrow toward the objective; positioned from script. */
.g-guide {
  position: absolute; left: 0; top: 0; display: grid; justify-items: center; gap: 2px; pointer-events: none;
  will-change: transform;
}
.g-guide-arrow { display: block; width: 32px; height: 32px; color: var(--g-teal); filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6)); }
.g-guide-arrow svg { display: block; }
.g-guide-dist {
  padding: 2px 8px; border-radius: 999px; background: rgba(13, 10, 26, 0.78); white-space: nowrap;
  font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: 0.04em;
}
.g-chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--g-pink); color: var(--g-ink);
  font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
}
.g-objective-text { margin-top: 6px !important; font-size: 16px; font-weight: 600; line-height: 1.3; }
.g-dots { display: flex; justify-content: center; gap: 9px; margin-top: 9px; }
.g-dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--g-amber); }
.g-dots i.g-on { background: var(--g-amber); box-shadow: 0 0 10px var(--g-amber); }

@media (min-width: 700px) {
  .g-map-wrap { width: 132px; height: 132px; }
  .g-objective { top: var(--g-top); width: min(44vw, 520px); }
  .g-objective-text { font-size: 18px; }
  #ui .g-objchip { top: var(--g-top); left: calc(var(--g-left) + 142px); max-width: 44vw; min-height: 34px; font-size: 12px; }
}
@media (min-width: 700px) and (max-height: 480px) {
  .g-map-wrap { width: 104px; height: 104px; }
  .g-objective { width: min(40vw, 420px); padding: 7px 12px 9px; }
  #ui .g-objchip { left: calc(var(--g-left) + 114px); }
}

/* ---------- Cards ---------- */
.g-card {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; overflow-y: auto; pointer-events: auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) calc(18px + env(safe-area-inset-right, 0px))
    calc(30px + env(safe-area-inset-bottom, 0px)) calc(18px + env(safe-area-inset-left, 0px));
  animation: g-in 0.28s ease both;
}
.g-scrim { background: rgba(13, 10, 26, 0.6); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.g-panel {
  width: min(100%, 400px); padding: 26px 22px 22px; text-align: center; border-radius: 24px;
  background: rgba(13, 10, 26, 0.84); border: 1px solid var(--g-line); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}
.g-panel h2 { font: 800 30px/1.05 var(--g-display); letter-spacing: 0.02em; margin-top: 6px; }
.g-kicker { color: var(--g-pink); font-size: 12px; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; }
.g-body { margin-top: 12px !important; font-size: 16px; line-height: 1.45; color: rgba(255, 255, 255, 0.9); }
.g-sheet .g-fact .g-btn { margin-top: 12px; width: 100%; min-height: 44px; }
.g-fact h2 { color: var(--g-amber); font-size: 26px; margin-top: 4px; }
.g-fact .g-body { margin-top: 8px !important; font-size: 15px; line-height: 1.4; }

/* Bottom sheet: the card sits low and the scene stays visible above it (beside it when the screen is wide). */
.g-sheet {
  place-items: end center; overflow: hidden;
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}
.g-sheet .g-panel {
  width: min(100%, 440px); max-height: 38vh; max-height: 38dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 18px; border-radius: 22px;
}
.g-sheet .g-fact { animation: g-rise 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@media (orientation: landscape) {
  .g-sheet { place-items: end end; }
  .g-sheet .g-panel { width: min(42vw, 400px); max-height: calc(100vh - 44px); max-height: calc(100dvh - 44px); }
}
.g-panel > .g-btn { margin-top: 20px; width: 100%; }
.g-disc { margin-top: 14px !important; font-size: 10.5px; color: rgba(255, 255, 255, 0.65); }

/* Title */
/* Fades in after the page loader has faded out (0.6 s), so the two wordmarks never overlap. */
.g-title {
  cursor: pointer; text-align: center; place-items: stretch center; overflow: hidden;
  background: linear-gradient(180deg, rgba(13, 10, 26, 0.74) 0%, rgba(13, 10, 26, 0.3) 22%, rgba(13, 10, 26, 0) 35%,
    rgba(13, 10, 26, 0) 63%, rgba(13, 10, 26, 0.5) 78%, rgba(13, 10, 26, 0.84) 100%);
  animation: g-in 0.5s ease 0.6s both;
}
.g-title-body { display: grid; grid-template-rows: auto 1fr auto; justify-items: center; width: min(100%, 520px); }
.g-title-top { grid-row: 1; display: grid; justify-items: center; padding-top: 6px; }
.g-title-bottom { grid-row: 3; display: grid; justify-items: center; }
.g-title-mute { position: absolute; top: var(--g-top); right: var(--g-right); }
.g-wordmark { display: grid; justify-items: center; line-height: 1; text-transform: uppercase; }
.g-mark { display: block; width: 68px; height: auto; color: var(--g-amber); }
.g-wm-a { margin-top: 10px; padding-left: 0.52em; font: 500 clamp(20px, 6.4vw, 34px)/1 var(--g-display); letter-spacing: 0.52em; }
.g-wm-b {
  margin-top: 4px; font: 800 clamp(72px, 25vw, 150px)/0.88 var(--g-display); letter-spacing: 0.03em; color: var(--g-amber);
  background: linear-gradient(180deg, #ffe2b0 8%, var(--g-amber) 52%, var(--g-pink) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 22px rgba(255, 61, 154, 0.35));
}
.g-sub { margin-top: 12px !important; text-shadow: 0 1px 8px rgba(13, 10, 26, 0.8); font-size: 13px; font-weight: 600; letter-spacing: 0.32em; text-transform: uppercase; }
.g-start {
  margin-top: 0; min-height: 54px; padding: 0 30px; border-radius: 999px; border: 2px solid #fff; background: rgba(13, 10, 26, 0.35);
  color: #fff; font-size: 15px; font-weight: 800; letter-spacing: 0.24em; text-transform: uppercase;
  animation: g-pulse 1.7s ease-in-out infinite;
}
.g-help { margin-top: 16px !important; max-width: 34ch; font-size: 13px; line-height: 1.45; color: rgba(255, 255, 255, 0.88); }

.g-wordmark-sm .g-mark { width: 40px; }
.g-wordmark-sm .g-wm-a { margin-top: 6px; font-size: 13px; }
.g-wordmark-sm .g-wm-b { font-size: 44px; filter: none; }

/* Banner */
.g-banner {
  position: absolute; left: 0; right: 0; top: 34%; z-index: 5; padding: 18px 20px 20px; text-align: center; pointer-events: none;
  background: linear-gradient(90deg, rgba(13, 10, 26, 0) 0%, rgba(13, 10, 26, 0.86) 22%, rgba(13, 10, 26, 0.86) 78%, rgba(13, 10, 26, 0) 100%);
  border-block: 1px solid rgba(255, 179, 71, 0.55);
  animation: g-sweep 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.g-banner h2 { font: 800 clamp(34px, 10.5vw, 62px)/1 var(--g-display); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 6px; }
.g-banner-detail { margin-top: 8px !important; color: var(--g-amber); font: 800 28px var(--g-display); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; }

/* End */
/* The building is the picture: the sheet takes the lower half upright, the right-hand side when wide. */
.g-end { background: none; }
.g-sheet .g-end-panel {
  max-height: 52vh; max-height: 52dvh; padding: 14px 18px 16px;
  background: rgba(13, 10, 26, 0.8); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.g-bigtime { font: 800 clamp(46px, 8.6vh, 84px)/1 var(--g-display); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; margin-top: 2px !important; }
.g-rank { margin-top: 4px !important; color: var(--g-amber); font: 700 22px var(--g-display); letter-spacing: 0.05em; text-transform: uppercase; }
.g-total { font-size: 13px; margin-top: 6px !important; opacity: 0.85; }
.g-end-panel .g-stack { margin-top: 12px; gap: 8px; }
.g-end-panel .g-row { gap: 8px; }
.g-end-panel .g-btn { min-height: 44px; padding: 0 10px; }
.g-best { margin-top: 8px !important; font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255, 255, 255, 0.82); }
.g-best-new {
  display: inline-block; padding: 5px 14px; border-radius: 999px; color: var(--g-ink);
  background: linear-gradient(135deg, var(--g-amber), var(--g-pink));
}
.g-title-best { margin-top: 16px !important; color: var(--g-amber); text-shadow: 0 1px 6px rgba(13, 10, 26, 0.7); }
@media (orientation: landscape) {
  .g-end.g-sheet { place-items: center end; }
  .g-sheet .g-end-panel { width: min(46vw, 400px); max-height: calc(100vh - 44px); max-height: calc(100dvh - 44px); }
}
@media (max-height: 520px) {
  .g-end-panel .g-total, .g-title .g-help { display: none; }
  .g-bigtime { font-size: 44px; }
  .g-title .g-mark { width: 44px; }
  .g-wm-b { font-size: clamp(54px, 20vh, 96px); }
}

/* ---------- Share view ---------- */
/* Scrolls when the screen is short (landscape phones); `safe` and the auto margins keep the top reachable. */
.g-share-view {
  z-index: 7; align-content: center; align-content: safe center; justify-items: center;
  max-height: 100vh; max-height: 100dvh; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
/* Opaque on every tier (the end card must not show through), and clear of the page disclaimer at the bottom. */
#ui .g-share-view {
  background: rgba(13, 10, 26, 0.96); -webkit-backdrop-filter: none; backdrop-filter: none;
  padding-bottom: calc(46px + env(safe-area-inset-bottom, 0px));
}
.g-share-body { display: grid; justify-items: center; gap: 10px; width: 100%; margin: auto 0; }
.g-share-close { position: absolute; top: var(--g-top); right: var(--g-right); z-index: 1; }
.g-share-img {
  display: block; max-width: min(86vw, 420px); max-height: 52vh; max-height: 52dvh; width: auto; height: auto; border-radius: 14px;
  border: 1px solid var(--g-line); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6); pointer-events: auto;
  -webkit-touch-callout: default !important; -webkit-user-select: auto !important; user-select: auto !important;
}
.g-hold { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: rgba(255, 255, 255, 0.85); }
.g-share-status { min-height: 1.3em; font-size: 14px; font-weight: 700; color: var(--g-teal); text-align: center; }
.g-share-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; width: min(100%, 420px); }
.g-share-actions .g-btn { padding: 0 8px; }
@media (max-height: 520px) {
  .g-share-img { max-width: min(70vw, 420px); max-height: 64vh; max-height: 64dvh; }
}

/* ---------- Photo mode ---------- */
.g-photo { position: absolute; inset: 0; z-index: 2; container-type: size; pointer-events: none; }
.g-photo-surface { position: absolute; inset: 0; pointer-events: auto; touch-action: none; cursor: grab; }
.g-photo-guide {
  --g-ratio: 0.5625;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none;
  width: min(100vw, calc(100vh * var(--g-ratio)));
  width: min(100cqw, calc(100cqh * var(--g-ratio)));
  aspect-ratio: var(--g-ratio);
  border: 1px solid rgba(255, 255, 255, 0.7); box-shadow: 0 0 0 100vmax rgba(13, 10, 26, 0.5);
}
.g-photo-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.g-photo-flash.g-on { animation: g-flash 0.35s ease-out; }
.g-photo-top { position: absolute; top: var(--g-top); left: var(--g-left); right: var(--g-right); display: flex; justify-content: space-between; gap: 10px; }
.g-chip-btn { min-height: 44px; border-radius: 999px; background: var(--g-glass); font-size: 13px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.g-photo-presets {
  position: absolute; top: calc(var(--g-top) + 54px); left: var(--g-left); right: var(--g-right);
  display: flex; justify-content: center; flex-wrap: wrap; gap: 8px;
}
.g-preset { padding: 0 14px; }
.g-preset[aria-pressed="true"] { background: var(--g-teal); color: var(--g-ink); border-color: transparent; }
.g-photo-bar {
  position: absolute; left: var(--g-left); right: var(--g-right); bottom: calc(var(--g-bottom) + 22px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 10px;
}
.g-photo-bar .g-icon-btn { justify-self: start; }
.g-photo-hint { justify-self: end; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; opacity: 0.85; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7); }
.g-shutter {
  width: 76px; height: 76px; padding: 0; display: grid; place-items: center; border-radius: 50%; color: var(--g-ink);
  background: #fff; background-clip: padding-box; border: 5px solid rgba(255, 255, 255, 0.45);
}
.g-shutter:active { transform: scale(0.94); }

/* ---------- Toast and fade ---------- */
.g-toast {
  position: absolute; left: 50%; bottom: calc(var(--g-bottom) + 84px); transform: translateX(-50%); z-index: 8;
  max-width: 86vw; padding: 10px 16px; border-radius: 999px; background: rgba(13, 10, 26, 0.92); border: 1px solid var(--g-line);
  font-size: 14px; font-weight: 600; text-align: center; pointer-events: none;
}
.g-fade {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 24px; text-align: center;
  background: var(--g-ink); opacity: 0; pointer-events: none; transition: opacity 0.5s ease;
}
.g-fade.g-on { opacity: 1; }
/* Walking into the lobby: a warm glow instead of black, carrying one line. */
.g-fade.g-warm { background: radial-gradient(circle at 50% 46%, #ffe9c4 0%, var(--g-amber) 48%, #e2703a 100%); }
.g-fade-line { color: var(--g-ink); font: 800 clamp(38px, 11vw, 68px)/1 var(--g-display); letter-spacing: 0.04em; text-transform: uppercase; }
.g-fade:not(.g-warm) .g-fade-line { display: none; }
.g-bump {
  position: absolute; inset: 0; z-index: 3; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(13, 10, 26, 0) 56%, rgba(255, 61, 154, 0.3) 100%);
}
.g-bump.g-on { animation: g-bump 0.45s ease-out; }

/* ---------- Motion ---------- */
@keyframes g-pulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.45); } 50% { transform: scale(1.04); box-shadow: 0 0 0 14px rgba(255, 255, 255, 0); } }
@keyframes g-beat { from { transform: scale(1); } to { transform: scale(1.05); } }
@keyframes g-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes g-sweep { from { opacity: 0; transform: translateX(-8%); } to { opacity: 1; transform: none; } }
@keyframes g-flash { from { opacity: 0.85; } to { opacity: 0; } }
@keyframes g-bump { from { opacity: 1; } to { opacity: 0; } }
@keyframes g-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- Blur budget ----------
   `g-noblur` (low quality, or after the frame rate stepped down) drops every backdrop blur for solid panels.
   `g-touch` drops only the full-screen scrim blur, which is the costly one on phones. */
#ui.g-noblur { --g-glass: rgba(13, 10, 26, 0.84); }
#ui.g-noblur .g-icon-btn, #ui.g-noblur .g-timer, #ui.g-noblur .g-speed, #ui.g-noblur .g-objective,
#ui.g-noblur .g-objchip, #ui.g-noblur .g-chip-btn, #ui.g-noblur .g-end-panel, #ui.g-noblur .g-scrim, #ui.g-touch .g-scrim {
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
#ui.g-noblur .g-scrim:not(.g-share-view), #ui.g-touch .g-scrim:not(.g-share-view) { background: rgba(13, 10, 26, 0.8); }
#ui.g-noblur .g-end-panel { background: rgba(13, 10, 26, 0.9); }

@media (prefers-reduced-motion: reduce) {
  #ui *, #ui *::before, #ui *::after { animation: none !important; transition: none !important; }
  /* Not motion: the title still waits for the page loader to clear, then simply appears. */
  #ui .g-title { animation: g-in 0.01s linear 0.6s both !important; }
}
