/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #fafafa;
    --bg-warm: #f5f3f0;
    --text: #1a1a1a;
    --text-muted: #888;
    --accent: #2a2a2a;
    --accent-hover: #444;
    --border: #e0ddd8;
    --font-display: 'Cormorant Garamond', Georgia, serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
    --font-body: 'Inter', -apple-system, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;
    background: var(--bg);
    font-family: var(--font-body);
    color: var(--text);
    overflow-x: hidden;
}



/* ===== Hero — vertical stack ===== */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 3rem 2rem 2rem;
}

.hero-left {
    flex-shrink: 0;
    cursor: crosshair;
}

.canvas-wrapper {
    position: relative;
    width: 320px;
    height: 320px;
    overflow: hidden;
}

#glCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hero-right {
    max-width: 580px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ===== Typography ===== */
.hello-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: var(--text);
    margin-bottom: 0.3rem;
    opacity: 0;
    animation: fadeUp 1.2s ease 0.3s forwards;
}

.hello-sub {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    color: var(--text-muted);
    opacity: 0;
    animation: fadeUp 1s ease 0.7s forwards;
    margin-bottom: 1.5rem;
}

/* ===== Character Panel ===== */

/* Panel Icons */
.panel-icon {
    width: 15px;
    height: 15px;
    stroke: var(--accent);
    flex-shrink: 0;
    opacity: 0.55;
}

.row-icon {
    width: 13px;
    height: 13px;
    stroke: currentColor;
    flex-shrink: 0;
    opacity: 0.35;
}

.char-panel {
    margin-bottom: 0.5rem;
    width: 100%;
    text-align: left;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    padding: 1.2rem 1.5rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.player-id {
    padding: 0.2rem 0 0.7rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.6rem;
    /* Force left alignment for ID and Name */
    justify-content: flex-start;
    gap: 0.5rem;
}

.player-id .value {
    margin-left: 0 !important;
}


/* ===== Floating Announcement Bar ===== */
.floating-notice {
    position: absolute;
    top: 0px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: auto;
    max-width: 90%;
    pointer-events: none;
    /* Let clicks pass through if needed, though window usually blocks */
}

.notice-window {
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    height: 36px;
    line-height: 36px;
    padding: 0 12px;
    /* Remove card styles */
    border-radius: 0;
    box-shadow: none;
    border: none;
    overflow: hidden;
    white-space: nowrap;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.notice-track {
    display: flex;
    flex-direction: column;
    height: 36px;
    /* 7 items + 1 duplicate = 8 items */
    animation: scroll-vertical 28s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.notice-track span {
    display: block;
    height: 36px;
    line-height: 36px;
    text-align: center;
    /* Ensure no wrapping */
    white-space: nowrap;
}

@keyframes scroll-vertical {

    /* Item 1 */
    0%,
    10.7% {
        transform: translateY(0);
    }

    /* Item 2 */
    14.3%,
    25% {
        transform: translateY(-36px);
    }

    /* Item 3 */
    28.6%,
    39.3% {
        transform: translateY(-72px);
    }

    /* Item 4 */
    42.9%,
    53.6% {
        transform: translateY(-108px);
    }

    /* Item 5 */
    57.1%,
    67.9% {
        transform: translateY(-144px);
    }

    /* Item 6 */
    71.4%,
    82.1% {
        transform: translateY(-180px);
    }

    /* Item 7 */
    85.7%,
    96.4% {
        transform: translateY(-216px);
    }

    /* Item 1 (Clone) */
    100% {
        transform: translateY(-252px);
    }
}

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 2rem;
    width: 100%;
}

.panel-col {
    display: flex;
    flex-direction: column;
}

.panel-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0;
    font-size: 0.82rem;
}

.panel-row .label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    white-space: nowrap;
    min-width: 3.2em;
}

.panel-row .value {
    font-weight: 500;
    color: var(--text);
    font-size: 0.85rem;
}

.highlight-name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: 0.02em;
}

.panel-block {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.panel-block:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.panel-heading {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text);
    letter-spacing: 0.01em;
    padding-left: 0.5rem;
    border-left: 2.5px solid var(--accent);
}

.level-badge {
    font-family: var(--font-mono);
    font-size: 0.56rem;
    font-weight: 500;
    background: var(--accent);
    color: #fff;
    padding: 0.15em 0.55em;
    border-radius: 8px;
    letter-spacing: 0.05em;
}

.tag-sm {
    font-family: var(--font-mono);
    font-size: 0.56rem;
    font-weight: 300;
    color: var(--text-muted);
    opacity: 0.7;
}

.stars {
    letter-spacing: 0.05em;
}

.max-tag {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-muted);
    font-weight: 300;
}

/* Skills */
.skill-item {
    padding: 0.3rem 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.skill-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
}

.skill-desc {
    font-size: 0.72rem;
    font-weight: 300;
    color: #666;
    line-height: 1.5;
}

.skill-cd {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: #e74c3c;
    font-weight: 400;
}

/* Hobbies */
.hobby-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 0.5rem;
}

.hobby-list li {
    font-size: 0.78rem;
    font-weight: 300;
    color: #555;
    padding: 0.3rem 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.hobby-list li:nth-child(even) {
    justify-content: flex-end;
    text-align: right;
}


/* ===== Tab Navigation ===== */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.6rem 0.4rem;
    border: none;
    background: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.76rem;
    font-weight: 400;
    cursor: pointer;
    position: relative;
    transition: color 0.25s ease;
}

.tab-btn::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 15%;
    width: 70%;
    height: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn.active {
    color: var(--text);
    font-weight: 500;
}

.tab-btn.active::after {
    transform: scaleX(1);
}

.tab-btn:hover {
    color: var(--text);
}

.tab-icon {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    flex-shrink: 0;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: tabFadeIn 0.3s ease;
}

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Equipment Styles ===== */
.equip-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.equip-item {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.15rem 0.6rem;
    padding: 0.55rem 0.6rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.015);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: background 0.2s;
}

.equip-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.equip-slot {
    grid-row: 1 / 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    min-width: 40px;
}

.equip-icon {
    width: 20px;
    height: 20px;
    stroke: var(--accent);
    opacity: 0.5;
}

.equip-slot-label {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--text-muted);
    font-weight: 300;
}

.equip-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.equip-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
}

.equip-rarity {
    font-family: var(--font-mono);
    font-size: 0.56rem;
    font-weight: 500;
    padding: 0.1em 0.45em;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.rarity-rare {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.rarity-epic {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

.rarity-legendary {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.equip-desc {
    grid-column: 2;
    font-size: 0.7rem;
    font-weight: 300;
    color: var(--text-muted);
}

/* ===== Quest Styles ===== */
.quest-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0;
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--text);
}

.quest-text {
    flex: 1;
}

.quest-status {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    font-weight: 500;
    padding: 0.12em 0.5em;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.status-progress {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.status-locked {
    background: rgba(0, 0, 0, 0.04);
    color: #aaa;
}

.status-done {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.quest-icon {
    color: var(--text-muted);
    font-size: 0.7rem;
}

/* ===== Bag / Inventory Styles ===== */
.bag-container {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    flex-direction: row-reverse;
    /* Swap Grid (Right) and Details (Left) */
}

.bag-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 2px;
    background: rgba(0, 0, 0, 0.03);
    padding: 2px;
    border-radius: 6px;
    margin-top: 0.5rem;
    flex: 0 0 auto;
    width: calc(100% - 140px);
    /* Adjust based on side panel width */
    aspect-ratio: 1 / 1;
}

.bag-details {
    flex: 1;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    margin-top: 0.5rem;
    padding: 0.8rem;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.bag-slot {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: none;
    /* Removed transition to prevent ghost highlight artifacts */
    cursor: pointer;
}

.bag-slot:hover,
.bag-slot.selected {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--accent);
}

.bag-slot.drag-over {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    box-shadow: inset 0 0 4px rgba(59, 130, 246, 0.3);
}

.bag-item-draggable {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    /* Critical */
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    /* Critical for mobile drag */
    position: relative;
    transition: opacity 0.2s, transform 0.2s;
}

.bag-item-draggable:active {
    cursor: grabbing;
}

.bag-item-draggable.dragging {
    opacity: 0.4;
    transform: scale(0.9);
}

/* Mobile Ghost Drag Item */
.bag-item-draggable.ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.8;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
    /* Visual pop */
}

.item-icon {
    width: 24px;
    height: 24px;
    stroke: var(--accent);
    opacity: 0.8;
}

/* Side Panel Content */
.bag-details-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.6;
}

.empty-icon {
    width: 24px;
    height: 24px;
    stroke: var(--text-muted);
}

.details-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 0.8rem;
}

.details-icon-wrapper {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.details-title-group h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text);
    font-weight: 600;
}

.details-body p {
    font-size: 0.75rem;
    color: #555;
    line-height: 1.4;
    margin-bottom: 0.8rem;
}

.stat-row {
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    color: var(--text);
}

.stat-value {
    font-weight: 600;
    font-family: var(--font-mono);
}

/* Responsive adjustments */
@media (max-width: 380px) {
    .bag-container {
        flex-direction: column;
        align-items: center;
    }

    .bag-grid {
        width: 100%;
        max-width: 280px;
    }

    .bag-details {
        width: 100%;
        min-height: auto;
        flex-direction: row;
        align-items: center;
        text-align: left;
    }

    .bag-details-content {
        display: flex;
        gap: 1rem;
        align-items: center;
        width: 100%;
    }

    .details-header {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
        flex-direction: row;
        text-align: left;
    }

    .details-body {
        flex: 1;
        font-size: 0.75rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 0.5rem;
    }

    .details-body p {
        margin: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

/* ===== Greet Button ===== */
.btn-ripple-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 3rem;
    align-self: center;
}

.greet-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.8rem 1.8rem;
    border: 1.5px solid var(--accent);
    border-radius: 50px;
    background: transparent;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.greet-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.greet-btn:hover::before {
    transform: scaleX(1);
}

.greet-btn:hover {
    color: #fff;
    border-color: var(--accent);
}

.greet-btn:active {
    transform: scale(0.97);
}

.btn-icon,
.btn-text {
    position: relative;
    z-index: 1;
}

.btn-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

/* Ripple rings */
.ripple-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border: 1.5px solid var(--text);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.5;
    pointer-events: none;
    animation: rippleExpand 1.2s cubic-bezier(0, 0.4, 0.4, 1) forwards;
}

@keyframes rippleExpand {
    0% {
        width: 50px;
        height: 50px;
        opacity: 0.4;
    }

    100% {
        width: 240px;
        height: 240px;
        opacity: 0;
    }
}

.greet-btn.playing {
    animation: btnPulseGlow 2s ease-in-out infinite;
}

@keyframes btnPulseGlow {

    0%,
    100% {
        box-shadow: 0 0 0px 0px rgba(26, 26, 26, 0.05);
    }

    50% {
        box-shadow: 0 0 12px 2px rgba(26, 26, 26, 0.1);
    }
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 2rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 300;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

.heart {
    color: #e74c3c;
    display: inline-block;
    animation: heartbeat 1.5s ease infinite;
}

/* ===== Animations ===== */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-icon {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.15);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.1);
    }
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .hero {
        padding: 2rem 1rem 1.5rem;
        gap: 1.5rem;
    }

    .canvas-wrapper {
        width: 80vw;
        height: 80vw;
        max-width: 380px;
        max-height: 380px;
    }

    .hero-right {
        max-width: 100%;
        padding: 0 0.3rem;
    }

    .hello-title {
        font-size: 2.6rem;
    }

    .char-panel {
        padding: 1rem 1.1rem;
        border-radius: 10px;
    }

    .panel-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .panel-row .value {
        margin-left: auto;
    }

    .skill-item {
        padding: 0.3rem 0;
    }

    .btn-ripple-wrapper {
        padding: 1.2rem 2rem;
    }
}