:root {
    --bg: #0f1320;
    --panel: #1a2032;
    --panel-2: #222a40;
    --ink: #e8ecf5;
    --muted: #9aa3bd;
    --accent: #6ea8ff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

.app-header {
    padding: 16px 20px;
    background: var(--bg);
    /* Match main's centered container so header content lines up with the panels. */
    max-width: 1100px;
    margin: 0 auto;
}

.app-header h1 { margin: 0 0 8px; font-size: 18px; }
.site-logo { margin: 0 0 10px; text-align: center; }
.site-logo img { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; }

.snapshot-picker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.snapshot-picker select { background: var(--panel-2); color: var(--ink); border: 1px solid #33405e; border-radius: 6px; padding: 6px 8px; }
.meta { color: var(--muted); font-size: 12px; }

main { padding: 16px 20px; max-width: 1100px; margin: 0 auto; display: grid; gap: 18px; }
.panel { background: var(--panel); border-radius: 10px; padding: 14px 16px; }
.panel h2 { margin: 0 0 10px; font-size: 15px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.rankings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px) {
    .rankings-row { grid-template-columns: 1fr; }
}

.card-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.char-card { background: var(--panel-2); border-radius: 8px; padding: 6px; text-align: center; cursor: pointer; border: 1px solid transparent; }
.char-card:hover { border-color: var(--accent); }
.char-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.char-card img { width: 100%; max-width: 110px; aspect-ratio: 78 / 142; object-fit: cover; object-position: top center; border-radius: 6px; background: #111; }
.char-card .name { font-size: 12px; margin-top: 4px; min-height: 26px; }
.char-card .count { font-size: 12px; color: var(--accent); }

/* Top-3 podium: always one row of three (2nd, 1st, 3rd) so the winner is centered. */
.podium { list-style: none; margin: 14px 0 28px; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.podium-card { position: relative; isolation: isolate; background: linear-gradient(155deg, #29344e, var(--panel-2)); border-radius: 10px 10px 5px 5px; padding: 10px 8px 8px; text-align: center; border: 2px solid transparent; box-shadow: 0 8px 14px rgba(0, 0, 0, .3); }
.podium-card::before { content: ""; position: absolute; inset: 4px; border: 1px solid rgba(255, 255, 255, .12); border-radius: 6px 6px 3px 3px; pointer-events: none; }
.podium-card::after { content: ""; position: absolute; z-index: -1; left: 9%; right: 9%; bottom: -14px; height: 16px; border-radius: 0 0 5px 5px; background: #66728b; box-shadow: 0 4px 7px rgba(0, 0, 0, .35); }
.podium-card img { position: relative; z-index: 1; width: 100%; max-width: 120px; aspect-ratio: 78 / 142; object-fit: cover; object-position: top center; border-radius: 8px; background: #111; box-shadow: 0 3px 8px rgba(0, 0, 0, .45); }
.podium-card .name { font-size: 13px; margin-top: 6px; min-height: 28px; font-weight: 600; }
.podium-card .count { font-size: 12px; color: var(--muted); }
.podium-card .rank-badge { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #1a1206; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); z-index: 1; }

/* 2nd — silver, slightly below the winner. */
.podium-card.rank-2 { border-color: #b8c0d0; transform: translateY(10px); }
.podium-card.rank-2::after { background: linear-gradient(#cdd5e3, #808ca3); }
.podium-card.rank-2 .rank-badge { background: linear-gradient(160deg, #f7f9fc, #9aa6bd); }

/* 3rd — bronze, the lowest step. */
.podium-card.rank-3 { border-color: #c98a5a; transform: translateY(16px); }
.podium-card.rank-3::after { background: linear-gradient(#d99a69, #8c512f); }
.podium-card.rank-3 .rank-badge { background: linear-gradient(160deg, #f0bb8c, #b06a3c); }

/* 1st — gold, largest, raised in the center with the tallest pedestal. */
.podium-card.rank-1 { z-index: 1; border-color: #f2c14e; background: linear-gradient(155deg, #4e4322, #292d35); box-shadow: 0 0 22px rgba(242, 193, 78, .45), 0 12px 18px rgba(0, 0, 0, .35); padding-top: 16px; transform: translateY(-10px); }
.podium-card.rank-1::before { border-color: rgba(255, 224, 138, .4); }
.podium-card.rank-1::after { left: 5%; right: 5%; bottom: -20px; height: 22px; background: linear-gradient(#ffe08a, #bd8420); }
.podium-card.rank-1 img { max-width: 150px; }
.podium-card.rank-1 .name { font-size: 15px; }
.podium-card.rank-1 .count { color: #f2c14e; font-weight: 700; }
.podium-card.rank-1 .rank-badge { width: 34px; height: 34px; font-size: 18px; background: linear-gradient(160deg, #ffe08a, #e0a52e); }

.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bar-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bar { height: 14px; background: var(--accent); border-radius: 4px; flex-shrink: 0; width: calc(var(--ratio, 0) * 180px); min-width: 6px; }
.job-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.job-stat { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }

.filter-bar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.filter-group { display: inline-flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.filter-bar select { background: var(--panel-2); color: var(--ink); border: 1px solid #33405e; border-radius: 6px; padding: 5px 8px; font-size: 13px; max-width: 190px; text-overflow: ellipsis; }
.filter-label { color: var(--muted); font-size: 12px; white-space: nowrap; }

.formation-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.formation-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.formation { }
.scene { position: relative; width: 100%; aspect-ratio: 680 / 600; background-color: #111; background-size: cover; background-position: top center; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.scene .count { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .65); color: var(--accent); font-weight: 700; padding: 2px 10px; border-radius: 12px; font-size: 14px; }
.scene .job-tag { position: absolute; top: 8px; left: 8px; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 70px); background: rgba(0, 0, 0, .6); border-radius: 8px; padding: 3px 9px 3px 3px; }
.scene .job-tag .job-badge { width: 30px; height: 30px; object-fit: contain; flex: 0 0 auto; }
.scene .job-tag .job-name { color: #fff; font-weight: 700; font-size: 13px; text-shadow: 0 1px 2px rgba(0, 0, 0, .8); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene .job-tag.is-clickable { cursor: pointer; user-select: none; transition: background .15s ease, transform .1s ease; }
.scene .job-tag.is-clickable:hover { background: rgba(30, 48, 85, .85); }
.scene .job-tag.is-clickable:active { transform: scale(0.96); }
.scene .job-tag .job-switch-icon { font-size: 12px; margin-left: 2px; color: var(--accent); opacity: .8; flex-shrink: 0; }
.scene .job-tag.is-clickable:hover .job-switch-icon { opacity: 1; }
.scene .kit { position: absolute; top: 48px; right: 28px; display: flex; gap: 6px; }
.scene .unit { width: 60px; height: 118px; object-fit: cover; object-position: top center; border-radius: 5px; border: 2px solid #d9c27a; background: #111; box-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.scene .members { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 0; padding: 8px 6px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
.scene .members .char { flex: 0 1 60px; min-width: 0; aspect-ratio: 78 / 142; object-fit: cover; object-position: top center; border-radius: 5px; border: 2px solid #d9c27a; background: #111; box-shadow: 0 1px 4px rgba(0, 0, 0, .6); }

.formation-more-wrap { display: flex; justify-content: flex-end; margin-top: 14px; }
.more-btn { background: var(--panel-2); color: var(--accent); border: 1px solid #33405e; border-radius: 6px; padding: 8px 24px; font-size: 13px; font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s; }
.more-btn:hover { background: #253352; border-color: var(--accent); }

.app-footer { color: var(--muted); font-size: 11px; text-align: center; padding: 20px; }
.app-footer .author { color: var(--accent); font-weight: 700; letter-spacing: .04em; text-decoration: none; }
.app-footer .author:hover { text-decoration: underline; }
.app-footer .with { font-size: 10px; opacity: .7; margin-left: 4px; }

@media (max-width: 600px) {
    main { padding: 12px; gap: 12px; }
    .app-header { padding: 12px; }
    .panel { padding: 12px; }
    /* Smaller MVP character cards so more fit per row on narrow phones. */
    .card-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
    .char-card img { max-width: 86px; }
    .char-card .name { font-size: 11px; min-height: 22px; }
    .char-card .count { font-size: 11px; }
    /* Keep the top-3 on a single row even on narrow phones, just tighter. */
    .podium { gap: 6px; margin: 12px 0 24px; }
    .podium-card { padding: 8px 4px 6px; }
    .podium-card::after { left: 7%; right: 7%; bottom: -10px; height: 12px; }
    .podium-card .name { font-size: 11px; min-height: 24px; }
    .podium-card .rank-badge { width: 24px; height: 24px; font-size: 13px; top: -10px; }
    .podium-card.rank-2 { transform: translateY(7px); }
    .podium-card.rank-3 { transform: translateY(11px); }
    .podium-card.rank-1 { padding-top: 12px; }
    .podium-card.rank-1 { transform: translateY(-7px); }
    .podium-card.rank-1::after { bottom: -14px; height: 16px; }
    .podium-card.rank-1 .name { font-size: 13px; }
    .podium-card.rank-1 .rank-badge { width: 30px; height: 30px; font-size: 16px; }
    .bar { width: calc(var(--ratio, 0) * 80px); }
    .bar-list li { font-size: 12px; gap: 6px; }
    .job-stat { font-size: 11px; }
}

/* The TOP character cards are display-only; the dialog cards are the interactive ones. */
#characters .char-card { cursor: default; }
#characters .char-card:hover { border-color: transparent; }

#owned-open { background: var(--accent); color: #06122b; border: none; border-radius: 6px; padding: 5px 14px; font-weight: 700; cursor: pointer; }

.owned-dialog { width: min(920px, 92vw); height: 85vh; padding: 0; border: 1px solid #33405e; border-radius: 12px; background: var(--panel); color: var(--ink); overflow: hidden; }
/* Only flex when open; leaving display set while closed would override the UA's display:none and keep the dialog visible. */
.owned-dialog[open] { display: flex; flex-direction: column; }
.owned-dialog::backdrop { background: rgba(0, 0, 0, .6); }
.owned-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; background: var(--panel); border-bottom: 1px solid #2a3550; }
.owned-head strong { font-size: 15px; }
.owned-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.owned-dialog button { background: var(--panel-2); color: var(--ink); border: 1px solid #33405e; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.owned-note { margin: 0; padding: 10px 16px 0; color: var(--muted); font-size: 12px; }
.owned-search { display: block; margin: 8px 16px 0; padding: 8px 10px; width: calc(100% - 32px); background: var(--panel-2); color: var(--ink); border: 1px solid #33405e; border-radius: 6px; font-size: 14px; }
.owned-grid { flex: 1 1 auto; min-height: 0; padding: 14px 16px; overflow: auto; align-content: start; }
.owned-toggle { position: relative; user-select: none; }
.owned-toggle.off { opacity: .35; filter: grayscale(1); }
.owned-toggle.off::after { content: "OFF"; position: absolute; top: 6px; right: 6px; font-size: 10px; font-weight: 700; color: #ff9a9a; background: rgba(0, 0, 0, .7); border-radius: 4px; padding: 1px 5px; }

.empty-notice { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; grid-column: 1 / -1; list-style: none; }

/* Hamburger menu button */
.menu-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 100;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(34, 42, 64, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid #33405e;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}
.menu-btn:hover {
    background: var(--panel-2);
    color: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}
.menu-btn svg {
    width: 22px;
    height: 22px;
}

/* Drawer backdrop */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.drawer-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer menu */
.drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 201;
    width: 280px;
    max-width: 80vw;
    background: var(--panel);
    border-right: 1px solid #2a3550;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer.active {
    transform: translateX(0);
}

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #2a3550;
}
.drawer-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}
.drawer-close {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}
.drawer-close:hover {
    color: var(--ink);
    background: var(--panel-2);
}
.drawer-close svg {
    width: 20px;
    height: 20px;
}

.drawer-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
}
.drawer-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.drawer-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}
.drawer-link:hover, .drawer-link.active {
    background: var(--panel-2);
    color: var(--accent);
}
.drawer-link svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.drawer-footer {
    padding: 16px 20px;
    border-top: 1px solid #2a3550;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* About page specific styles */
.about-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    max-width: 840px;
    margin: 0 auto;
}
.about-header .site-logo {
    margin: 0;
}
.about-header .site-logo img {
    max-width: 260px;
}
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--panel-2);
    border: 1px solid #33405e;
    transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.back-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.back-link svg {
    width: 16px;
    height: 16px;
}

.about-main {
    max-width: 840px;
    margin: 0 auto;
    padding: 0 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.about-hero {
    text-align: center;
    margin-bottom: 10px;
}
.about-hero h1 {
    font-size: 24px;
    margin: 12px 0 6px;
    color: var(--ink);
}
.about-hero .lead {
    color: var(--muted);
    font-size: 14px;
    margin: 0;
}

.about-section {
    background: var(--panel);
    border-radius: 10px;
    padding: 20px 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.about-section h2 {
    font-size: 17px;
    margin: 0 0 14px;
    color: var(--accent);
    border-bottom: 1px solid #2a3550;
    padding-bottom: 8px;
}
.about-section p {
    font-size: 14px;
    line-height: 1.8;
    margin: 0 0 12px;
    color: var(--ink);
}
.about-section p:last-child {
    margin-bottom: 0;
}
.about-section ul {
    margin: 0;
    padding-left: 20px;
    font-size: 14px;
    line-height: 1.8;
    color: var(--ink);
}
.about-section li {
    margin-bottom: 8px;
}
.about-section li:last-child {
    margin-bottom: 0;
}
.about-section a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}
.about-section a:hover {
    text-decoration: underline;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.history-item {
    border-left: 2px solid var(--accent);
    padding-left: 14px;
}
.history-date {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    margin-bottom: 4px;
}
.history-desc {
    font-size: 13px;
    line-height: 1.6;
    position: relative;
    padding-left: 1.1em;
}
.history-desc::before {
    content: "・";
    position: absolute;
    left: 0;
    color: var(--muted);
}

/* Stream mode: mosaic blur for specified characters */
img.stream-mosaic {
    filter: blur(8px);
}

/* Milder blur for smaller portraits in formation members to avoid transparency */
.scene .members .char.stream-mosaic {
    filter: blur(4px);
    transform: scale(1.04);
}

.stream-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 600;
}


