@font-face {
    font-family: 'FOTNewRodin';
    src: url('/FOT-NewRodin Pro EB.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'PingFangHeavy';
    src: url('/PingFang Heavy.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #0b0f12;
    --surface: #12171c;
    --surface-2: #1c242c;
    --text: #ffffff;
    --muted: #a0a0a0;
    --accent: #5ad1ff;
    --border: #2c363f;
}

html, body { background-color: var(--bg); color: var(--text); margin: 0; padding: 0; width: 100%; min-height: 100%; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; font-family: 'PingFangHeavy', 'PingFang SC', sans-serif; }
a { text-decoration: none; color: inherit; }

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(11, 15, 18, 0.95);
    border-bottom: 1px solid var(--border);
    width: 100%;
    padding: 15px 0;
    padding-top: calc(15px + env(safe-area-inset-top, 0px));
}
.header-inner {
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
.brand { display: flex; flex-direction: column; }
.logo { font-size: 22px; font-weight: bold; color: var(--accent); letter-spacing: 1px; font-family: 'FOTNewRodin', sans-serif; }
.subtitle { font-size: 10px; color: var(--muted); line-height: 1.4; font-family: 'FOTNewRodin', sans-serif; }
.subtitle a { color: var(--accent); text-decoration: underline; }

.auth-area { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.auth-area .user-name { font-size: 13px; color: var(--muted); }
.auth-area .user-name b { color: var(--text); }
.auth-area .btn-logout { background: none; border: none; color: #ff4d4d; cursor: pointer; font-size: 13px; font-family: 'PingFangHeavy', 'PingFang SC', sans-serif; padding: 0; }
.auth-area .btn-logout:hover { text-decoration: underline; }

.enter-btn {
    background: var(--accent);
    color: #000;
    padding: 9px 22px;
    border-radius: 8px;
    border: none;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: 0.2s;
    font-family: 'PingFangHeavy', 'PingFang SC', sans-serif;
    font-size: 13px;
}
.enter-btn:hover { transform: scale(1.05); filter: brightness(1.1); }
.enter-btn.secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
}
.enter-btn.secondary:hover { border-color: var(--accent); }

/* Main content */
.content { max-width: 1500px; margin: 0 auto; padding: 30px 20px 60px; }

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.accent-bar { width: 4px; height: 22px; background: var(--accent); border-radius: 2px; flex-shrink: 0; }
.section-header h2 { margin: 0; font-size: 18px; color: var(--text); }

/* Grid & Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}
.card-wrapper { position: relative; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    color: var(--text);
    text-decoration: none;
}
.card:hover { transform: translateY(-5px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.card:hover .cover { transform: scale(1.08); }
.img-container { width: 100%; height: 0; padding-bottom: 100%; position: relative; overflow: hidden; background: #000; }
.cover { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; display: block; }
.meta { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; }
.title { font-size: 13px; font-weight: bold; margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 11px; color: var(--muted); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-msg { grid-column: 1 / -1; text-align: center; padding: 100px 20px; color: var(--muted); font-size: 14px; }
.error-msg { grid-column: 1 / -1; text-align: center; padding: 100px 20px; color: #ff4d4d; font-size: 14px; }

/* Difficulty badges */
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; padding-top: 8px; }
.badge { font-size: 8px; padding: 2px 6px; border-radius: 4px; font-weight: bold; color: #fff; }
.lv-0 { background-color: #053d87; }
.lv-1 { background-color: #3e8a24; }
.lv-2 { background-color: #6a6a21; }
.lv-3 { background-color: #950000; }
.lv-4 { background-color: #7c157c; }
.lv-5 { background-color: #f48df4; color: #000; }
.lv-6 { background-color: #cc7400; }

@media (min-width: 640px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px; }
}
@media (max-width: 480px) {
    .header-inner { padding: 0 14px; }
    .auth-area { flex-direction: column; align-items: flex-end; gap: 6px; }
    .content { padding: 20px 14px 60px; }
    .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .title { font-size: 12px; }
    .sub { font-size: 10px; }
    .meta { padding: 8px 10px 10px; }
    .badge { font-size: 7px; padding: 2px 5px; }
}

/* ── Network indicator ─────────────────────────────────────────────── */
.net-indicator {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: default;
}
.net-indicator svg { width: 35px; height: 35px; flex-shrink: 0; }
.net-indicator .net-ms {
    font-size: 10px;
    line-height: 1;
    margin-left: 2px;
    color: #8b949e;
    font-variant-numeric: tabular-nums;
}
.net-indicator .net-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1c2128;
    border: 1px solid #30363d;
    color: #e6edf3;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 200;
    pointer-events: none;
}
.net-indicator:hover .net-tooltip { display: block; }
.net-indicator .net-tooltip.warn { border-color: #f85149; color: #f85149; }

/* ── Upload progress ───────────────────────────────────────────────── */
.upload-progress-wrap {
    width: 100%;
    margin-top: 6px;
    display: none;
}
.upload-progress-bar {
    width: 100%;
    height: 6px;
    background: #21262d;
    border-radius: 3px;
    overflow: hidden;
}
.upload-progress-bar > div {
    height: 100%;
    width: 0%;
    background: #5ad1ff;
    border-radius: 3px;
    transition: width 0.2s ease;
}
.upload-progress-label {
    font-size: 11px;
    color: #8b949e;
    margin-top: 2px;
}