:root {
    --primary-color: #82c91e;
    --primary-dark: #5c940d;
    --primary-soft: #f1f8e8;
    --ink: #243024;
    --muted: #687568;
    --line: #dde6d9;
    --surface: #ffffff;
    --surface-soft: #f7f9f5;
    --shadow: 0 16px 44px rgba(36, 48, 36, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% 4%, rgba(130, 201, 30, 0.12), transparent 24rem),
        linear-gradient(180deg, #fbfcfa 0, #f5f8f2 100%);
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.global-nav-bar {
    position: absolute;
    top: 30px;
    left: 0;
    z-index: 999;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
}

.global-nav-bar a {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a8b1a8;
    text-decoration: none;
    font-weight: 650;
    transition: color 0.2s ease;
}

.global-nav-bar a:last-child {
    font-size: 1.35rem;
}

.global-nav-bar a:hover,
.global-nav-bar a:focus-visible {
    color: var(--primary-dark);
}

.app-header {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 92px 0 30px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.title-icon {
    width: 66px;
    height: 66px;
    flex: 0 0 66px;
    display: grid;
    place-items: center;
    border-radius: 20px;
    color: #fff;
    background: linear-gradient(145deg, #94d82d, #66a80f);
    box-shadow: 0 12px 28px rgba(102, 168, 15, 0.23);
    font-size: 1.65rem;
    transform: rotate(-3deg);
}

.eyebrow,
.section-kicker {
    margin: 0 0 5px;
    color: var(--primary-dark);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: clamp(2rem, 4vw, 3.15rem);
    line-height: 1;
    letter-spacing: -0.035em;
}

.subtitle,
.planner-header p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.5;
}

.app-main {
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding-bottom: 64px;
}

.view-switch {
    width: fit-content;
    display: flex;
    gap: 6px;
    margin-bottom: 24px;
    padding: 5px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 8px 24px rgba(36, 48, 36, 0.05);
}

.view-tab {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 11px 17px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-weight: 750;
    cursor: pointer;
}

.view-tab.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
    box-shadow: inset 0 0 0 1px rgba(130, 201, 30, 0.18);
}

.app-view {
    padding: 30px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.91);
    box-shadow: var(--shadow);
}

.library-toolbar,
.planner-header,
.list-heading,
.dialog-heading,
.plan-toolbar,
.sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.library-toolbar h2,
.planner-header h2,
.dialog-heading h2 {
    margin-bottom: 0;
    font-size: clamp(1.55rem, 3vw, 2.1rem);
    letter-spacing: -0.025em;
}

.search-box {
    min-width: 260px;
    height: 46px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: #96a096;
    background: var(--surface-soft);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(130, 201, 30, 0.13);
}

.search-box input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
}

.category-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 28px 0 34px;
}

.category-button {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    text-align: left;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.category-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(36, 48, 36, 0.07);
}

.category-button.active {
    border-color: var(--category-color);
    box-shadow: inset 0 0 0 1px var(--category-color), 0 8px 20px rgba(36, 48, 36, 0.06);
}

.category-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--category-color);
    background: color-mix(in srgb, var(--category-color) 13%, white);
}

.category-name {
    min-width: 0;
    display: block;
    overflow: hidden;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 750;
    text-overflow: ellipsis;
}

.category-count {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.75rem;
}

.list-heading {
    margin-bottom: 13px;
}

.list-heading h3 {
    margin-bottom: 0;
    font-size: 1.2rem;
}

.count-badge,
.small-count {
    padding: 5px 9px;
    border-radius: 999px;
    color: var(--muted);
    background: #eef2eb;
    font-size: 0.77rem;
    font-weight: 750;
}

.game-list {
    display: grid;
    gap: 12px;
}

.game-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-left: 4px solid var(--game-color, var(--primary-color));
    border-radius: 15px;
    background: var(--surface);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.game-card.open {
    box-shadow: 0 12px 30px rgba(36, 48, 36, 0.08);
}

.game-card.dragging {
    opacity: 0.45;
}

.game-card.drop-target {
    border-top: 3px solid var(--primary-color);
}

.game-summary {
    display: flex;
    align-items: stretch;
}

.game-toggle {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 17px 18px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.game-order {
    min-width: 31px;
    height: 31px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    font-size: 0.78rem;
    font-weight: 850;
}

.game-title-wrap {
    min-width: 0;
    flex: 1;
}

.game-title {
    display: block;
    overflow: hidden;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.game-meta {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 0.78rem;
}

.chevron {
    color: #a0aaa0;
    transition: transform 0.2s ease;
}

.game-card.open .chevron {
    transform: rotate(180deg);
}

.summary-actions {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-right: 11px;
}

.add-game-button,
.icon-button,
.move-button,
.tree-action {
    display: inline-grid;
    place-items: center;
    border: 0;
    cursor: pointer;
}

.add-game-button {
    min-width: 42px;
    height: 36px;
    padding: 0 11px;
    border-radius: 10px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    font-size: 0.82rem;
    font-weight: 750;
}

.add-game-button:hover {
    background: #e4f2d3;
}

.game-details {
    display: none;
    padding: 3px 20px 22px;
    border-top: 1px solid #edf1eb;
}

.game-card.open .game-details {
    display: block;
}

.detail-block {
    padding-top: 17px;
}

.detail-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: var(--primary-dark);
    font-size: 0.74rem;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.detail-value {
    margin-bottom: 0;
    color: #3f4a3f;
    line-height: 1.62;
}

.variants {
    margin: 0;
    padding-left: 20px;
    color: #3f4a3f;
    line-height: 1.55;
}

.variants li + li {
    margin-top: 6px;
}

.empty-state {
    padding: 50px 20px;
    border: 1px dashed #ccd6c8;
    border-radius: 15px;
    color: var(--muted);
    background: var(--surface-soft);
    text-align: center;
}

.empty-state i {
    display: block;
    margin-bottom: 12px;
    color: #acb9a7;
    font-size: 1.8rem;
}

.empty-state strong {
    display: block;
    margin-bottom: 5px;
    color: var(--ink);
}

.planner-header {
    align-items: flex-end;
    margin-bottom: 26px;
}

.planner-header p {
    max-width: 620px;
}

.header-actions,
.dialog-actions,
.plan-actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-weight: 750;
    cursor: pointer;
}

.button-primary {
    color: #fff;
    background: var(--primary-dark);
}

.button-primary:hover {
    background: #4c7f09;
}

.button-secondary {
    border-color: var(--line);
    background: #fff;
}

.button-secondary:hover,
.button-quiet:hover {
    background: var(--surface-soft);
}

.button-quiet {
    color: var(--muted);
    background: transparent;
}

.button-danger {
    color: #c92a2a;
    background: #fff5f5;
}

.planner-layout {
    min-height: 500px;
    display: grid;
    grid-template-columns: 270px minmax(0, 1fr);
    gap: 18px;
}

.plan-sidebar,
.plan-workspace {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-soft);
}

.plan-sidebar {
    overflow: hidden;
}

.sidebar-heading {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    font-size: 0.84rem;
    font-weight: 800;
}

.folder-tree {
    padding: 9px;
}

.folder-block + .folder-block {
    margin-top: 8px;
}

.folder-row {
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 4px 7px 4px 10px;
    border-radius: 10px;
    color: #4f5a4f;
}

.folder-row:hover {
    background: #edf2ea;
}

.folder-label {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.85rem;
    font-weight: 800;
}

.folder-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-actions {
    display: flex;
    opacity: 0;
    transition: opacity 0.2s;
}

.folder-row:hover .tree-actions,
.folder-row:focus-within .tree-actions {
    opacity: 1;
}

.tree-action {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    color: #7b867b;
    background: transparent;
}

.tree-action:hover {
    color: var(--ink);
    background: #e0e8dc;
}

.plan-links {
    display: grid;
    gap: 3px;
    margin: 2px 0 0 20px;
}

.plan-link {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    border: 0;
    border-radius: 9px;
    color: var(--muted);
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.plan-link span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.plan-link:hover {
    background: #edf2ea;
}

.plan-link.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
    font-weight: 750;
}

.plan-workspace {
    padding: 22px;
    background: #fff;
}

.plan-workspace > .empty-state {
    min-height: 100%;
    display: grid;
    place-content: center;
}

.plan-toolbar {
    align-items: flex-start;
    margin-bottom: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.plan-toolbar h3 {
    margin-bottom: 4px;
    font-size: 1.45rem;
}

.plan-folder-name,
.reorder-hint {
    margin-bottom: 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.plan-actions .icon-button,
.dialog-heading .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: #748074;
    background: #f1f4ef;
}

.plan-actions .icon-button:hover,
.dialog-heading .icon-button:hover {
    color: var(--ink);
    background: #e7ece4;
}

.plan-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 12px;
}

.reorder-hint i {
    margin-right: 5px;
}

.move-controls {
    display: flex;
    gap: 4px;
    padding-right: 5px;
}

.move-button {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: #758075;
    background: transparent;
}

.move-button:hover:not(:disabled) {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.move-button:disabled {
    opacity: 0.28;
    cursor: default;
}

.drag-handle {
    color: #b0b8ad;
    cursor: grab;
}

.app-dialog {
    width: min(460px, calc(100% - 32px));
    padding: 24px;
    border: 0;
    border-radius: 18px;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 24px 80px rgba(26, 38, 24, 0.28);
}

.app-dialog::backdrop {
    background: rgba(28, 38, 27, 0.48);
    backdrop-filter: blur(3px);
}

.app-dialog form {
    display: grid;
    gap: 20px;
}

.dialog-heading {
    align-items: flex-start;
}

.form-field {
    display: grid;
    gap: 7px;
    color: #556055;
    font-size: 0.84rem;
    font-weight: 750;
}

.form-field input,
.form-field select {
    width: 100%;
    height: 45px;
    padding: 0 12px;
    border: 1px solid #ccd6c8;
    border-radius: 10px;
    outline: 0;
    color: var(--ink);
    background: #fff;
}

.form-field input:focus,
.form-field select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(130, 201, 30, 0.13);
}

.dialog-message {
    padding: 12px;
    border-radius: 10px;
    color: #8a3f10;
    background: #fff4e6;
    line-height: 1.45;
}

.dialog-actions {
    justify-content: flex-end;
}

.picker-dialog {
    width: min(610px, calc(100% - 32px));
}

.picker-search {
    width: 100%;
    margin: 20px 0 14px;
}

.picker-list {
    max-height: min(480px, 58vh);
    display: grid;
    gap: 7px;
    overflow-y: auto;
    padding-right: 4px;
}

.picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: #fff;
}

.picker-item .category-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
}

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

.picker-item-info strong,
.picker-item-info span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-item-info span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.75rem;
}

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1200;
    max-width: min(360px, calc(100% - 44px));
    padding: 12px 16px;
    border-radius: 11px;
    color: #fff;
    background: #293329;
    box-shadow: 0 10px 30px rgba(20, 30, 20, 0.24);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(130, 201, 30, 0.35);
    outline-offset: 2px;
}

@media (max-width: 900px) {
    .category-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .planner-layout {
        grid-template-columns: 230px minmax(0, 1fr);
    }

    .planner-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 720px) {
    .global-nav-bar {
        padding: 0 15px;
    }

    .global-nav-bar .nav-text {
        display: none;
    }

    .global-nav-bar a:first-child {
        font-size: 1.2rem;
    }

    .app-header,
    .app-main {
        width: min(100% - 24px, 1120px);
    }

    .app-header {
        padding-top: 82px;
    }

    .title-icon {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
        border-radius: 16px;
        font-size: 1.3rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .app-view {
        padding: 18px;
        border-radius: 18px;
    }

    .library-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .search-box {
        min-width: 0;
        width: 100%;
    }

    .planner-layout {
        grid-template-columns: 1fr;
    }

    .plan-sidebar {
        max-height: 330px;
        overflow-y: auto;
    }

    .tree-actions {
        opacity: 1;
    }

    .planner-header .header-actions {
        width: 100%;
    }

    .planner-header .header-actions .button {
        flex: 1;
    }

    .plan-toolbar {
        flex-direction: column;
    }

    .plan-actions {
        align-self: flex-end;
    }
}

@media (max-width: 520px) {
    .view-switch {
        width: 100%;
    }

    .view-tab {
        flex: 1;
        justify-content: center;
        padding-inline: 10px;
        font-size: 0.88rem;
    }

    .category-filters {
        grid-template-columns: 1fr 1fr;
        gap: 7px;
    }

    .category-button {
        gap: 8px;
        padding: 10px;
    }

    .category-icon {
        width: 32px;
        height: 32px;
        flex-basis: 32px;
    }

    .category-name {
        font-size: 0.8rem;
    }

    .game-toggle {
        padding: 14px 12px;
    }

    .game-meta,
    .add-game-button span,
    .reorder-hint {
        display: none;
    }

    .game-details {
        padding-inline: 15px;
    }

    .header-actions {
        flex-direction: column;
    }

    .planner-header .header-actions .button {
        width: 100%;
    }

    .plan-workspace {
        padding: 15px;
    }
}
