:root {
    --primary: #c5a059;
    --primary-light: #f7ebd3;
    --primary-dark: #8c6a2c;
    --text-main: #2d3748;
    --text-muted: #718096;
    --bg-main: #f7fafc;
    --bg-soft: #f7fafc;
    --white: #ffffff;
    --border: rgba(0, 0, 0, 0.08);
    --good-bg: #e6fffa;
    --good-text: #047481;
    --good-border: #b2f5ea;
    --bad-bg: #fff5f5;
    --bad-text: #c53030;
    --bad-border: #fed7d7;
    --special-bg: #ebf8ff;
    --special-text: #2b6cb0;
    --special-border: #bee3f8;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 15px 35px rgba(140, 106, 44, 0.1);
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --transition: all 0.25s ease;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 10px;
    background: var(--bg-main);
    color: var(--text-main);
    font-family: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background: var(--white);
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

h1,
h2,
h3,
p {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0 0 12px;
    color: #7d5a15;
    font-size: clamp(22px, 5vw, 34px);
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: 0;
}

h1 i {
    margin-right: 8px;
    color: #7d5a15;
}

h2 {
    margin: 36px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
    color: var(--text-main);
    font-size: clamp(18px, 4vw, 23px);
    font-weight: 800;
    line-height: 1.45;
}

h2 i {
    margin-right: 8px;
}

h3 {
    margin: 22px 0 10px;
    color: var(--primary-dark);
    font-size: 17px;
    font-weight: 800;
    line-height: 1.45;
}

p {
    margin: 0 0 14px;
}

a {
    color: inherit;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 22px;
    font-size: 14px;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    text-align: left;
    vertical-align: top;
}

th {
    background: var(--bg-soft);
    color: var(--text-muted);
    font-weight: 700;
}

code {
    padding: 2px 5px;
    border-radius: 5px;
    background: #edf2f7;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
}

ul {
    margin: 8px 0 0;
    padding-left: 1.2em;
}

li {
    margin: 4px 0;
}

.lead,
.subtitle,
.note,
.footer-note,
.small {
    color: var(--text-muted);
}

.lead {
    font-size: 15px;
}

.note,
.base-score,
.breakdown-box {
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: var(--radius-md);
    background: var(--bg-soft);
}

.note {
    padding: 14px 16px;
    font-size: 14px;
}

.small,
.footer-note {
    font-size: 13px;
}

.footer-note {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.back-link,
.btn-link,
.btn-submit,
.btn-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--white);
    color: var(--text-main);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    white-space: normal;
}

.back-link {
    margin-bottom: 20px;
}

.back-link:hover,
.btn-link:hover,
.btn-reset:hover {
    color: var(--primary-dark);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-submit {
    border-color: transparent;
    background: var(--primary-dark);
    color: var(--white);
    cursor: pointer;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.header-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 30px;
    text-align: center;
}

.header-top-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    width: 100%;
    margin-bottom: 20px;
}

.subtitle {
    font-size: 15px;
    font-weight: 500;
}

.nav-tabs,
.mode-tabs,
.cat-nav {
    display: grid;
    gap: 8px;
    margin-bottom: 24px;
}

.nav-tabs {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
}

.mode-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cat-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.nav-tabs a,
.mode-tabs a,
.cat-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--text-main);
    font-size: clamp(12px, 3.2vw, 14px);
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow-wrap: anywhere;
}

.nav-tabs a:hover,
.mode-tabs a:hover,
.cat-nav a:hover {
    border-color: var(--primary-light);
    background: var(--bg-soft);
    transform: translateY(-2px);
}

.nav-tabs a.active,
.mode-tabs a.active,
.cat-nav a.active {
    border-color: transparent;
    background: var(--primary-dark);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.filter-card,
.rule-card,
.item-card,
.card,
.ranking-card {
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.filter-card,
.rule-card,
.item-card,
.card {
    padding: 18px;
    margin-bottom: 16px;
}

.filter-card {
    margin-bottom: 28px;
}

.filter-form-grid,
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-group {
    min-width: 160px;
    flex: 1;
}

.filter-period {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: min(100%, 430px);
}

.filter-period select {
    width: auto;
    min-width: 88px;
    flex: 0 0 auto;
}

.filter-group label,
.influence-label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--text-main);
    font-size: 14px;
}

.filter-period select {
    width: auto;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    margin: 3px;
    padding: 5px 10px;
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 30px;
    background: var(--white);
    font-size: 13px;
    cursor: pointer;
}

.checkbox-label:hover {
    background: var(--bg-soft);
}

.responsive-table {
    overflow-x: auto;
    border-radius: var(--radius-md);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 22px 0 16px;
}

.calendar-nav h2 {
    margin: 0;
    border: 0;
    padding: 0;
    text-align: center;
}

.calendar-nav a {
    padding: 8px 13px;
    border-radius: 30px;
    background: var(--white);
    color: var(--primary-dark);
    font-weight: 800;
    text-decoration: none;
    box-shadow: var(--shadow-sm);
}

.calendar-table {
    min-width: 700px;
    table-layout: fixed;
}

.calendar-table th {
    text-align: center;
}

.calendar-table td {
    width: 14.28%;
    height: 118px;
    padding: 8px;
    position: relative;
    background: var(--white);
    transition: var(--transition);
}

.calendar-table td.empty {
    background: #fafafa;
}

.calendar-table td:hover:not(.empty) {
    background: #fffaf0;
}

.day-num {
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 800;
}

.holiday-badge {
    display: block;
    margin-top: 2px;
    color: #c53030;
    font-size: 10px;
    font-weight: 700;
}

.day-score {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 800;
}

.score-high {
    background: #fff5d6;
}

.score-premium {
    background: var(--primary-dark);
    color: var(--white);
}

.premium-cell {
    box-shadow: inset 0 0 0 2px rgba(197, 160, 89, 0.35);
}

.sunday-holiday .day-num,
.sunday-holiday {
    color: #c53030;
}

.saturday .day-num,
.saturday {
    color: #2b6cb0;
}

.day-content {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.tag,
.breakdown-item,
.influence-badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.tag,
.breakdown-item {
    margin: 2px;
    padding: 3px 8px;
}

.tag-good,
.badge-good {
    border: 1px solid var(--good-border);
    background: var(--good-bg);
    color: var(--good-text);
}

.tag-bad,
.badge-bad {
    border: 1px solid var(--bad-border);
    background: var(--bad-bg);
    color: var(--bad-text);
}

.tag-special {
    border: 1px solid var(--special-border);
    background: var(--special-bg);
    color: var(--special-text);
}

.list-table {
    min-width: 760px;
}

.breakdown-box {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding: 10px;
}

.ranking-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
    padding: 18px;
    transition: var(--transition);
}

.ranking-card:hover,
.item-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.rank-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rank-num {
    width: 42px;
    color: var(--primary-dark);
    font-size: 30px;
    font-weight: 900;
    line-height: 1;
}

.rank-info {
    flex: 1;
}

.rank-info strong {
    display: block;
    margin-bottom: 6px;
    font-size: 17px;
}

.rank-score {
    color: var(--primary-dark);
    font-size: 24px;
    font-weight: 900;
}

.base-score {
    margin-bottom: 25px;
    padding: 20px;
    text-align: center;
    font-weight: 700;
}

.base-score span {
    color: var(--primary-dark);
    font-size: 28px;
    font-weight: 900;
}

.rule-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-size: 16px;
    font-weight: 900;
}

.score-plus {
    color: var(--good-text);
    font-weight: 900;
}

.score-minus {
    color: var(--bad-text);
    font-weight: 900;
}

.score-special {
    color: var(--special-text);
    font-weight: 900;
}

.item-card dt {
    margin-bottom: 6px;
    color: var(--primary-dark);
    font-size: 16px;
    font-weight: 900;
}

.item-card dd {
    margin: 0;
    font-size: 15px;
}

.influence-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
}

.influence-badge {
    padding: 3px 10px;
    cursor: default;
}

.mode-tabs-wrap {
    text-align: center;
}

.icon-primary {
    color: var(--primary);
}

.icon-primary-dark {
    color: var(--primary-dark);
}

.icon-good {
    color: var(--good-text);
}

.icon-bad {
    color: var(--bad-text);
}

.icon-special {
    color: var(--special-text);
}

.page-lead {
    margin-bottom: 25px;
    color: var(--text-muted);
    font-size: 15px;
}

.section-lead {
    margin-bottom: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.filter-label {
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 800;
}

.filter-label-good {
    color: var(--good-text);
}

.filter-label-bad {
    color: var(--bad-text);
}

.checkbox-wrap,
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.section-title,
.logic-title {
    margin-bottom: 15px;
    font-size: clamp(16px, 3.8vw, 18px);
    font-weight: 800;
}

.th-sunday {
    color: #e53e3e;
}

.th-saturday {
    color: #3182ce;
}

.text-right,
.score-cell,
.total-th {
    text-align: right;
}

.score-cell {
    color: var(--primary-dark);
    font-weight: 900;
}

.muted-empty {
    color: #a0aec0;
    font-size: 13px;
}

.table-scroll {
    overflow-x: auto;
}

.rank-th {
    width: 60px;
    text-align: center;
}

.date-th {
    width: 140px;
}

.total-th {
    width: 100px;
}

.rank-highlight {
    background: #fffdf4;
}

.rank-highlight-card {
    border: 2px solid var(--primary);
    background: #fffdf6;
}

.rank-cell {
    color: var(--primary-dark);
    font-size: 20px;
    font-weight: 900;
    text-align: center;
}

.crown-icon {
    color: #d4af37;
}

.rank-tag-list {
    margin: 5px 0;
}

.breakdown-label {
    margin-bottom: 4px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
}

.footer-copy {
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    text-align: center;
}

.base-score-note {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 400;
}

.rule-title-good {
    color: var(--good-text);
}

.rule-title-bad {
    color: var(--bad-text);
}

.rule-title-special {
    color: var(--special-text);
}

.item-th {
    width: 150px;
}

.score-th {
    width: 80px;
}

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

.card.good {
    background: var(--good-bg);
}

.card.bad {
    background: var(--bad-bg);
}

.pc-only {
    display: none !important;
}

@media (min-width: 768px) {
    body {
        padding: 20px;
    }

    .container {
        padding: 30px;
    }

    .filter-form-grid,
    .grid.two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cat-nav {
        grid-template-columns: repeat(9, minmax(0, 1fr));
    }

    .ranking-card {
        flex-direction: row;
        align-items: center;
        padding: 22px;
    }

    .rank-top {
        width: 120px;
        flex-shrink: 0;
    }

    .rank-score {
        width: 110px;
        text-align: right;
    }

    .rank-info {
        padding: 0 20px;
        border-right: 1px solid rgba(0, 0, 0, 0.08);
        border-left: 1px solid rgba(0, 0, 0, 0.08);
    }

    .pc-only {
        display: block !important;
    }

    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 767px) {
    body {
        padding: 10px;
    }

    .container {
        margin: 10px auto;
        padding: 16px;
        border-radius: 18px;
    }

    .header-top-buttons {
        justify-content: stretch;
    }

    .header-top-buttons .btn-link {
        flex: 1 1 150px;
    }

    .nav-tabs,
    .mode-tabs,
    .cat-nav {
        gap: 6px;
    }

    .responsive-table {
        overflow: visible;
        box-shadow: none;
        background: transparent;
    }

    .calendar-table,
    .calendar-table thead,
    .calendar-table tbody,
    .calendar-table th,
    .calendar-table td,
    .calendar-table tr {
        display: block;
        width: 100% !important;
    }

    .calendar-table {
        min-width: 0;
    }

    .calendar-table thead {
        display: none;
    }

    .calendar-table td {
        height: auto !important;
        min-height: 72px;
        margin-bottom: 12px;
        padding: 16px 16px 16px 76px;
        border: 1px solid rgba(0, 0, 0, 0.05);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }

    .calendar-table td.empty {
        display: none;
    }

    .day-num {
        position: absolute;
        top: 16px;
        left: 16px;
        width: 42px;
        color: var(--primary-dark);
        font-size: 26px;
        line-height: 1;
        text-align: center;
    }

    .day-num::after {
        content: attr(data-weekday);
        display: block;
        margin-top: 5px;
        color: var(--text-muted);
        font-size: 12px;
    }

    .day-score {
        top: 16px;
        right: 16px;
        font-size: 13px;
    }

    .day-content {
        margin-top: 0;
    }

    .list-table,
    .list-table thead,
    .list-table tbody,
    .list-table tr,
    .list-table th,
    .list-table td,
    .rule-card table,
    .rule-card thead,
    .rule-card tbody,
    .rule-card tr,
    .rule-card th,
    .rule-card td {
        display: block;
        width: 100% !important;
    }

    .list-table thead,
    .rule-card thead {
        display: none;
    }

    .list-table tr,
    .rule-card tr {
        padding: 12px 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    .list-table td,
    .rule-card td {
        padding: 6px 0;
        border-bottom: none;
    }

    .rule-card table:not(.special-rules-table) td:nth-child(1) {
        font-weight: 900;
    }

    .rule-card table:not(.special-rules-table) td:nth-child(2) {
        font-weight: 800;
    }

    .rule-card table:not(.special-rules-table) td:nth-child(3),
    .special-rules-table td:nth-child(3) {
        margin-top: 6px;
        padding: 8px 10px;
        border: 1px solid rgba(0, 0, 0, 0.04);
        border-radius: var(--radius-sm);
        background: var(--bg-soft);
    }
}
