* {
    box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@500;700&display=swap');

:root {
    --text-color: #1e2a37;
    --card-bg: #ffffff;
    --border-color: #d7dee8;
    --accent-color: #2f80ed;
    --primary-color: #1f6dad;
    --success-color: #219653;
    --danger-color: #d93025;
    --warning-color: #f39c12;
    --hover-color: #f4f7fb;
    --shadow: 0 12px 28px rgba(15, 30, 48, 0.12);
    --transition: all 0.25s ease;
}

body {
    margin: 0;
    font-family: 'Noto Sans SC', "PingFang SC", "Microsoft YaHei", sans-serif;
    background: radial-gradient(circle at 8% 6%, #f6fbff 0%, #ecf3fa 40%, #e8eef5 100%);
    color: var(--text-color);
    min-height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    overflow-y: hidden;
}

html,
body {
    overscroll-behavior-y: none;
}

img {
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.hidden {
    display: none !important;
}

.app-root {
    min-height: 100vh;
}

.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.login-shell {
    width: min(980px, 100%);
}

.login-layout {
    display: flex;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.62);
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.66);
    box-shadow: 0 18px 40px rgba(17, 35, 78, 0.12);
    backdrop-filter: blur(8px);
}

.login-hero {
    flex: 1 0 52%;
    position: relative;
    min-height: 290px;
    padding: 92px 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo {
    width: min(90%, 620px);
    max-height: 170px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 8px 20px rgba(28, 55, 190, 0.18));
}

.login-logo-fallback {
    font-size: clamp(2rem, 8vw, 4.4rem);
    font-weight: 700;
    color: #1c37be;
    letter-spacing: 1px;
}

.login-hero::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: min(80%, 320px);
    height: min(75%, 160px);
    transform: translate(-50%, -50%);
    z-index: -1;
    background: linear-gradient(135deg, #1c37be 0%, #7476f7 25%, #74cff3 50%, #7476f7 75%, #1c37be 100%);
    filter: blur(48px);
    background-size: 300% 300%;
    animation: gradientFlow 15s ease infinite;
}

.login-main {
    flex: 1 0 48%;
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@keyframes gradientFlow {
    0% { background-position: 0% 0%; }
    25% { background-position: 100% 0%; }
    50% { background-position: 100% 100%; }
    75% { background-position: 0% 100%; }
    100% { background-position: 0% 0%; }
}

.login-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-col {
    display: flex;
    align-items: center;
}

.login-select,
#nameInput {
    width: 100%;
    height: 56px;
    border-radius: 10px;
    border: 0;
    background: #f2f4ff;
    font-size: 15px;
    padding: 0 16px;
    transition: var(--transition);
    color: #2d3547;
}

.login-select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, #6f7d90 50%), linear-gradient(135deg, #6f7d90 50%, transparent 50%);
    background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
    background-size: 7px 7px, 7px 7px;
    background-repeat: no-repeat;
}

.login-select:invalid,
#nameInput::placeholder {
    color: #9ca3af;
}

.login-select:focus,
#nameInput:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(28, 55, 190, 0.18);
}

.primary-btn,
.ghost-btn {
    border: none;
    cursor: pointer;
}

.primary-btn {
    width: 100%;
    margin-top: 10px;
    border-radius: 10px;
    padding: 13px;
    font-size: 16px;
    color: #fff;
    background: #1c37be;
    transition: var(--transition);
    box-shadow: #1c37be 0 16px 28px -12px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: #1c37be 0 12px 24px -12px;
}

.error-text {
    display: block;
    min-height: 20px;
    color: var(--danger-color);
    margin-top: 6px;
}

.main-view {
    min-height: 100vh;
    overflow: hidden;
}

.money {
    color: #4b5563;
    font-size: 14px;
}

.ghost-btn {
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid #cfd4db;
    background: #fff;
    color: #233042;
    transition: var(--transition);
}

.ghost-btn:hover {
    background: #f3f6fb;
}

.image-stage {
    position: relative;
    min-height: 100dvh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overscroll-behavior-y: contain;
    background: #000;
}

.image-stage.image-overflow-y {
    align-items: flex-start;
}

#mainImage {
    width: auto;
    max-width: 100%;
    height: auto;
    min-height: 0;
    margin: 0 auto;
    opacity: 1;
    transition: opacity 0.28s ease;
    display: block;
    transform-origin: center center;
    will-change: transform;
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
}

#mainImage.fade {
    opacity: 0.2;
}

.image-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 20px;
    background: linear-gradient(145deg, #1c1c1c, #2e2e2e);
}

.toggle-sidebar-btn {
    position: fixed;
    left: 18px;
    bottom: 18px;
    border: none;
    border-radius: 12px;
    color: #111;
    background: #fff;
    width: 54px;
    height: 54px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.24);
    animation: floatPulse 2.2s ease-in-out infinite;
    z-index: 7;
}

.toggle-sidebar-btn:hover {
    transform: translateY(-2px);
}

.answer-btn {
    left: auto;
    right: 18px;
}

.answer-btn svg {
    width: 22px;
    height: 22px;
    color: #111;
}

.hamburger {
    width: 20px;
    height: 14px;
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
}

.hamburger i {
    display: block;
    width: 100%;
    height: 2px;
    background: #111;
    border-radius: 999px;
}

@keyframes floatPulse {
    0% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
    100% {
        transform: translateY(0);
    }
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 8;
}

.sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9;
    background: #fff;
    color: #111;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    max-height: 72vh;
    transform: translateY(105%);
    transition: transform 0.35s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    transform: translateY(0);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid #eceff3;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 18px;
}

.sidebar-user-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.category-container {
    overflow-y: auto;
    padding: 10px 14px 18px;
}

.category {
    border: 1px solid #e5e8ee;
    border-radius: 12px;
    margin-bottom: 10px;
}

.category-header {
    width: 100%;
    border: none;
    background: #fff;
    color: #111;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
}

.category-header:hover {
    background-color: var(--hover-color);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.category-grid {
    max-height: 0;
    overflow: hidden;
}

.category-grid.open {
    max-height: none;
}

.category-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    padding: 6px 12px 12px;
    opacity: 0;
    clip-path: inset(0 0 100% 0 round 10px);
    transition: clip-path 0.24s ease, opacity 0.18s ease;
    will-change: clip-path, opacity;
    pointer-events: none;
}

.category-grid.open .category-grid-inner {
    opacity: 1;
    clip-path: inset(0 0 0 0 round 10px);
    pointer-events: auto;
}

.thumb {
    --thumb-title-height: 24px;
    position: relative;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    background: #fafafa;
    transition: var(--transition);
}

.thumb:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.12);
}

.thumb img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
}

.thumb-title {
    font-size: 12px;
    min-height: var(--thumb-title-height);
    padding: 6px;
    text-align: center;
}

.thumb.pursuable img {
    filter: grayscale(1) brightness(0.52) contrast(1.08) blur(2px);
}

.lock {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: var(--thumb-title-height);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

.thumb.pursuable .thumb-title {
    color: #4b5563;
}

.thumb.bought.active {
    outline: 2px solid var(--success-color);
}

.empty-tip {
    color: #6b7280;
    padding: 4px 0 10px;
}

.confirmation-dialog {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    z-index: 12;
    padding: 16px;
}

.confirmation-content {
    width: min(460px, 100%);
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.25);
}

.confirmation-header {
    background-color: #f7faff;
    color: #0b1752;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e8effa;
}

.confirmation-title {
    font-size: 1.05rem;
    font-weight: 700;
}

.confirmation-body {
    padding: 1.5rem 1.25rem 2rem;
}

.confirmation-message {
    font-size: 1rem;
    line-height: 1.5;
}

.confirmation-warning {
    margin-top: 0.75rem;
    color: #27487c;
    background: #fbfdff;
    border: 1px solid #edf2fb;
    border-radius: 8px;
    padding: 0.5rem 0.6rem;
    font-size: 0.92rem;
}

.confirmation-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid var(--border-color);
    padding: 0.85rem 1.2rem;
}

.btn {
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.2rem;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

.btn-secondary {
    background: #f0f3f7;
    color: #2d3644;
}

.btn-secondary:hover {
    background: #e6ebf2;
}

.btn-primary {
    color: #fff;
    background: #1c37be;
    border: 1px solid #1c37be;
    box-shadow: #1c37be 0 10px 24px -14px;
}

.btn-primary:hover {
    transform: translateY(-1px);
    background: #1933af;
}

.answer-modal-content {
    width: min(560px, 100%);
}

.answer-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.answer-close-btn {
    border: none;
    background: transparent;
    color: #44506a;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.answer-modal-body {
    padding: 1rem 1.25rem 1.1rem;
}

.answer-label {
    display: block;
    margin: 0.45rem 0 0.45rem;
    color: #1f2937;
}

.answer-input {
    width: 100%;
    border: 1px solid #d7dee8;
    border-radius: 10px;
    font: inherit;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.35rem;
}

.answer-input:focus {
    outline: none;
    border-color: #b9c8ef;
    box-shadow: 0 0 0 3px rgba(28, 55, 190, 0.12);
}

.answer-textarea {
    min-height: 140px;
    resize: vertical;
}

.answer-hint {
    margin: 0.65rem 0 0;
    color: #7b8799;
    font-size: 0.92rem;
}

.answer-info-content {
    width: min(520px, 100%);
}

.answer-info-body {
    padding: 1rem 1.25rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-info-image {
    width: 100%;
    max-height: 52vh;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid #e7edf8;
    background: #f7f9fd;
}

#answerInfoImage {
    user-select: auto;
    -webkit-user-select: auto;
    -webkit-touch-callout: default;
    -webkit-user-drag: auto;
}

.answer-info-tip {
    margin: 0;
    font-size: 0.88rem;
    color: #67758d;
    text-align: center;
}

.msg-pop-container {
    position: fixed;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.msg-pop {
    min-width: 220px;
    max-width: 72vw;
    padding: 11px 14px;
    border-radius: 10px;
    background: #f8fbff;
    border: 1px solid #e8eef9;
    color: #0b1752;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.16);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.msg-pop.show {
    opacity: 1;
    transform: translateY(0);
}

.msg-pop.hide {
    opacity: 0;
    transform: translateY(-10px);
}

@media (max-width: 700px) {
    .login-layout {
        flex-direction: column;
        min-height: 480px;
    }

    .login-hero {
        min-height: 130px;
        padding: 24px 84px 10px;
        margin-top: 28px;
    }

    .login-logo {
        width: min(100%, 360px);
        max-height: 120px;
    }

    .login-main {
        padding: 16px 18px 20px;
    }

    .sidebar {
        max-height: 78vh;
    }

    .sidebar-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .category-grid-inner {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
    .login-hero::before {
        max-width: 300px;
        max-height: 50px;
    }
}

@media (min-width: 480px) and (max-width: 571px) {
    .category-grid-inner {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 572px) and (max-width: 700px) {
    .category-grid-inner {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 400px) {
    .login-logo {
        width: 180px;
    }

    .login-hero {
        padding: 24px 0 10px;
        display: flex;
        justify-content: center;
    }
}