/* Colours and radii follow Nightjar's design tokens (design/tokens.json). */
@font-face { font-family: Figtree; src: url(/figtree-400.ttf); font-weight: 400; }
@font-face { font-family: Figtree; src: url(/figtree-600.ttf); font-weight: 600; }

:root {
  --moon: #F2A93B;
  --on-moon: #2B1700;
  --night: #14161F;
  --canvas: #0B0D12;
  --surface: #1E202B;
  --surface-high: #282A36;
  --surface-top: #333541;
  --label: #F5F6FB;
  --secondary: #CDD0DC;
  --error: #FFB4AB;
  --danger: #93000A;
  --on-danger: #FFDAD6;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--canvas); color: var(--label); }
body { font: 400 20px/1.4 Figtree, system-ui, sans-serif; user-select: none; }
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.4px; }
h1 { font-size: 36px; }
h2 { font-size: 26px; }
p { margin: 8px 0; }
.muted { color: var(--secondary); }
.error { color: var(--error); }
.error:empty { display: none; }

button, input {
  font: 600 20px Figtree, system-ui, sans-serif;
  min-height: 60px;
  border: 0;
  border-radius: 16px;
  padding: 0 24px;
  color: var(--label);
  background: var(--surface-high);
}
button { cursor: pointer; touch-action: manipulation; }
button:active { background: var(--surface-top); }
button:disabled { opacity: 0.5; }
button.primary { background: var(--moon); color: var(--on-moon); }
button.danger { background: var(--danger); color: var(--on-danger); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--moon); outline-offset: 2px; }
input { user-select: text; width: 100%; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

#login { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: var(--surface); border-radius: 28px; padding: 32px; width: 100%; max-width: 620px; }
#loginForm { display: flex; flex-direction: column; gap: 16px; text-align: center; }
#code { text-align: center; font-size: 28px; letter-spacing: 2px; min-height: 72px; }

#library { min-height: 100%; display: flex; flex-direction: column; padding: 28px 32px; gap: 20px; }
header { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
header p { margin: 0; }
nav { display: flex; gap: 12px; }
.banner { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 2px solid var(--moon); border-radius: 22px; padding: 16px 20px; }
#apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 20px; align-content: start; flex: 1; }
.app { display: flex; flex-direction: column; padding: 0; overflow: hidden; background: var(--surface); text-align: left; }
.cover { position: relative; width: 100%; padding-top: 133.33%; background: linear-gradient(160deg, var(--surface-top), var(--night)); }
.cover span { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; font-size: 72px; color: var(--moon); }
.cover img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.app .name { padding: 14px 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
footer { font-size: 16px; text-align: center; }

#player { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: #000; overflow: hidden; touch-action: none; }
#video { width: 100%; height: 100%; object-fit: contain; }
#video::-webkit-media-controls { display: none !important; }
#surface { position: absolute; top: 0; left: 0; right: 0; bottom: 0; touch-action: none; }
#menuButton { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); min-height: 48px; width: 96px; background: rgba(30, 32, 43, 0.65); }
#status { position: absolute; top: 45%; left: 24px; right: 24px; text-align: center; font-size: 26px; pointer-events: none; }
#tapToPlay { position: absolute; top: 55%; left: 50%; transform: translateX(-50%); }
#stats { position: absolute; top: 10px; left: 10px; margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(0, 0, 0, 0.7); font: 15px/1.5 monospace; pointer-events: none; }
.overlay-panel { position: absolute; left: 16px; right: 16px; padding: 16px; border-radius: 28px; background: rgba(30, 32, 43, 0.94); display: flex; flex-direction: column; gap: 12px; }
#menu { top: 72px; max-width: 820px; margin: 0 auto; }
/* At the top: the car's own keyboard covers the bottom of the screen. */
#keyboard { top: 72px; }
#keyboard input { flex: 1; width: auto; background: var(--night); border: 2px solid var(--moon); }
#keyboard .hint { margin: 0; font-size: 16px; }
#keys button { flex: 1; padding: 0 8px; min-width: 64px; }

.backdrop { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.72); display: flex; align-items: center; justify-content: center; padding: 24px; overflow: auto; }
.backdrop .card { max-height: 100%; overflow: auto; }
fieldset { border: 0; padding: 0; margin: 20px 0; display: flex; flex-wrap: wrap; gap: 10px; }
legend { margin-bottom: 10px; color: var(--secondary); }
fieldset button[aria-pressed="true"] { background: var(--moon); color: var(--on-moon); }

/* On-screen gamepad. Only the controls take touches; the rest falls through to the game. */
#pad { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
#pad > * { position: absolute; pointer-events: auto; touch-action: none; }
.ctl { display: flex; align-items: center; justify-content: center; border-radius: 50%; width: 76px; height: 76px; background: rgba(11, 13, 18, 0.5); border: 2px solid rgba(245, 246, 251, 0.75); font-weight: 600; text-shadow: 0 1px 3px #000; }
.ctl.pill { border-radius: 20px; width: 104px; height: 60px; }
.ctl.small { width: 60px; height: 60px; font-size: 16px; }
.ctl.on { background: rgba(242, 169, 59, 0.75); }
.stick { width: 150px; height: 150px; border-radius: 50%; background: rgba(11, 13, 18, 0.35); border: 2px solid rgba(245, 246, 251, 0.75); }
.stick i { position: absolute; left: 41px; top: 41px; box-sizing: border-box; width: 64px; height: 64px; border-radius: 50%; background: rgba(40, 42, 54, 0.8); border: 2px solid rgba(245, 246, 251, 0.75); pointer-events: none; }

@media (max-width: 760px) {
  #library { padding: 20px 16px; }
  h1 { font-size: 30px; }
  #apps { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
}
