@font-face {
  font-family: "Player";
  src: url("/font.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  --paper: #f3f5f4;
  --ink: #202725;
  --muted: #65706b;
  --line: #d7ddda;
  --signal: #28715b;
  font-family: "Player", monospace;
  letter-spacing: 0;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; min-height: 100dvh; background-image: linear-gradient(115deg, #fff8, transparent 65%); }
[hidden] { display: none !important; }
button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: inherit; font: inherit; font-size: 16px; letter-spacing: 0; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .6; }
.icon-button { width: 40px; height: 40px; padding: 8px; border-color: transparent; background: transparent; }
.icon { display: inline-block; flex-shrink: 0; width: 1em; font-size: 20px; font-style: normal; line-height: 1; text-align: center; }
button:focus-visible, #screen:focus-visible { outline: 3px solid var(--signal); outline-offset: 4px; }
.topbar { height: 80px; padding: 0 32px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
h1 { margin: 0; font-size: 24px; font-weight: 400; line-height: 1.1; }
.connection { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
main { max-width: 1600px; margin: auto; padding: 32px; }
#login-view { margin: 10vh auto; width: min(100%, 320px); }
#login-form { display: grid; gap: 12px; }
h2 { font-size: 28px; font-weight: 400; margin: 0 0 16px; }
#login-form label { font-size: 14px; }
input { width: 100%; min-width: 0; height: 44px; padding: 10px 12px; border: 1px solid #9fa9a3; background: #fff; color: var(--ink); border-radius: 6px; font: inherit; font-size: 16px; }
input:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
input:user-invalid { border-color: #b13636; }
#login-submit { margin-top: 12px; background: var(--ink); color: #fff; }
#login-error { color: #a52525; font-size: 14px; min-height: 42px; margin: 0; }
#player-view { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.television { grid-column: 2; grid-row: 1; min-width: 0; }
.screen-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; margin-bottom: 12px; }
.screen-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 9px; min-width: 0; font-size: 14px; color: var(--muted); }
#hdmi-status { overflow-wrap: anywhere; }
.status-dot { height: 7px; width: 7px; border-radius: 50%; background: var(--signal); }
.screen-tools { display: flex; gap: 4px; }
#screen { aspect-ratio: 16 / 9; overflow: clip; position: relative; background: #101210; border: 5px solid #252b28; border-radius: 6px; display: grid; place-items: center; }
#screen-image { display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
#screen.actual { display: block; overflow: auto; place-items: normal; }
#screen.actual #screen-image { width: auto; height: auto; max-width: none; }
#screen-placeholder { color: #d2d7d4; font-size: 15px; padding: 16px; }
#screen:fullscreen { border: 0; border-radius: 0; width: 100%; height: 100%; background: #101210; }
.screen-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 12px; min-height: 36px; }
#status { max-width: 100%; overflow-wrap: anywhere; }
.remote-area { grid-column: 1; grid-row: 1; display: flex; justify-content: center; padding-top: 60px; }
.remote { width: 196px; height: 408px; flex-shrink: 0; padding: 14px; border: 1px solid #b1b8b4; border-radius: 30px; background: linear-gradient(100deg, #d6dcda, #f8faf9 45%, #e1e5e3); box-shadow: inset 0 1px 1px #fff, 0 10px 24px #172a2118, 0 2px 3px #172a2120; }
.remote-power { display: flex; justify-content: center; margin-bottom: 16px; }
.remote-power button { width: 48px; height: 48px; padding: 12px; border-radius: 50%; color: #a52525; }
.direction-pad { position: relative; width: 166px; height: 166px; border-radius: 50%; background: #272d2a; box-shadow: inset 0 0 0 1px #111, inset 0 1px 3px #ffffff38; }
.direction-pad button { position: absolute; width: 50px; height: 50px; min-height: 0; padding: 13px; border-radius: 50%; background: transparent; border: 0; box-shadow: none; color: #e6ebe8; }
.direction-pad .select { top: 54px; left: 54px; width: 58px; height: 58px; border-radius: 50%; border: 1px solid #141a16; background: #373e39; box-shadow: inset 0 1px 2px #ffffff18; }
.up { top: 0; left: 58px; }
.down { bottom: 0; left: 58px; }
.left { top: 58px; left: 0; }
.right { top: 58px; right: 0; }
.remote-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; padding: 22px 10px 0; }
.remote-buttons button { width: 60px; height: 60px; min-height: 0; border: 1px solid #c0c8c3; border-radius: 50%; background: #f9fbfa; color: #26332c; padding: 18px; box-shadow: 0 1px 2px #24372d18; }
.remote-buttons [data-action="back"] { gap: 1px; padding: 14px; }
.remote-buttons [data-action="back"] .icon { font-size: 16px; }
.reverse-play { transform: rotate(180deg); }
.remote button:active, .remote button.is-held { background: #b7c8be; color: #13281b; box-shadow: inset 0 1px 4px #0002; }
.remote-mark { text-align: center; color: #829087; font-size: 11px; margin-top: 24px; }
@media (hover: hover) { button:not(:disabled):hover { background: #e2e8e4; } .remote button:hover { background: #c5d2cb; color: #15291d; } }
@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 16px; }
  h1 { font-size: 20px; }
  .connection { gap: 4px; font-size: 12px; }
  main { padding: 12px 16px 24px; }
  #player-view { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .television { grid-column: 1; grid-row: 1; }
  .remote-area { grid-column: 1; grid-row: 2; padding-top: 8px; }
  .screen-toolbar { margin-bottom: 6px; }
  .remote { height: 388px; }
  .remote-mark { margin-top: 12px; }
}
@media (prefers-reduced-motion: no-preference) {
  #player-view { animation: appear 180ms ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
}

#install-view { width: min(100%, 320px); margin: 5vh auto 0; }
#install-app { width: 100%; background: var(--ink); color: white; }
#install-status { font-size: 14px; }
#remote-status:empty { display: none; }
body:not(.public-remote) #remote-status { display: none; }
.public-remote .television, .public-remote.remote-active .topbar { display: none; }
.public-remote.remote-active main { max-width: none; padding: 0; }
.public-remote #player-view { display: block; }
.public-remote .remote-area { min-height: 100dvh; padding: 0; }
.public-remote .remote {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
  justify-items: center;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: 0;
}
.public-remote .remote-power, .public-remote .remote-buttons { margin: 0; padding: 0; }
.public-remote .remote-mark { display: none; }
.public-remote .direction-pad {
  width: min(70vw, 44dvh, 310px);
  height: auto;
  aspect-ratio: 1;
  display: grid;
  grid: repeat(3, 1fr) / repeat(3, 1fr);
}
.public-remote .direction-pad button {
  position: static;
  width: 100%;
  height: 100%;
}
.public-remote .direction-pad .up { grid-area: 1 / 2; }
.public-remote .direction-pad .left { grid-area: 2 / 1; }
.public-remote .direction-pad .select { grid-area: 2 / 2; }
.public-remote .direction-pad .right { grid-area: 2 / 3; }
.public-remote .direction-pad .down { grid-area: 3 / 2; }
.public-remote .remote-buttons { gap: clamp(24px, 15vw, 100px); }
.public-remote #remote-status { position: absolute; bottom: 0; padding-inline: 10px; text-align: center; }
#remote-logout { display: none; }
.public-remote #remote-logout { display: inline-flex; position: absolute; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); }
#pair-view p { line-height: 1.4; }
#pair-camera { width: 100%; margin-top: 12px; border-radius: 6px; }
.public-remote #install-view:not([hidden]) + #login-view:has(#login-form[hidden]):has(#pair-view[hidden]) { display: none; }
