/* ============================================================
   ZlsNet Web Hub — 深色主题样式表
   设计参考：BeatArray.cn (琥珀金品牌色 · 极简工业风)
   暗色适配：背景 #0d1117 · 卡片 #161b22 · 主色 #ffd666
   ============================================================ */

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
    --ba-primary: #ffd666;
    --ba-primary-soft: rgba(255, 214, 102, 0.12);
    --ba-primary-glow: rgba(255, 214, 102, 0.25);
    --ba-primary-hover: #ffe082;
    --ba-primary-active: #ffcb3d;

    --bg-body: #0d1117;
    --bg-elevated: #161b22;
    --bg-card: #1a1f2b;
    --bg-card-hover: #21262d;
    --bg-input: #0d1117;
    --bg-code: #0d1117;
    --bg-chip: #21262d;
    --bg-table-stripe: rgba(255, 255, 255, 0.02);

    --border-color: #30363d;
    --border-light: #21262d;
    --divider: #21262d;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-disabled: #484f58;

    --color-success: #3fb950;
    --color-error: #f85149;
    --color-warning: #d29922;
    --color-info: #58a6ff;

    --font-sans:
        "Noto Sans SC", "Segoe UI", "PingFang SC", "Microsoft YaHei",
        -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;

    --radius-s: 2px;
    --radius-m: 4px;
    --radius-l: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(255, 214, 102, 0.15);

    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

    --nav-height: 56px;
    --content-max-width: 1080px;
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--ba-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--ba-primary-hover);
}

/* ---- Typography ---- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}
h1 {
    font-size: 1.75rem;
}
h2 {
    font-size: 1.35rem;
}
h3 {
    font-size: 1.1rem;
}

code {
    font-family: var(--font-mono);
    background: var(--bg-code);
    border: 1px solid var(--border-color);
    padding: 1px 6px;
    border-radius: var(--radius-m);
    font-size: 0.875em;
    color: var(--ba-primary);
}

/* ---- Layout ---- */
body {
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
    max-width: var(--content-max-width);
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px 48px;
}

/* ---- Navigation ---- */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-base);
}

header .brand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}
header .brand span {
    color: var(--ba-primary);
}

header nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

header nav a {
    color: var(--text-secondary);
    margin: 0;
    padding: 6px 14px;
    border-radius: var(--radius-l);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}
header nav a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

header nav form {
    display: inline;
    margin-left: 4px;
}

header nav form button {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: var(--radius-l);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}
header nav form button:hover {
    color: var(--color-error);
    border-color: var(--color-error);
    background: rgba(248, 81, 73, 0.08);
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-l);
    padding: 24px;
    margin-bottom: 20px;
    transition: all var(--transition-base);
}
.card:hover {
    border-color: rgba(255, 214, 102, 0.15);
    box-shadow: var(--shadow-glow);
}

.card h2,
.card h3 {
    margin-bottom: 16px;
}
.card h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.card p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.7;
}
.card p:last-child {
    margin-bottom: 0;
}

.card ul {
    padding-left: 20px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}
.card ul li {
    margin-bottom: 4px;
}

/* ---- Forms ---- */
form p {
    margin-bottom: 14px;
}

input,
textarea,
select {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-m);
    padding: 10px 14px;
    color: var(--text-primary);
    width: 100%;
    max-width: 400px;
    transition: all var(--transition-fast);
    outline: none;
}
input:focus,
textarea:focus,
select:focus {
    border-color: var(--ba-primary);
    box-shadow: 0 0 0 3px var(--ba-primary-soft);
}
input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    -webkit-box-shadow: 0 0 0 30px var(--bg-input) inset;
    caret-color: var(--text-primary);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.inline-form input {
    width: auto;
    min-width: 160px;
    flex: 1 1 160px;
}

/* ---- Buttons ---- */
button,
.btn {
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 9px 20px;
    border: none;
    border-radius: var(--radius-m);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

button[type="submit"],
button:not(.btn-secondary):not(.btn-danger) {
    background: var(--ba-primary);
    color: #0d1117;
}
button[type="submit"]:hover,
button:not(.btn-secondary):not(.btn-danger):hover {
    background: var(--ba-primary-hover);
    box-shadow: 0 0 16px var(--ba-primary-glow);
}
button[type="submit"]:active {
    background: var(--ba-primary-active);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: var(--bg-card-hover);
}

.btn-danger {
    background: transparent;
    color: var(--color-error);
    border: 1px solid var(--color-error);
}
.btn-danger:hover {
    background: rgba(248, 81, 73, 0.1);
}

a.btn,
a.btn-secondary,
a.btn-danger {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
}

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

tbody tr:hover td {
    background: var(--bg-table-stripe);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ---- Status Messages ---- */
.success {
    background: rgba(63, 185, 80, 0.1);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--color-success);
    padding: 10px 16px;
    border-radius: var(--radius-m);
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.error {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--color-error);
    padding: 10px 16px;
    border-radius: var(--radius-m);
    font-size: 0.875rem;
    margin-bottom: 12px;
}

/* ---- Chips / Tags ---- */
.chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.chip {
    background: var(--bg-chip);
    border: 1px solid var(--border-color);
    padding: 5px 14px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
}
.chip:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
}
.chip.active {
    background: var(--ba-primary);
    color: #0d1117;
    border-color: var(--ba-primary);
    font-weight: 600;
}

/* ---- Grid Utilities ---- */
.split-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.metric-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-l);
    padding: 12px 14px;
    transition: all var(--transition-fast);
}
.metric-item:hover {
    border-color: rgba(255, 214, 102, 0.15);
}
.metric-item .label {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.metric-item strong {
    font-size: 1.15rem;
    color: var(--text-primary);
}

/* ---- Game Rows ---- */
.game-row {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
    margin-top: 16px;
}
.game-row:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}
.game-row h4 {
    margin-bottom: 12px;
    color: var(--ba-primary);
}

/* ---- Inventory / Library ---- */
.inventory-header {
    text-align: center;
    margin-bottom: 24px;
}
.inventory-header h1 {
    margin: 0 0 6px;
    font-size: 1.5rem;
}
.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.inventory-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.inventory-section,
.library-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-l);
    padding: 20px;
}
.inventory-section h3,
.library-section h3 {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
}

.inventory-items-list,
.item-library-list {
    min-height: 240px;
    max-height: 400px;
    overflow-y: auto;
}
.inventory-items-list::-webkit-scrollbar,
.item-library-list::-webkit-scrollbar {
    width: 6px;
}
.inventory-items-list::-webkit-scrollbar-thumb,
.item-library-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-full);
}

.inventory-item,
.library-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-m);
    padding: 12px;
    margin-bottom: 8px;
    transition: all var(--transition-fast);
}
.inventory-item:hover,
.library-item:hover {
    border-color: var(--border-color);
}

.library-item.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.item-icon {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
    flex-shrink: 0;
}

.item-info {
    flex: 1;
    min-width: 0;
}
.item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.item-capacity,
.item-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}
.item-effect {
    font-size: 0.75rem;
    color: var(--color-success);
    margin-top: 2px;
}
.item-count {
    color: var(--ba-primary);
}

.remove-item-btn {
    background: transparent;
    color: var(--color-error);
    border: 1px solid var(--color-error);
    padding: 4px 10px;
    border-radius: var(--radius-m);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.remove-item-btn:hover {
    background: rgba(248, 81, 73, 0.1);
}

.add-item-btn {
    background: transparent;
    color: var(--color-success);
    border: 1px solid var(--color-success);
    padding: 4px 10px;
    border-radius: var(--radius-m);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}
.add-item-btn:hover:not(:disabled) {
    background: rgba(63, 185, 80, 0.1);
}
.add-item-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Capacity */
.capacity-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-l);
    padding: 20px;
    margin-bottom: 20px;
}
.capacity-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.remaining {
    color: var(--color-success);
}
.capacity-bar-bg {
    width: 100%;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.capacity-bar-fill {
    height: 100%;
    background: var(--ba-primary);
    border-radius: var(--radius-full);
    transition:
        width var(--transition-base),
        background var(--transition-base);
}
.capacity-tip {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
}

/* Preview */
.preview-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-l);
    padding: 20px;
    margin-bottom: 20px;
}
.preview-section h3 {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
}
.preview-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}
.preview-item {
    display: flex;
    gap: 8px;
    align-items: baseline;
}
.preview-label {
    color: var(--text-muted);
    font-size: 0.8rem;
}
.preview-value {
    color: var(--ba-primary);
    font-weight: 700;
    font-size: 1.1rem;
}
.preview-effects {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.preview-effects .preview-label {
    flex-shrink: 0;
    padding-top: 2px;
}
.preview-effects-list {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.preview-effect {
    margin-bottom: 3px;
}

/* Inventory footer / actions */
.inventory-footer {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 20px 0 8px;
}
.inventory-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    justify-content: flex-end;
}

/* ---- Game Container ---- */
.game-container {
    text-align: center;
    margin-top: 20px;
}
#gameCanvas {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-l);
    background: var(--bg-elevated);
    margin: 20px auto;
    display: block;
}
.game-controls {
    margin-top: 12px;
}
.game-info {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* ---- Empty state ---- */
.empty-tip {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
}

/* ---- Notices / Info boxes ---- */
.notice {
    background: rgba(88, 166, 255, 0.08);
    border: 1px solid rgba(88, 166, 255, 0.2);
    padding: 12px 16px;
    border-radius: var(--radius-m);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}
.notice strong {
    color: var(--text-primary);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    header {
        padding: 0 16px;
        flex-wrap: wrap;
        height: auto;
        min-height: var(--nav-height);
    }
    header nav {
        flex-wrap: wrap;
        gap: 2px;
    }
    header nav a,
    header nav form button {
        padding: 4px 10px;
        font-size: 0.8rem;
    }

    main {
        padding: 16px 12px 32px;
    }

    .card {
        padding: 16px;
    }

    .split-grid {
        grid-template-columns: 1fr;
    }

    .inventory-layout {
        grid-template-columns: 1fr;
    }

    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .preview-stats {
        flex-direction: column;
        gap: 12px;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }
    .inline-form input {
        min-width: 0;
    }

    table {
        font-size: 0.8rem;
    }
    thead th,
    tbody td {
        padding: 6px 8px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.4rem;
    }
    h2 {
        font-size: 1.15rem;
    }

    .metric-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .metric-item {
        padding: 8px 10px;
    }

    .chip {
        font-size: 0.75rem;
        padding: 3px 10px;
    }
}
