:root {
  --bg: #14161b;
  --panel: #1d2028;
  --panel-2: #262a34;
  --line: #333845;
  --text: #eceef3;
  --muted: #9aa1b2;
  --accent: #6c8cff;
  --good: #4fbf7a;
  --warm: #e8b04b;
  --danger: #e2605b;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

a { color: inherit; }

button, input, select {
  font: inherit;
  color: inherit;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }

/* ---------- Title tiles ---------- */
.title { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: center; margin-bottom: 6px; }
.tiles { display: flex; gap: 5px; }
.tile {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px; text-transform: uppercase;
  border-radius: 8px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  animation: flip .5s ease both;
}
.tile.a { background: var(--accent); border-color: var(--accent); }
.tile.g { background: var(--good); border-color: var(--good); }
.tile.w { background: var(--warm); border-color: var(--warm); color: #1b1b1b; }
@keyframes flip { from { transform: rotateX(90deg); } to { transform: rotateX(0); } }

.subtitle { color: var(--muted); margin: 4px 0 22px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  position: sticky; top: 10px; z-index: 5;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.search {
  flex: 1 1 220px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}
.search:focus { border-color: var(--accent); }

.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }

.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

/* ---------- Progress ---------- */
.progress { display: flex; align-items: center; gap: 12px; margin: 14px 0 18px; color: var(--muted); font-size: 14px; }
.bar { flex: 1; height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--good); width: 0; transition: width .3s; }
.linkish { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }
.linkish:hover { color: var(--text); }

/* ---------- Grid ---------- */
.section-title { font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

.card {
  position: relative;
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 14px 14px;
  text-decoration: none;
  transition: transform .12s, border-color .12s, background .12s;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); background: #212532; }
.card .icon {
  flex: none; width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center; font-size: 24px;
  background: var(--panel-2);
}
.card .body { min-width: 0; padding-right: 26px; }
.card .name { font-weight: 700; font-size: 16px; }
.card .desc { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card .host { color: #6f7687; font-size: 12px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card.played { opacity: .55; }
.card.played .icon { background: var(--good); }
.card .done-badge {
  display: none;
  font-size: 11px; font-weight: 700; color: var(--good);
  margin-left: 6px; vertical-align: 2px;
}
.card.played .done-badge { display: inline; }

.card-actions { position: absolute; top: 8px; right: 8px; display: flex; flex-direction: column; gap: 2px; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 7px;
  border: 0; background: transparent; color: var(--muted);
  cursor: pointer; display: grid; place-items: center; font-size: 15px;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.fav-on { color: var(--warm); }
.card .more { opacity: 0; }
.card:hover .more, .card:focus-within .more { opacity: 1; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.footer { margin-top: 40px; color: #6f7687; font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Dialog ---------- */
dialog {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; width: min(440px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input, .field select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; color: var(--text);
}
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---------- Random page ---------- */
.random-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.spinner-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 28px 26px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.spinner-card .label { color: var(--muted); font-size: 13px; letter-spacing: .1em; text-transform: uppercase; }
.reel {
  margin: 18px auto 8px;
  width: 120px; height: 120px; border-radius: 26px;
  display: grid; place-items: center; font-size: 64px;
  background: var(--panel-2);
  border: 2px solid var(--line);
}
.reel.landed { border-color: var(--good); animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.12); } }
.pick-name { font-size: 30px; font-weight: 800; margin-top: 10px; min-height: 42px; }
.pick-desc { color: var(--muted); min-height: 22px; }
.countdown { margin: 18px 0 6px; color: var(--muted); min-height: 22px; }
.random-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.random-opts { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; }
.random-opts select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; }
