/* Screen Fit (public/screen-fit.js): the page drawn inside the box set on this device. The page itself (<html>) is
   shrunk to the box and given a transform, so everything fixed (players, overlays, side drawers) is placed in the box
   instead of on the whole screen; the body scrolls inside it instead of the window, and a player opened after
   scrolling still fills the box exactly. Pop-up windows (<dialog>) sit above everything, so they are moved into the
   box on their own. Full screen (html.kk-fs) ignores the box. */
html.kk-fit:not(.kk-fs) {
  position: static !important;
  width: auto !important; min-height: 0 !important; max-width: none !important; max-height: none !important;
  height: var(--kk-h, calc(100vh - var(--kk-t, 0px) - var(--kk-b, 0px))) !important;   /* the screen as it is now, not the tallest it gets */
  margin: var(--kk-t, 0) var(--kk-r, 0) var(--kk-b, 0) var(--kk-l, 0) !important;
  padding: 0 !important;
  overflow: hidden !important;
  transform: translateZ(0);
}
html.kk-fs { --kk-vw: 1vw !important; --kk-vh: 1vh !important; }
html.kk-fit:not(.kk-fs) body {
  position: static !important; inset: auto !important; transform: none !important;
  width: auto !important; height: 100% !important; min-height: 0 !important; max-width: none !important; max-height: none !important;
  margin: 0 !important;
  overflow: auto !important;
  overscroll-behavior: contain;
}
html.kk-fit:not(.kk-fs) dialog:modal {
  position: fixed;
  top: var(--kk-t, 0); right: var(--kk-r, 0); bottom: var(--kk-b, 0); left: var(--kk-l, 0);
  margin: auto;
  max-width: calc(100vw - var(--kk-l, 0px) - var(--kk-r, 0px) - 16px);
  max-height: calc(100vh - var(--kk-t, 0px) - var(--kk-b, 0px) - 16px);
}

/* the box to drag */
.kk-edit { position: fixed; inset: 0; z-index: 2147483647; background: #0b090d; touch-action: none; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff; -webkit-user-select: none; user-select: none; }
.kk-box { position: absolute; border: 3px solid #ff5fa2; border-radius: 10px; background: rgba(255, 95, 162, 0.1); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset, 0 0 30px rgba(255, 95, 162, 0.45); }
.kk-h, .kk-c { position: absolute; display: block; }
.kk-h::after, .kk-c::after { content: ""; position: absolute; background: #ff5fa2; border: 2px solid #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.6); }
.kk-ht, .kk-hb { left: 20%; right: 20%; height: 48px; cursor: ns-resize; }
.kk-ht { top: -26px; } .kk-hb { bottom: -26px; }
.kk-ht::after, .kk-hb::after { left: 50%; top: 50%; width: 64px; height: 12px; margin: -6px 0 0 -32px; border-radius: 6px; }
.kk-hl, .kk-hr { top: 20%; bottom: 20%; width: 48px; cursor: ew-resize; }
.kk-hl { left: -26px; } .kk-hr { right: -26px; }
.kk-hl::after, .kk-hr::after { top: 50%; left: 50%; height: 64px; width: 12px; margin: -32px 0 0 -6px; border-radius: 6px; }
.kk-c { width: 52px; height: 52px; }
.kk-c::after { left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; }
.kk-ctl { top: -28px; left: -28px; cursor: nwse-resize; } .kk-cbr { bottom: -28px; right: -28px; cursor: nwse-resize; }
.kk-ctr { top: -28px; right: -28px; cursor: nesw-resize; } .kk-cbl { bottom: -28px; left: -28px; cursor: nesw-resize; }
.kk-in { position: absolute; inset: 34px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; cursor: move; overflow: auto; }
.kk-in b { font-size: 19px; }
.kk-in p { margin: 0; max-width: 30em; color: rgba(255, 255, 255, 0.85); }
.kk-nums { font: 12px/1.4 ui-monospace, Menlo, monospace; color: rgba(255, 255, 255, 0.7); }
.kk-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 6px; }
.kk-btns button { font: inherit; color: #fff; padding: 10px 16px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.12); cursor: pointer; }
.kk-btns .kk-use { background: linear-gradient(135deg, #ff5fa2, #c04cff); border-color: transparent; font-weight: 600; }
