:root {
  color-scheme: dark;
  --night: #070b12;
  --panel: #101826;
  --panel-2: #172234;
  --line: #24324a;
  --neon: #3ee6ff;
  --leaf: #59f08a;
  --gold: #f2c45c;
  --rose: #ff7a8a;
  --ink: #eaf2f5;
  --muted: #9fb2c2;
  --font: "Cairo", "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--night); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.7; overflow-x: hidden; }
button, input { font: inherit; }
h1, h2, h3, p { margin: 0; }

/* opening */
.opening { position: fixed; inset: 0; height: 100dvh; display: grid; place-items: center; overflow: hidden; z-index: 10; }
.opening-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 47% 40%; animation: drift 24s ease-in-out infinite alternate; }
@keyframes drift { from { transform: scale(1.04); } to { transform: scale(1.14) translateY(-1.5%); } }
.opening-veil { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 50%, rgba(7,11,18,.45), rgba(7,11,18,.86)); }
.opening-box { position: relative; z-index: 2; width: min(380px, calc(100vw - 40px)); text-align: center; display: grid; gap: 14px; }
.opening h1 { font-size: clamp(44px, 12vw, 76px); font-weight: 800; line-height: 1.15; text-shadow: 0 0 34px rgba(62,230,255,.55), 0 2px 12px rgba(0,0,0,.7); }
.opening-sub { color: var(--gold); font-weight: 700; font-size: 18px; text-shadow: 0 1px 8px rgba(0,0,0,.8); }
.login { display: grid; gap: 8px; text-align: right; background: rgba(16,24,38,.82); border: 1px solid var(--line); border-radius: 14px; padding: 18px; backdrop-filter: blur(8px); }
.login label { font-weight: 700; }
.login input { width: 100%; padding: 12px 14px; font-size: 16px; color: var(--ink); background: var(--night); border: 1px solid var(--line); border-radius: 10px; direction: ltr; }
.login input:focus-visible, .btn:focus-visible, .tabs button:focus-visible, .link:focus-visible, .plaque:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.login-msg { color: var(--rose); min-height: 1.7em; font-size: 14px; }
.btn { border: 0; border-radius: 10px; padding: 12px 20px; font-weight: 800; color: #04121a; background: linear-gradient(180deg, #7df0ff, var(--neon)); cursor: pointer; box-shadow: 0 0 24px rgba(62,230,255,.4); }
.btn-big { font-size: 20px; padding: 15px 34px; width: 100%; }
.enter { display: grid; gap: 12px; }
.voice { color: var(--muted); font-size: 14px; text-shadow: 0 1px 6px rgba(0,0,0,.9); }
.curtain { position: absolute; top: 0; bottom: 0; width: 51%; z-index: 3; pointer-events: none; transform: translateX(var(--off)); transition: transform 1.3s cubic-bezier(.7,0,.2,1); background: linear-gradient(90deg, #4a0f1c, #7c1a2e 28%, #4a0f1c 55%, #7c1a2e 80%, #4a0f1c); background-size: 120px 100%; }
.curtain-r { right: 0; --off: 101%; }
.curtain-l { left: 0; --off: -101%; }
.opening.closing .curtain { transform: translateX(0); }
.opening.opened { opacity: 0; transition: opacity .7s ease; pointer-events: none; }

/* app */
.app { width: min(1400px, 100%); margin: 0 auto; padding: max(12px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.top h2 { font-size: 24px; font-weight: 800; line-height: 1.3; text-shadow: 0 0 22px rgba(62,230,255,.4); }
.fresh { color: var(--muted); font-size: 13px; }
.link { background: none; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); padding: 5px 12px; cursor: pointer; }

.stage-wrap { position: relative; }
.stage { border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; overflow-y: hidden; direction: ltr; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.scene { position: relative; isolation: isolate; width: max(100%, calc(56dvh * 1.498)); aspect-ratio: 1600 / 1068; overflow: hidden; background: #05080d; }
body.playing { overflow: hidden; }
body.playing .app { visibility: hidden; }
.scene .bg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.room { opacity: 0; transition: opacity .45s ease; }
.room.on { opacity: 1; }
.scene:not([data-place="office"]) .plaque, .scene:not([data-place="office"]) .seat, .scene:not([data-place="office"]) .hubdesk { display: none; }
.hubdesk { position: absolute; pointer-events: none; }
.h-back { border-radius: 10% 10% 2% 2%; background: linear-gradient(180deg, #06222e, #0a3442 70%, #0b3a48); border: 2px solid var(--neon); box-shadow: 0 0 26px rgba(62,230,255,.75), inset 0 0 40px rgba(62,230,255,.22); }
.h-back::before { content: ""; position: absolute; inset: 4%; border-radius: 8%; background: repeating-linear-gradient(0deg, rgba(62,230,255,.1) 0 1px, transparent 1px 7%), repeating-linear-gradient(90deg, rgba(62,230,255,.1) 0 1px, transparent 1px 7%); }
.h-top { background: linear-gradient(180deg, #5a3a26, #3d271a); clip-path: polygon(7% 0, 93% 0, 100% 100%, 0 100%); }
.h-front { background: linear-gradient(180deg, #191512, #0e0c0b); border-bottom: 2px solid #ffb648; box-shadow: 0 10px 26px rgba(255,170,60,.7); }
.plaque[data-id="hub"] { z-index: 591; border-color: var(--gold); }
.d-stick { position: absolute; left: 12px; bottom: 12px; width: 104px; height: 104px; border-radius: 50%; border: 2px solid rgba(62,230,255,.6); background: rgba(6,16,26,.35); touch-action: none; z-index: 6; }
.d-nub { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(62,230,255,.7); pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .d-stick { display: none; } }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: screen; }
.hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: -6px; }

.cut { position: absolute; background-image: url("/scene-v1.jpg"); background-repeat: no-repeat; pointer-events: none; -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 55%, #000 62%, transparent 100%); mask-image: radial-gradient(ellipse 50% 50% at 50% 55%, #000 62%, transparent 100%); }

.plaque { position: absolute; transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); background: linear-gradient(180deg, #080e18, #04080e); border: 1px solid rgba(62,230,255,.4); border-radius: 6px; display: grid; place-content: center; text-align: center; color: var(--ink); direction: rtl; white-space: nowrap; cursor: pointer; padding: 0; font-family: var(--font); }
.plaque b { display: flex; align-items: center; justify-content: center; gap: 5px; font-weight: 800; font-size: clamp(10px, 1.08vw, 16px); line-height: 1.3; }
.plaque small { display: block; font-size: clamp(8px, .76vw, 12px); color: #c4d4dd; line-height: 1.4; }
.plaque.sel { border-color: var(--gold); box-shadow: 0 0 18px rgba(242,196,92,.55); }
.lamp { width: .62em; height: .62em; border-radius: 50%; background: #71808f; flex: none; display: inline-block; }
.lamp.ok { background: var(--leaf); box-shadow: 0 0 8px var(--leaf); }
.lamp.warn { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.lamp.bad { background: var(--rose); box-shadow: 0 0 8px var(--rose); }

/* crew */
.sp { position: absolute; pointer-events: none; transform: scaleX(var(--dir, 1)); }
.sp .bod { width: 100%; height: 100%; transform-origin: 50% 96%; position: relative; }
.sp img, .sp svg { width: 100%; height: 100%; display: block; }
.sp.away::after, .sp.boss::after { content: ""; position: absolute; left: 4%; right: 4%; bottom: -5%; height: 16%; border-radius: 50%; background: radial-gradient(ellipse, rgba(62,230,255,.95), rgba(62,230,255,.15) 70%, transparent); z-index: 2; }
.sp.walking .bod { animation: hop .16s ease-in-out infinite alternate !important; }
.sp.boss.home::after { display: none; }
.tagname { position: absolute; left: 50%; top: -15%; transform: translateX(-50%) scaleX(var(--dir, 1)); background: var(--gold); color: #1a1204; font-weight: 800; font-size: clamp(9px, .9vw, 13px); line-height: 1.5; padding: 0 8px; border-radius: 999px; white-space: nowrap; }
.seat { position: absolute; border-radius: 50%; opacity: 0; transition: opacity .3s; pointer-events: none; -webkit-backdrop-filter: blur(18px) saturate(1.2); backdrop-filter: blur(18px) saturate(1.2); -webkit-mask-image: radial-gradient(ellipse 50% 50%, #000 66%, transparent 100%); mask-image: radial-gradient(ellipse 50% 50%, #000 66%, transparent 100%); }
.seat.on { opacity: 1; }
.type { animation: type .2s ease-in-out infinite alternate; }
.look { animation: look 1.5s ease-in-out infinite; }
.stretch { animation: stretch 1.7s ease-in-out infinite; }
.doze { animation: doze 3s ease-in-out infinite; }
.nod { animation: nod .46s ease-in-out infinite alternate; }
.sip { animation: sip 1.3s ease-in-out infinite; }
.sway { animation: sway .62s ease-in-out infinite alternate; }
.bounce { animation: bounce .5s ease-in-out infinite alternate; }
.jump { animation: jump .4s cubic-bezier(.3,0,.5,1) infinite alternate; }
@keyframes hop { from { transform: translateY(0) rotate(-7deg) scale(1.04, .95); } to { transform: translateY(-14%) rotate(7deg) scale(.97, 1.04); } }
@keyframes type { from { transform: translateY(0) scale(1, 1); } to { transform: translateY(2.2%) scale(1.012, .985); } }
@keyframes look { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-5deg); } 65% { transform: rotate(5deg); } }
@keyframes stretch { 0%,55%,100% { transform: scale(1, 1); } 75% { transform: scale(.95, 1.11); } }
@keyframes doze { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(6%) rotate(5deg); } }
@keyframes nod { from { transform: rotate(-2deg) translateY(0); } to { transform: rotate(2deg) translateY(4%); } }
@keyframes sip { 0%,60%,100% { transform: rotate(0); } 78% { transform: rotate(-11deg) translateY(-3%); } }
@keyframes sway { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }
@keyframes bounce { from { transform: translateY(0) scale(1.03, .97); } to { transform: translateY(-9%) scale(.98, 1.03); } }
@keyframes jump { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-34%) rotate(4deg); } }

.modes { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-top: -4px; }
.modes::-webkit-scrollbar { display: none; }
.modes button { flex: none; min-height: 42px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); font-weight: 800; border-radius: 10px; padding: 5px 15px; cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1a1204; }
.modes .playbtn { background: linear-gradient(180deg, #8df7a8, var(--leaf)); color: #05210f; border-color: var(--leaf); margin-inline-start: auto; }

/* the game */
.game { position: fixed; inset: 0; z-index: 30; background: #050912; height: 100dvh; touch-action: none; overflow: hidden; }
.game canvas.world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.g-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; gap: 8px; z-index: 3; }
.g-top button, .g-act { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: rgba(16,24,38,.9); color: var(--ink); font-weight: 800; padding: 5px 15px; cursor: pointer; }
.g-msg { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: min(420px, calc(100vw - 32px)); text-align: center; background: rgba(16,24,38,.92); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-weight: 700; z-index: 3; }
.g-act { position: absolute; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--leaf); color: #05210f; border: 0; font-size: 18px; padding: 8px 34px; z-index: 3; }
.g-stick { position: absolute; left: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); width: 116px; height: 116px; border-radius: 50%; border: 2px solid rgba(62,230,255,.45); background: rgba(62,230,255,.08); z-index: 3; }
.g-nub { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px; border-radius: 50%; background: rgba(62,230,255,.6); }
.g-over { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(5,9,18,.9); padding: 16px; touch-action: auto; }
.catch { display: grid; gap: 10px; justify-items: center; text-align: center; }
.catch canvas { width: min(300px, 76vw); height: min(300px, 76vw); touch-action: manipulation; }
.catch h3 { font-size: 24px; font-weight: 800; color: var(--neon); }
.catch p { color: var(--muted); }
.album { width: min(760px, 100%); max-height: 100%; overflow-y: auto; display: grid; gap: 10px; }
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.mon { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; text-align: center; display: grid; justify-items: center; }
.mon canvas { width: 76px; height: 76px; }
.mon b { font-size: 15px; font-weight: 800; }
.mon small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.b-hp { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); width: min(320px, calc(50vw - 18px)); background: rgba(10,16,28,.9); border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px 9px; z-index: 3; }
.b-hp.me { left: 12px; }
.b-hp.foe { right: 12px; }
.b-who { display: block; color: var(--gold); font-size: 12px; font-weight: 800; line-height: 1.4; }
.b-hp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.b-hp-head b { font-size: 16px; font-weight: 800; line-height: 1.3; }
.b-hp-head small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.b-hp i { display: block; height: 11px; border-radius: 6px; background: #22343a; overflow: hidden; margin-top: 3px; direction: ltr; }
.b-hp s { display: block; height: 100%; transition: background .2s; }
.b-log { position: absolute; left: 50%; bottom: calc(190px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); text-align: center; background: rgba(10,16,28,.92); border: 1px solid var(--line); border-radius: 10px; padding: 5px 12px; font-weight: 700; z-index: 3; }
.b-panel { position: absolute; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 7px; z-index: 3; justify-items: center; }
.b-moves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; width: min(620px, 100%); }
.b-move { min-height: 54px; border-radius: 12px; border: 2px solid var(--c); background: rgba(10,16,28,.94); color: var(--ink); cursor: pointer; display: grid; line-height: 1.3; padding: 3px 6px; touch-action: manipulation; }
.b-move b { font-size: 17px; font-weight: 800; }
.b-move small { color: var(--muted); font-size: 11.5px; }
.b-move:disabled, .b-sw:disabled { opacity: .55; cursor: default; }
.b-bench { display: flex; gap: 7px; justify-content: center; }
.b-sw { width: 62px; min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: rgba(10,16,28,.94); color: var(--ink); display: grid; justify-items: center; padding: 1px; cursor: pointer; touch-action: manipulation; }
.b-sw.on { border-color: var(--gold); }
.b-sw canvas { width: 32px; height: 32px; }
.b-sw small { font-size: 11px; line-height: 1.2; }
.b-end { width: min(420px, 100%); display: grid; gap: 12px; text-align: center; justify-items: center; max-height: 100%; overflow-y: auto; }
.b-end.b-wide { width: min(620px, 100%); }
.b-end h3 { font-size: 30px; font-weight: 800; color: var(--neon); line-height: 1.3; }
.b-end p { color: var(--ink); }
.b-end .btn { min-width: 220px; min-height: 50px; }
.b-end .btn:disabled { opacity: .5; }
.b-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; }
.b-card { position: relative; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 6px 3px; color: var(--ink); display: grid; justify-items: center; cursor: pointer; touch-action: manipulation; }
.b-card.on { border-color: var(--gold); box-shadow: 0 0 14px rgba(242,196,92,.5); }
.b-card canvas { width: min(84px, 19dvh); height: min(84px, 19dvh); }
.b-card b { font-size: 15px; font-weight: 800; line-height: 1.3; }
.b-card small { color: var(--muted); font-size: 12px; }
.b-card em { position: absolute; top: 3px; right: 8px; font-style: normal; font-weight: 800; color: var(--gold); }
@media (min-width: 900px) { .b-moves { grid-template-columns: repeat(4, minmax(0, 1fr)); } .b-log { bottom: calc(140px + env(safe-area-inset-bottom)); } }
.bubble { position: absolute; z-index: 5000; transform: translate(-50%, -100%); background: rgba(240,252,255,.97); color: #0b1420; font-weight: 700; font-size: clamp(10px, 1vw, 15px); line-height: 1.5; padding: 3px 11px; border-radius: 10px; white-space: nowrap; direction: rtl; box-shadow: 0 0 16px rgba(62,230,255,.55); pointer-events: none; animation: pop .25s ease-out; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: rgba(240,252,255,.97); }
@keyframes pop { from { transform: translate(-50%, -70%) scale(.8); opacity: 0; } }

.desk { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: grid; gap: 2px; }
.desk h3 { font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.desk p { color: var(--muted); font-size: 14px; }
.desk .strong { color: var(--ink); }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; position: sticky; top: 0; z-index: 4; background: var(--night); padding-top: 6px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px; padding: 6px 14px; font-weight: 700; cursor: pointer; min-height: 40px; }
.tabs button[aria-selected="true"] { background: var(--neon); color: #04121a; border-color: var(--neon); }
.tabs .count { color: var(--gold); margin-inline-start: 4px; }
.tabs button[aria-selected="true"] .count { color: #04121a; }

.panel { display: grid; gap: 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.card h4 { margin: 0; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 7px; }
.card p { font-size: 14px; color: var(--muted); }
.card .val { color: var(--ink); }
.big { font-size: 30px; font-weight: 800; color: var(--neon); line-height: 1.25; font-variant-numeric: tabular-nums; }
.tag { justify-self: start; font-size: 12px; font-weight: 700; color: var(--gold); border: 1px solid rgba(242,196,92,.45); border-radius: 999px; padding: 0 9px; }
.row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 5px; margin-top: 3px; }
.row span:first-child { color: var(--muted); min-width: 0; }
.row b { font-variant-numeric: tabular-nums; flex: none; }
.spark { display: flex; gap: 1px; height: 16px; align-items: stretch; margin-top: 4px; direction: ltr; }
.spark i { flex: 1; background: var(--leaf); opacity: .75; min-width: 1px; }
.spark i.off { background: var(--rose); opacity: 1; }
.empty { color: var(--muted); padding: 10px 0; }

.ring { position: relative; width: min(100%, 560px); aspect-ratio: 1; margin: 4px auto; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--line); stroke-width: .8; }
.ring .run { fill: none; stroke: var(--neon); stroke-width: 1.3; stroke-linecap: round; stroke-dasharray: 9 91; animation: circle 7s linear infinite; filter: drop-shadow(0 0 2px var(--neon)); }
@keyframes circle { to { stroke-dashoffset: -100; } }
.node { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 5px; white-space: nowrap; min-height: 38px; font-weight: 800; font-size: clamp(12px, 3.3vw, 15px); color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.node.sel { border-color: var(--gold); box-shadow: 0 0 14px rgba(242,196,92,.45); }
.node:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ring-mid { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 48%; text-align: center; display: grid; gap: 2px; }
.ring-mid b { font-size: clamp(16px, 4.6vw, 22px); font-weight: 800; color: var(--neon); line-height: 1.3; }
.ring-mid small { color: var(--gold); font-weight: 700; font-size: 13px; }
.ring-mid p { font-size: clamp(11.5px, 3.1vw, 14px); color: var(--muted); line-height: 1.55; }
.row .lamp { margin-inline-end: 3px; }

@media (prefers-reduced-motion: reduce) {
  .opening-bg, .ring .run, .sp .bod { animation: none !important; }
}
