:root {
  color-scheme: dark;
  --ink: #10100e;
  --ink-soft: #191915;
  --paper: #fff8e8;
  --muted: #b7b09f;
  --gold: #e8b86a;
  --gold-bright: #ffd98f;
  --line: rgba(255, 248, 232, 0.14);
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--ink);
  color: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; background: var(--ink); }
body { min-height: 100dvh; overflow-x: hidden; }
button { font: inherit; }

.app-shell { min-height: 100dvh; background: var(--ink); }

.intro {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto auto;
  gap: 20px;
  padding: var(--safe-top) 18px var(--safe-bottom);
  overflow: hidden;
  isolation: isolate;
}

.intro::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 90vw;
  height: 90vw;
  left: 5vw;
  top: 20vh;
  border: 1px solid rgba(232, 184, 106, 0.12);
  border-radius: 50%;
  box-shadow: 0 0 0 42px rgba(232, 184, 106, 0.025), 0 0 0 100px rgba(232, 184, 106, 0.018);
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--gold-bright); font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(232, 184, 106, .45); border-radius: 50%; font-size: .8rem; }
.intro-copy { align-self: end; max-width: 560px; }
.eyebrow { margin: 0 0 7px; color: var(--gold); font-size: .75rem; font-weight: 800; letter-spacing: .19em; }
h1 { margin: 0; max-width: 11ch; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.4rem, 10vw, 4.8rem); font-weight: 500; line-height: .98; letter-spacing: -.04em; }
.lead { margin: 14px 0 0; max-width: 36ch; color: var(--muted); font-size: 1rem; line-height: 1.5; }

.characters { display: grid; grid-template-columns: repeat(4, minmax(68px, 1fr)); gap: 8px; width: 100%; max-width: 620px; }
.character { position: relative; display: grid; gap: 7px; min-width: 0; padding: 0; color: var(--muted); border: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.portrait { position: relative; height: clamp(100px, 28vw, 180px); overflow: hidden; border: 1px solid var(--line); border-radius: 50px 50px 16px 16px; background: linear-gradient(160deg, #29271f, #161612); transition: .2s ease; }
.portrait::after { content: ""; position: absolute; inset: auto 10% 0; height: 20%; background: radial-gradient(ellipse, rgba(0,0,0,.5), transparent 70%); }
.portrait img { position: absolute; z-index: 1; inset: 7px 0 0; width: 100%; height: calc(100% - 7px); object-fit: contain; object-position: center bottom; filter: saturate(.85) brightness(.82); transition: .2s ease; }
.character-name { font-size: .84rem; font-weight: 700; }
.character.is-selected { color: var(--paper); }
.character.is-selected .portrait { border-color: var(--gold); background: linear-gradient(160deg, #4c3b22, #1c1811); box-shadow: 0 0 0 2px rgba(232,184,106,.15), 0 12px 30px rgba(0,0,0,.32); transform: translateY(-4px); }
.character.is-selected .portrait img { filter: saturate(1.05) brightness(1); transform: scale(1.03); }
.character:focus-visible .portrait { outline: 3px solid var(--paper); outline-offset: 3px; }

.primary-action { min-height: 56px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; max-width: 620px; padding: 14px 20px; border: 0; border-radius: 18px; background: var(--gold-bright); color: #20180c; font-size: 1rem; font-weight: 800; box-shadow: 0 12px 32px rgba(0,0,0,.35); cursor: pointer; }
.primary-action:active { transform: translateY(1px); }
.primary-action:disabled { cursor: wait; opacity: .72; }
.primary-action.is-loading .camera-icon { border-radius: 50%; border-color: currentColor transparent currentColor currentColor; animation: spin .8s linear infinite; }
.primary-action.is-loading .camera-icon::before, .primary-action.is-loading .camera-icon::after { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.camera-icon { width: 20px; height: 15px; border: 2px solid currentColor; border-radius: 4px; position: relative; }
.camera-icon::before { content: ""; position: absolute; width: 7px; height: 4px; left: 5px; top: -6px; border: 2px solid currentColor; border-bottom: 0; border-radius: 3px 3px 0 0; }
.camera-icon::after { content: ""; position: absolute; width: 5px; height: 5px; left: 5px; top: 3px; border: 2px solid currentColor; border-radius: 50%; }
.privacy-note { margin: -9px 0 0; color: #837e72; text-align: center; font-size: .75rem; }
.lock { color: var(--gold); }

.ar-stage { position: fixed; inset: 0; min-height: 100dvh; overflow: hidden; background: #050505; touch-action: none; }
.ar-stage[hidden] { display: none; }
#camera, #ar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#camera { object-fit: cover; opacity: 1; pointer-events: none; }
#ar-canvas { display: block; }
#character-video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.top-bar { position: absolute; z-index: 3; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 12px; padding: var(--safe-top) 16px 10px; background: linear-gradient(to bottom, rgba(0,0,0,.6), transparent); }
.icon-button { display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(10,10,8,.44); color: white; font-size: 1.35rem; backdrop-filter: blur(12px); cursor: pointer; }
.active-character { justify-self: center; display: flex; align-items: center; gap: 8px; padding: 9px 13px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: rgba(10,10,8,.48); backdrop-filter: blur(12px); font-size: .85rem; }
.active-character span { width: 7px; height: 7px; border-radius: 50%; background: var(--gold-bright); box-shadow: 0 0 10px var(--gold); }

.placement-guide { position: absolute; z-index: 2; inset: 0; display: grid; place-content: center; justify-items: center; gap: 20px; pointer-events: none; transition: opacity .25s ease; }
.placement-guide p { margin: 0; padding: 10px 15px; border-radius: 999px; background: rgba(10,10,8,.58); color: white; font-size: .9rem; backdrop-filter: blur(12px); }
.reticle { width: 92px; height: 46px; border: 1px solid rgba(255,255,255,.8); border-radius: 50%; box-shadow: 0 0 0 5px rgba(255,255,255,.08); animation: breathe 1.8s ease-in-out infinite; }
.reticle::before, .reticle::after { content: ""; position: absolute; left: 50%; top: 50%; background: white; transform: translate(-50%, -50%); }
.reticle::before { width: 14px; height: 1px; }
.reticle::after { width: 1px; height: 14px; }
@keyframes breathe { 50% { transform: scale(1.12); opacity: .72; } }

.ar-controls { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; display: grid; justify-items: center; gap: 9px; padding: 16px 16px var(--safe-bottom); background: linear-gradient(to top, rgba(0,0,0,.7), transparent); }
.ar-controls[hidden] { display: none; }
.ar-controls p { margin: 0; color: rgba(255,255,255,.82); font-size: .75rem; text-shadow: 0 1px 5px #000; }
.ar-controls > div { display: flex; justify-content: center; gap: 10px; }
.control-button { min-height: 48px; padding: 0 17px; border: 1px solid rgba(255,255,255,.26); border-radius: 999px; background: rgba(10,10,8,.62); color: white; font-size: .86rem; font-weight: 700; backdrop-filter: blur(14px); cursor: pointer; }

dialog { width: min(calc(100% - 36px), 420px); padding: 28px 22px 20px; border: 1px solid rgba(232,184,106,.26); border-radius: 24px; background: #1c1b17; color: var(--paper); text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,.58); }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(7px); }
.dialog-icon { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 16px; border: 1px solid rgba(232,184,106,.4); border-radius: 50%; color: var(--gold); font-size: 1.5rem; }
dialog h2 { margin: 0; font: 500 1.65rem/1.1 Georgia, serif; }
dialog p { margin: 12px auto 20px; color: var(--muted); line-height: 1.5; }
dialog .primary-action { min-height: 50px; }
.text-button { margin: 12px auto 0; padding: 8px 16px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }

@media (min-width: 720px) {
  .intro { width: min(100%, 880px); margin: auto; padding-inline: 32px; }
  .intro-copy { align-self: center; }
  .characters, .primary-action { justify-self: center; }
  .privacy-note { justify-self: center; }
}

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