:root {
    --bg: #010101;
    --fg: #f4f5f7;
    --muted: rgba(244, 245, 247, 0.55);
    --line: rgba(255, 255, 255, 0.14);
    --line-strong: rgba(255, 255, 255, 0.3);
    --panel: rgba(4, 4, 4, 0.82);
    --ok: #8ff0b0;
    --bad: #ff8f8f;
    --radius: 16px;
    --font: "Montserrat", "Gotham", "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

[hidden] { display: none !important; }

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 35%, rgba(247, 247, 248, 0.035) 0%, transparent 55%),
        var(--bg);
    color: var(--fg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
    margin: 0;
}

code {
    font-family: var(--mono);
    background: rgba(255, 255, 255, 0.08);
    padding: 1px 6px;
    border-radius: 6px;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

/* ---------- ASCII water + screen edge glow ---------- */

#water {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.edge-glow {
    position: fixed;
    inset: 0;
    z-index: 50;
    pointer-events: none;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.18),
        inset 0 0 40px rgba(255, 255, 255, 0.05);
    background:
        linear-gradient(to bottom, rgba(255, 255, 255, 0.07), transparent 90px),
        linear-gradient(to top, rgba(255, 255, 255, 0.07), transparent 90px),
        linear-gradient(to right, rgba(255, 255, 255, 0.07), transparent 90px),
        linear-gradient(to left, rgba(255, 255, 255, 0.07), transparent 90px);
}

/* ---------- Top bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 14px 28px;
    background: rgba(2, 2, 2, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--fg);
    text-decoration: none;
}

.brand-name {
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 0.2px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
    flex: none;
    border-radius: 8px;
}

.tabs {
    display: flex;
    gap: 6px;
}

.tab {
    font: inherit;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 7px 16px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.tab:hover { color: var(--fg); }

.tab.active {
    color: var(--fg);
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.06);
}

.top-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pill,
.chip {
    font: inherit;
    font-size: 13px;
    color: var(--fg);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 14px;
}

.pill { cursor: pointer; }
.pill:hover { border-color: var(--line-strong); }
.top-signin { padding: 6px 12px; white-space: nowrap; text-decoration: none; }
.chip { text-decoration: none; }
.header-icon {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
}
.header-icon:hover { border-color: var(--line-strong); }
.header-icon img { width: 18px; height: 18px; object-fit: contain; }
.admin-icon-badge {
    display: inline-block;
    flex: none;
    width: 16px;
    height: 16px;
    margin-left: 5px;
    vertical-align: middle;
    background-color: #f5d27a;
    -webkit-mask: url("/Icons/shield-check.png") center / contain no-repeat;
    mask: url("/Icons/shield-check.png") center / contain no-repeat;
}
.admin-badge {
    color: #f5d27a;
    border-color: rgba(245, 210, 122, 0.45);
    background: rgba(245, 210, 122, 0.1);
}

.pairing-code-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pairing-code {
    font-size: 1.2rem;
    letter-spacing: 0.08em;
}

/* ---------- Layout ---------- */

main {
    position: relative;
    z-index: 10;
    max-width: 1120px;
    margin: 0 auto;
    padding: 40px 24px 90px;
}

.view { display: none; }
.view.active { display: block; }

.hero {
    margin-bottom: 26px;
}

.hero h1 {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.hero p { margin-top: 6px; }

/* ---------- Controls ---------- */

.input {
    width: 100%;
    font: inherit;
    color: var(--fg);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 11px 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input::placeholder { color: rgba(244, 245, 247, 0.32); }

.input:focus {
    border-color: var(--line-strong);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

textarea.input { resize: vertical; }

.input.code {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre;
    tab-size: 4;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    border-radius: 999px;
    padding: 10px 20px;
    cursor: pointer;
    border: 1px solid var(--line-strong);
    transition: transform 0.12s, background 0.15s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn.primary {
    background: #fff;
    color: #05060a;
    border-color: #fff;
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.06);
    color: var(--fg);
}

.btn.ghost:hover { background: rgba(255, 255, 255, 0.12); }

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.toolbar {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}

.toolbar .input { flex: 1 1 260px; }
.sort-control { flex: 0 1 210px; }
.sort-control select {
    width: 100%;
    cursor: pointer;
    color: var(--fg);
    background-color: #070707;
    color-scheme: dark;
}
.sort-control option { color: #f4f5f7; background-color: #070707; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.seg {
    display: flex;
    padding: 4px;
    gap: 2px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid var(--line);
    border-radius: 999px;
}

.seg-btn {
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 999px;
    padding: 7px 14px;
    cursor: pointer;
}

.seg-btn.active {
    background: rgba(255, 255, 255, 0.14);
    color: var(--fg);
}

/* ---------- Cards ---------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    border-color: var(--line-strong);
    box-shadow: 0 0 28px rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
}

.card-head {
    display: flex;
    gap: 14px;
    align-items: center;
}

.card-title {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.card-sub {
    font-size: 13px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.card-desc {
    font-size: 14px;
    color: rgba(244, 245, 247, 0.78);
    overflow-wrap: anywhere;
    min-height: 1.5em;
}

.card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn.danger {
    color: #ffb3b3;
    border-color: rgba(255, 112, 112, 0.4);
}

.btn.danger:hover {
    background: rgba(255, 80, 80, 0.14);
    border-color: rgba(255, 112, 112, 0.7);
}

.tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tag {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
}
.profile-author { display: inline-flex; align-items: center; gap: 5px; text-decoration: none; }
.profile-author:hover { color: var(--fg); border-color: var(--line-strong); }
.verified-badge {
    display: inline-block;
    flex: none;
    width: 15px;
    height: 15px;
    object-fit: contain;
    vertical-align: middle;
    filter: brightness(0) saturate(100%) invert(71%) sepia(45%) saturate(1333%) hue-rotate(174deg) brightness(101%) contrast(98%);
}

.icon {
    flex: none;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #000;
    object-fit: cover;
    display: block;
}

.icon.universal {
    position: relative;
}

.icon.universal::before,
.icon.universal::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    border: 2px solid #fff;
    border-radius: 4px;
    transform: rotate(45deg);
}

.icon.universal::before { width: 24px; height: 24px; }
.icon.universal::after { width: 12px; height: 12px; opacity: 0.55; }

/* ---------- Upload ---------- */

.upload-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 18px;
    align-items: start;
}

.panel {
    padding: 22px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.admin-account-form {
    max-width: 560px;
    margin: 18px 0;
}

.admin-account-form h3 { margin-bottom: 8px; }
.admin-account-form .field { margin: 14px 0; }

.field {
    display: block;
    margin-bottom: 16px;
}

.label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.hint,
.counter {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
}

.counter.bad { color: var(--bad); }

.row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.game-preview {
    min-height: 0;
    margin: -6px 0 16px;
}

.game-preview:empty { display: none; }

.game-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.45);
    font-size: 14px;
}

.game-box .icon { width: 44px; height: 44px; border-radius: 10px; }
.game-box.bad { border-color: rgba(255, 143, 143, 0.5); color: var(--bad); }

.rules h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.checks,
.issues {
    list-style: none;
    margin: 0;
    padding: 0;
}

.checks li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    font-size: 14px;
    color: var(--muted);
}

.checks li.ok { color: var(--fg); }
.checks li.bad { color: var(--bad); }

.dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
}

.checks li.ok .dot { background: var(--ok); border-color: var(--ok); }
.checks li.bad .dot { background: var(--bad); border-color: var(--bad); }

.rules .small { margin-top: 12px; }

.issues { margin-top: 12px; }

.issues li {
    font-size: 13px;
    color: var(--bad);
    padding: 6px 0;
    border-top: 1px solid var(--line);
}

.errors {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 143, 143, 0.45);
    border-radius: 12px;
    color: var(--bad);
    font-size: 14px;
}

.errors ul { margin: 0; padding-left: 18px; }

/* ---------- Viewer dialog ---------- */

dialog {
    width: min(860px, 94vw);
    max-height: 88vh;
    padding: 0;
    color: var(--fg);
    background: rgba(6, 7, 10, 0.97);
    border: 1px solid var(--line-strong);
    border-radius: 20px;
    box-shadow: 0 0 60px rgba(255, 255, 255, 0.07);
}

dialog[open] {
    display: flex;
    flex-direction: column;
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.viewer-head,
.viewer-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
}

.viewer-head { border-bottom: 1px solid var(--line); }
.viewer-foot { border-top: 1px solid var(--line); justify-content: flex-start; gap: 8px; }

.viewer-title {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.viewer-title h2 { font-size: 18px; overflow-wrap: anywhere; }

.viewer-admin {
    display: grid;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    overflow-y: auto;
    max-height: 42vh;
}

.viewer-admin h3 { font-size: 15px; }
.viewer-admin .field { margin: 0; }
.viewer-admin .errors { color: var(--bad); }
.viewer-foot { flex-wrap: wrap; }

.viewer-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    border-radius: 12px;
}

.viewer-icon-button.is-editable { cursor: pointer; }
.viewer-icon-button.is-editable:hover { outline: 2px solid var(--line-strong); }
.viewer-icon-button:disabled { cursor: default; }

.viewer-code {
    flex: 1;
    margin: 0;
    padding: 18px 20px;
    overflow: auto;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.55;
    tab-size: 4;
}

.simple-dialog { width: min(440px, 94vw); max-height: 88vh; }
.settings-form { display: grid; gap: 12px; padding: 20px; }
.settings-form .field { margin: 0; }
.settings-background { border-top: 1px solid var(--line); }
.settings-account-actions { border-top: 1px solid var(--line); }
.account-action-buttons { display: flex; gap: 10px; flex-wrap: wrap; }
.profile-dialog { width: min(860px, 94vw); }
.profile-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.profile-heading > div { min-width: 0; }
.profile-avatar { width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; object-fit: cover; }
.profile-dialog h2 { display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.profile-dialog h2 .verified-badge { width: 22px; height: 22px; }
.profile-dialog h2 .admin-icon-badge { width: 22px; height: 22px; }
.profile-scripts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 20px; overflow-y: auto; }
#profileEmpty { padding: 20px; }

/* ---------- Toasts ---------- */

#toasts {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 11px 16px;
    font-size: 14px;
    background: rgba(6, 7, 10, 0.95);
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    animation: toast-in 0.2s ease-out;
}

.toast.bad { border-color: rgba(255, 143, 143, 0.6); color: var(--bad); }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Responsive / accessibility ---------- */

@media (max-width: 860px) {
    .upload-layout { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
    .top-right { margin-left: 0; }
    main { padding: 28px 16px 80px; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

