:root {
  --bg: #0f1115; --panel: #181b22; --panel2: #1f232c; --fg: #e6e8ec; --muted: #9aa1ad;
  --accent: #4f8cff; --ok: #3fbf7f; --err: #ff6b6b; --border: #333a48;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.4 system-ui, sans-serif; }
body:not(.center):not(.page) { height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 10px; }
code { background: var(--panel2); padding: 1px 4px; border-radius: 4px; }
.muted { color: var(--muted); }
.error { color: var(--err); min-height: 1.2em; }
.grow { flex: 1; }
.hidden { display: none !important; }

header, footer { background: var(--panel); padding: 8px 16px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
footer { flex-direction: column; align-items: stretch; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

button, input, .button { font: inherit; color: var(--fg); background: #232733; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
button, .button { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover:not(:disabled), .button:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger:hover { border-color: var(--err); color: var(--err); }
input[type=checkbox] { padding: 0; }
label { display: flex; flex-direction: column; gap: 4px; }
label.inline { flex-direction: row; align-items: center; gap: 6px; }

/* login / password */
body.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 24px; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }

/* player */
main { flex: 1; min-height: 0; display: flex; position: relative; }
#stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; background: #000; }
video { width: 100%; height: 100%; object-fit: contain; background: #000; }
#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); pointer-events: none; text-align: center; padding: 16px; }
#stage:fullscreen video { width: 100vw; height: 100vh; }
#status, #pad, #seats { color: var(--muted); }
#live { font-family: ui-monospace, monospace; min-height: 1.4em; color: var(--muted); }
kbd { background: #232733; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 12px; }

/* library */
.panel { position: absolute; inset: 0; background: rgba(15, 17, 21, .97); overflow: auto; padding: 16px; z-index: 2; }
#slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.slot { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.slot img, .slot .empty { width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; border-radius: 4px; }
.slot .empty { display: flex; align-items: center; justify-content: center; color: var(--muted); }
#library { position: absolute; inset: 0; background: rgba(15, 17, 21, .97); overflow: auto; padding: 16px; }
.libhead { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.libhead h2 { margin: 0; }
.libhead input { flex: 1; min-width: 160px; max-width: 360px; }
#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.game { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 6px; text-align: left; background: var(--panel); }
.game img, .nocover { width: 100%; aspect-ratio: 7 / 10; object-fit: cover; border-radius: 4px; background: var(--panel2); }
.nocover { display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px; color: var(--muted); font-size: 13px; }
.game.playing { border-color: var(--ok); }
.gtitle { font-weight: 600; font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gmeta { color: var(--muted); font-size: 12px; }
.badge { background: var(--ok); color: #06210f; border-radius: 4px; padding: 0 6px; font-size: 12px; font-weight: 600; margin-left: 6px; }
.game .badge { position: absolute; top: 10px; left: 10px; margin: 0; }

/* admin */
body.page header { position: sticky; top: 0; z-index: 1; }
.content { max-width: 1100px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 28px; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; }
td.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.notice { background: var(--panel2); border: 1px solid var(--accent); border-radius: 8px; padding: 10px 12px; margin: 10px 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.notice p { flex-basis: 100%; margin: 0; }

#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--border); padding: 8px 14px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; }
#toast.error { border-color: var(--err); color: var(--err); }
