:root {
    --bg: #0a0e13;
    --panel: #131a21;
    --panel-2: #1a232c;
    --ink: #e8eef4;
    --muted: #8b9aab;
    --amber: #e8a83a;
    --amber-dim: rgba(232, 168, 58, 0.16);
    --teal: #2ec4b6;
    --teal-dim: rgba(46, 196, 182, 0.16);
    --danger: #ef6a6a;
    --line: rgba(232, 238, 244, 0.08);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    --radius: 18px;
    --font: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; }
body.hub {
    min-height: 100dvh;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(232, 168, 58, 0.08), transparent 50%),
        linear-gradient(180deg, #101820 0%, var(--bg) 40%);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { appearance: none; border: 0; background: none; cursor: pointer; }
img { display: block; max-width: 100%; }

.env-strip {
    display: none;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--amber);
    color: #1a1204;
    text-align: center;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.28em;
    padding: 4px 0;
}
body.is-local .env-strip { display: block; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 8px;
    gap: 12px;
}
.brand {
    font-weight: 800;
    letter-spacing: 0.12em;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--amber);
}
.nav { display: flex; gap: 6px; }
.nav button {
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    color: var(--muted);
}
.nav button.on, .nav button[aria-current="page"] {
    background: var(--panel-2);
    color: var(--ink);
}

.screen { display: none; padding: 8px 16px 32px; }
.screen.on { display: block; }
#screen-play.on { display: flex; }

.loading, .state-screen, .invite {
    min-height: calc(100dvh - 80px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    max-width: 520px;
    margin: 0 auto;
    padding: 24px 8px 80px;
}
.eyebrow {
    color: var(--amber);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 10px;
    font-weight: 800;
    margin: 0 0 10px;
}
h1, h2 { margin: 0 0 12px; letter-spacing: -0.03em; }
h1 { font-size: clamp(26px, 6.5vw, 40px); line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.15; }
.lede { color: var(--muted); font-size: 15px; line-height: 1.45; margin: 0 0 28px; }

.btn {
    min-height: 52px;
    padding: 0 22px;
    border-radius: 14px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn.primary { background: var(--amber); color: #1a1204; width: 100%; }
.btn.ghost { width: 100%; color: var(--ink); border: 1px solid var(--line); margin-top: 10px; }
.btn.small { min-height: 44px; width: auto; }
.btn.danger { color: var(--danger); }
.btn[disabled] { opacity: 0.5; }

.manual-install {
    margin-top: 22px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 13px;
    display: none;
}
.manual-install.on { display: block; }
.manual-install ol { margin: 8px 0 0; padding-left: 18px; }
.manual-install li { margin: 6px 0; }

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (min-width: 720px) { .grid { grid-template-columns: 1fr 1fr 1fr; } }
@media (min-width: 1100px) { .grid { grid-template-columns: 1fr 1fr 1fr 1fr; } }

.tile {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    background: var(--panel);
    min-height: 168px;
    text-align: left;
    box-shadow: var(--shadow);
}
.tile .cover {
    aspect-ratio: 16 / 10;
    background:
        linear-gradient(180deg, transparent 30%, rgba(0,0,0,0.72)),
        var(--panel-2);
    background-size: cover;
    background-position: center;
}
.tile .meta { padding: 10px 12px 12px; }
.tile h3 { font-size: 14px; margin: 0 0 2px; }
.tile p { margin: 0; color: var(--muted); font-size: 11px; }
.pill {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.35);
    background: transparent;
}
.pill.ok { background: var(--teal); border-color: var(--teal); }
.pill.update { background: var(--amber); border-color: var(--amber); }
.ribbon {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--amber);
    color: #1a1204;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    padding: 3px 6px;
    border-radius: 6px;
}
.tile .chev {
    position: absolute;
    right: 8px;
    bottom: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    color: var(--ink);
}

.empty {
    grid-column: 1 / -1;
    padding: 40px 10px;
    color: var(--muted);
    text-align: center;
}

.sheet-wrap {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0,0,0,0.55);
}
.sheet-wrap.on { display: block; }
.sheet {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    background: var(--panel);
    border-radius: 22px 22px 0 0;
    padding: 14px 16px 28px;
    max-height: 88dvh;
    overflow: auto;
    box-shadow: var(--shadow);
}
.sheet .handle {
    width: 42px; height: 4px; border-radius: 4px;
    background: var(--line); margin: 0 auto 14px;
}
.sheet .cover {
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    background: var(--panel-2) center/cover;
    margin-bottom: 14px;
}
.sheet .row { display: flex; gap: 10px; margin: 16px 0; }
.sheet .row .btn { flex: 1; }
.fine { color: var(--muted); font-size: 12px; }
.links { display: flex; justify-content: space-between; margin-top: 8px; }

#screen-play {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: #000;
    flex-direction: column;
}
#screen-play iframe {
    flex: 1;
    width: 100%;
    border: 0;
    background: #000;
}
.play-chrome {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: #0a0e13;
    border-bottom: 1px solid var(--line);
    position: relative;
    z-index: 40;
}
html.force-landscape,
html.force-portrait {
    overflow: hidden;
}
html.force-landscape #screen-play.on {
    top: 0;
    left: 100dvw;
    width: 100dvh;
    height: 100dvw;
    transform: rotate(90deg);
    transform-origin: top left;
}
html.force-portrait #screen-play.on {
    top: 0;
    left: 0;
    width: 100dvw;
    height: 100dvh;
    transform: none;
}
.play-chrome button {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--ink);
    font-weight: 700;
}
.play-exit {
    background: var(--amber);
    color: #1a1204;
    min-width: 88px;
}
.play-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.list { display: flex; flex-direction: column; gap: 10px; }
.card {
    background: var(--panel);
    border-radius: 16px;
    padding: 14px;
    border: 1px solid var(--line);
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.about dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0 0 20px; }
.about dt { color: var(--muted); }
.about dd { margin: 0; }

.kinds { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.kinds button {
    min-height: 40px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
}
.kinds button.on { background: var(--amber-dim); color: var(--amber); border-color: var(--amber); }
textarea, input[type="text"], input[type="email"], input[type="password"], select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    min-height: 48px;
}
textarea { min-height: 120px; resize: vertical; }

.spin {
    width: 28px; height: 28px;
    border: 3px solid var(--line);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error-banner, .ok-banner {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
}
.error-banner {
    background: rgba(239, 106, 106, 0.12);
    color: #ffd0d0;
    border: 1px solid rgba(239, 106, 106, 0.3);
}
.ok-banner {
    background: rgba(46, 196, 182, 0.12);
    color: #d4fff8;
    border: 1px solid rgba(46, 196, 182, 0.3);
}

/* Admin */
body.admin { background: var(--bg); }
.admin-shell { display: flex; min-height: 100dvh; }
.admin-nav {
    width: 220px;
    background: var(--panel);
    padding: 20px 14px;
    border-right: 1px solid var(--line);
}
.admin-nav a {
    display: block;
    color: var(--muted);
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 10px;
    min-height: 44px;
}
.admin-nav a.on, .admin-nav a:hover { background: var(--panel-2); color: var(--ink); }
.admin-main { flex: 1; padding: 24px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.tag.pending { background: var(--amber-dim); color: var(--amber); }
.tag.active, .tag.ok { background: var(--teal-dim); color: var(--teal); }
.tag.blocked, .tag.crash { background: rgba(239,106,106,0.15); color: var(--danger); }
.form-grid { display: grid; gap: 12px; max-width: 480px; }

@media (max-width: 720px) {
    .admin-shell { flex-direction: column; }
    .admin-nav { width: auto; display: flex; gap: 6px; overflow: auto; }
}
