:root {
  --bg: #06080c;
  --fg: #e8edf4;
  --muted: #8592a5;
  --line: rgba(255, 255, 255, 0.10);
  --panel: rgba(14, 18, 26, 0.86);
  --gold: #ffd166;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: radial-gradient(ellipse at 50% 40%, #0d1320 0%, var(--bg) 70%); }
#tiles, #labels { position: fixed; inset: 0; pointer-events: none; }

/* ---------- brand ---------- */
#brand { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; }
#brand h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
#brand h1 span { color: var(--muted); font-weight: 400; }
#brand p { margin: 2px 0 0; font-size: 11px; color: var(--muted); letter-spacing: .04em; }

/* ---------- tiles ---------- */
.tile {
  position: absolute; left: 0; top: 0; padding: 0; border: 0; background: none; cursor: pointer;
  pointer-events: auto; will-change: transform, opacity; transform-origin: 0 0;
}
.tile .face {
  position: absolute; inset: 0; border-radius: 22%; background: #f4f6f9; overflow: hidden;
  display: grid; place-items: center; box-shadow: 0 2px 10px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.08);
  transition: box-shadow .2s;
}
.tile img { width: 78%; height: 78%; object-fit: contain; display: block; }
.tile .face.fill img { width: 100%; height: 100%; object-fit: cover; }
.tile .face.dark { background: #1c2332; }
.tile .face.wide img, .d-logo .face.wide img { width: 92%; height: 92%; }
.tile .mono { font-weight: 700; color: #1a2130; letter-spacing: -.02em; }
.tile .bar { position: absolute; left: 22%; right: 22%; bottom: -5px; height: 3px; border-radius: 2px; }
.tile .name {
  position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 11px; color: #c6cfdb; text-shadow: 0 1px 3px #000; pointer-events: none;
  opacity: 0; transition: opacity .25s;
}
.tile.show-name .name { opacity: 1; }
.tile:hover .face, .tile:focus-visible .face { box-shadow: 0 0 0 2px #fff, 0 4px 18px rgba(0,0,0,.6); }
.tile:focus-visible { outline: none; }
.tile.selected .face { box-shadow: 0 0 0 2px #fff, 0 0 28px rgba(255,255,255,.35); }
.tile.hidden { pointer-events: none; }

/* ---------- layer labels ---------- */
.layer-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; border: 0; background: none;
  font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  padding: 3px 6px; border-radius: 4px; transition: background .2s; will-change: transform, opacity;
}
.layer-label:hover { background: rgba(255,255,255,.08); }
.layer-label.hidden { opacity: 0; pointer-events: none; }

/* ---------- stepper ---------- */
#stepper {
  position: fixed; left: 14px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 4px; padding: 8px 0;
}
#stepper button {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer;
  padding: 5px 6px; border-radius: 6px; color: var(--muted); font-size: 11px; text-align: left;
}
#stepper button .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; opacity: .55; transition: transform .2s, opacity .2s; }
#stepper button .txt { opacity: 0; transform: translateX(-4px); transition: opacity .2s, transform .2s; white-space: nowrap; }
#stepper:hover button .txt, #stepper button.active .txt { opacity: 1; transform: none; }
#stepper button:hover { color: var(--fg); }
#stepper button.active { color: var(--fg); }
#stepper button.active .dot { opacity: 1; transform: scale(1.35); }
#stepper button.near .dot { opacity: .9; }
#stepper .all .dot { background: transparent; border: 1.5px solid var(--muted); }
#stepper .sep { height: 1px; background: var(--line); margin: 4px 6px; }

/* ---------- selection bar ---------- */
#selection {
  position: fixed; top: 58px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(10px);
}
#selection[hidden] { display: none; }
.sel-name { font-weight: 600; }
.sel-layer { font-size: 12px; color: var(--muted); }

/* ---------- details card ---------- */
#details {
  position: fixed; top: 16px; right: 16px; bottom: 16px; width: min(380px, 40vw); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 22px 18px;
  backdrop-filter: blur(12px); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
#details[hidden] { display: none; }
#details h2 { margin: 0; font-size: 19px; line-height: 1.25; font-weight: 650; }
#details h3 { margin: 22px 0 8px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
#details h3 .count { color: #5d6a7d; margin-left: 4px; }
.d-head { display: flex; gap: 14px; align-items: center; padding-right: 24px; }
.d-logo { position: relative; width: 52px; height: 52px; flex: none; }
.d-logo .face { position: absolute; inset: 0; border-radius: 22%; background: #f4f6f9; display: grid; place-items: center; overflow: hidden; }
.d-logo .face.dark { background: #1c2332; }
.d-logo img { width: 78%; height: 78%; object-fit: contain; }
.d-logo .face.fill img { width: 100%; height: 100%; object-fit: cover; }
.d-logo .mono { font-weight: 700; color: #1a2130; font-size: 18px; }
.d-meta { display: flex; gap: 10px; align-items: center; margin-top: 4px; font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); }
.chip::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.d-desc { margin: 16px 0 0; color: #cfd7e3; }
.play { margin-top: 14px; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 999px; padding: 6px 14px 6px 10px; cursor: pointer; font-size: 12px; }
.play:hover { background: rgba(255,255,255,.09); }
.play.on .ic { color: var(--gold); }
.play.blocked { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255,209,102,.25); }
.partners, .sources { list-style: none; margin: 0; padding: 0; }
.partners li { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(255,255,255,.05); font-size: 13px; }
.partner { border: 0; background: none; padding: 0; cursor: pointer; text-align: left; font-weight: 550; }
.partner:hover { text-decoration: underline; }
.partners .what { color: var(--muted); font-size: 12px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.partners .src, .sources a { color: #8fb6ff; font-size: 11px; text-decoration: none; }
.partners .src:hover, .sources a:hover { text-decoration: underline; }
.sources li { padding: 3px 0; font-size: 12px; }
.partners .flag { font-size: 10px; letter-spacing: .04em; color: #ffcf8a; border: 1px solid rgba(255,207,138,.45); border-radius: 4px; padding: 0 5px; white-space: nowrap; }
#details .close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }

/* ---------- portrait phones ---------- */
#rotate { display: none; }
@media (orientation: portrait) and (max-width: 820px) {
  #rotate {
    display: grid; place-content: center; justify-items: center; gap: 18px; position: fixed; inset: 0; z-index: 100;
    background: var(--bg); color: var(--fg); font-size: 16px; text-align: center;
  }
  #rotate .phone { width: 38px; height: 64px; border: 2px solid var(--fg); border-radius: 8px; animation: tilt 2.4s ease-in-out infinite; }
  body > :not(#rotate) { visibility: hidden; }
}
@keyframes tilt { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; letter-spacing: .06em; background: var(--bg); transition: opacity .5s; }
#loading.done { opacity: 0; pointer-events: none; }

/* ---------- tutorial ---------- */
#tut-offer { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(6,8,12,.55), rgba(6,8,12,.85)); }
#tut-offer[hidden] { display: none; }
#tut-offer .card { width: min(460px, calc(100vw - 32px)); text-align: center; padding: 34px 32px 28px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(14px); box-shadow: 0 30px 80px rgba(0,0,0,.5); }
#tut-offer .kicker { margin: 0 0 6px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
#tut-offer h2 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
#tut-offer .sub { margin: 10px 0 24px; color: var(--muted); }
#tut-offer .row { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#tut-play { display: inline-flex; align-items: center; gap: 10px; border: 0; border-radius: 999px; padding: 12px 30px; font-size: 15px; font-weight: 650; cursor: pointer; background: var(--gold); color: #1b1405; box-shadow: 0 0 0 6px rgba(255,209,102,.15); }
#tut-play:hover { filter: brightness(1.06); }
#tut-play .ic { font-size: 12px; }
#tut-offer .ghost { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px; }
#tut-offer .ghost:hover { color: var(--fg); }

#tut-caption {
  position: fixed; left: 50%; bottom: 38px; transform: translateX(-50%); z-index: 30; width: min(760px, calc(100vw - 260px));
  padding: 14px 22px; text-align: center; font-size: 17px; line-height: 1.5; color: #f1f4f9;
  background: rgba(10, 13, 20, .82); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(10px);
}
#tut-caption[hidden] { display: none; }
#tut-caption.task { border-color: rgba(255,209,102,.45); box-shadow: 0 0 30px rgba(255,209,102,.12); }
#tut-skip { position: fixed; top: 18px; left: 20px; z-index: 45; border: 1px solid var(--line); background: rgba(14,18,26,.8); border-radius: 999px; padding: 7px 18px; cursor: pointer; font-size: 13px; }
#tut-skip:hover { background: rgba(255,255,255,.1); }
#tut-skip[hidden] { display: none; }
#tut-progress { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 30; display: flex; gap: 5px; }
#tut-progress[hidden] { display: none; }
#tut-progress i { width: 18px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.15); transition: background .3s; }
#tut-progress i.on { background: var(--gold); }

#tut-arrow { position: fixed; left: 0; top: 0; z-index: 35; width: 72px; height: 72px; color: var(--gold); pointer-events: none; filter: drop-shadow(0 0 10px rgba(255,209,102,.9)) drop-shadow(0 0 22px rgba(255,209,102,.5)); transition: opacity .2s; }
#tut-arrow[hidden] { display: none; }
#tut-arrow svg { width: 100%; height: 100%; animation: nudge 1s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

/* story mode: only Skip is shown; map is locked */
body.tut-story #stepper, body.tut-story #selection, body.tut-story #details { display: none !important; }
body.tut-story .tile, body.tut-story .layer-label { pointer-events: none; }
.tut-target { position: relative; }
#stepper button.tut-target .txt { opacity: 1; transform: none; color: var(--fg); }
#stepper button.tut-target .dot { opacity: 1; transform: scale(1.5); box-shadow: 0 0 0 4px rgba(255,209,102,.35); }
#details .partner.tut-target { color: var(--gold); text-decoration: underline; }
#tut-offer .sound svg { width: 16px; height: 16px; flex: none; }
#tut-offer .sound { margin: -8px 0 20px; font-size: 14px; color: var(--fg); display: inline-flex; gap: 8px; align-items: center; padding: 6px 12px; border-radius: 999px; background: rgba(255,209,102,.1); border: 1px solid rgba(255,209,102,.35); }

/* named company: flash + spinning gold ring */
.tile.spot { z-index: 5; }
.tile.spot .face { animation: flash 1.2s ease-out 1; box-shadow: 0 0 0 2px var(--gold), 0 0 26px rgba(255,209,102,.65); }
.tile.spot::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%; padding: 2.5px;
  background: conic-gradient(var(--gold) 0 25%, transparent 25% 50%, var(--gold) 50% 75%, transparent 75%);
  -webkit-mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: spin 2.4s linear infinite; pointer-events: none;
}

@keyframes spin { to { transform: rotate(1turn); } }
@keyframes flash { 0% { filter: brightness(2.2); } 100% { filter: none; } }
.layer-label.glow { text-shadow: 0 0 12px currentColor, 0 0 2px currentColor; background: rgba(255,255,255,.06); }

/* small landscape screens (phones): compact chrome */
@media (max-height: 560px), (max-width: 999px) {
  #brand { top: 8px; }
  #brand h1 { font-size: 12px; }
  #brand p { display: none; }
  #stepper { left: 6px; gap: 0; }
  #stepper button { padding: 4px; }
  #stepper button .txt { display: none; }
  #selection { top: 30px; padding: 4px 4px 4px 12px; gap: 8px; }
  .sel-layer { display: none; }
  #details { top: 8px; bottom: 8px; right: 8px; padding: 16px; }
  #tut-caption { bottom: 18px; font-size: 13px; padding: 8px 14px; width: min(640px, calc(100vw - 120px)); }
  #tut-progress { bottom: 6px; }
  .layer-label { font-size: 9px; }
}
