:root {
    color-scheme: light;
    --bg: #f7f7fa;
    --panel: #ffffff;
    --text: #243044;
    --muted: #71809a;
    --line: #e7ebf2;
    --primary: #145fc2;
    --accent: #ff6a3d;
    --green: #18a058;
    --shadow: 0 8px 18px rgba(21, 31, 56, .09);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 19px;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 300px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 26px 14px;
    overflow-y: auto;
}

.brand,
.logo {
    display: block;
    margin: 0 16px 28px;
    font-size: 50px;
    line-height: 1;
    font-weight: 900;
    color: #2596c9;
    letter-spacing: 0;
}

nav {
    display: grid;
    gap: 5px;
}

nav a {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 48px;
    padding: 0 16px;
    border-radius: 8px;
    color: #63728d;
    font-size: 19px;
}

nav a.active {
    background: #fff0ea;
    color: var(--accent);
    border-left: 4px solid var(--accent);
}

nav a.sub-link {
    min-height: 40px;
    padding-left: 22px;
    color: #71809a;
}

nav a.sub-link span {
    color: #a7afbd;
    font-size: 25px;
    line-height: 0;
}

nav a.sub-active {
    color: #63728d;
    background: transparent;
    border-left: 0;
}

.app {
    margin-left: 300px;
    padding: 0 26px 40px;
}

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--panel);
    margin: 0 -26px 24px;
    padding: 0 26px;
    border-bottom: 1px solid var(--line);
}

.topbar strong {
    display: inline-flex;
    margin-left: 8px;
    padding: 9px 14px;
    background: #e3e3e8;
    border-radius: 6px;
}

.profile {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #ffe7dc;
    color: var(--accent);
    font-weight: 800;
    text-transform: uppercase;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 22px;
    margin-bottom: 24px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.metric {
    min-height: 90px;
}

.metric span,
.muted,
.section-title p {
    color: var(--muted);
}

.metric strong {
    display: block;
    margin-top: 8px;
    font-size: 25px;
}

h1,
h2 {
    margin: 0 0 12px;
    letter-spacing: 0;
}

h1 {
    font-size: 36px;
}

h2 {
    font-size: 24px;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
}

.grid-chart {
    height: 330px;
    display: grid;
    grid-template-columns: repeat(14, 1fr);
    align-items: end;
    gap: 10px;
    padding: 18px 10px 42px;
    background-image: linear-gradient(#8991a8 1px, transparent 1px), linear-gradient(90deg, #8991a8 1px, transparent 1px);
    background-size: 100% 33px, 56px 100%;
    border: 1px solid #8991a8;
}

.bar {
    position: relative;
    min-height: 8px;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, var(--primary), #40b7d8);
}

.bar span {
    position: absolute;
    left: 50%;
    bottom: -34px;
    transform: translateX(-50%) rotate(-45deg);
    transform-origin: top left;
    white-space: nowrap;
    font-size: 12px;
    color: #7b87a1;
}

.task-layout,
.split,
.auth-grid {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 22px;
}

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

.profile-page {
    display: grid;
    gap: 24px;
}

.fanpage-page {
    display: grid;
    gap: 22px;
}

.fanpage-card {
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.fanpage-button {
    min-width: 220px;
    background: #1877f2;
}

.profile-hero {
    min-height: 140px;
    display: flex;
    align-items: center;
    gap: 22px;
}

.profile-avatar {
    width: 82px;
    height: 82px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #ffe7dc;
    color: var(--accent);
    font-size: 34px;
    font-weight: 900;
}

.profile-hero h1 {
    margin-bottom: 6px;
}

.info-list {
    display: grid;
    gap: 14px;
    margin: 18px 0 0;
}

.info-list div {
    display: grid;
    grid-template-columns: 190px 1fr;
    gap: 18px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.info-list dt {
    color: var(--muted);
    font-weight: 800;
}

.info-list dd {
    margin: 0;
    color: var(--text);
    font-weight: 900;
    overflow-wrap: anywhere;
}

.mission-page {
    display: grid;
    gap: 16px;
}

.mission-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(240px, 1fr));
    gap: 24px;
}

.mission-stat {
    min-height: 102px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px 24px;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    border: 1px solid #edf0f6;
}

.mission-stat .stat-icon {
    width: 50px;
    height: 50px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #edf0ff;
    font-size: 27px;
}

.mission-stat .coin {
    background: #fff1be;
}

.mission-stat strong {
    display: block;
    margin-bottom: 4px;
    font-size: 30px;
    color: #28344d;
}

.mission-stat span:last-child {
    color: #5d6880;
    font-size: 20px;
}

.mission-stat em {
    display: block;
    margin-top: 5px;
    color: #ff6a3d;
    font-size: 18px;
    font-style: normal;
    font-weight: 800;
}

.notice-panel {
    padding: 38px 22px;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
    color: #17b84f;
    line-height: 1.45;
    border: 1px solid #edf0f6;
}

.notice-panel strong {
    display: block;
    margin-bottom: 2px;
    color: #ff2f22;
}

.notice-panel p {
    margin: 2px 0;
    font-size: 20px;
    font-style: italic;
}

.notice-panel b {
    color: #0f8b41;
    font-style: normal;
}

.cooldown-panel {
    padding: 16px 20px;
    border: 1px solid #ffd6c8;
    border-radius: 8px;
    background: #fff3ee;
    color: #b6401f;
    box-shadow: var(--shadow);
    font-size: 22px;
    font-weight: 900;
    text-align: center;
}

.cooldown-panel strong {
    color: #ff4d22;
}

.mission-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(360px, 1fr));
    gap: 34px 20px;
}

.mission-card {
    min-height: 260px;
    display: grid;
    grid-template-rows: auto auto auto 1fr auto;
    gap: 16px;
    padding: 20px 22px 18px;
    border: 2px dashed #b8c3d0;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.mission-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 20px;
    font-size: 20px;
}

.mission-head strong {
    color: #454e61;
}

.level,
.rank {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.level {
    color: #6b69ff;
    background: #ebeaff;
}

.rank {
    margin-left: 4px;
    color: #ff9800;
    border: 1px solid #ff9800;
    background: #fff9ec;
}

.mission-start {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #fff;
    background: linear-gradient(90deg, #155bbb, #1978d1);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12);
    font-size: 24px;
    font-weight: 900;
    text-align: center;
}

.mission-card.locked .mission-start {
    opacity: .9;
}

.mission-card h2 {
    min-height: 34px;
    margin: 6px 0 0;
    text-align: center;
    color: #687384;
    font-size: 19px;
    font-weight: 800;
}

.pending-pill {
    justify-self: center;
    margin: 0;
    padding: 7px 14px;
    border: 1px solid #ffc8c8;
    border-radius: 999px;
    background: #fff0f0;
    color: #ff4b55;
    box-shadow: 0 3px 8px rgba(255, 75, 85, .16);
    font-size: 14px;
}

.mission-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #eef1f6;
}

.mission-meta.ad-meta {
    grid-template-columns: repeat(3, 1fr);
}

.mission-meta div {
    display: grid;
    gap: 7px;
    text-align: center;
}

.mission-meta strong {
    font-size: 20px;
}

.mission-meta span {
    color: #9aa4b5;
    font-size: 17px;
}

.red {
    color: #ff373b;
}

.green {
    color: #53d61d;
}

.blue {
    color: #11aaf4;
}

.task-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #eef0ff;
    font-size: 32px;
}

.progress-line {
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.task-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

button,
.button {
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    min-height: 46px;
    padding: 0 20px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.button.secondary {
    background: #26324b;
}

.plain-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.plain-list li {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.plain-list span {
    color: var(--muted);
}

.plain-list strong {
    display: block;
    margin-bottom: 4px;
}

.plain-list small {
    display: block;
    color: var(--muted);
    line-height: 1.35;
}

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

.withdraw-fields {
    display: grid;
    gap: 14px;
}

.hidden {
    display: none !important;
}

label {
    display: grid;
    gap: 7px;
    color: #53617b;
    font-weight: 700;
    font-size: 19px;
}

input {
    width: 100%;
    border: 1px solid #d8deea;
    border-radius: 8px;
    min-height: 46px;
    padding: 0 14px;
    font: inherit;
    color: var(--text);
}

textarea {
    width: 100%;
    border: 1px solid #d8deea;
    border-radius: 8px;
    min-height: 92px;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    resize: vertical;
}

select {
    width: 100%;
    border: 1px solid #d8deea;
    border-radius: 8px;
    min-height: 46px;
    padding: 0 14px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

th {
    color: #53617b;
}

.alert {
    margin-bottom: 18px;
    border-radius: 8px;
    padding: 12px 14px;
    background: #e9f8ef;
    color: #0d7139;
    border: 1px solid #bde8cb;
}

.alert.error {
    background: #fff1ee;
    color: #b63118;
    border-color: #ffc9bd;
}

.modal-flash {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(17, 24, 39, .42);
}

.modal-flash-card {
    width: min(520px, 100%);
    display: grid;
    gap: 18px;
    padding: 30px;
    border: 1px solid #bde8cb;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .24);
    text-align: center;
}

.modal-flash-card.error {
    border-color: #ffc9bd;
}

.modal-flash-card h2 {
    margin: 0;
    color: #243044;
    font-size: 30px;
}

.modal-flash-card p {
    margin: 0;
    color: #53617b;
    font-size: 22px;
    line-height: 1.45;
    font-weight: 800;
}

.modal-flash-card.error p {
    color: #b63118;
}

.modal-flash-card .button {
    justify-self: center;
    min-width: 150px;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        radial-gradient(circle at 26% 15%, rgba(135, 35, 170, .18), transparent 34%),
        radial-gradient(circle at 76% 34%, rgba(0, 224, 255, .15), transparent 38%),
        linear-gradient(135deg, #110817 0%, #071216 52%, #06151a 100%);
}

.watch-body {
    background: #eef2f7;
}

.watch-shell {
    position: relative;
    min-height: 100vh;
    max-height: 100vh;
    display: grid;
    grid-template-rows: 70px minmax(0, 1fr) 100px;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
}

.watch-ad-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    min-height: 0;
}

.watch-layout {
    display: grid;
    grid-template-columns: 170px minmax(520px, 1fr) 310px;
    gap: 12px;
    align-items: stretch;
    min-height: 0;
}

.watch-ad-slot {
    position: relative;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px dashed #b9c4d4;
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.ad-468x60 {
    width: 468px;
    height: 60px;
}

.ad-320x50 {
    width: 320px;
    height: 50px;
}

.ad-160x600 {
    width: 160px;
    height: min(600px, 100%);
}

.ad-160x300 {
    width: 160px;
    height: 300px;
}

.ad-300x250 {
    width: 300px;
    height: 250px;
}

.ad-728x90 {
    width: 728px;
    height: 90px;
}

.ad-native {
    width: 300px;
    height: 90px;
}

.watch-ad-slot iframe,
.watch-ad-slot img,
.watch-ad-slot ins,
.watch-ad-slot div {
    max-width: 100% !important;
    max-height: 100% !important;
}

.watch-ad-slot img {
    object-fit: contain;
}

.watch-ad-slot iframe {
    border: 0;
}

.watch-ad-frame {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
}

.watch-placeholder {
    color: #9aa4b5;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    opacity: .72;
}

.watch-side-stack {
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.watch-panel {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
}

.watch-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.watch-title h1 {
    margin-bottom: 6px;
}

.watch-title p {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

.watch-countdown {
    min-width: 150px;
    min-height: 54px;
    display: grid;
    place-items: center;
    padding: 0 18px;
    border-radius: 8px;
    background: #fff0ea;
    color: var(--accent);
    font-size: 24px;
}

.watch-video {
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 8px;
    background: #050b16;
}

.watch-video video {
    width: 100%;
    max-height: 48vh;
    display: block;
    background: #050b16;
}

.watch-video iframe {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: min(48vh, 560px);
    min-height: 260px;
    border: 0;
    display: block;
    background: #050b16;
}

.watch-empty {
    color: #fff;
    font-size: 24px;
    font-weight: 800;
}

.watch-status {
    padding: 14px 16px;
    border-radius: 8px;
    background: #fff6df;
    color: #9a6500;
    font-weight: 900;
    text-align: center;
}

.watch-status.done {
    background: #e9f8ef;
    color: #0d7139;
}

.watch-actions {
    display: flex;
    justify-content: center;
}

.auth-card {
    width: min(450px, 100%);
    padding: 34px 40px 36px;
    border: 2px solid #00e5ff;
    border-radius: 8px;
    background: rgba(18, 18, 30, .9);
    box-shadow: 0 0 28px rgba(0, 229, 255, .28);
    color: #eef5ff;
}

.auth-logo {
    margin: 0 0 16px;
    text-align: center;
    font-size: 26px;
    font-weight: 900;
    color: #00f0ff;
    text-shadow: 0 0 12px rgba(0, 240, 255, .75);
    letter-spacing: 0;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 26px;
    padding: 4px;
    border: 1px solid rgba(0, 229, 255, .35);
    border-radius: 8px;
    background: rgba(255, 255, 255, .04);
}

.auth-tabs a {
    min-height: 38px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    color: #9aa6b8;
    font-weight: 800;
}

.auth-tabs a.active {
    color: #08111a;
    background: linear-gradient(90deg, #22d3ee, #a855f7);
}

.auth-card .alert {
    margin-bottom: 18px;
}

.auth-card h1 {
    margin-bottom: 24px;
    text-align: center;
    font-size: 26px;
    text-transform: uppercase;
    color: #00f0ff;
    text-shadow: 0 0 12px rgba(0, 240, 255, .75);
}

.auth-card label {
    color: #f4f7ff;
    font-size: 20px;
}

.auth-card input {
    min-height: 44px;
    border-color: #cfd8ea;
    background: #eaf1ff;
    color: #07111d;
    font-weight: 700;
}

.auth-card button {
    min-height: 48px;
    margin-top: 6px;
    color: #07111d;
    text-transform: uppercase;
    background: linear-gradient(90deg, #22d3ee, #a855f7);
}

.turnstile-box {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px 0;
    max-width: 100%;
    overflow: hidden;
}

.turnstile-box .cf-turnstile {
    max-width: 100%;
}

.auth-switch {
    margin: 6px 0 0;
    text-align: center;
    color: #9aa6b8;
}

.auth-switch a {
    color: #00f0ff;
    font-weight: 900;
}

.auth-form {
    display: none;
}

.auth-mode-login .auth-login,
.auth-mode-register .auth-register {
    display: grid;
}

.copy-field {
    margin-top: 10px;
}

.admin-shell {
    min-height: 100vh;
    padding: 24px;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.admin-topbar strong {
    display: block;
    margin-bottom: 4px;
    font-size: 26px;
}

.admin-topbar span {
    color: var(--muted);
}

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 18px;
}

.admin-tabs a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #53617b;
    font-weight: 800;
    font-size: 17px;
}

.admin-tabs a.active {
    background: #fff0ea;
    color: var(--accent);
    border-color: #ffd3c6;
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 18px;
    align-items: start;
}

.admin-form {
    position: sticky;
    top: 18px;
}

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

.inline-edit {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.coin-edit {
    display: flex;
    gap: 8px;
    min-width: 160px;
}

.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.row-actions form {
    margin: 0;
}

.checkline {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
}

.checkline input {
    width: auto;
    min-height: auto;
}

.checkline.compact {
    margin-top: 8px;
    font-size: 13px;
}

button.danger {
    background: #d93636;
}

@media (max-width: 1500px) {
    .mission-grid {
        grid-template-columns: repeat(3, minmax(330px, 1fr));
    }
}

@media (max-width: 1180px) {
    .mission-grid {
        grid-template-columns: repeat(2, minmax(300px, 1fr));
    }

    .mission-stats {
        grid-template-columns: 1fr;
    }

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

    .watch-side-stack {
        flex-direction: row;
        justify-content: center;
        min-height: 0;
        overflow: visible;
    }

    .watch-shell {
        max-height: none;
        overflow: visible;
    }

}

@media (max-height: 780px) {
    .watch-shell {
        grid-template-rows: 60px minmax(0, 1fr) 90px;
        gap: 10px;
        padding: 10px;
    }

    .watch-panel {
        gap: 10px;
        padding: 12px;
    }

    .watch-ad-row,
    .watch-side-stack {
        gap: 10px;
    }

    .watch-title h1 {
        font-size: 26px;
    }

    .watch-title p {
        font-size: 16px;
    }

    .watch-countdown {
        min-height: 42px;
        font-size: 20px;
    }

    .watch-video iframe,
    .watch-video video {
        max-height: 38vh;
    }

    .watch-video iframe {
        height: min(38vh, 420px);
        min-height: 220px;
    }

    .ad-160x600 {
        height: 420px;
    }

    .ad-160x300 {
        height: 210px;
    }

    .ad-300x250 {
        height: 210px;
    }
}

@media (max-width: 980px) {
    .sidebar {
        position: static;
        width: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .app {
        margin-left: 0;
        padding: 0 16px 28px;
    }

    .topbar {
        margin: 0 -16px 20px;
        padding: 0 16px;
    }

    .stats,
    .task-layout,
    .split,
    .auth-grid,
    .admin-grid,
    .mission-grid {
        grid-template-columns: 1fr;
    }

    .profile-hero {
        align-items: flex-start;
        flex-direction: column;
    }

    .fanpage-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .info-list div {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .admin-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .auth-card {
        padding: 28px 22px;
    }
}
