:root {
    --bg: #f4ecf0;
    --bg-soft: rgba(255, 255, 255, 0.75);
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --surface-tint: #faeef2;
    --border: rgba(103, 16, 40, 0.12);
    --text: #2d1120;
    --text-soft: #684554;
    --accent: #a50f3d;
    --accent-strong: #7f092f;
    --accent-2: #d61b55;
    --gold: #ffca38;
    --gold-deep: #f3ab11;
    --green: #3caa5c;
    --danger: #d96a83;
    --shadow: 0 24px 60px rgba(86, 16, 37, 0.15);
    --shadow-soft: 0 10px 24px rgba(86, 16, 37, 0.1);
    --radius-xl: 30px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

body.theme-dark {
    --bg: #140810;
    --bg-soft: rgba(28, 12, 21, 0.74);
    --surface: rgba(31, 13, 24, 0.92);
    --surface-strong: #2c1020;
    --surface-tint: #40142c;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f8dce7;
    --text-soft: #d7adbd;
    --accent: #c51f57;
    --accent-strong: #e72f6f;
    --accent-2: #81153a;
    --gold: #ffcd42;
    --gold-deep: #ebaa18;
    --green: #56c97a;
    --danger: #f08aa3;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
    --shadow-soft: 0 10px 28px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Barlow", sans-serif;
    background: radial-gradient(circle at top, rgba(255, 205, 66, 0.18), transparent 32%),
        linear-gradient(180deg, rgba(184, 22, 73, 0.12), transparent 28%),
        var(--bg);
    color: var(--text);
}

body.modal-open {
    overflow: hidden;
}

img {
    max-width: 100%;
    display: block;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.page-background {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 10% 15%, rgba(255, 204, 56, 0.22), transparent 22%),
        radial-gradient(circle at 85% 12%, rgba(165, 15, 61, 0.18), transparent 18%),
        radial-gradient(circle at 50% 85%, rgba(214, 27, 85, 0.12), transparent 22%);
    opacity: 0.9;
}

.layout-shell {
    position: relative;
    z-index: 1;
    width: min(1280px, calc(100% - 28px));
    margin: 20px auto 40px;
}

.topbar {
    position: relative;
    z-index: 30;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--accent) 0%, #c41d53 58%, #f04c82 100%);
    border-radius: 28px;
    box-shadow: var(--shadow);
    color: #fff8fb;
}

.brand-cluster,
.brand-logos {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-logo {
    width: 46px;
    height: 46px;
    object-fit: contain;
    filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.22));
}

.brand-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.16);
    padding: 8px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.brand-copy strong,
.top-nav button,
.hero-strip h1,
.panel-header h2,
.metric-value,
.island-name,
.task-title,
.summary-total,
.hero-badge strong {
    font-family: "Rajdhani", sans-serif;
    letter-spacing: 0.02em;
}

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand-copy strong {
    font-size: 1.35rem;
}

.eyebrow {
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    font-weight: 700;
    opacity: 0.78;
}

.top-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.nav-pill {
    border: 0;
    min-height: 50px;
    padding: 0 22px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.nav-pill:hover,
.nav-pill:focus-visible {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.22);
}

.nav-pill.active {
    background: rgba(81, 8, 30, 0.56);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.account-slot {
    display: flex;
    justify-content: flex-end;
}

.content-shell {
    position: relative;
    z-index: 1;
    margin-top: 18px;
    display: grid;
    gap: 18px;
}

.hero-strip {
    display: grid;
    grid-template-columns: 1.2fr auto;
    gap: 20px;
    align-items: center;
    padding: 30px 32px;
    border-radius: var(--radius-xl);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72));
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(14px);
}

body.theme-dark .hero-strip {
    background: linear-gradient(180deg, rgba(40, 16, 29, 0.92), rgba(28, 12, 22, 0.82));
}

.hero-strip h1 {
    margin: 8px 0 10px;
    font-size: clamp(2rem, 5vw, 3rem);
    line-height: 0.98;
}

.hero-strip p,
.muted-copy,
.empty-card p,
.panel-copy {
    margin: 0;
    color: var(--text-soft);
    line-height: 1.55;
}

.hero-badge {
    min-width: 200px;
    padding: 18px 22px;
    border-radius: 24px;
    background: linear-gradient(160deg, rgba(165, 15, 61, 0.92), rgba(255, 202, 56, 0.86));
    color: #fff;
    text-align: right;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.hero-badge span {
    display: block;
    opacity: 0.84;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.78rem;
}

.hero-badge strong {
    font-size: 2rem;
}

.panel {
    display: none;
    padding: 28px;
    border-radius: var(--radius-xl);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(18px);
}

.panel.active {
    display: block;
    animation: panel-in 240ms ease;
}

@keyframes panel-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h2 {
    margin: 6px 0 4px;
    font-size: 2rem;
}

.two-column {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 20px;
}

.card-grid {
    display: grid;
    gap: 16px;
}

.island-list,
.task-list,
.stats-grid,
.admin-grid,
.overview-grid,
.wealth-list {
    display: grid;
    gap: 14px;
}

.island-card,
.task-card,
.metric-card,
.admin-card,
.summary-card,
.empty-card,
.player-card,
.search-card {
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.island-card {
    width: 100%;
    border: 0;
    text-align: left;
    padding: 18px;
    transition: transform 180ms ease, background 180ms ease;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(252, 239, 244, 0.88));
}

body.theme-dark .island-card {
    background: linear-gradient(180deg, rgba(47, 17, 31, 0.94), rgba(35, 14, 25, 0.92));
}

.island-card.active {
    background: linear-gradient(180deg, rgba(165, 15, 61, 0.96), rgba(117, 12, 43, 0.98));
    color: #fff;
}

.island-card:not(.active):hover,
.island-card:not(.active):focus-visible {
    transform: translateY(-2px);
}

.island-name {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.island-meta,
.task-meta,
.profile-subline,
.helper-text {
    color: var(--text-soft);
    font-size: 0.96rem;
}

.island-card.active .island-meta {
    color: rgba(255, 255, 255, 0.82);
}

.task-card {
    padding: 18px 20px;
    display: grid;
    gap: 14px;
}

.task-card.is-complete {
    opacity: 0.58;
    background: linear-gradient(180deg, rgba(214, 214, 214, 0.7), rgba(196, 196, 196, 0.55));
}

body.theme-dark .task-card.is-complete {
    background: linear-gradient(180deg, rgba(78, 67, 74, 0.84), rgba(58, 50, 55, 0.84));
}

.task-head,
.task-foot,
.wealth-row,
.profile-head,
.player-head,
.stats-periods,
.admin-footer,
.summary-layout {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
}

.task-title {
    margin: 0;
    font-size: 1.55rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(165, 15, 61, 0.08);
    color: var(--accent);
    font-weight: 700;
}

.chip.success {
    background: rgba(60, 170, 92, 0.12);
    color: var(--green);
}

.chip.info {
    background: rgba(255, 202, 56, 0.18);
    color: #9f6500;
}

body.theme-dark .chip.info {
    color: #ffd36a;
}

.primary-button,
.secondary-button,
.ghost-button,
.status-button,
.profile-button,
.icon-button {
    border: 0;
    border-radius: 14px;
    min-height: 48px;
    padding: 0 18px;
    font-weight: 700;
    transition: transform 180ms ease, filter 180ms ease, background 180ms ease;
}

.primary-button {
    background: linear-gradient(180deg, var(--gold) 0%, var(--gold-deep) 100%);
    color: #2d1120;
    box-shadow: 0 10px 22px rgba(255, 202, 56, 0.28);
}

.secondary-button {
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #fff;
}

.ghost-button,
.status-button,
.profile-button,
.icon-button {
    background: rgba(165, 15, 61, 0.08);
    color: var(--text);
}

.status-button.complete {
    background: rgba(60, 170, 92, 0.12);
    color: var(--green);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.status-button:hover,
.profile-button:hover,
.icon-button:hover,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible,
.status-button:focus-visible,
.profile-button:focus-visible,
.icon-button:focus-visible {
    transform: translateY(-1px);
    filter: brightness(1.02);
}

.wide-button {
    width: 100%;
}

.money-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
}

.money-inline img {
    width: 20px;
    height: 20px;
}

.money-inline.large {
    font-size: 1.4rem;
}

.search-card,
.summary-card,
.player-card,
.admin-card {
    padding: 22px;
}

.stats-search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 14px;
    align-items: end;
}

.field {
    display: grid;
    gap: 8px;
}

.field span,
.section-label {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-soft);
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid transparent;
    outline: 0;
    min-height: 52px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-tint);
    color: var(--text);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.field textarea {
    resize: vertical;
    min-height: 116px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: rgba(165, 15, 61, 0.3);
    box-shadow: 0 0 0 4px rgba(165, 15, 61, 0.1);
}

.player-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 18px;
    align-items: center;
}

.avatar,
.profile-avatar {
    width: 72px;
    height: 72px;
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(186, 210, 233, 0.74), rgba(221, 230, 244, 0.92));
    padding: 10px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.profile-avatar {
    width: 54px;
    height: 54px;
    border-radius: 18px;
    padding: 8px;
}

.player-name {
    margin: 0 0 2px;
    font-size: 1.65rem;
    font-family: "Rajdhani", sans-serif;
}

.stats-periods {
    flex-wrap: wrap;
}

.period-button {
    border: 0;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 12px;
    background: rgba(165, 15, 61, 0.08);
    color: var(--text);
    font-weight: 700;
}

.period-button.active {
    background: var(--accent);
    color: #fff;
}

.stats-grid {
    margin-top: 16px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.metric-card {
    padding: 18px;
    min-height: 148px;
}

.metric-label {
    font-size: 0.92rem;
    color: var(--text-soft);
    margin-bottom: 10px;
}

.metric-value {
    font-size: 1.9rem;
    line-height: 1;
}

.metric-card small {
    display: block;
    margin-top: 10px;
    color: var(--text-soft);
}

.summary-layout {
    align-items: stretch;
}

.chart-wrap {
    position: relative;
    width: min(360px, 100%);
    aspect-ratio: 1;
    margin: 0 auto;
}

#wealth-chart {
    width: 100%;
    height: 100%;
}

.summary-total {
    font-size: 2rem;
}

.wealth-list {
    min-width: 320px;
}

.wealth-row {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-tint);
}

.wealth-row strong {
    font-size: 1.1rem;
}

.admin-grid {
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

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

.stats-config-row {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) auto;
    gap: 14px 18px;
    align-items: center;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface-tint);
}

.stats-config-title {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.stats-config-title strong {
    display: block;
    line-height: 1.2;
    overflow-wrap: normal;
    word-break: normal;
}

.stats-config-title span {
    font-size: 0.85rem;
    color: var(--text-soft);
    overflow-wrap: normal;
    word-break: break-word;
}

.stats-config-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
    max-width: 240px;
}

.stats-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    min-width: 0;
    white-space: nowrap;
}

.stats-toggle input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
}

.stats-toggle span {
    line-height: 1.15;
}

.stats-order-field {
    gap: 6px;
    min-width: 92px;
    width: 92px;
}

.stats-order-field input {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
}

@media (max-width: 1200px) {
    .admin-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }

    .stats-config-row {
        grid-template-columns: minmax(150px, 1fr) auto;
        align-items: center;
    }

    .stats-config-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        justify-content: flex-end;
    }

    .stats-order-field {
        min-width: 0;
        width: 92px;
    }
}

@media (max-width: 560px) {
    .stats-config-row {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .stats-config-controls {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        max-width: none;
        justify-content: stretch;
    }

    .stats-order-field {
        width: 100%;
    }
}

.stack-form {
    display: grid;
    gap: 14px;
}

.inline-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.checkbox-grid {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface-tint);
}

.checkbox-item input {
    width: 18px;
    height: 18px;
}

.overview-grid {
    margin-top: 18px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.summary-card h3,
.admin-card h3 {
    margin: 0 0 6px;
    font-size: 1.35rem;
}

.summary-card strong {
    font-size: 1.9rem;
    font-family: "Rajdhani", sans-serif;
}

.empty-card {
    padding: 34px;
    text-align: center;
}

.empty-card h3,
.modal-card h2 {
    margin: 10px 0 8px;
    font-size: 2rem;
    font-family: "Rajdhani", sans-serif;
}

.profile-menu {
    position: relative;
    z-index: 40;
}

.profile-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border: 0;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 80;
    width: 290px;
    padding: 18px;
    border-radius: 24px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.profile-menu.open .profile-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.profile-name {
    margin: 0;
    font-size: 1.3rem;
}

.profile-stack {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.profile-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(24, 8, 16, 0.64);
    backdrop-filter: blur(8px);
}

.modal.hidden {
    display: none;
}

.modal-card {
    position: relative;
    width: min(440px, 100%);
    padding: 28px;
    border-radius: 28px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.modal-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    padding: 0;
    font-size: 1.5rem;
}

.toast-area {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 60;
    display: grid;
    gap: 12px;
}

.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-soft);
}

.toast.success {
    border-color: rgba(60, 170, 92, 0.24);
}

.toast.error {
    border-color: rgba(217, 106, 131, 0.28);
}

@media (max-width: 1080px) {
    .topbar {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .brand-cluster {
        justify-content: center;
    }

    .account-slot {
        width: 100%;
        justify-content: center;
        overflow: visible;
    }

    .two-column,
    .hero-strip,
    .summary-layout,
    .player-card {
        grid-template-columns: 1fr;
    }

    .player-card {
        justify-items: start;
    }
}

@media (max-width: 760px) {
    .layout-shell {
        width: min(100% - 16px, 100%);
        margin-top: 8px;
    }

    .topbar,
    .panel,
    .hero-strip {
        padding: 20px;
        border-radius: 22px;
    }

    .stats-search-form,
    .inline-grid {
        grid-template-columns: 1fr;
    }

    .top-nav {
        width: 100%;
    }

    .nav-pill {
        flex: 1 1 calc(50% - 8px);
    }

    .profile-dropdown {
        right: 50%;
        transform: translate(50%, 10px);
        width: min(290px, calc(100vw - 32px));
    }

    .profile-menu.open .profile-dropdown {
        transform: translate(50%, 0);
    }
}
