* { box-sizing: border-box; }
body {
    margin: 0;
    background: #0d1117;
    color: #c9d1d9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 16px 24px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
}
header h1 {
    margin: 0 0 12px;
    font-size: 20px;
}
header h1 a {
    color: #58a6ff;
    text-decoration: none;
}
header h1 a:hover { color: #79c0ff; }
.controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
input[type="search"], select {
    padding: 8px 12px;
    background: #0d1117;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
    font: inherit;
}
input[type="search"] {
    flex: 1;
    min-width: 200px;
}
#count {
    color: #8b949e;
    font-size: 14px;
}
main {
    padding: 24px;
}
#grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.tile {
    margin: 0;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: transform .15s, border-color .15s;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.tile:hover {
    transform: translateY(-2px);
    border-color: #58a6ff;
}
.tile img {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    background: repeating-conic-gradient(#1c2128 0% 25%, #222831 0% 50%) 50% / 10px 10px;
    border-radius: 4px;
}
.tile figcaption {
    margin-top: 6px;
    font-size: 11px;
    text-align: center;
    word-break: break-all;
    color: #8b949e;
}
.tile figcaption b { color: #e6edf3; }

#load-more {
    display: block;
    margin: 24px auto;
    padding: 12px 24px;
    background: #238636;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}
#load-more:hover { background: #2ea043; }

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-content {
    max-width: 90%;
    max-height: 90%;
    text-align: center;
}
.modal img {
    max-width: 100%;
    max-height: 80vh;
    image-rendering: pixelated;
}
.modal .close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 36px;
    cursor: pointer;
}
#modal-caption {
    color: #c9d1d9;
    margin-top: 12px;
    font-family: monospace;
}

.cat-unit { border-color: #3fb950; }
.cat-monster { border-color: #d29922; }
.cat-npc { border-color: #58a6ff; }
.cat-battle_bg { border-color: #bc8cff; }
.cat-map { border-color: #e3b341; }

/* Loading */
.loading {
    text-align: center;
    padding: 80px 24px;
    color: #8b949e;
    font-size: 16px;
}

/* Crumbs */
.crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 13px;
}
.crumb {
    color: #8b949e;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
}
a.crumb:hover { background: #21262d; color: #58a6ff; }
.crumb.current { color: #e6edf3; font-weight: 500; }
.crumb-sep { color: #484f58; }

/* Categories landing */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
    max-width: 1400px;
    margin: 0 auto;
}
.cat-card {
    display: flex;
    flex-direction: column;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.cat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.cat-card.cat-unit:hover      { border-color: #3fb950; }
.cat-card.cat-monster:hover   { border-color: #d29922; }
.cat-card.cat-npc:hover       { border-color: #58a6ff; }
.cat-card.cat-battle_bg:hover { border-color: #bc8cff; }
.cat-card.cat-map:hover       { border-color: #e3b341; }
.cat-card.cat-other:hover     { border-color: #8b949e; }
.cat-thumb {
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d1117;
    border-bottom: 1px solid #30363d;
    overflow: hidden;
}
.cat-thumb img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    image-rendering: pixelated;
}
.cat-icon { font-size: 56px; opacity: 0.6; }
.cat-meta { padding: 14px 18px; }
.cat-title { font-size: 17px; font-weight: 600; color: #e6edf3; margin-bottom: 4px; }
.cat-counts { font-size: 13px; color: #8b949e; }

/* Item grid (overrides #grid in items view) */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.item-grid .tile {
    text-decoration: none;
    color: inherit;
}

/* Detail view */
.detail { max-width: 1200px; margin: 0 auto; }
.detail-head {
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: center;
    gap: 16px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 18px 24px;
    margin-bottom: 20px;
}
.detail-title { text-align: center; }
.detail-title h2 { margin: 0 0 4px; color: #e6edf3; font-size: 22px; }
.detail-title p { margin: 0; color: #8b949e; font-size: 13px; }
.nav-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 50%;
    text-decoration: none;
    font-size: 32px;
    line-height: 1;
    transition: background .15s, border-color .15s, color .15s;
}
.nav-arrow:hover {
    background: #1f6feb;
    border-color: #1f6feb;
    color: white;
}
.variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}
.variant {
    margin: 0;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}
.variant img {
    max-width: 100%;
    max-height: 220px;
    object-fit: contain;
    image-rendering: pixelated;
    background: repeating-conic-gradient(#1c2128 0% 25%, #222831 0% 50%) 50% / 12px 12px;
    border-radius: 6px;
}
.variant figcaption {
    margin-top: 10px;
    text-align: center;
    font-size: 12px;
    color: #8b949e;
    word-break: break-all;
}
.variant code {
    background: #0d1117;
    color: #79c0ff;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #30363d;
    font-size: 11px;
}

/* Header title row with nav */
.title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.title-row h1 { margin: 0; }
.top-nav {
    display: flex;
    gap: 8px;
}
.nav-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, border-color .15s;
}
.nav-btn:hover {
    background: #30363d;
    border-color: #58a6ff;
}
.nav-btn.primary {
    background: #1f6feb;
    border-color: #1f6feb;
    color: white;
}
.nav-btn.primary:hover {
    background: #388bfd;
    border-color: #388bfd;
}

/* Downloads page */
.downloads {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.download-card {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 10px;
    padding: 24px;
}
.download-card h2 {
    margin: 0 0 12px;
    color: #58a6ff;
    font-size: 20px;
}
.download-card p {
    margin: 0 0 16px;
    color: #c9d1d9;
    line-height: 1.5;
}
.download-card code {
    background: #0d1117;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #30363d;
    font-size: 13px;
    color: #79c0ff;
}
.specs {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 8px;
}
.specs li {
    color: #8b949e;
    font-size: 14px;
}
.specs strong { color: #c9d1d9; font-weight: 500; }
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    background: #238636;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    border: none;
    transition: background .15s;
}
.download-btn:hover { background: #2ea043; }
.download-btn.primary { background: #1f6feb; }
.download-btn.primary:hover { background: #388bfd; }
.dl-icon {
    font-size: 24px;
    line-height: 1;
}
.dl-label {
    display: flex;
    flex-direction: column;
}
.dl-title {
    font-size: 16px;
    font-weight: 600;
}
.dl-size {
    font-size: 12px;
    opacity: 0.85;
}
.download-card.info h2 { color: #79c0ff; }
.download-card.info ol {
    margin: 0;
    padding-left: 24px;
    color: #c9d1d9;
    line-height: 1.7;
}
.download-card.warning {
    border-color: #9e6a03;
}
.download-card.warning h2 { color: #d29922; }
.download-card.warning ul {
    margin: 0;
    padding-left: 24px;
    color: #c9d1d9;
    line-height: 1.7;
}
