/* ===== fonts (subset to English glyphs only) ===== */
@font-face {
  font-family: 'MonaS10';
  src: url('../assets/fonts/monas10.woff2') format('woff2');
  font-display: block;
}
@font-face {
  font-family: 'DOSGothic';
  src: url('../assets/fonts/dosgothic.woff2') format('woff2');
  font-display: block;
}

:root {
  --ui: 'MonaS10', 'Tahoma', 'Verdana', sans-serif;
  --dos: 'DOSGothic', 'Courier New', monospace;
  --silver: #c0c0c0;
  --silver-hi: #dfdfdf;
  --gray: #808080;
  --ink: #0a0a0a;
  --navy: #000080;
  --blue: #1084d0;
  --text: #e8e8e8;
  --dim: #7a7a7a;
  --led: #39ff14;
  --warn: #ffd400;
  --red: #ff3b3b;
  --bevel-out: inset -1px -1px var(--ink), inset 1px 1px #fff, inset -2px -2px var(--gray), inset 2px 2px var(--silver-hi);
  --bevel-in: inset -1px -1px #fff, inset 1px 1px var(--gray), inset -2px -2px var(--silver-hi), inset 2px 2px var(--ink);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --cursor: url('../assets/images/cursor-32.png') 3 1, pointer;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: #000;
  color: var(--text);
  font-family: var(--ui);
  font-size: 16px;
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
  cursor: var(--cursor);
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: var(--cursor); touch-action: manipulation; }
img { display: block; -webkit-user-drag: none; }
[hidden] { display: none !important; }

/* ===== app shell ===== */
#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #000;
}
/* faint CRT scanlines over everything */
#app::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  background:
    repeating-linear-gradient(to bottom, rgba(255,255,255,0.025) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.45) 100%);
}
.screens { position: relative; flex: 1; min-height: 0; }
.shell-bar { display: none; }

/* PC: show the site as a retro app window */
@media (min-width: 640px) and (min-height: 640px) {
  body {
    display: grid;
    place-items: center;
    background:
      radial-gradient(circle, #1c1c1c 1px, transparent 1.5px) 0 0 / 14px 14px,
      #000;
  }
  #app {
    width: 420px;
    height: min(880px, calc(100dvh - 48px));
    background: var(--silver);
    padding: 3px;
    box-shadow: var(--bevel-out), 0 0 0 1px #000, 0 0 60px rgba(200,200,220,0.12);
  }
  .screens { background: #000; box-shadow: var(--bevel-in); padding: 2px; }
  .screens > .screen { inset: 2px; }
  .shell-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 24px;
    padding: 0 3px 0 6px;
    margin-bottom: 3px;
    background: linear-gradient(90deg, var(--navy), var(--blue));
    color: #fff;
    font-size: 14px;
  }
  .shell-title { display: flex; align-items: center; gap: 6px; }
  .shell-title img { width: 16px; }
}

/* ===== shared Win98 bits ===== */
.win {
  background: var(--silver);
  color: #000;
  padding: 3px;
  box-shadow: var(--bevel-out), 4px 4px 0 rgba(0,0,0,0.5);
}
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 24px;
  padding: 0 3px 0 6px;
  background: linear-gradient(90deg, var(--navy), var(--blue));
  color: #fff;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}
.titlebar > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.tb-btns { display: flex; gap: 2px; flex-shrink: 0; }
.tb-btns i, .tb-btns button {
  position: relative;
  width: 18px;
  height: 16px;
  background: var(--silver);
  box-shadow: var(--bevel-out);
}
.tb-min::after { content: ''; position: absolute; left: 4px; bottom: 3px; width: 7px; height: 2px; background: #000; }
.tb-max::after { content: ''; position: absolute; left: 3px; top: 2px; width: 9px; height: 8px; border: 1px solid #000; border-top-width: 2px; }
.tb-x::before, .tb-x::after {
  content: ''; position: absolute; left: 4px; top: 7px; width: 10px; height: 2px; background: #000;
}
.tb-x::before { transform: rotate(45deg); }
.tb-x::after { transform: rotate(-45deg); }
.tb-btns button:active { box-shadow: var(--bevel-in); }

.btn {
  min-width: 88px;
  padding: 7px 14px 6px;
  background: var(--silver);
  color: #000;
  font-size: 15px;
  box-shadow: var(--bevel-out);
}
.btn:active, .btn.pressed { box-shadow: var(--bevel-in); padding: 8px 13px 5px 15px; }
.btn.default { outline: 1px solid #000; outline-offset: -1px; }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -5px; }
.btn-row { display: flex; justify-content: center; gap: 10px; padding: 4px 0 10px; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    repeating-conic-gradient(rgba(0,0,0,0.55) 0 25%, rgba(0,0,0,0.25) 0 50%) 0 0 / 4px 4px;
}
.overlay.top { z-index: 60; }
.dialog { width: min(100%, 340px); animation: pop 0.18s steps(3); }
.win-body { padding: 14px 12px 12px; }
.dim { color: #555; }

.led { display: inline-block; width: 7px; height: 7px; background: var(--led); margin-right: 6px; vertical-align: middle; box-shadow: 0 0 4px var(--led); }
.led.red { background: var(--red); box-shadow: 0 0 4px var(--red); }
.blink { animation: blink 1s steps(1) infinite; }
.caret { animation: blink 0.8s steps(1) infinite; }

/* ===== screens ===== */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; animation: crtOn 0.32s ease-out; }

/* ===== 1. boot ===== */
#boot {
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(var(--safe-t) + 24px) 20px calc(var(--safe-b) + 24px);
  font-family: var(--dos);
  text-align: center;
}
.boot-head { font-family: var(--ui); font-size: 12px; letter-spacing: 0.3em; color: var(--dim); }
.boot-glow {
  width: min(72%, 300px);
  flex-shrink: 0;
  background: radial-gradient(ellipse at center, rgba(255,255,255,0.14) 0%, transparent 68%);
}
.boot-wichu {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 640 / 345;
  animation: float 3s ease-in-out infinite;
}
.boot-type { font-size: 20px; min-height: 1.4em; }
.dotbar { display: flex; gap: 4px; }
.dotbar i { width: 10px; height: 10px; border: 1px solid #444; }
.dotbar i.on { background: var(--text); border-color: var(--text); box-shadow: 0 0 6px rgba(255,255,255,0.5); }
.boot-cta {
  font-size: 22px;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 0 8px rgba(255,255,255,0.7), 2px 0 rgba(255,0,80,0.5), -2px 0 rgba(0,200,255,0.5);
  animation: blink 1s steps(1) infinite;
}
.boot-foot { position: absolute; bottom: calc(var(--safe-b) + 14px); font-family: var(--ui); font-size: 11px; color: #555; letter-spacing: 0.08em; }

/* ===== 2. desktop ===== */
#desktop {
  background:
    radial-gradient(circle, #1a1a1a 1px, transparent 1.5px) 0 0 / 12px 12px,
    #000;
}
.desk-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: var(--safe-t);
  padding-bottom: 56px;
}
.desk-banner img { width: 100%; height: auto; }
.desk-path {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  font-size: 13px;
  color: #9a9a9a;
  border-bottom: 1px dashed #333;
}
.desk-online { margin-left: auto; font-family: var(--ui); font-size: 12px; color: var(--dim); }
.desk-hint { padding: 12px 14px 0; font-size: 13px; color: var(--dim); text-align: center; }
.desk-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px 6px;
  padding: 18px 10px;
}
.icon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
}
.icon img { width: 64px; height: 52px; object-fit: contain; }
.icon .label {
  padding: 1px 4px;
  font-size: 14px;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
  border: 1px dotted transparent;
}
.icon .label .led { width: 6px; height: 6px; margin-right: 4px; }
.icon.selected img { filter: sepia(1) hue-rotate(185deg) saturate(4) brightness(0.65); }
.icon.selected .label { background: var(--navy); border-color: #fff; }
.icon:active img { transform: translateY(1px); }
.desk-sep { text-align: center; font-size: 12px; color: #444; letter-spacing: 0.1em; }
.desk-extras img { width: 44px; height: 44px; }
.desk-extras .label { font-size: 12px; color: #bbb; }
.icon.wiggle img { animation: wiggle 0.4s steps(4); }
.hint-pointer {
  position: absolute;
  width: 30px !important;
  height: auto !important;
  right: 2px;
  top: 30px;
  pointer-events: none;
  animation: tap 0.9s steps(2) infinite;
}

.taskbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 4px;
  height: calc(40px + var(--safe-b));
  padding: 4px 4px calc(4px + var(--safe-b));
  background: var(--silver);
  box-shadow: inset 0 1px var(--silver-hi), inset 0 2px #fff;
  color: #000;
}
.start-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 8px 0 4px;
  font-family: var(--dos);
  font-size: 15px;
  box-shadow: var(--bevel-out);
}
.start-btn img { width: 26px; }
.start-btn:active, .start-btn.pressed { box-shadow: var(--bevel-in); }
.task {
  flex: 1;
  height: 30px;
  line-height: 30px;
  padding: 0 8px;
  font-size: 13px;
  box-shadow: var(--bevel-in);
  background: repeating-conic-gradient(#fff 0 25%, var(--silver) 0 50%) 0 0 / 2px 2px;
  overflow: hidden;
  white-space: nowrap;
}
.tray {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px;
  font-size: 13px;
  box-shadow: inset -1px -1px #fff, inset 1px 1px var(--gray);
}
.tray img { width: 16px; }
.start-menu {
  position: absolute;
  left: 4px;
  bottom: calc(40px + var(--safe-b));
  z-index: 15;
  display: flex;
  width: 230px;
  background: var(--silver);
  color: #000;
  padding: 3px;
  box-shadow: var(--bevel-out);
}
.start-side {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 8px 4px;
  background: linear-gradient(0deg, var(--navy), var(--blue));
  color: #c0c0c0;
  font-family: var(--dos);
  font-size: 18px;
}
.start-side b { color: #fff; }
.start-items { flex: 1; padding: 6px 4px; display: flex; flex-direction: column; gap: 6px; }
.start-info { font-size: 13px; padding: 0 6px; }
.start-info.dim { font-size: 11px; }
.start-item { text-align: left; padding: 6px; font-size: 14px; border-top: 1px solid var(--gray); box-shadow: 0 -1px #fff; }
.start-item:active { background: var(--navy); color: #fff; }

/* ===== 3. incoming ===== */
.dialog.ringing { animation: pop 0.18s steps(3), ring 2.6s 0.2s infinite; }
.incoming-body { display: flex; gap: 12px; align-items: center; }
.profile-box {
  flex-shrink: 0;
  width: 92px;
  height: 118px;
  padding: 4px;
  background: #fff;
  box-shadow: var(--bevel-in);
}
.profile-box img { width: 100%; height: 100%; object-fit: contain; }
.incoming-text { font-size: 15px; line-height: 1.5; }
.incoming-name { font-family: var(--dos); font-size: 24px; line-height: 1.2; }
.incoming-ring { margin-top: 6px; font-size: 13px; color: #333; }

/* ===== 4. loading ===== */
#loading {
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: calc(var(--safe-t) + 16px) 12px calc(var(--safe-b) + 16px);
}
.transfer-win { width: min(100%, 380px); }
.transfer-win .win-body { position: relative; padding: 16px 14px 6px; }
.transfer { position: relative; display: flex; justify-content: space-between; align-items: flex-end; height: 118px; }
.transfer > img { width: 62px; height: 62px; object-fit: contain; }
.fly-track { position: absolute; left: 44px; right: 44px; top: 0; bottom: 18px; }
.fly-x { position: absolute; left: 0; bottom: 0; width: 60px; animation: flyx 1.6s linear infinite; }
.fly-y { width: 60px; animation: flyy 1.6s infinite; }
.load-line {
  margin: 14px 0 10px;
  font-family: var(--dos);
  font-size: 16px;
  letter-spacing: 0.16em;
  text-align: center;
}
.blocks {
  display: flex;
  gap: 2px;
  height: 26px;
  padding: 4px;
  background: #fff;
  box-shadow: var(--bevel-in);
}
.blocks i { flex: 1; }
.blocks i.on { background: #1a3ea8; box-shadow: inset -1px -1px #0b1f6b, inset 1px 1px #4a6fe0; }
.load-meta { display: flex; justify-content: space-between; margin: 8px 2px 14px; font-size: 12px; color: #222; }
.load-cursor { position: absolute; right: 22px; bottom: 16px; width: 28px; animation: tap 1s steps(2) infinite; pointer-events: none; }
.modem-log {
  width: min(100%, 380px);
  min-height: 7.5em;
  font-size: 13px;
  line-height: 1.25;
  color: var(--dim);
  white-space: pre-wrap;
}

/* ===== 5. call ===== */
#call {
  gap: 8px;
  padding: calc(var(--safe-t) + 8px) 10px calc(var(--safe-b) + 10px);
}
.call-status {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #333;
  background: #0b0b0b;
  font-size: 13px;
  color: #cfcfcf;
}
.signal { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.signal i { width: 4px; background: #333; }
.signal i:nth-child(1) { height: 25%; }
.signal i:nth-child(2) { height: 50%; }
.signal i:nth-child(3) { height: 75%; }
.signal i:nth-child(4) { height: 100%; }
.signal i.on { background: var(--text); }
.signal.unstable i.on { background: var(--warn); }
.conn.unstable { color: var(--warn); animation: blink 0.4s steps(1) infinite; }
.conn.lost { color: var(--red); }
.live { margin-left: auto; font-family: var(--dos); font-size: 16px; color: #fff; }

.slot {
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
.slot:nth-of-type(2) { align-items: end; }
.slot:nth-of-type(3) { align-items: start; }
/* window-frame.png is 983x659; its transparent screen area is inset
   16/92/47/47 px — the video sits in that hole */
.frame {
  position: relative;
  width: 100%;
  width: min(100cqw, calc(100cqh * 983 / 659));
  aspect-ratio: 983 / 659;
}
.frame-img { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; pointer-events: none; }
.frame-inner {
  position: absolute;
  left: 1.4%;
  top: 13.7%;
  right: 4.6%;
  bottom: 6.9%;
  overflow: hidden;
  background: #000;
}
.frame-inner video,
.frame-inner canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.frame-inner video { object-fit: contain; }
#localVideo { object-fit: cover; transform: scaleX(-1); }
.frame-inner canvas {
  z-index: 1;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: pixelated;
  filter: contrast(1.08) saturate(0.85);
}
.frame-inner.glitch canvas { animation: jitter 0.12s steps(2) infinite; }
.scan {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0.16) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.5) 100%);
  animation: roll 6s linear infinite;
}
.tag {
  position: absolute;
  left: 5px;
  top: 5px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  background: rgba(0,0,0,0.7);
  border: 1px solid #666;
  font-size: 11px;
  color: #fff;
  letter-spacing: 0.05em;
}
.tag img { width: 14px; }
.cam-msg {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: #cfcfcf;
  text-align: center;
  background: rgba(0,0,0,0.55);
}
.cam-msg img { width: 44px; opacity: 0.55; filter: grayscale(1); }
.cam-msg small { font-family: var(--ui); font-size: 11px; color: #888; }
.cam-msg:not(.missing) p { animation: blink 1s steps(1) infinite; }
.cam-msg.missing p { color: var(--red); }

.call-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 52px;
}
.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 10px;
  font-size: 12px;
}
.icon-btn img { width: 24px; }
.icon-btn:active { padding: 6px 9px 4px 11px; }
.icon-btn.off img { opacity: 0.4; filter: grayscale(1); }
.icon-btn.attn { animation: blink 0.8s steps(1) infinite; }
.end-btn {
  flex: 1;
  max-width: 180px;
  padding: 12px 10px 10px;
  background: #c41818;
  color: #fff;
  font-family: var(--dos);
  font-size: 17px;
  letter-spacing: 0.08em;
  box-shadow: inset -1px -1px #2a0000, inset 1px 1px #ff9a9a, inset -2px -2px #6e0000, inset 2px 2px #e85050;
}
.end-btn:active { box-shadow: inset -1px -1px #ff9a9a, inset 1px 1px #2a0000, inset -2px -2px #e85050, inset 2px 2px #6e0000; padding: 13px 9px 9px 11px; }
.call-meta { font-size: 11px; line-height: 1.3; color: #555; text-align: right; }

/* ===== 6. ended ===== */
.ended-body { display: flex; align-items: center; gap: 14px; font-size: 15px; line-height: 1.5; }
.ended-body img { width: 34px; }
.ended-title { font-family: var(--dos); font-size: 20px; }

/* ===== effects ===== */
.flash { position: absolute; inset: 0; z-index: 80; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash 0.35s ease-out; }
.tap-fx {
  position: fixed;
  z-index: 100;
  width: 34px;
  margin: -2px 0 0 -8px;
  pointer-events: none;
  animation: tapfx 0.5s steps(4) forwards;
}

@keyframes blink { 50% { opacity: 0; } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes crtOn {
  0% { transform: scaleY(0.01); filter: brightness(3); }
  60% { transform: scaleY(1.02); filter: brightness(1.4); }
  100% { transform: none; filter: none; }
}
@keyframes pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes ring {
  0%, 30%, 100% { transform: none; }
  3%, 11%, 19%, 27% { transform: translateX(-3px) rotate(-0.6deg); }
  7%, 15%, 23% { transform: translateX(3px) rotate(0.6deg); }
}
@keyframes flyx { from { left: 0; } to { left: calc(100% - 60px); } }
@keyframes flyy {
  0% { transform: translateY(0) scale(0.35) rotate(-10deg); opacity: 0; animation-timing-function: ease-out; }
  12% { opacity: 1; }
  50% { transform: translateY(-64px) scale(1) rotate(0deg); animation-timing-function: ease-in; }
  88% { opacity: 1; }
  100% { transform: translateY(0) scale(0.35) rotate(10deg); opacity: 0; }
}
@keyframes tap { 50% { transform: translate(-3px, -4px); } }
@keyframes wiggle { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
@keyframes jitter { 0% { transform: translate(2px, 0) skewX(2deg); } 100% { transform: translate(-2px, 1px) skewX(-2deg); } }
@keyframes roll { from { background-position: 0 0, 0 0; } to { background-position: 0 60px, 0 0; } }
@keyframes flash { from { opacity: 0.85; } to { opacity: 0; } }
@keyframes tapfx {
  0% { transform: scale(1.3); opacity: 1; }
  60% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-wichu, .scan, .hint-pointer, .load-cursor, .dialog.ringing { animation: none; }
}

/* ===== photo mode ===== */
.desk-extras { grid-template-columns: repeat(4, 1fr); padding-left: 4px; padding-right: 4px; }
.desk-extras img { object-fit: contain; }
a.icon { text-decoration: none; color: inherit; }
.photo {
  position: absolute; inset: 0; z-index: 70;
  display: flex; flex-direction: column; justify-content: center; gap: 12px;
  padding: calc(var(--safe-t) + 12px) 10px calc(var(--safe-b) + 12px);
  background: #000;
}
.photo-frame { container-type: inline-size; }
.photo .frame { width: 100%; }
.photo canvas, .photo #photoResult { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; object-fit: cover; }
#photoVideo { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
#photoResult { -webkit-user-select: auto; user-select: auto; -webkit-touch-callout: default; z-index: 2; }
.photo-hint { font-size: 12px; color: var(--warn); text-align: center; }
.photo-bar { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

.photo-members { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 340px; width: 100%; margin: 0 auto; }
.photo-members .btn { min-width: 0; padding-left: 6px; padding-right: 6px; }

.fly-y, .start-btn img { height: auto; aspect-ratio: 640 / 345; }
.fly-y { flex-shrink: 0; }
