:root {
  --bg:        #0e1116;
  --panel:     #161b22;
  --panel-2:   #1c232d;
  --line:      #2a323d;
  --text:      #e6edf3;
  --muted:     #98a4b3;
  --accent:    #6ea8fe;
  --accent-ink:#08111f;
  --ok:        #3fb950;
  --warn:      #d29922;
  --bad:       #f85149;
  --radius:    12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
h1 { font-size: 1.6rem; margin: 0 0 .3rem; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; letter-spacing: .01em; }
h3 { font-size: 1rem; margin: 0 0 .3rem; }

/* ---------------------------------------------------------------- layout */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.2rem;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { color: var(--text); font-weight: 650; letter-spacing: .01em; }
.brand:hover { text-decoration: none; color: var(--accent); }
.topnav { display: flex; align-items: center; gap: 1rem; }
.topnav a { color: var(--muted); }
.topnav form { margin: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }
.wrap.wide { max-width: 1400px; }
.wrap.narrow { max-width: 430px; padding-top: 3rem; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1.2rem;
}
.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.2rem; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

.muted { color: var(--muted); }
.small { font-size: .86rem; }
.warn  { color: var(--warn); }
.grow  { flex: 1 1 220px; min-width: 0; }
.row   { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- forms */

label { display: block; margin: .8rem 0 .3rem; font-size: .9rem; font-weight: 550; }
input[type=text], input[type=password], input[type=search], input:not([type]),
select, textarea {
  width: 100%; padding: .55rem .7rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type=file] { color: var(--muted); }

button, .button {
  display: inline-block; padding: .55rem .95rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer;
}
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button:disabled { opacity: .6; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ghost { background: transparent; }
.block { width: 100%; margin-top: 1.2rem; }
.destructive { background: transparent; border-color: var(--bad); color: var(--bad); margin-top: .7rem; }
.destructive:hover { background: var(--bad); color: #fff; border-color: var(--bad); }
.linkish { background: none; border: none; color: var(--muted); padding: 0; font-weight: 400; }
.linkish:hover { color: var(--accent); }

fieldset.toggles { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem 1rem; margin: 1.2rem 0 0; }
fieldset.toggles legend { padding: 0 .4rem; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.check { display: flex; gap: .6rem; align-items: flex-start; margin: .7rem 0 0; font-weight: 400; }
.check input { margin-top: .3rem; flex: none; width: auto; }
.check em { display: block; font-style: normal; margin-top: .15rem; }

/* ---------------------------------------------------------------- flashes */

.flash {
  padding: .65rem .9rem; border-radius: 8px; margin-bottom: .8rem;
  border: 1px solid var(--line); background: var(--panel);
}
.flash-error { border-color: var(--bad); background: #2a1416; }
.flash-ok    { border-color: var(--ok);  background: #10241a; }

/* ---------------------------------------------------------------- upload */

.dropzone .drop-head { margin-bottom: .8rem; }
.dropzone p { margin: .2rem 0 0; }
.drop-target {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  min-height: 92px; padding: 1rem; margin: 0;
  border: 2px dashed var(--line); border-radius: var(--radius);
  background: var(--bg); cursor: pointer; text-align: center;
}
.drop-target.over { border-color: var(--accent); background: #121a26; }
.drop-target input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-hint { color: var(--muted); font-weight: 550; }
#uploadprogress { width: 100%; margin-top: .8rem; height: 6px; }

/* ---------------------------------------------------------------- toolbar */

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; }
.filters input[type=search] { min-width: 240px; }
.count { margin: 0; }

/* ---------------------------------------------------------------- grid */

.grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.game-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .12s ease, transform .12s ease;
}
.game-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.thumb {
  position: relative; display: block; aspect-ratio: 16 / 10;
  background: var(--panel-2); overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-fallback {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 2.6rem; opacity: .35;
}
.game-body { padding: .75rem .85rem .9rem; }
.game-body h3 a { color: var(--text); }
.desc { margin: .25rem 0 .4rem; color: var(--muted); font-size: .89rem;
        display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { margin: .2rem 0 0; color: var(--muted); font-size: .82rem; }

.status {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid var(--line); background: var(--panel);
}
.thumb .status { position: absolute; top: .5rem; left: .5rem; backdrop-filter: blur(4px); }
.status-works   { color: var(--ok);   border-color: var(--ok); }
.status-broken  { color: var(--bad);  border-color: var(--bad); }
.status-playing { color: var(--accent); border-color: var(--accent); }
.status-untested{ color: var(--muted); }
.status-shelved { color: var(--muted); opacity: .8; }

.empty { text-align: center; color: var(--muted); padding: 2.5rem; }

/* ---------------------------------------------------------------- stage */

.game-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.game-head .meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.stage {
  background: #000; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; aspect-ratio: 16 / 9; width: 100%;
}
.stage:fullscreen { aspect-ratio: auto; height: 100%; border: none; border-radius: 0; }
.stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.stage-note { margin: .6rem 0 1.4rem; font-size: .87rem; }

.notes-preview { white-space: pre-wrap; margin: 0; color: var(--muted); }
.card.danger { border-color: #46242a; }

/* ---------------------------------------------------------------- files */

.filelist { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow: auto; }
.filelist li { padding: .25rem 0; border-bottom: 1px solid var(--line); }
.filelist.mono a { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
.tag { margin-left: .5rem; font-size: .72rem; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 0 .4rem; }

.login-card h1 { margin-bottom: .2rem; }
