/* Tengoku Gaming Studio: night-purple family shared with the other Tengoku apps. */
:root {
  --bg: #0d0a1a;
  --panel: #171230;
  --panel-2: #1f1940;
  --line: #2b2452;
  --text: #f4f0ff;
  --muted: #b4abd2;
  --gold: #ffb454;
  --gold-soft: #ffd08a;
  --pink: #ff3d81;
  --violet: #a64dff;
  --green: #5fd39a;
  --safe-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --safe-bottom: max(var(--tg-safe-area-inset-bottom, 0px), env(safe-area-inset-bottom, 0px));
  --safe-left: max(var(--tg-safe-area-inset-left, 0px), env(safe-area-inset-left, 0px));
  --safe-right: max(var(--tg-safe-area-inset-right, 0px), env(safe-area-inset-right, 0px));
  --tabs-h: 58px;
  --head: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--body);
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  padding: var(--safe-top) var(--safe-right) calc(var(--tabs-h) + var(--safe-bottom) + 16px) var(--safe-left);
}

h1, h2, h3, .chip, .tab-btn, .num { font-family: var(--head); }
button, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* ---- header */
.top { padding: 12px 14px 4px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .2px; min-width: 0; }
h1 span { color: var(--gold); }
#freshness { margin: 2px 0 0; }
.icon-btn {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); font-size: 18px; line-height: 1;
}
.icon-btn.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.top-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.text-btn {
  height: 36px; padding: 0 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: none; border: 1px solid var(--line); color: var(--muted);
}

main { padding: 8px 14px 0; }

/* ---- sign-in screen (body.locked hides the app until someone is signed in) */
body.locked > .top, body.locked > main, body.locked > .tabs, body.locked > .toast { display: none; }
.login { max-width: 380px; margin: 0 auto; padding: 48px 18px 0; }
.login h1 { font-size: 24px; text-align: center; }
.login > p { text-align: center; margin: 6px 0 18px; font-size: 14px; }
.login h2 { margin: 36px 0 0; text-align: center; font-size: 19px; }
.login form { display: flex; flex-direction: column; padding: 16px; }
.login label { font-size: 13px; color: var(--muted); margin: 0 0 5px; }
.login input {
  width: 100%; margin: 0 0 14px; padding: 11px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  font: 16px var(--body); /* 16px stops phones zooming in on focus */
}
.login input:focus { outline: none; border-color: var(--gold); }
.login button[type="submit"] {
  padding: 12px; border-radius: 999px; border: 0; background: var(--gold); color: #1a1206;
  font: 600 15px var(--head);
}
.login button[disabled] { opacity: .6; }
.panel p.login-error { margin: 0 0 12px; color: #ff7aa8; font-size: 13.5px; }

/* ---- filter chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 13px; border-radius: 999px; font-size: 14px; font-weight: 500;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
}
.chip.small { padding: 5px 11px; font-size: 13px; }
.chip.on { background: var(--gold); border-color: var(--gold); color: #1a1206; font-weight: 600; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.sort select, .game-select {
  appearance: none; -webkit-appearance: none;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 13px; color: var(--gold-soft); max-width: 100%;
}
.game-select { margin-top: 8px; }

/* ---- lists and cards */
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.panel, .card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
}
.card { overflow: hidden; }
.card-link { display: flex; gap: 10px; padding: 10px; color: inherit; text-decoration: none; }
.card-link:active { background: var(--panel-2); }
.thumb {
  flex: none; width: 104px; height: 59px; border-radius: 8px; object-fit: cover;
  background: var(--panel-2);
}
.card-main { flex: 1; min-width: 0; }
.card-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 4px; }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600;
  letter-spacing: .2px; background: var(--panel-2); color: var(--muted); white-space: nowrap;
}
.tag.youtube { background: rgba(255, 61, 129, .16); color: #ff7aa8; }
.tag.twitch { background: rgba(166, 77, 255, .18); color: #c794ff; }
.tag.reddit { background: rgba(255, 180, 84, .16); color: var(--gold-soft); }
.tag.hot { background: var(--pink); color: #fff; }
.tag.gold { background: rgba(255, 180, 84, .16); color: var(--gold-soft); }
.tag.outline { background: none; border: 1px solid var(--line); }
.card-title {
  margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.card-nums { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.num { color: var(--gold); font-weight: 600; font-size: 14px; }
.card-actions { display: flex; border-top: 1px solid var(--line); }
.card-actions button {
  flex: 1; padding: 9px 6px; background: none; border: 0; font-size: 13.5px; font-weight: 600;
  color: var(--muted);
}
.card-actions button + button { border-left: 1px solid var(--line); }
.card-actions button.primary { color: var(--gold); }
.card-actions button:active { background: var(--panel-2); }

.more {
  padding: 11px; border-radius: 12px; background: none; border: 1px dashed var(--line);
  color: var(--gold-soft); font-weight: 600;
}

/* ---- states */
.state { padding: 28px 16px; text-align: center; }
.state h3 { margin: 0 0 6px; font-size: 16px; }
.state p { margin: 0; color: var(--muted); font-size: 13.5px; }
.state button {
  margin-top: 14px; padding: 8px 18px; border-radius: 999px; border: 0;
  background: var(--gold); color: #1a1206; font-weight: 600;
}
.skeleton { height: 96px; border-radius: 14px; background: var(--panel); opacity: .6; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---- sources tab */
.panel { padding: 12px; }
.panel h3 { margin: 0 0 2px; font-size: 15px; }
.panel p { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px; text-align: center; min-width: 0; }
.stat b { display: block; font: 700 19px var(--head); color: var(--gold); }
.stat span { font-size: 12px; color: var(--muted); }
.src { display: flex; gap: 10px; align-items: flex-start; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--muted); }
.dot.working { background: var(--green); }
.dot.stale { background: var(--gold); }
.dot.failing { background: var(--pink); }
.src-text { min-width: 0; overflow-wrap: anywhere; }
.note { border-style: dashed; }

/* ---- studio tab */
.intro { margin: 4px 2px 0; font-size: 13.5px; }
.soon h3 { margin-top: 6px; }

/* ---- toast */
.toast {
  position: fixed; left: calc(12px + var(--safe-left)); right: calc(12px + var(--safe-right));
  bottom: calc(var(--tabs-h) + var(--safe-bottom) + 10px);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px 10px 14px; border-radius: 12px; z-index: 30;
  background: #2a2156; border: 1px solid var(--violet); font-size: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
.toast button { flex: none; padding: 6px 14px; border-radius: 999px; border: 0; background: var(--gold); color: #1a1206; font-weight: 700; }

/* ---- bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex;
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: rgba(13, 10, 26, .96); border-top: 1px solid var(--line);
}
.tab-btn {
  flex: 1; min-width: 0; height: var(--tabs-h); background: none; border: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 500; color: var(--muted);
}
.tab-ico { font-size: 15px; line-height: 1; }
.tab-btn.on { color: var(--gold); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .skeleton, .icon-btn.spin { animation: none; }
}
