:root {
  --brand: #6229d0;
  --brand-2: #8c5cf0;
  --ink: #f4f1ea;
  --panel: rgba(18, 16, 30, 0.72);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0c0b18; color: var(--ink);
  font-family: "Jost", system-ui, sans-serif; }
canvas#scene { display: block; width: 100vw; height: 100vh; }

/* ---------- Start / pause overlay ---------- */
#overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 70%, rgba(98,41,208,.25), rgba(8,7,20,.82) 70%);
  backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity .5s; z-index: 20; }
#overlay.show { opacity: 1; pointer-events: auto; }
.card { width: min(560px, 100%); text-align: center; padding: 36px 32px 26px;
  background: rgba(16,14,28,.78); border: 1px solid rgba(255,255,255,.08); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5); }
#ov-logo { width: 84px; height: 84px; border-radius: 14px; display: block; margin: 0 auto 14px; }
.card h1 { font-weight: 300; letter-spacing: .18em; text-transform: uppercase; margin: 0; font-size: 28px; }
.card .sub { margin: 4px 0 18px; letter-spacing: .14em; text-transform: uppercase; font-size: 12px; color: #b9a8ee; font-weight: 500; }
.card .lead { margin: 0 0 22px; line-height: 1.55; color: #d8d4cc; font-weight: 300; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 10px; margin-bottom: 20px; }
.k { display: flex; flex-direction: column; align-items: center; gap: 8px; justify-content: flex-end; }
.k em { font-style: normal; font-size: 12px; color: #aaa4b8; letter-spacing: .04em; }
.k b, .wasd b { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 6px;
  border: 1px solid rgba(255,255,255,.35); border-bottom-width: 3px; border-radius: 6px; font-weight: 500; font-size: 13px; }
.k b.wide { min-width: 62px; }
.wasd { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.wasd span { display: flex; gap: 3px; }
.mouse { width: 24px; height: 36px; border: 1.5px solid rgba(255,255,255,.55); border-radius: 12px; position: relative; }
.mouse::after { content: ""; position: absolute; left: 50%; top: 6px; width: 2px; height: 7px; margin-left: -1px;
  background: #fff; border-radius: 2px; animation: wheel 1.6s infinite; }
@keyframes wheel { 0% { opacity: 1; transform: translateY(0) } 100% { opacity: 0; transform: translateY(8px) } }
.tip { font-size: 13px; color: #c9bff0; margin: 0 0 18px; }
/* ---------- Loading splash ---------- */
#splash { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4vh; padding: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 60%, #241a44 0%, #0c0b18 70%); transition: opacity .9s ease, visibility .9s; }
#splash.hide { opacity: 0; visibility: hidden; pointer-events: none; }
#splash img { width: clamp(64px, 9vw, 110px); border-radius: 16px; box-shadow: 0 20px 60px rgba(98,41,208,.45); }
#splash h1 { margin: 0; font-weight: 300; font-size: clamp(40px, 8vw, 112px); line-height: 1.05; letter-spacing: .04em; color: #f4f1ea;
  animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1 } 50% { opacity: .55 } }
#loader { width: min(520px, 80vw); }
#loader .bar { height: 5px; border-radius: 5px; background: rgba(255,255,255,.1); overflow: hidden; }
#loader .bar i { display: block; height: 100%; width: 0; border-radius: 5px;
  background: linear-gradient(90deg, var(--brand), #b796ff); box-shadow: 0 0 14px rgba(140,92,240,.8); transition: width .3s ease-out; }
#loader .ltext { display: flex; justify-content: space-between; margin-top: 10px; font-size: 14px; color: #a39db5; letter-spacing: .06em; }
#enter { font: inherit; font-size: 15px; letter-spacing: .16em; text-transform: uppercase; color: #fff;
  background: var(--brand); border: 0; border-radius: 999px; padding: 14px 38px; cursor: pointer;
  box-shadow: 0 8px 30px rgba(98,41,208,.55); transition: transform .15s, background .2s; }
#enter:hover:not(:disabled) { transform: translateY(-1px); background: var(--brand-2); }
#enter:disabled { opacity: .6; cursor: progress; }
.esc { font-size: 12px; color: #8d879c; margin: 14px 0 0; }
.esc b { font-weight: 500; color: #cfc9dc; }

/* ---------- HUD ---------- */
#crosshair { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: rgba(255,255,255,.7); box-shadow: 0 0 0 1px rgba(0,0,0,.25); z-index: 5;
  opacity: 0; transition: opacity .3s; }
body.playing #crosshair { opacity: 1; }

#hint { position: fixed; left: 50%; bottom: 7vh; transform: translate(-50%, 10px); z-index: 6;
  padding: 12px 22px; border-radius: 999px; background: var(--panel); backdrop-filter: blur(8px);
  font-size: 15px; letter-spacing: .03em; opacity: 0; transition: opacity .6s, transform .6s; pointer-events: none;
  white-space: nowrap; max-width: calc(100vw - 32px); }
#hint.show { opacity: 1; transform: translate(-50%, 0); }
#hint b { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 5px; margin: 0 2px;
  border: 1px solid rgba(255,255,255,.4); border-bottom-width: 2px; border-radius: 5px; font-weight: 500; font-size: 12px; }

#toast { position: fixed; top: 6vh; left: 50%; transform: translate(-50%, -12px); text-align: center; z-index: 6;
  opacity: 0; transition: opacity .7s, transform .7s; pointer-events: none; text-shadow: 0 1px 8px rgba(0,0,0,.5);
  width: max-content; max-width: calc(100vw - 32px); padding: 16px 34px 18px;
  background: rgba(14, 12, 26, .62); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,.08); border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast small { display: block; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: #c9b8ff; }
#toast strong { display: block; font-weight: 300; font-size: clamp(26px, 4vw, 42px); letter-spacing: .14em; text-transform: uppercase; margin: 4px 0; }
#toast span { font-size: 15px; color: #e6e1d8; font-weight: 300; }

/* ---------- Artwork info panel ---------- */
#info { position: fixed; right: 28px; bottom: 28px; width: min(380px, calc(100vw - 32px)); z-index: 6;
  padding: 22px 24px 20px; background: var(--panel); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.08); border-radius: 12px;
  opacity: 0; transform: translateY(16px); transition: opacity .35s, transform .35s; pointer-events: none; }
#info.show { opacity: 1; transform: translateY(0); }
#info .cat { font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: #b9a8ee; }
#info h2 { margin: 6px 0 2px; font-weight: 400; font-size: 24px; line-height: 1.2; }
#info .year { font-size: 13px; color: #9c96aa; min-height: 4px; }
#info .desc:empty { display: none; }
#info .desc { white-space: pre-line; }
#info .desc { margin: 10px 0 14px; line-height: 1.55; font-weight: 300; color: #e2ded6; font-size: 15px; }
#info .actions { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: #aaa4b8; }
#info .actions button { font: inherit; color: inherit; background: none; border: 0; padding: 0; display: inline-flex; align-items: center; cursor: pointer; }
#info.show .actions button { pointer-events: auto; }
#info .actions b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; margin-right: 4px;
  border: 1px solid rgba(255,255,255,.4); border-bottom-width: 2px; border-radius: 5px; font-weight: 500; color: #fff; }

/* ---------- Lightbox ---------- */
#lightbox { position: fixed; inset: 0; z-index: 30; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 14px;
  padding: 4vh 4vw 3vh; background: rgba(8,7,16,.94); opacity: 0; pointer-events: none; transition: opacity .3s; }
#lightbox.show { opacity: 1; pointer-events: auto; }
#lightbox .lb-media { min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#lightbox .lb-media img, #lightbox .lb-media video { max-width: 100%; max-height: 100%; object-fit: contain;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); }
#lightbox .lb-media img.paper { background: #f4f2ec; padding: 4vh; box-sizing: border-box; }
#lightbox .lb-text { text-align: center; max-width: 720px; margin: 0 auto; }
#lightbox h2 { margin: 0 0 4px; font-weight: 400; letter-spacing: .04em; }
#lightbox p { margin: 0; color: #c9c4bb; font-weight: 300; line-height: 1.5; }
.lb-close { position: absolute; top: 18px; right: 22px; font: inherit; font-size: 14px; letter-spacing: .08em;
  color: #fff; background: var(--brand); border: 0; border-radius: 999px; padding: 10px 20px; cursor: pointer; }

#error { position: fixed; inset: 0; display: none; place-items: center; z-index: 50; padding: 24px; text-align: center;
  background: #0c0b18; line-height: 1.6; }
#error.show { display: grid; }
#error code { background: #1f1c33; padding: 3px 8px; border-radius: 5px; }

@media (max-width: 600px) {
  .card { padding: 26px 18px 20px; }
  .keys { grid-template-columns: repeat(2, 1fr); }
  #info { right: 16px; bottom: 16px; }
}

/* ---------- PIN keypad ---------- */
#keypad { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: rgba(8,7,16,.7); backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity .25s; }
#keypad.show { opacity: 1; pointer-events: auto; }
.kp-card { width: min(320px, 100%); padding: 26px 24px 18px; text-align: center; border-radius: 20px;
  background: linear-gradient(180deg, #1b1828, #121019); border: 1px solid rgba(183,150,255,.25);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(98,41,208,.25); }
.kp-title { font-size: 13px; letter-spacing: .3em; text-transform: uppercase; color: #b796ff; }
.kp-sub { font-size: 14px; color: #a39db5; margin: 6px 0 16px; font-weight: 300; }
.kp-display { height: 54px; border-radius: 10px; background: #0b0a12; border: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; font-size: 14px; color: #8d879c; }
.kp-display i { width: 14px; height: 14px; border-radius: 50%; background: #b796ff; box-shadow: 0 0 10px rgba(183,150,255,.8); }
.kp-display.err { border-color: #ff5d7a; color: #ff8fa3; animation: shake .4s; }
.kp-display.ok { border-color: #7dffb0; color: #7dffb0; }
@keyframes shake { 0%,100% { transform: translateX(0) } 20%,60% { transform: translateX(-8px) } 40%,80% { transform: translateX(8px) } }
.kp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kp-grid button { font: inherit; font-size: 22px; height: 58px; border-radius: 12px; cursor: pointer; color: #eee9ff;
  background: #262236; border: 1px solid rgba(255,255,255,.06); border-bottom-width: 3px; transition: background .12s, transform .08s; }
.kp-grid button:hover { background: #312b47; }
.kp-grid button:active, .kp-grid button.press { transform: translateY(2px); background: #3a3354; }
.kp-grid button.ok { background: var(--brand); }
.kp-close { margin-top: 14px; font: inherit; font-size: 13px; letter-spacing: .1em; color: #a39db5; background: none; border: 0; cursor: pointer; }

/* ---------- Touch devices ---------- */
.touch-only { display: none; }
body.touch .touch-only { display: revert; }
body.touch .keys.touch-only { display: grid; }
body.touch .desktop-only { display: none; }
.t-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.45); font-size: 18px; color: #fff; }
.t-ico.joyico { background: radial-gradient(circle, rgba(255,255,255,.7) 0 30%, transparent 32%); }
body.touch .k em { text-align: center; line-height: 1.35; }
body.touch canvas#scene { touch-action: none; }
body.touch #crosshair { display: none; }

#touch-ui { display: none; }
body.touch.playing #touch-ui { display: block; }
#joy { position: fixed; left: max(28px, env(safe-area-inset-left)); bottom: max(28px, env(safe-area-inset-bottom));
  width: 128px; height: 128px; border-radius: 50%; z-index: 7; touch-action: none;
  background: radial-gradient(circle, rgba(255,255,255,.06), rgba(255,255,255,.14));
  border: 1.5px solid rgba(255,255,255,.28); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
#joy i { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(255,255,255,.75); box-shadow: 0 4px 16px rgba(0,0,0,.35); transition: transform .08s; }
#joy.active { border-color: rgba(183,150,255,.8); }
#joy.active i { background: #fff; transition: none; }
#t-pause, #t-music, #t-heart { position: fixed; top: max(14px, env(safe-area-inset-top)); z-index: 7; width: 44px; height: 44px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.25); background: rgba(14,12,26,.55); color: #fff;
  font-size: 15px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); touch-action: manipulation; }
#t-pause { left: max(14px, env(safe-area-inset-left)); }
#t-pause, #t-music, #t-heart { display: grid; place-items: center; padding: 0; }
#t-music { right: max(14px, env(safe-area-inset-right)); }
#t-music.off { opacity: .4; }
#t-heart { top: calc(max(14px, env(safe-area-inset-top)) + 54px); right: max(14px, env(safe-area-inset-right)); color: #ff5c8d; }
#t-heart:active { transform: scale(.9); }
#t-heart.cool { opacity: .35; transition: opacity .2s; }
.t-ico.heart { color: #ff5c8d; font-size: 20px; }

/* on phones the info card becomes a compact bottom-right sheet with big tap targets */
body.touch #info { right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom));
  width: min(330px, calc(100vw - 190px)); padding: 14px 16px 14px; max-height: 46vh; overflow: auto; }
body.touch #info h2 { font-size: 19px; }
body.touch #info .desc { font-size: 13.5px; margin: 6px 0 10px; }
body.touch #info .actions button { padding: 9px 14px; border-radius: 999px; background: var(--brand); color: #fff; font-size: 13px; }
body.touch #info .actions button b { display: none; }
body.touch #hint { bottom: auto; top: 70px; white-space: normal; text-align: center; font-size: 14px; }
body.touch #toast { top: 64px; padding: 10px 22px 12px; }
@media (max-width: 600px) and (orientation: portrait) {
  body.touch #info { width: calc(100vw - 28px); bottom: 180px; }
}

/* short screens (phones in landscape): compact start card, always reachable */
#overlay { overflow-y: auto; }
@media (max-height: 560px) {
  #overlay { place-items: start center; }
  .card { margin: auto; padding: 16px 22px 14px; width: min(640px, 100%); }
  #ov-logo { width: 44px; height: 44px; border-radius: 9px; margin-bottom: 6px; }
  .card h1 { font-size: 20px; }
  .card .sub { margin: 2px 0 8px; font-size: 10px; }
  .card .lead { display: none; }
  .keys { gap: 8px 10px; margin-bottom: 10px; }
  .k { gap: 4px; }
  .k b, .wasd b { min-width: 24px; height: 24px; font-size: 11px; }
  .t-ico { width: 32px; height: 32px; font-size: 14px; }
  .mouse { width: 18px; height: 28px; }
  .tip { margin-bottom: 10px; font-size: 12px; }
  #enter { padding: 11px 30px; font-size: 13px; }
  .esc { margin-top: 8px; }
}

/* ---------- credit, bottom left (desktop only) ---------- */
#credit { position: fixed; left: 16px; bottom: 14px; z-index: 45; padding: 7px 12px; border-radius: 8px;
  background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.08); color: #f4f1ea; font-size: 13px; letter-spacing: .04em; pointer-events: auto; }
#credit a { color: inherit; text-decoration: none; }
#credit a:hover { color: #b796ff; }
body.touch #credit { display: none; }

/* ---------- "Jump to" (pause screen, after you've entered) ---------- */
#jump { display: none; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
body.started #jump, body.returning #jump { display: flex; }
#jump span { width: 100%; font-size: 11px; letter-spacing: .26em; text-transform: uppercase; color: #9d97ae; }
#jump button { font: inherit; font-size: 13px; color: #eee9ff; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; }
#jump button:hover { background: var(--brand); border-color: var(--brand); }

/* ---------- multiplayer: "n other visitors here" ---------- */
#online { position: fixed; left: 16px; bottom: 56px; z-index: 45; padding: 6px 12px 6px 26px; border-radius: 999px;
  background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.08);
  color: #f4f1ea; font-size: 12px; letter-spacing: .03em; display: none; }
#online::before { content: ""; position: absolute; left: 11px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; border-radius: 50%;
  background: #7dffb0; box-shadow: 0 0 8px #7dffb0; }
#online.show { display: block; }
body.touch #online { left: auto; right: max(70px, env(safe-area-inset-right)); top: max(20px, env(safe-area-inset-top)); bottom: auto; }

/* ---------- privacy notice ---------- */
.privacy-link { font: inherit; font-size: 12px; letter-spacing: .04em; color: #9d97ae; background: none; border: 0;
  padding: 4px 6px; margin-top: 10px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.privacy-link:hover { color: #eee9ff; }
#privacy-bar { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  width: min(640px, calc(100% - 32px)); display: none; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 12px;
  background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,.08);
  color: #f4f1ea; font-size: 13px; line-height: 1.45; }
#privacy-bar.show { display: flex; }
body.playing #privacy-bar { display: none; }
#privacy-bar span { flex: 1; }
#privacy-bar .privacy-link { margin: 0; white-space: nowrap; }
#privacy-bar .pb-ok { font: inherit; font-size: 13px; color: #fff; background: var(--brand); border: 0; border-radius: 999px;
  padding: 7px 16px; cursor: pointer; }
#privacy { position: fixed; inset: 0; z-index: 90; display: none; align-items: center; justify-content: center; padding: 16px;
  background: rgba(8,6,14,.6); }
#privacy.show { display: flex; }
#privacy .pv-card { width: min(560px, 100%); max-height: calc(100% - 32px); overflow: auto; padding: 26px 28px; border-radius: 14px;
  background: rgba(18,15,26,.94); border: 1px solid rgba(255,255,255,.1); color: #e9e5f2; font-size: 14px; line-height: 1.55; text-align: left; }
#privacy h2 { margin: 0 0 12px; font-weight: 500; font-size: 20px; color: #fff; }
#privacy p { margin: 0 0 10px; }
#privacy b { color: #fff; font-weight: 500; }
#privacy a { color: #b796ff; }
#privacy .pv-close { font: inherit; font-size: 13px; color: #fff; background: var(--brand); border: 0; border-radius: 999px;
  padding: 8px 18px; margin-top: 8px; cursor: pointer; }
@media (max-width: 560px) { #privacy-bar { flex-wrap: wrap; } #privacy-bar span { flex-basis: 100%; } }
body.privacy-bar:not(.playing) #credit, body.privacy-bar:not(.playing) #online { visibility: hidden; }

/* ---------- hidden FPS meter (F) ---------- */
#fps { position: fixed; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); z-index: 46;
  padding: 5px 10px; border-radius: 8px; background: rgba(10,8,20,.72); color: #9dffb8; font: 500 12px/1.3 ui-monospace, Menlo, monospace;
  letter-spacing: .02em; pointer-events: none; display: none; }
#fps.show { display: block; }
