:root {
    --bg: #17120f;
    --surface: rgba(30, 23, 19, 0.82);
    --surface-solid: #221a15;
    --surface-raised: #2c221c;
    --surface-hover: #3a2d25;
    --field: rgba(0, 0, 0, 0.32);
    --line: rgba(243, 236, 228, 0.12);
    --line-strong: rgba(243, 236, 228, 0.24);
    --text: #f3ece4;
    --muted: #b9ab9b;
    --accent: #e8873a;
    --accent-hover: #f09a52;
    --accent-text: #1b120b;
    --danger: #ff8a7a;
    --danger-line: rgba(255, 138, 122, 0.35);
    --ok: #8fd18a;
    --warn: #f0c36a;
    --radius: 6px;
    --radius-card: 10px;
    --gutter: clamp(16px, 3vw, 36px);
    --content-max: 960px;
    --font: "Segoe UI Variable", "Segoe UI", "Inter", "Cantarell", "Noto Sans", system-ui, sans-serif;
    color-scheme: dark;
}

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

html { background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font: 15px/1.5 var(--font);
}

.backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(120% 70% at 78% 112%, rgba(232, 135, 58, 0.34), transparent 60%),
        radial-gradient(60% 50% at 10% 0%, rgba(120, 72, 40, 0.25), transparent 70%),
        linear-gradient(180deg, #120e0c 0%, #1b1411 100%);
}

.backdrop::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(18, 14, 12, 0.55), rgba(18, 14, 12, 0.88)), var(--bg-image, none) center / cover;
}

#content {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 0 var(--gutter) 32px;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.2; font-weight: 600; }
h1 { font-size: 28px; letter-spacing: -0.01em; }
h2 { font-size: 20px; }
h3, h4 { font-size: 16px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
small { font-size: 13px; }
code, pre { font-family: ui-monospace, "Cascadia Mono", "Noto Sans Mono", monospace; font-size: 13px; }
pre { padding: 12px; overflow-x: auto; background: var(--field); border: 1px solid var(--line); border-radius: var(--radius); }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

/* Header */
.header-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 16px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.logo:hover { color: var(--text); }
.logo svg { width: 26px; height: 26px; color: var(--accent); }

.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

.nav-links a,
.nav-links input[type=submit] {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    margin: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
}

.nav-links a:hover,
.nav-links input[type=submit]:hover { color: var(--text); background: rgba(243, 236, 228, 0.08); }
.nav-links a[aria-current=page] { color: var(--text); background: rgba(243, 236, 228, 0.1); }

/* Messages */
.success-message, .warning-message, .error-message {
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
}

.success-message { color: var(--ok); }
.warning-message { color: var(--warn); }
.error-message { color: var(--danger); border-color: var(--danger-line); }

/* Cards and page structure */
.card {
    padding: 24px;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    backdrop-filter: blur(14px);
}

.card > :last-child { margin-bottom: 0; }

.card-narrow { max-width: 400px; margin: 8vh auto 16px; }

.page-head { margin: 8px 0 20px; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }

.eyebrow {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.crumbs { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }

.hint { color: var(--muted); max-width: 65ch; }

.danger-zone { border-color: var(--danger-line); }
.danger-zone summary { color: var(--danger); font-weight: 600; cursor: pointer; }
.danger-zone details[open] summary { margin-bottom: 12px; }

/* Forms */
label { font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: 13px; color: var(--muted); }
.field > small { margin-top: -2px; }

input[type=text],
input[type=password],
input[type=number],
input[type=url],
select {
    width: 100%;
    max-width: 420px;
    height: 40px;
    padding: 0 12px;
    margin: 0;
    color: var(--text);
    font: inherit;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

input[type=number] { max-width: 120px; }
select option { background: var(--surface-solid); }

input:hover, select:hover { border-color: var(--line-strong); }

input[type=text]:focus-visible,
input[type=password]:focus-visible,
input[type=number]:focus-visible,
select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

input::placeholder { color: var(--muted); opacity: 0.8; }
input:disabled { opacity: 0.5; }

input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }

.check { display: flex; align-items: center; gap: 10px; min-height: 32px; font-weight: 400; cursor: pointer; }

fieldset { margin: 0 0 16px; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.choice { display: flex; flex-wrap: wrap; gap: 4px 20px; }

input[type=file] { max-width: 100%; color: var(--muted); font: inherit; }

button,
input[type=submit],
input[type=file]::file-selector-button {
    min-height: 38px;
    padding: 0 16px;
    margin: 0;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    background: var(--surface-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
}

input[type=file]::file-selector-button { margin-right: 12px; }

button:hover:not(:disabled),
input[type=submit]:hover:not(:disabled),
input[type=file]::file-selector-button:hover { background: var(--surface-hover); }

button:active:not(:disabled),
input[type=submit]:active:not(:disabled) { transform: translateY(1px); }

button:disabled, input[type=submit]:disabled { opacity: 0.45; cursor: not-allowed; }

input[type=submit].primary,
.actions input[type=submit] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

input[type=submit].primary:hover:not(:disabled),
.actions input[type=submit]:hover:not(:disabled) { background: var(--accent-hover); }

input[type=submit].danger,
.danger-zone input[type=submit] { background: transparent; color: var(--danger); border-color: var(--danger-line); }

input[type=submit].danger:hover,
.danger-zone input[type=submit]:hover { background: rgba(255, 138, 122, 0.1); }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.inline-form .field { margin: 0; flex: 0 1 420px; }

/* Tables (admin page) */
table { width: 100%; border-collapse: collapse; }
thead td { color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; }
td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
td:last-child { text-align: right; padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }

/* Player cards */
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }

.player-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    color: var(--text);
    text-decoration: none;
}

.player-card:hover { color: var(--text); border-color: var(--accent); background: rgba(232, 135, 58, 0.08); }
.player-card .name { display: block; font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.player-card .action { display: block; color: var(--accent); font-size: 14px; font-weight: 600; }

.list-profile-picture {
    --list-profile-picture-size: 24px;
    flex: none;
    position: relative;
    width: var(--list-profile-picture-size);
    height: var(--list-profile-picture-size);
}

.player-card .list-profile-picture { --list-profile-picture-size: 48px; }

.list-profile-picture-back,
.list-profile-picture-body,
.list-profile-picture-front {
    position: absolute;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    background-repeat: no-repeat;
    background-image: var(--list-profile-picture-image);
    background-position-y: calc(-1 * var(--list-profile-picture-size));
    background-size: calc(8 * var(--list-profile-picture-size)), calc(8 * var(--list-profile-picture-size));
}

.list-profile-picture-back { background-position-x: calc(-7 * var(--list-profile-picture-size)); }
.list-profile-picture-body { transform: scale(0.92); background-position-x: calc(-1 * var(--list-profile-picture-size)); }
.list-profile-picture-front { background-position-x: calc(-5 * var(--list-profile-picture-size)); }

.no-face { background: var(--surface-raised); border-radius: 4px; }

/* Player page */
.player-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.preview { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; position: sticky; top: 16px; }
#skin-container { width: 100%; min-height: 320px; display: grid; place-items: center; }
.texture-preview { width: 200px; image-rendering: pixelated; }
.small-texture-preview { width: 64px; image-rendering: pixelated; vertical-align: middle; }
.uuid { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; user-select: all; }
.texture-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.player-layout .actions { margin: 0 0 16px; }

.noscript-hidden { display: none !important; }
.svg-defs { position: absolute; width: 0; height: 0; }
.divider { display: flex; align-items: center; gap: 0.5em; margin: 16px 0; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.openid-logo { height: 3rem; vertical-align: middle; }

/* Footer */
.footer { margin-top: 32px; color: var(--muted); font-size: 12px; opacity: 0.8; text-align: center; }
.footer a { color: var(--muted); }

@media (max-width: 720px) {
    .player-layout { grid-template-columns: 1fr; }
    .preview { position: static; }
    #content table { display: block; overflow-x: auto; }
    .card { padding: 18px; }
}

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