:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0c101a;
  color: #e4e7ee;
}
* { box-sizing: border-box; }
body { margin: 0; isolation: isolate; font-size: 16px; line-height: 1.55; }
#deep-sky { position: fixed; z-index: -1; inset: 0; overflow: hidden; pointer-events: none; background: #090d1c; }
#deep-sky::before, #deep-sky::after { content: ""; position: absolute; inset: -6%; }
#deep-sky::before {
  background: linear-gradient(100deg,#0b0e1842,#0b0f1875 55%,#0d101a36), url("sky.webp") 48% 50% / cover;
}
#deep-sky::after {
  background: radial-gradient(ellipse at 8% 71%,#605fbc42,transparent 43%),
              radial-gradient(ellipse at 86% 18%,#b682b235,transparent 40%);
}
#stars { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  #deep-sky::before { animation: sky-drift 42s ease-in-out infinite alternate; }
  #deep-sky::after { animation: nebula-drift 24s ease-in-out infinite alternate; }
}
@keyframes sky-drift {
  from { transform: translate3d(-1.3%,.8%,0) scale(1); }
  to { transform: translate3d(1.7%,-1.1%,0) scale(1.045); }
}
@keyframes nebula-drift {
  from { transform: translate3d(-3%,1.5%,0) scale(1); opacity: .46; }
  to { transform: translate3d(3%,-1.5%,0) scale(1.08); opacity: .96; }
}
.profile {
  max-width: 930px; margin: clamp(12px, 3vw, 40px) auto 0;
  padding: clamp(16px, 3.4vw, 44px); background: linear-gradient(110deg,#0e121bd4,#0e121ac4 60%,#101221bf);
  border: 1px solid #303448; border-radius: 12px; overflow-wrap: break-word;
}
.profile h1 { margin: 0 0 16px; line-height: 0; }
.profile h2 { font-size: 1.5rem; margin: 28px 0 15px; padding-bottom: .3em; border-bottom: 1px solid #303644; line-height: 1.3; scroll-margin-top: 20px; }
.profile h3 { font-size: 1.23rem; margin: 22px 0 13px; line-height: 1.4; }
.profile h2 img, .profile h3 img, .profile img[align="absmiddle"] { vertical-align: middle; }
.profile h3 img { margin-left: 3px; }
.profile h2 img { margin-right: 3px; }
.profile p { margin: 0 0 16px; }
.profile img { max-width: 100%; }
.profile img[width="100%"] { width: 100%; display: block; }
.profile ul { padding-left: 2em; }
.profile li { margin: 3px 0; }
.profile table { border-collapse: collapse; margin-bottom: 18px; width: fit-content; max-width: 100%; }
.profile th, .profile td { border: 1px solid #343a48; padding: 6px 13px; text-align: left; }
.profile tr:nth-child(even) { background: #151b27; }
.profile code { background: #222737; padding: .16em .38em; border-radius: 5px; font-size: .86em; }
a { color: #b5c9ff; text-underline-offset: 3px; }
a:hover { color: #e4d8ff; }
.profile a { position: relative; z-index: 11; }
body { padding-bottom: 110px; }
:focus-visible { outline: 2px solid #ffdeb6; outline-offset: 4px; }
/* Keep labeled links reachable while the dragon crosses them; the flight controls sit above both. */
#flight { position: absolute; inset: 0; pointer-events: none; }
#effects { position: fixed; z-index: 9; width: 100%; height: 100%; inset: 0; pointer-events: none; }
#creature {
  position: fixed; z-index: 10; left: 0; top: 0; width: clamp(150px, 26vw, 360px); aspect-ratio: 2 / 1;
  border: 0; padding: 0; background: none; color: inherit; border-radius: 0; cursor: grab; appearance: none; -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; box-shadow: none;
  pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none;
  will-change: transform;
}
#creature:focus, #creature:focus-visible { outline: none; }
#creature:focus-visible:not([data-pointer-focus]) { filter: drop-shadow(0 0 3px #ffe1ba); }
#creature::before { content:""; position:absolute; inset:-5px; }
#creature .dragon-body { position:absolute; inset:0; pointer-events:auto; touch-action:none; }
@media (pointer:coarse) { #creature::before { inset:-9px; } }
#creature:active { cursor: grabbing; }
#creature #texture, #creature .flight-preview, #creature #rig {
  position:absolute; left:-11%; top:-32%; width:122%; height:164%; pointer-events:none;
}
#creature .flight-preview, #creature #rig { display:none; }
#creature .flight-preview { background-size:1600% 1600%; background-repeat:no-repeat; }
#creature.atlas-ready .flight-preview, #creature.rigged #rig { display:block; }
#creature.atlas-ready #texture, #creature.rigged #texture, #creature.rigged .flight-preview { display:none; }
#creature .dragon-body::before {
  content:""; position:absolute; inset:-25% -8% -14%; pointer-events:auto;
  clip-path: polygon(0 18%,18% 0,82% 0,100% 18%,100% 84%,55% 100%,0 84%);
}
.controls { position: fixed; z-index: 12; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: grid; gap: 7px; justify-items: end; }
.buttons, #guide { border: 1px solid #857c9b80; background: #15182af2; box-shadow: 0 5px 24px #0007; }
.buttons { pointer-events: auto; display: flex; align-items: center; gap: 4px; border-radius: 24px; padding: 4px; }
.controls button { font: inherit; font-weight: 600; font-size: 13px; line-height: 1.25; color: #e4def0; border-radius: 18px; border: 0; padding: 10px 12px; background: transparent; cursor: pointer; }
.controls button:hover { background: #32344e; }
.controls #fire { display: inline-flex; align-items: center; gap: 5px; background: #442a3a; color: #ffdebd; }
.controls #fire:hover, .controls #fire:active { background: #623748; }
.controls #fire svg { width: 17px; height: 17px; fill: #ffbd83; }
.controls #help { width: 32px; padding: 8px 0; border: 1px solid #716c87; margin-right: 3px; }
#guide { max-width: min(365px, calc(100vw - 32px)); margin: 0; border-radius: 10px; color: #e2deef; padding: 8px 12px; font-size: 13px; line-height: 1.45; }
.touch-help { display: none; }
[hidden] { display: none !important; }
@media (pointer: coarse) { .desktop-help { display: none; } .touch-help { display: inline; } }
@media (max-width: 700px) {
  .profile { border: 0; border-radius: 0; margin: 0 auto; }
  .profile td, .profile th { padding: 5px 8px; }
  body { padding-bottom: 128px; }
}
