:root {
    --bg: #f4f6f8;
    --surface: #ffffff;
    --surface-soft: #f9fafb;
    --surface-muted: #eef2f7;
    --border: #dce3ec;
    --border-strong: #c8d2df;
    --text: #172033;
    --text-muted: #667085;
    --text-subtle: #8a94a6;
    --primary: #6366f1;
    --primary-strong: #4f46e5;
    --primary-soft: #e0e7ff;
    --accent: #8b5cf6;
    --heat-0: #e5e7eb;
    --heat-1: #c7d2fe;
    --heat-2: #a5b4fc;
    --heat-3: #818cf8;
    --heat-4: #6366f1;
    --warning: #b45309;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 16px 40px rgba(15, 23, 42, 0.08);
    --radius: 8px;
    --radius-sm: 6px;
    --page-max: 1180px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    min-height: 100%;
    background: var(--bg);
}

body {
    width: 100%;
    min-height: 100vh;
    touch-action: manipulation;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    padding: 0 24px 44px;
}

body::before {
    content: "";
    position: fixed;
    inset: 0 0 auto;
    height: 260px;
    background: linear-gradient(180deg, #e9eef6 0%, rgba(244, 246, 248, 0) 100%);
    pointer-events: none;
    z-index: -1;
}

button,
input,
textarea {
    font: inherit;
}

.topbar {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto 26px;
    padding: 22px 0 0;
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 44px;
}

.topbar-title {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 750;
    letter-spacing: 0;
}

.topbar-title::after {
    content: "独立开发者的数字客厅";
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
}

.topbar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.nav-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 36px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 0 12px;
    text-decoration: none;
    transition: background 0.16s, border-color 0.16s, color 0.16s, box-shadow 0.16s;
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--surface-soft);
    border-color: var(--border);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-soft);
    border-color: #bfd4ff;
    color: var(--primary-strong);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.05);
}

.game-link {
    color: var(--warning) !important;
}

.is-guest .topbar-nav {
    justify-content: flex-start;
}

.is-guest .topbar-nav .game-link {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412 !important;
}

.nav-dropdown {
    position: relative;
}

.dropdown-content,
.user-menu {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 100;
}

.dropdown-content {
    display: none;
    left: 0;
    min-width: 160px;
    position: absolute;
    top: calc(100% + 8px);
}

.nav-dropdown:hover .dropdown-content,
.nav-dropdown.open .dropdown-content {
    display: flex;
    flex-direction: column;
}

.dropdown-content .nav-item {
    justify-content: flex-start;
    width: 100%;
}

.auth-group {
    position: relative;
}

.auth-btn {
    min-height: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 650;
    padding: 0 14px;
    transition: border-color 0.16s, box-shadow 0.16s, color 0.16s;
    white-space: nowrap;
}

.auth-btn:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
}

.auth-btn.logged-in {
    color: var(--primary-strong);
    border-color: #bfd4ff;
    background: var(--primary-soft);
}

.auth-btn.admin {
    color: #7c3aed;
    border-color: #ddd6fe;
    background: #f5f3ff;
}

.user-menu {
    min-width: 150px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 34px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.86rem;
    padding: 0 10px;
    text-align: left;
}

.user-menu-item:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.danger-menu {
    color: var(--danger);
}

.danger-menu:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.icon {
    flex-shrink: 0;
    opacity: 0.72;
    vertical-align: middle;
}

.icon-inline {
    margin-right: 0.35em;
    margin-top: -1px;
    vertical-align: middle;
}

.container,
.admin-panel.active {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
}

.container {
    display: grid;
    grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
    gap: 18px;
    align-items: start;
}

.message-card {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.counter-card,
.stock-card {
    grid-column: 1;
}

.stock-card {
    align-self: stretch;
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.admin-panel.active > .card {
    max-width: var(--page-max);
    margin: 0 auto;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.card:hover {
    border-color: var(--border-strong);
}

.card-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    margin-bottom: 18px;
    text-transform: uppercase;
}

.counter-card {
    min-height: 290px;
    text-align: left;
}

.count-display {
    color: var(--text);
    font-size: clamp(4rem, 8vw, 6.8rem);
    font-weight: 800;
    letter-spacing: 0;
    line-height: 0.95;
    margin: 12px 0 22px;
    transition: transform 0.15s;
}

.count-display.pop {
    transform: scale(1.04);
}

.hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-top: 14px;
}

.highlight-hint {
    color: var(--warning);
    font-size: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    background: var(--text);
    border: 1px solid var(--text);
    border-radius: var(--radius-sm);
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 700;
    padding: 0 18px;
    transition: transform 0.12s, background 0.16s, border-color 0.16s, box-shadow 0.16s;
    white-space: nowrap;
}

.btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

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

/* 查询中按钮禁用状态 */
.btn:disabled,
.btn.loading {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: var(--text);
    border-color: var(--text);
}
.btn:disabled:hover,
.btn.loading:hover {
    background: var(--text);
    border-color: var(--text);
    box-shadow: none;
}

.btn.small {
    min-height: 32px;
    padding: 0 12px;
    font-size: 0.8rem;
}

input,
textarea {
    width: 100%;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.94rem;
    outline: none;
    padding: 11px 12px;
    transition: background 0.16s, border-color 0.16s, box-shadow 0.16s;
}

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

input:focus,
textarea:focus {
    background: #fff;
    border-color: #9bbcff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-subtle);
}

.form-footer,
.stock-input-row,
.file-input-row,
.reply-form.active {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-footer {
    justify-content: space-between;
    margin-top: 12px;
}

.name-hint,
.stock-example,
.file-meta,
.note-item-time {
    color: var(--text-muted);
    font-size: 0.82rem;
}

.stock-example {
    margin-top: 10px;
}

.stock-result {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* 行情状态标签 */
.stock-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 6px;
    letter-spacing: 0.02em;
}
.stock-tag-realtime { background: #d1fae5; color: #065f46; }
.stock-tag-close { background: #dbeafe; color: #1e40af; }
.stock-tag-history { background: #f3f4f6; color: #6b7280; }

/* 多字段行情详情 */
.stock-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 8px 0 10px;
    padding: 8px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.stock-detail-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 0.82rem;
}
.detail-label { color: var(--text-muted); font-size: 0.75rem; }
.detail-value { color: var(--text); font-weight: 600; }

/* 错误状态 */
.stock-error {
    color: var(--text);
    font-size: 0.88rem;
    padding: 12px;
    text-align: center;
    line-height: 1.6;
}
.stock-error-hint {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 4px;
}

/* 加载动画 */
.loading-dots::after {
    content: '';
    animation: loading-dots 1.5s steps(4, end) infinite;
}
@keyframes loading-dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* 空输入提示条 */
.stock-empty-hint {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 6px;
    animation: hint-in 0.2s ease-out;
}
@keyframes hint-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* 元数据时间戳行 */
.stock-meta {
    display: flex;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin: 4px 0 10px;
}
.stock-meta-label {}
.stock-meta-time {}
.stock-meta-date {}

/* 查询结果淡入效果 */
.stock-result.active {
    animation: result-fade-in 0.2s ease-out;
}
@keyframes result-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
    display: block;
}

.stock-result-loading {
    color: var(--text-muted);
    font-size: 0.88rem;
    padding: 12px;
    text-align: center;
}

.stock-result-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.stock-name {
    color: var(--text);
    font-size: 1.08rem;
    font-weight: 800;
}

.stock-code {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.stock-price {
    font-size: 2rem;
    font-weight: 800;
    margin: 4px 0;
}

.stock-price.up,
.stock-change.up {
    color: var(--danger);
}

.stock-price.down,
.stock-change.down {
    color: var(--success);
}

.stock-change {
    font-size: 0.88rem;
    margin-bottom: 10px;
}

.stock-comment {
    border-top: 1px solid var(--border);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.7;
    padding-top: 12px;
}

#messageForm {
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
    padding-bottom: 18px;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thread {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.thread-main {
    background: #fff;
    padding: 16px;
}

.thread-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.thread-floor {
    min-width: 38px;
    color: var(--text-subtle);
    font-size: 0.75rem;
    font-weight: 700;
}

.thread-name {
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 750;
}

.thread-name.bot {
    color: #7c3aed;
}

.thread-time {
    color: var(--text-subtle);
    font-size: 0.75rem;
    margin-left: auto;
}

.thread-text {
    color: var(--text);
    font-size: 0.94rem;
    line-height: 1.75;
    word-break: break-word;
}

.replies {
    border-top: 1px solid var(--border);
}

.reply {
    border-top: 1px solid var(--border);
    padding: 12px 16px 12px 34px;
    position: relative;
}

.reply:first-child {
    border-top: none;
}

.reply::before {
    content: "↳";
    color: var(--text-subtle);
    left: 14px;
    position: absolute;
}

.reply .thread-text {
    font-size: 0.88rem;
}

.reply-btn,
.inline-btn {
    display: inline-flex;
    align-items: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--primary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 650;
    padding: 5px 8px;
    text-decoration: none;
}

.reply-btn:hover,
.inline-btn:hover {
    background: var(--primary-soft);
}

.reply-form {
    display: none;
    border-top: 1px solid var(--border);
    padding: 12px 16px 12px 34px;
}

.reply-form input {
    min-width: 0;
}

.loading {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 28px 0;
    text-align: center;
}

#panel-notes .card,
#panel-files .card {
    display: grid;
    grid-template-columns: minmax(300px, 0.9fr) minmax(420px, 1.4fr);
    gap: 20px;
    align-items: start;
}

#panel-notes .card-label,
#panel-files .card-label {
    grid-column: 1 / -1;
    margin-bottom: 0;
}

#noteForm,
#fileUploadForm {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    padding: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

#noteForm {
    grid-column: 1;
}

#fileUploadForm {
    grid-column: 1;
}

#noteForm .form-footer,
#fileUploadForm .file-input-row {
    margin-top: 0;
}

#noteForm textarea {
    min-height: 220px;
}

#panel-notes .search-box {
    grid-column: 2;
    grid-row: 2;
    margin-top: 0;
}

#panel-notes .note-list {
    grid-column: 2;
    grid-row: 3;
}

#panel-files .file-list {
    grid-column: 2;
    grid-row: 2 / span 2;
}

.note-list,
.file-list {
    margin-top: 0;
    min-width: 0;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.note-item,
.file-item {
    border-bottom: 1px solid var(--border);
    padding: 16px;
}

.note-item:last-child,
.file-item:last-child {
    border-bottom: none;
}

.note-item-header,
.file-item-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.note-item-header {
    justify-content: space-between;
}

.note-item-title,
.file-name {
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 750;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-item-summary {
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.55;
    margin-top: 6px;
}

.note-item-actions,
.file-actions {
    display: flex;
    flex-shrink: 0;
    gap: 6px;
}

.danger-action {
    color: var(--danger);
}

.danger-action:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.search-box {
    margin-top: 16px;
}

.file-icon {
    color: var(--primary);
    flex-shrink: 0;
    opacity: 0.75;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-uploader {
    color: var(--primary);
    margin-left: 8px;
}

.download-btn {
    color: var(--success);
}

.download-btn:hover {
    background: #ecfdf3;
    color: #15803d;
}

input[type="file"]::file-selector-button {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 650;
    margin-right: 10px;
    padding: 6px 10px;
}

.form-msg {
    font-size: 0.84rem;
    min-height: 1.2em;
    text-align: center;
}

.form-error {
    color: var(--danger);
}

.form-success {
    color: var(--success);
}

.danger-btn {
    background: var(--danger);
    border-color: var(--danger);
}

.danger-btn:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    box-shadow: 0 10px 24px rgba(220, 38, 38, 0.18);
}

#createUserForm,
#resetPassForm,
#changePassForm {
    display: grid;
    gap: 12px;
    max-width: 520px;
}

.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    padding: 18px 0 4px;
}

.page-btn {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.82rem;
    padding: 6px 10px;
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.user-table {
    display: flex;
    flex-direction: column;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.user-table-header,
.user-table-row {
    display: grid;
    grid-template-columns: 56px minmax(120px, 1fr) 96px 160px;
    gap: 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
}

.user-table-header {
    color: var(--text-muted);
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.user-table-row {
    background: #fff;
    color: var(--text);
    font-size: 0.9rem;
}

.user-table-row:last-child {
    border-bottom: none;
}

.role-badge {
    border-radius: 999px;
    display: inline-flex;
    font-size: 0.76rem;
    font-weight: 750;
    padding: 3px 8px;
}

.role-badge.admin {
    background: #f5f3ff;
    color: #7c3aed;
}

.role-badge.user {
    background: var(--primary-soft);
    color: var(--primary-strong);
}

.modal-overlay {
    align-items: center;
    background: rgba(15, 23, 42, 0.48);
    display: none;
    inset: 0;
    justify-content: center;
    padding: 20px;
    position: fixed;
    z-index: 99999;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: 380px;
    max-width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.modal-wide {
    width: 620px;
    max-height: 84vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 8px;
}

.modal-title {
    color: var(--text);
    font-size: 1.08rem;
    font-weight: 800;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 4px;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 20px 20px;
}

.modal-wide .modal-body {
    max-height: 62vh;
    overflow-y: auto;
}

.modal-body .btn {
    width: 100%;
}

.modal-body .form-error {
    color: var(--danger);
    font-size: 0.84rem;
    text-align: center;
}

.modal-body .form-success {
    color: var(--success);
    font-size: 0.84rem;
    text-align: center;
}

.modal-body .modal-link {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.84rem;
    text-align: center;
    text-decoration: underline;
}

.note-detail-time {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.note-detail-content {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
}

.note-detail-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

#panel-game {
    margin: 0 auto;
    max-width: var(--page-max) !important;
    padding: 0;
    width: 100%;
}

#panel-game.active {
    display: block;
}

#panel-game iframe {
    border: none;
    display: block;
    min-height: 700px;
    width: 100%;
}

.game-panel-link {
    display: block;
    padding: 60px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--primary);
    font-size: 1rem;
    font-weight: 750;
    text-align: center;
    text-decoration: none;
}

.emoji-particle {
    position: fixed;
    pointer-events: none;
    font-size: 1.5rem;
    z-index: 9999;
    animation: float-up 1.2s ease-out forwards;
}

@keyframes float-up {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-220px) rotate(40deg) scale(0.3);
    }
}

.title-toast {
    position: fixed;
    color: var(--primary);
    font-size: 2rem;
    font-weight: 800;
    z-index: 99999;
    pointer-events: none;
    text-shadow: 0 8px 26px rgba(15, 23, 42, 0.16);
    white-space: nowrap;
    transform: translateX(-50%);
    animation: title-rise 3s ease-out forwards;
}

@keyframes title-rise {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0.5);
    }
    10% {
        opacity: 1;
        transform: translateX(-50%) scale(1.15);
    }
    25% {
        transform: translateX(-50%) scale(1);
    }
    70% {
        opacity: 1;
        transform: translateX(-50%) translateY(-80px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-180px) scale(0.8);
    }
}

.emoji-frenzy {
    position: fixed;
    top: -60px;
    pointer-events: none;
    z-index: 9998;
    animation: frenzy-fall linear forwards;
}

@keyframes frenzy-fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes rainbow {
    0% {
        color: var(--primary);
    }
    25% {
        color: var(--accent);
    }
    50% {
        color: var(--warning);
    }
    75% {
        color: #7c3aed;
    }
    100% {
        color: var(--primary);
    }
}

footer {
    width: 100%;
    max-width: var(--page-max);
    margin: 34px auto 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
}

.footer-brand {
    color: var(--text);
    font-weight: 650;
}

.footer-sep {
    margin: 0 8px;
}

@media (max-width: 900px) {
    body {
        padding: 0 18px 36px;
    }

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

    .counter-card,
    .stock-card,
    .message-card {
        grid-column: auto;
        grid-row: auto;
    }

    .message-card {
        min-height: auto;
    }

    #panel-notes .card,
    #panel-files .card {
        grid-template-columns: 1fr;
    }

    #panel-notes .card-label,
    #panel-files .card-label,
    #noteForm,
    #fileUploadForm,
    #panel-notes .search-box,
    #panel-notes .note-list,
    #panel-files .file-list {
        grid-column: auto;
        grid-row: auto;
    }

    #noteForm textarea {
        min-height: 150px;
    }
}

@media (max-width: 560px) {
    body {
        padding: 0 12px 28px;
    }

    .topbar {
        margin-bottom: 18px;
        padding-top: 14px;
    }

    .topbar-row {
        align-items: flex-start;
    }

    .topbar-title {
        font-size: 0.95rem;
    }

    .topbar-nav {
        gap: 6px;
        overflow-x: auto;
        padding: 6px;
    }

    .nav-item {
        min-height: 34px;
        padding: 0 10px;
        font-size: 0.82rem;
    }

    .card {
        padding: 18px;
    }

    .count-display {
        font-size: 4rem;
    }

    .stock-input-row,
    .file-input-row,
    .form-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .stock-input-row .btn,
    .file-input-row .btn,
    .form-footer .btn {
        width: 100%;
    }

    .thread-meta {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .thread-time {
        flex-basis: 100%;
        margin-left: 0;
    }

    .reply-form.active {
        align-items: stretch;
        flex-direction: column;
    }

    .file-item-row,
    .note-item-header {
        align-items: flex-start;
    }

    .file-actions,
    .note-item-actions {
        flex-direction: column;
    }

    .user-table-header,
    .user-table-row {
        grid-template-columns: 42px minmax(100px, 1fr) 76px;
    }

    .user-col-time {
        display: none;
    }

    .modal {
        width: 100%;
    }

    #panel-notes .card,
    #panel-files .card {
        gap: 14px;
    }

    #noteForm,
    #fileUploadForm {
        padding: 14px;
    }
}


/* ======================
   首页重构：玄弈的客厅
   ====================== */

/* 视图页面 */
.view-page {
    display: none;
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    animation: fadeInUp 0.6s ease;
}

.view-page.active {
    display: block;
}

/* Hero 区域 */
.hero {
    text-align: center;
    padding: 48px 20px 40px;
    position: relative;
}

.hero-title {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.05rem;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto 28px;
    line-height: 1.6;
}

.hero-stats {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 24px;
    box-shadow: var(--shadow-sm);
}

.hero-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 0 20px;
}

.hero-stat-num {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.hero-stat-label {
    font-size: 0.72rem;
    color: var(--text-subtle);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-stat-divider {
    width: 1px;
    height: 32px;
    background: var(--border);
}

/* Bento Grid */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding-bottom: 40px;
}

.bento-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: fadeInUp 0.5s ease backwards;
    display: flex;
    flex-direction: column;
}

.bento-item:nth-child(1) { animation-delay: 0.05s; }
.bento-item:nth-child(2) { animation-delay: 0.1s; }
.bento-item:nth-child(3) { animation-delay: 0.15s; }
.bento-item:nth-child(4) { animation-delay: 0.2s; }
.bento-item:nth-child(5) { animation-delay: 0.25s; }

.bento-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.1);
}

.bento-item-wide {
    grid-column: span 2;
}

.bento-item-full {
    grid-column: 1 / -1;
}

.bento-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.bento-card-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.bento-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}

.bento-card-action {
    font-size: 0.82rem;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.16s;
}

.bento-card-action:hover {
    background: var(--primary-soft);
}

/* 打卡卡片 */
.checkin-card {
    min-height: 280px;
}

.checkin-body {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

.checkin-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    flex-shrink: 0;
}

.checkin-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 3px solid var(--border);
    background: var(--surface-soft);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.checkin-btn:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 8px var(--primary-soft);
    transform: scale(1.05);
}

.checkin-btn.checked {
    border-color: var(--success);
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.15);
    cursor: default;
}

.checkin-btn-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.checkin-btn.checked .checkin-btn-text {
    color: var(--success);
}

.checkin-btn-streak {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.checkin-info {
    display: flex;
    gap: 20px;
}

.checkin-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.checkin-stat-num {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.checkin-stat-label {
    font-size: 0.75rem;
    color: var(--text-subtle);
    font-weight: 500;
}

.checkin-badge {
    font-size: 0.78rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    padding: 4px 10px;
    border-radius: 100px;
    font-weight: 600;
}

/* 热力图 */
.heatmap {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    gap: 4px;
    flex: 1;
    align-content: start;
}

.heatmap-cell {
    aspect-ratio: 1;
    border-radius: 3px;
    background: var(--heat-0);
    transition: transform 0.15s ease;
    position: relative;
}

.heatmap-cell:hover {
    transform: scale(1.3);
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.heatmap-cell.level-1 { background: var(--heat-1); }
.heatmap-cell.level-2 { background: var(--heat-2); }
.heatmap-cell.level-3 { background: var(--heat-3); }
.heatmap-cell.level-4 { background: var(--heat-4); }

.heatmap-cell::after {
    content: attr(data-date);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    margin-bottom: 6px;
    z-index: 10;
}

.heatmap-cell:hover::after {
    opacity: 1;
}

/* 留言簿卡片 */
.guestbook-card {
    min-height: 280px;
}

.guestbook-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 12px;
}

.guestbook-preview {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding-right: 4px;
}

.guestbook-empty {
    color: var(--text-subtle);
    font-size: 0.88rem;
    text-align: center;
    padding: 24px 0;
}

.guestbook-item {
    background: var(--surface-soft);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 0.88rem;
    line-height: 1.5;
}

.guestbook-item-name {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
    font-size: 0.82rem;
}

.guestbook-item-time {
    font-size: 0.72rem;
    color: var(--text-subtle);
    margin-top: 6px;
}

.guestbook-form {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.guestbook-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    background: var(--surface-soft);
    outline: none;
    transition: border-color 0.16s, box-shadow 0.16s;
}

.guestbook-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.guestbook-submit {
    padding: 10px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 0.16s, transform 0.16s;
    white-space: nowrap;
}

.guestbook-submit:hover {
    background: var(--primary-strong);
    transform: translateY(-1px);
}

/* 笔记预览卡片 */
.notes-card {
    min-height: 280px;
}

.notes-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
}

.notes-empty {
    color: var(--text-subtle);
    font-size: 0.88rem;
    text-align: center;
    padding: 24px 0;
}

.note-preview-item {
    background: var(--surface-soft);
    border-radius: 12px;
    padding: 14px;
    cursor: pointer;
    transition: background 0.16s, transform 0.16s;
    border: 1px solid transparent;
}

.note-preview-item:hover {
    background: var(--surface-muted);
    transform: translateX(4px);
    border-color: var(--border);
}

.note-preview-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-preview-content {
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.note-preview-time {
    font-size: 0.72rem;
    color: var(--text-subtle);
    margin-top: 8px;
}

/* 游戏大厅卡片 */
.game-card {
    min-height: 280px;
}

.game-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.game-link-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border-radius: 14px;
    text-decoration: none;
    border: 1px solid #e9d5ff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex: 1;
}

.game-link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.12);
}

.game-link-emoji {
    font-size: 1.6rem;
    line-height: 1;
}

.game-link-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text);
}

.game-link-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* 快捷入口 */
.quicklinks-card {
    padding: 20px 24px;
}

.quicklinks-body {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.quicklink {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 20px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    flex: 1;
}

.quicklink:hover {
    background: var(--surface-muted);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.quicklink-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.quicklink-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* 旧版计数器彩蛋 */
#panel-counter-legacy {
    display: none;
}

#panel-counter-legacy.active {
    display: block;
}

/* 行情查询面板 */
#panel-stock {
    display: none;
}

#panel-stock.active {
    display: block;
}

/* 动画 */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 响应式 */
@media (max-width: 1023px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .bento-item-wide {
        grid-column: span 2;
    }
    .checkin-body {
        flex-direction: column;
        gap: 20px;
    }
    .heatmap {
        grid-template-columns: repeat(20, 1fr);
    }
    .hero-stats {
        padding: 12px 16px;
    }
    .hero-stat {
        padding: 0 14px;
    }
}

@media (max-width: 767px) {
    .bento-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .bento-item-wide,
    .bento-item-full {
        grid-column: span 1;
    }
    .hero {
        padding: 32px 16px 28px;
    }
    .hero-title {
        font-size: 2rem;
    }
    .hero-stats {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }
    .hero-stat-divider {
        width: 40px;
        height: 1px;
    }
    .checkin-main {
        align-items: center;
        width: 100%;
    }
    .checkin-info {
        justify-content: center;
        width: 100%;
    }
    .heatmap {
        grid-template-columns: repeat(12, 1fr);
    }
    .quicklinks-body {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    .game-body {
        flex-direction: row;
    }
    .game-link-card {
        flex: 1;
    }
}
