@font-face {
  font-family: Vazirmatn;
  src: url("assets/vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #151821;
  --ivory: #f9f1e5;
  --muted: #c9c9d3;
  --metal: #262b36;
  --line: #525766;
  --display: #d9f8fa;
  --light: #ff7777;
  font: 16px/1.55 Vazirmatn, Tahoma, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; background: var(--background); color: var(--ivory); }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
:where(button, summary, .world-link),
:where(button, summary, .world-link) * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, p { margin: 0; }
img, video, svg { display: block; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; width: 1.25em; height: 1.25em; }
:focus-visible { outline: 3px solid #d3f7ff; outline-offset: 4px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

#scene {
  position: relative;
  isolation: isolate;
  height: 100%;
  height: 100dvh;
  width: 100%;
  container: screen / size;
  --scene-w: 1vw;
  --scene-h: 1vh;
  overflow: hidden;
  background: #2b2935;
}

@supports (width: 1cqw) {
  #scene { --scene-w: 1cqw; --scene-h: 1cqh; }
}

.street, .interior, .scene-chrome { position: absolute; inset: 0; }
.street { background: #252a34; direction: ltr; }
.world {
  --world-width: max(calc(100 * var(--scene-w)), calc(400 * var(--scene-h) / 3));
  --world-height: max(calc(100 * var(--scene-h)), calc(75 * var(--scene-w)));
  position: absolute;
  left: calc((100% - var(--world-width)) * .5);
  top: calc((100% - var(--world-height)) * .77);
  width: var(--world-width);
  height: var(--world-height);
  transform: perspective(1400px) scale(1.014) rotateX(var(--tilt-y, 0deg)) rotateY(var(--tilt-x, 0deg));
  transition: transform .55s cubic-bezier(.2,.7,.15,1);
  isolation: isolate;
}
.plate, .reflection, .air { position: absolute; inset: 0; width: 100%; height: 100%; }
.plate { object-fit: fill; transition: filter .5s ease, opacity .5s ease; }
.light-plate, .ambient-plate { opacity: 0; pointer-events: none; }
.ambient-plate {
  mask-image: radial-gradient(ellipse 25% 64% at 1% 29%, #000 51%, transparent 99%),
    radial-gradient(ellipse 16% 36% at 99% 66%, #000 60%, transparent 99%),
    linear-gradient(180deg, #000d 0%, #0009 4%, transparent 26%);
}
[data-light="day"] .ambient-plate[data-ambient="day"][data-showing],
[data-light="dusk"] .ambient-plate[data-ambient="dusk"][data-showing],
[data-light="night"] .ambient-plate[data-ambient="night"][data-showing] { opacity: 1; }
[data-light="day"] [data-plate="day"][data-ready], [data-light="night"] [data-plate="night"][data-ready] { opacity: 1; }
[data-light="day"] .base-plate { filter: brightness(1.12) saturate(.86); }
[data-light="night"] .base-plate { filter: brightness(.68) contrast(1.12) saturate(.91); }
.reflection, .air { pointer-events: none; }
.reflection { background: linear-gradient(#15192424, transparent 20%, transparent 85%, #0e111627); }
[data-light="night"] .reflection { box-shadow: inset 0 0 calc(24 * var(--scene-h)) #030b252d; }

.window-frame {
  position: absolute;
  left: 46.85%;
  top: 63.75%;
  width: 13.38%;
  height: 19.07%;
  overflow: hidden;
  border-radius: 51% 51% 0 0 / 52% 52% 0 0;
  isolation: isolate;
  pointer-events: none;
  background: #462b18;
}
.window-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(132deg, #d1d7ff4d, transparent 32%, transparent 51%, #aad2ff21 56%, transparent 66%); box-shadow: inset 0 0 14px #140d1b58; }
.player-slot, .window-poster, #window-player { position: absolute; inset: 0; width: 100%; height: 100%; }
.window-poster, #window-player { object-fit: cover; object-position: 50% 48%; }
#window-player { opacity: 0; }
#window-player[data-showing] { opacity: 1; }
[data-light="day"] .window-frame { filter: brightness(.82) saturate(.73); }
[data-light="night"] .window-frame { filter: brightness(1.02) saturate(1.13); }

.watch-window {
  position: absolute;
  left: 47%;
  top: 64%;
  width: 13%;
  height: 18%;
  background: transparent;
  padding: 0;
  border-radius: 51% 51% .2rem .2rem / 52% 52% .2rem .2rem;
  border: 0;
  z-index: 3;
}
.watch-window span { position: absolute; display: grid; place-items: center; left: 50%; bottom: 6%; transform: translateX(-50%); width: 28px; height: 24px; border-radius: 50%; color: #fff5e4; background: #1e1717c4; border: 1px solid #eed9ac80; opacity: 0; transition: opacity .18s linear; font-size: 12px; }
.watch-window:is(:hover, :focus-visible) span { opacity: 1; }

.shop-sign {
  position: absolute;
  left: 62.25%;
  top: 72.25%;
  transform: translateX(-50%) rotate(-3deg);
  z-index: 2;
  direction: rtl;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  padding: 4px 7px;
  color: #fff4df;
  border: 1px solid #e8c5948f;
  border-radius: 3px;
  background: linear-gradient(#3a2f29, #211918);
  box-shadow: 1px 3px 6px #1210106b;
  font-size: clamp(12px, .88rem, 22px);
  font-weight: 750;
}
.shop-sign i { display: block; width: 6px; height: 6px; flex: none; border-radius: 50%; background: #9af1be; box-shadow: 0 0 5px #b1f5c5c2; }
[data-shop="closed"] .shop-sign i { background: #f7bc87; box-shadow: none; }
.queue span { position: absolute; bottom: 6.05%; width: 5.5%; height: 22%; background: url("assets/ruen-queue.webp") left center / 200% 100% no-repeat; visibility: hidden; z-index: 2; }
.queue span:nth-child(1) { left: 27%; }
.queue span:nth-child(2) { left: 33%; background-position: right center; }
.queue span:nth-child(3) { left: 67%; }
.queue span:nth-child(4) { left: 73%; background-position: right center; }
.queue span.is-visible { visibility: visible; }
.air { z-index: 4; }
.air span { position: absolute; width: 8px; height: 4px; border-radius: 75% 20% 75% 20%; background: linear-gradient(125deg, #e2bb65, #704225); box-shadow: 1px 1px 1px #35271957; }

.door-cavity { position: absolute; left: 38.45%; top: 68.3%; width: 2.72%; height: 18.7%; perspective: calc(13 * var(--scene-w)); visibility: hidden; background: linear-gradient(90deg, #482619, #b2764f 68%, #ffc889); }
.door-leaf { display: block; width: 100%; height: 100%; border: 1px solid #1f191d; background: linear-gradient(90deg, #1e1b1d, #302521); transform-origin: left center; }
.door-lock {
  --device-width: clamp(48px, calc(4.35 * var(--scene-w)), 67px);
  direction: rtl;
  position: absolute;
  left: 39.7%;
  top: 77.55%;
  z-index: 6;
  width: var(--device-width);
  min-height: 54px;
  display: grid;
  justify-items: stretch;
  gap: 3px;
  padding: 5px 4px 6px;
  border: 1px solid #b5b1a6;
  border-radius: 7px;
  background: linear-gradient(156deg, #66646a 0%, #373a43 16%, #24262d 68%, #30333b 100%);
  color: var(--display);
  transform: translate(-50%, -50%) perspective(160px) rotateY(-9deg);
  box-shadow: inset 1px 1px #d7ccc6b8, inset -2px -2px #17191ebf, 3px 5px 7px #0c0809a3;
}
.door-lock::after { content: ""; position: absolute; border: 1px solid #a1f0fa75; opacity: .7; pointer-events: none; inset: 0; border-radius: inherit; box-shadow: 0 0 12px #72dbfd55; }
.door-lock:hover .lock-display, .door-lock:focus-visible .lock-display { background: radial-gradient(ellipse at center, #42616a, #142830); color: #f4feff; }
.lock-led { justify-self: center; width: 5px; height: 5px; border-radius: 50%; background: var(--light); box-shadow: 0 0 7px var(--light); }
[data-session="valid"] { --light: #85f0ad; }
.lock-display { text-align: center; min-height: 23px; border-radius: 2px; background: linear-gradient(165deg, #254150, #142c36 70%); border: 1px solid #111c24; box-shadow: inset 0 0 3px #090d13, 0 1px #77767a82; font-weight: 900; font-size: clamp(14px, .98rem, 21px); line-height: 1.45; text-shadow: 0 0 6px #b1eeffc2; }
.lock-keys { direction: ltr; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; color: #e7e3df; }
.lock-keys i { display: grid; place-items: center; min-height: 8px; padding: 1px 0 0; border-radius: 2px; background: linear-gradient(#5b5b61, #373940); box-shadow: inset 0 1px #8b8c9252, 0 1px #19191c; font: 600 7px/.93 Vazirmatn, Tahoma, sans-serif; }

.scene-chrome { z-index: 8; pointer-events: none; }
.clock, .glass-control { color: var(--ivory); background: #181a20d9; border: 1px solid #e9d8c176; border-radius: 8px; box-shadow: 0 3px 12px #120e1d75; }
.clock {
  position: absolute;
  inset: max(.8rem, env(safe-area-inset-top)) auto auto max(.8rem, env(safe-area-inset-left));
  direction: ltr;
  display: flex;
  align-items: center;
  gap: .36rem;
  min-height: 34px;
  padding: .22rem .48rem;
  font-size: .82rem;
  font-weight: 720;
}
.clock time { font-variant-numeric: tabular-nums; }
.clock-face { width: 19px; height: 19px; position: relative; border: 1px solid #f5c48d; border-radius: 50%; color: #f5c48d; }
.clock-face::after { position: absolute; content: ""; inset: calc(50% - 1px) auto auto calc(50% - 1px); width: 2px; height: 2px; border-radius: 50%; background: currentColor; }
.clock-face i { position: absolute; left: calc(50% - .5px); bottom: 50%; width: 1px; height: 33%; transform-origin: center bottom; background: currentColor; }
.clock-face i:first-child { height: 25%; width: 2px; }
.scene-controls { direction: ltr; position: absolute; bottom: max(.8rem, env(safe-area-inset-bottom)); right: max(.8rem, env(safe-area-inset-right)); display: flex; gap: .4rem; pointer-events: auto; }
.glass-control { display: inline-flex; gap: .4rem; justify-content: center; align-items: center; min-width: 44px; min-height: 44px; padding: .25rem .55rem; font-size: .83rem; font-weight: 720; }
.glass-control:hover { background: #303344; }
.scene-controls .glass-control { width: 44px; height: 44px; padding: 0; font-size: 16px; }

#scene.is-entering .world { z-index: 1; transform-origin: 39.7% 78%; animation: approach-door .95s cubic-bezier(.32,.11,.52,1) both; }
#scene.is-entering .door-cavity { visibility: visible; }
#scene.is-entering .door-leaf { animation: open-door .95s ease-in-out both; }
#scene.is-entering .door-lock, #scene.is-entering .shop-sign, #scene.is-entering .watch-window { opacity: 0; pointer-events: none; }
#scene.is-entering::after { content: ""; inset: 0; position: absolute; z-index: 9; pointer-events: none; background: #ecc494; animation: entry-light .95s ease-in both; }
@keyframes approach-door {
  from { transform: scale(1.014); }
  to { transform: translate(var(--door-pan-x, 0px), var(--door-pan-y, 0px)) scale(3.25); }
}
@keyframes open-door { 16% { transform: rotateY(0); } to { transform: rotateY(-84deg); } }
@keyframes entry-light { 0%, 56% { opacity: 0; } to { opacity: 1; } }

.interior { background: #271d1a; isolation: isolate; }
.interior-view, .interior-background, .interior-cast, .entry-player { position: absolute; inset: 0; width: 100%; height: 100%; }
.interior-view { background: #271d1a url("assets/ruen-kitchen.webp") center 54% / cover no-repeat; }
.interior-background { object-fit: cover; object-position: center 54%; }
.interior-cast { width: min(100%, calc(140 * var(--scene-h))); left: 50%; right: auto; transform: translateX(-50%); }
.interior-cast img { position: absolute; bottom: 33%; width: min(45%, calc(55 * var(--scene-h))); transform-origin: center bottom; }
.interior-cast .interior-chef { left: 20%; }
.interior-cast .interior-mouse { left: 62%; width: min(20%, calc(21 * var(--scene-h))); z-index: 2; }
.interior-cast.hiding .interior-chef { animation: chef-notices 1.35s ease-in-out both; }
.interior-cast.hiding .interior-mouse { animation: mouse-hides 1.35s cubic-bezier(.3,.2,.6,1) both; }
.interior-cast.hide-complete .interior-mouse { visibility: hidden; }
[data-shop="closed"] .interior-background { filter: brightness(.42) saturate(.71); }
[data-shop="closed"] .interior-chef { visibility: hidden; }
[data-shop="closed"] .interior-cast .interior-mouse { left: 65%; bottom: 36%; filter: brightness(.75); width: min(14%, calc(16 * var(--scene-h))); }
.entry-player { display: none; object-fit: cover; object-position: center 51%; }
.entry-player[data-showing] { display: block; }
.back-to-street { position: absolute; top: max(.8rem, env(safe-area-inset-top)); right: max(.8rem, env(safe-area-inset-right)); z-index: 9; }
.back-to-street svg { transform: rotate(180deg); }
@keyframes chef-notices { 28% { transform: rotate(6deg); } 62% { transform: rotate(-4deg); } }
@keyframes mouse-hides {
  15% { transform: translate(-8%, 3%) scale(.94,.82); }
  38% { transform: translate(-86%, -148%) rotate(-20deg) scale(.83); opacity: 1; }
  60%, 100% { transform: translate(-97%, -152%) scale(.12); opacity: 0; }
}

.dialog { position: fixed; color: var(--ivory); border: 1px solid #77747b; background: #262630; border-radius: 14px; box-shadow: 0 20px 70px #070610b3; max-height: calc(100dvh - 28px); max-width: calc(100vw - 22px); overflow: auto; }
.dialog::backdrop { background: #111018a8; backdrop-filter: blur(4px); }
.dialog-close { position: absolute; display: grid; place-items: center; z-index: 5; top: 8px; left: 8px; padding: 0; width: 44px; height: 44px; border-radius: 7px; border: 1px solid #8c929da0; color: var(--ivory); background: #20222bed; }
.dialog-close:hover { background: #414552; }

.auth-dialog {
  width: min(21rem, calc(100vw - 22px));
  background: linear-gradient(152deg, #797980, #3d404a 14%, #282a35 71%, #31343d);
  box-shadow: inset 1px 1px #d8d6d5a0, inset -3px -3px #16171b, 6px 18px 52px #070610c2;
  padding: 14px clamp(.65rem, 4vw, 1rem);
}
.keypad-head { display: flex; align-items: center; justify-content: center; gap: 7px; margin-block: 0 10px; min-height: 32px; color: #cbcdd4; }
.keypad-head i { background: var(--light); box-shadow: 0 0 9px var(--light); width: 6px; height: 6px; border-radius: 50%; }
.keypad-head svg { width: 16px; height: 16px; }
.keypad-screen { padding: .45rem .6rem; display: grid; gap: .22rem; border: 1px solid #102026; border-radius: 5px; box-shadow: inset 0 1px 11px #0b171dd0, 0 1px #8583889c; color: var(--display); background: repeating-linear-gradient(0deg, #122b360e 0 1px, transparent 1px 4px), radial-gradient(ellipse at 50% 20%, #2e4b58, #152b35 70%); }
.keypad-screen strong { text-align: center; font-weight: 900; font-size: 1.45rem; line-height: 1.25; text-shadow: 0 0 12px #70dbf6bf; }
.keypad-screen label { display: flex; justify-content: space-between; color: #dfedf0; font-size: .76rem; }
.keypad-screen b { color: #f5e3b1; }
.keypad-screen input { background: #142730; color: #effbff; border: 1px solid #779ca4; border-radius: 4px; width: 100%; min-width: 0; min-height: 42px; text-align: center; font-size: .95rem; font-weight: 750; letter-spacing: .14em; }
.keypad-screen input::placeholder { color: #bfdfdf; opacity: 1; }
.device-button { display: flex; justify-content: center; align-items: center; gap: .45rem; margin-top: .6rem; width: 100%; min-height: 46px; border: 1px solid #9aa0a7; border-radius: 6px; background: linear-gradient(#545a68,#3e434d); font-weight: 750; }
.device-button:hover { background: #636a7b; }
.pin-pad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin-top: 7px; }
.pin-pad button, .keypad-back {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 44px;
  border-radius: 5px;
  border: 1px solid #747782;
  background: linear-gradient(#51545b, #363943);
  box-shadow: inset 0 1px #b9bbc269, 0 2px 1px #1a1821;
  font-weight: 800;
}
.pin-pad button:hover, .keypad-back:hover { background: #5d606b; }
.pin-pad button:active { box-shadow: inset 0 2px 6px #161820; }
.pin-pad .pin-confirm { background: linear-gradient(#496950, #2c4537); border-color: #829c89; }
.keypad-back { min-height: 44px; margin-top: 8px; width: 100%; font-size: .8rem; }
.code-error { margin-block: 6px 0; color: #ffd7d7; font-size: .82rem; }
.code-error:empty { display: none; }

.settings-dialog { width: min(26rem, calc(100vw - 22px)); padding: .9rem; }
.settings-dialog h2 { padding-left: 48px; font-size: 1.16rem; }
.settings-dialog fieldset { border: 0; margin: .7rem 0; padding: 0; min-width: 0; }
.settings-dialog legend { padding: 0; margin-bottom: 4px; color: var(--muted); font-size: .79rem; }
.options { display: flex; flex-wrap: wrap; gap: 4px; }
.options button, .settings-reset { min-height: 44px; min-width: 44px; padding: .23rem .52rem; border: 1px solid var(--line); border-radius: 6px; color: var(--ivory); background: #30313d; font-size: .87rem; }
.options button[aria-pressed="true"] { background: #40517a; border-color: #a3b8e9; }
.settings-reset:hover, .options button:hover { border-color: #b2bde4; }

.window-dialog { padding: 0; overflow: hidden; width: min(48rem, calc(100vw - 22px)); height: min(48rem, calc(100dvh - 28px)); background: #211a18; }
.closeup-slot { position: absolute; inset: 0; }
.closeup-slot #window-player, .closeup-slot .window-poster { object-fit: contain; }
.closeup-caption { position: absolute; inset: auto 0 0; padding: 1.15rem .65rem .55rem; color: #fffdf5; background: linear-gradient(transparent, #100e13ed 40%); display: flex; gap: .35rem .65rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.closeup-caption h2 { font-size: 1.06rem; }
.closeup-caption p { color: #f1e3d8; font-size: .82rem; }

.motion-paused .world { transform: none; transition: none; }
.motion-paused *, .motion-paused *::before, .motion-paused *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-allowed) *, :root:not(.motion-allowed) *::before, :root:not(.motion-allowed) *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
}
@media (max-aspect-ratio: 4 / 5) {
  .world { left: calc((100% - var(--world-width)) * .488); }
  .shop-sign { left: 62%; top: 62%; }
  .door-lock { top: 78.5%; }
  .interior-background { object-position: 55% center; }
  .entry-player { object-position: center; }
  [data-shop="open"] .entry-player[data-framing="square"] { object-fit: contain; background: #211a18; }
  [data-shop="closed"] .entry-player { object-position: 65% center; }
}
@media (max-width: 380px) {
  .shop-sign { left: 59.7%; }
}
@media (max-height: 440px) {
  .clock { inset-block-start: 6px; }
  .scene-controls { bottom: 6px; }
}

@media (max-aspect-ratio: 4 / 5) {
  .queue span { width: 4.1%; height: 16%; bottom: 5.2%; }
  .queue span:nth-child(1) { left: 32%; }
  .queue span:nth-child(2) { left: 36.2%; }
  .queue span:nth-child(3) { left: 58.3%; }
  .queue span:nth-child(4) { left: 62.3%; }
}
@media (hover: none), (pointer: coarse), (max-aspect-ratio: 4 / 5) {
  .watch-window span { opacity: .86; }
}

.scene-controls .world-link { width:auto; padding-inline:.64rem; text-decoration:none; font-size:.78rem; font-weight:700; line-height:1.2; white-space:nowrap; }

.member-link, .world-link, .plain-menu { position: absolute; text-decoration: none; pointer-events: auto; }
.member-link { top: max(.8rem, env(safe-area-inset-top)); right: max(.8rem, env(safe-area-inset-right)); padding-inline: .75rem; }
.scene-controls .world-link { position: fixed; bottom: max(.8rem, env(safe-area-inset-bottom)); left: max(.8rem, env(safe-area-inset-left)); gap: .55rem; padding: .28rem .75rem; }
.world-link svg, .member-link svg { color: #f5c48d; }
.world-link small { display: block; margin-top: .12rem; color: #f4d8b4; font-size: .68rem; font-weight: 450; }
.plain-menu { z-index: 10; top: 4.4rem; right: .8rem; }
