:root {
  --sky: #bfe3f2;
  --paper: #fbf8f1;
  --ink: #1d1b17;
  --muted: #5d574c;
  --line: rgba(29, 27, 23, .14);
  --glass: rgba(251, 248, 241, .86);
  --shadow: 0 10px 30px rgba(20, 30, 40, .18);
  --radius: 14px;
  --accent: #d7262e;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="night"] {
  --sky: #0c1424;
  --paper: #161d2b;
  --ink: #eef1f6;
  --muted: #a9b2c2;
  --line: rgba(238, 241, 246, .16);
  --glass: rgba(22, 29, 43, .86);
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --accent: #ff6b6b;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sky); color: var(--ink); font: 15px/1.5 var(--font); }
button { font: inherit; color: inherit; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }

.mark { display: inline-block; width: 18px; height: 14px; flex: none; border-radius: 2px;
  background: linear-gradient(#fff 0 33.3%, var(--trail, #fff) 33.3% 66.6%, #fff 66.6%); box-shadow: 0 0 0 1px rgba(0, 0, 0, .25); }
.mark.big { width: 28px; height: 22px; }

.brand, .tools, #chips, .keys, .hint, #map { position: fixed; z-index: 5; }
.brand { top: 14px; left: 16px; display: flex; flex-direction: column; padding: 8px 14px; border-radius: var(--radius);
  background: var(--glass); backdrop-filter: blur(8px); box-shadow: var(--shadow); line-height: 1.25; }
.brand strong { font-size: 16px; }
.brand span { font-size: 13px; color: var(--muted); }
.tools { top: 14px; right: 16px; display: flex; gap: 8px; }
.tool { display: inline-flex; align-items: center; justify-content: center; min-width: 42px; height: 40px; padding: 0 14px;
  border: 0; border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px); box-shadow: var(--shadow);
  color: var(--ink); font-weight: 650; font-size: 14px; text-decoration: none; cursor: pointer; }
.tool:hover { outline: 2px solid var(--line); }
.tool:focus-visible, .chip:focus-visible, #panel-close:focus-visible, .actions > *:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tool.icon { padding: 0; width: 40px; }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
:root[data-theme="day"] .tool .sun, :root[data-theme="night"] .tool .moon { display: none; }

#chips { left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 8px; padding: 6px; max-width: calc(100vw - 32px);
  border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px); box-shadow: var(--shadow); overflow-x: auto; scrollbar-width: none; }
#chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; border: 0; border-radius: 999px; padding: 8px 14px;
  background: transparent; font-weight: 600; font-size: 14px; cursor: pointer; }
.chip:hover { background: var(--line); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

#map { right: 16px; bottom: 16px; width: 150px; height: 150px; border-radius: 50%; box-shadow: var(--shadow); cursor: pointer; }
.keys { left: 16px; bottom: 16px; margin: 0; max-width: 300px; padding: 8px 12px; border-radius: 10px; font-size: 12.5px;
  color: var(--muted); background: var(--glass); backdrop-filter: blur(8px); }
.keys b { color: var(--ink); }
.hint { left: 50%; bottom: 76px; transform: translateX(-50%); margin: 0; display: flex; align-items: center; gap: 8px; padding: 6px 14px;
  border-radius: 999px; background: var(--glass); backdrop-filter: blur(8px); font-weight: 600; font-size: 13.5px; white-space: nowrap; transition: opacity .4s; }
.hint { --trail: #d7262e; }
.gone { opacity: 0; pointer-events: none; }

#panel { position: fixed; z-index: 10; top: 72px; right: 16px; bottom: 16px; width: min(460px, calc(100vw - 32px));
  display: flex; flex-direction: column; border-radius: 18px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
  transform: translateX(calc(100% + 24px)); transition: transform .26s cubic-bezier(.2, .8, .2, 1); }
#panel.open { transform: none; }
#panel[hidden], [hidden] { display: none !important; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px 22px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; flex: 1; font-size: 21px; line-height: 1.2; }
#panel-close { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--line); font-size: 24px; line-height: 1; cursor: pointer; }
#panel-body { overflow-y: auto; padding: 6px 22px 22px; overscroll-behavior: contain; }

.prose h3 { margin: 20px 0 6px; font-size: 16px; }
.prose .when { display: block; font-weight: 500; font-size: 13.5px; color: var(--muted); }
.prose ul { margin: 6px 0; padding-left: 20px; }
.prose li { margin: 5px 0; }
.prose p { margin: 10px 0; }
.prose .lead { font-size: 16.5px; }
.prose .muted, .prose .org { color: var(--muted); }
.prose a { color: var(--accent); font-weight: 600; }
.prose dl.skills { margin: 12px 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; }
.prose dl.skills dt { font-weight: 700; }
.prose dl.skills dd { margin: 0; }
.prose ul.facts { list-style: none; padding: 0; display: grid; gap: 10px; }
.prose ul.facts li { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--line); }
.prose .big { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.prose ul.contact { list-style: none; padding: 0; display: grid; gap: 10px; }
.prose ul.contact a { display: inline-block; padding: 10px 16px; border-radius: 10px; background: var(--line); text-decoration: none; }

#intro { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .08), rgba(0, 0, 0, .35)); transition: opacity .5s; }
#intro .card { width: min(520px, 100%); padding: 30px 30px 26px; border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); }
#intro h1 { margin: 12px 0 2px; font-size: clamp(28px, 6vw, 40px); letter-spacing: -.02em; line-height: 1.1; }
#intro .role { margin: 0 0 14px; color: var(--muted); font-weight: 600; }
#intro .small { font-size: 13.5px; color: var(--muted); }
#intro .small b { color: var(--ink); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions > * { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 22px; border-radius: 999px;
  font-weight: 700; font-size: 15.5px; text-decoration: none; cursor: pointer; }
.primary { border: 0; background: #d7262e; color: #fff; }
.primary:hover { background: #b81e25; }
.secondary { border: 2px solid var(--line); color: var(--ink); }

#joystick, .touch-buttons { display: none; }
.touch #joystick { display: block; position: fixed; z-index: 6; left: 22px; bottom: 26px; width: 120px; height: 120px; border-radius: 50%;
  background: var(--glass); box-shadow: var(--shadow); touch-action: none; }
#joystick span { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: var(--ink); opacity: .75; }
.touch .touch-buttons { display: flex; position: fixed; z-index: 6; right: 18px; bottom: 30px; gap: 12px; }
.touch-buttons button { width: 62px; height: 62px; border: 0; border-radius: 50%; background: var(--glass); box-shadow: var(--shadow); font-size: 24px; touch-action: none; }
.touch .keys { display: none; }
.touch #map { bottom: auto; top: 112px; width: 96px; height: 96px; }
.touch #chips { bottom: auto; top: 66px; left: 16px; right: 16px; transform: none; max-width: none; }
.touch .hint { bottom: 168px; }

.noscript { position: fixed; inset: auto 16px 16px; z-index: 30; padding: 14px; background: var(--paper); border-radius: 12px; }

@media (max-width: 720px) {
  .brand { padding: 6px 12px; }
  .brand strong { font-size: 14.5px; }
  .brand span { font-size: 12px; }
  .tool { height: 38px; min-width: 38px; padding: 0 12px; font-size: 13px; }
  #chips { bottom: auto; top: 66px; left: 16px; right: 16px; transform: none; max-width: none; }
  #map { bottom: auto; top: 112px; width: 96px; height: 96px; }
  .keys { display: none; }
  #panel { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-height: 64vh; border-radius: 20px 20px 0 0;
    transform: translateY(calc(100% + 24px)); padding-bottom: env(safe-area-inset-bottom); }
  #panel.open { transform: none; }
  #intro .card { padding: 24px 20px 20px; }
}
@media (max-width: 480px) {
  .brand span { display: none; }
  .tools { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) { #panel, #intro, .hint { transition: none; } }
