/* =========================
   GLOBAL STYLES
========================= */

* {
    box-sizing: border-box;
}

body {
    background: repeating-linear-gradient(
        90deg,
        #ffb2ec 0 145px,
        #ffe0f2 145px 290px
    );
    font-family: Arial, sans-serif;
    text-align: center;
    margin: 0;
    padding: 0 0 30px;
    color: #222;
}

button {
    font-family: inherit;
    font-size: 16px;
    padding: 10px 16px;
    margin: 5px;
    border: 3px solid #ff40ac;
    border-radius: 12px;
    background: white;
    color: #222;
    cursor: pointer;
    transition:
        transform 0.15s ease,
        background 0.15s ease,
        opacity 0.15s ease;
}

button:hover:not(:disabled) {
    transform: scale(1.04);
    background: #fff0fa;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.map-location:disabled,
.twin-mountain-view [data-mountain-activity]:disabled {
    filter: grayscale(1);
}

/* =========================
   TOP BANNER
========================= */

.banner-container {
    width: 100%;
    margin: 0 auto;
    padding: 20px 0 0;
    line-height: 0;
}

#game-banner {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
}


/* =========================
   MAIN GAME
========================= */

.game {
    width: 1220px;
    max-width: calc(100% - 24px);
    margin: 28px auto;
}


/* =========================
   PET SELECTOR
========================= */

#pet-selector {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
}

#pet-selector > button {
    width: 100%;
    height: 100%;
    min-width: 0;
}

#pet-selector button:hover:not(:disabled) {
    background: #fff0fa;
}

#pet-selector .pet-selector-button.selected {
    background: #ff40ac;
    color: white;
}

.pet-selector-menu {
    position: absolute;
    z-index: 100;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    gap: 8px;
    min-width: 100%;
    box-sizing: border-box;
    justify-items: stretch;
    padding: 10px;
    border: 4px solid #ff40ac;
    border-radius: 18px;
    background: #feffe8;
    box-shadow: 0 6px 18px #4b2c3c33;
}

.pet-selector-menu[hidden] { display: none; }

.pet-selector-menu .pet-selector-button {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
    white-space: nowrap;
    text-align: center;
}

.top-navigation {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin: 8px 0 18px;
}


/* =========================
   TWO COLUMN LAYOUT
========================= */

.game-layout {
    display: grid;
    grid-template-columns: 600px 600px;
    gap: 20px;
    align-items: start;
}

.pet-dashboard {
    width: 600px;
}


/* =========================
   PET ROOM
========================= */

.room {
    width: 600px;
    min-height: 700px;

    background: #feffe8;
    border: 5px solid #ff40ac;
    border-radius: 30px;

    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;

    position: relative;
    overflow: hidden;

    padding: 14px 18px 18px;
}


/* =========================
   PET NAME
========================= */

#pet-name {
    width: 100%;

    background: #ff40ac;
    border: 4px solid #ff40ac;
    border-radius: 18px;

    padding: 9px;
    margin-bottom: 10px;

    font-size: 22px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 2px;
}


/* =========================
   PET
========================= */

#pet {
    position: relative;
    display: inline-block;

    flex-shrink: 0;
    cursor: pointer;

    transform-origin: center center;
    transition: transform 0.2s ease;

    margin: auto 0;
}

#pet:hover {
    transform: scale(1.08);
}

#pet img {
    display: block;

    width: 175px;
    max-width: none;
    height: auto;

    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}


/* =========================
   PET EFFECTS
========================= */

#food,
#heart,
#sleep,
#item-pop {
    position: absolute;

    font-size: 40px;
    display: none;

    pointer-events: none;
    /* Reactions should stay above every accessory, including user-added ones. */
    z-index: 1000;
}

#food {
    top: 20px;
    right: -20px;
}

#heart {
    top: 20px;
    left: -20px;
}

#sleep {
    top: 10px;
    right: -30px;
}

#item-pop {
    left: 50%;
    top: -18px;
    font-size: 44px;
    display: none;
    z-index: 1001;
    transform: translateX(-50%);
}

#food.show,
#heart.show,
#sleep.show {
    display: block;
}

#item-pop.show {
    display: block;
    animation: item-pop 1s ease-out forwards;
}

@keyframes item-pop {
    0% {
        opacity: 0;
        transform: translate(-50%, 12px) scale(0.65);
    }
    25% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1.15);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -28px) scale(0.9);
    }
}


/* =========================
   ACCESSORIES
========================= */

.pet-accessory-slot {
    position: absolute;

    left: 50%;
    top: 5px;

    width: 0;
    height: 0;
    transform: none;

    font-size: 45px;
    cursor: default;

    display: none;
    align-items: initial;
    gap: 0;

    z-index: 10;
    user-select: none;
    touch-action: none;
}

.pet-accessory-slot.show {
    display: block;
}

.accessory-copy {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    white-space: nowrap;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

body:not(.accessories-active) .accessory-copy {
    pointer-events: none;
    cursor: default;
}

.accessory-copy:active {
    cursor: grabbing;
}

.accessory-rotate-controls {
    position: absolute;
    display: none;
    grid-template-columns: repeat(2, 20px);
    gap: 2px;
    top: -21px;
    right: -9px;
    z-index: 2;
}

.accessory-copy.selected .accessory-rotate-controls {
    display: grid;
}

body:not(.accessories-active) .accessory-rotate-controls {
    display: none !important;
}

.accessory-rotate-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin: 0;
    padding: 0;
    border: 2px solid #ff40ac;
    border-radius: 6px;
    background: #fff;
    color: #a72b76;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    touch-action: none;
    user-select: none;
}

.accessory-remove-button {
    grid-column: 1 / -1;
    justify-self: center;
    background: #ffe3eb;
    color: #b4234a;
}

.accessory-copy img {
    display: block;
    width: 175px;
    height: 175px;
    object-fit: contain;
    pointer-events: none;
}

.accessory-copy[data-inventory-image-accessory="true"] img {
    width: 210px;
    height: 210px;
}

/* =========================
   PET REACTION
========================= */

#pet.pet-react {
    animation: pet-pop 0.35s ease;
}

#pet.pet-needs-zero {
    animation: pet-needs-zero-shake 0.2s linear infinite;
    transform-origin: center bottom;
}

@keyframes pet-needs-zero-shake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    20% { transform: translate(-8px, -2px) rotate(-7deg); }
    40% { transform: translate(7px, 1px) rotate(7deg); }
    60% { transform: translate(-6px, -1px) rotate(-6deg); }
    80% { transform: translate(8px, -2px) rotate(7deg); }
}

@keyframes pet-pop {

    0% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.12);
    }

    75% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
    }

}


/* =========================
   PET MESSAGE
========================= */

#message {
    width: 100%;

    background: #fff024;
    border: 3px solid #ff40ac;
    border-radius: 16px;

    padding: 10px;
    margin: 0 0 8px;

    font-size: 15px;
    min-height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow-wrap: anywhere;
}


/* =========================
   PET STATS
========================= */

.stats {
    width: 100%;

    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;

    margin-top: 0;
}

.stat-box {
    background: #ffe0f2;

    border: 3px solid #ff40ac;
    border-radius: 15px;

    padding: 9px 5px;
    min-width: 0;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    gap: 4px;
}

.stat-label {
    font-size: 11px;
    font-weight: bold;

    color: #a72b76;

    letter-spacing: 0.5px;
    white-space: nowrap;
}

.stat-box strong {
    font-size: 20px;
    color: #000;
}


/* =========================
   XP + COINS
========================= */

.progress-wallet-row {
    width: 100%;

    display: flex;
    align-items: stretch;

    gap: 8px;
    margin-top: 8px;
}

#xp-box {
    position: relative;
    flex: 1;
    min-height: 72px;
    overflow: hidden;
    background: #ff40ac;
    border: 3px solid #ff40ac;
    border-radius: 15px;
    padding: 0;
    margin-top: 0;
    font-size: 15px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

#xp-progress-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: #fff024;
    transition: width 300ms ease;
}

.xp-progress-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(254, 255, 232, 0.88);
    color: #222;
    text-align: center;
}

#xp-box strong {
    font-size: 17px;
}


/* =========================
   COIN WALLET
========================= */

#coin-wallet {
    flex: 0 0 190px;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;

    background: #ff40ac;
    border: 3px solid #ff40ac;
    border-radius: 15px;
    color: #fff;

    padding: 10px 14px;
    margin: 0;
}

.coin-icon {
    font-size: 32px;
}

.coin-wallet-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-align: center;
}

.coin-wallet-label {
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1.5px;
}

#coin-balance {
    font-size: 24px;
    line-height: 1.1;
    color: #fff;
}


/* =========================
   MAIN TABS
========================= */

#items-panel {
    width: 600px;
    margin-top: 0;
}

.main-tabs {
    display: contents;
}

.main-tab-button {
    flex: 1;
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;

    margin: 0;
    padding: 14px 8px;

    border: 4px solid #ff40ac;
    border-radius: 18px;

    background: #feffe8;
    color: #a72b76;

    font-size: 16px;
    font-weight: bold;
}

.main-tab-button.selected {
    background: #ff40ac;
    color: white;
}

.main-tab-content {
    display: none;
}

.main-tab-content.active {
    display: block;
}

#cloud-account-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px auto 0;
    color: #a72b76;
    font-size: 14px;
}

#cloud-account-open,
.cloud-auth-actions button {
    border: 3px solid #ff40ac;
    border-radius: 14px;
    background: #feffe8;
    color: #a72b76;
    padding: 8px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

#cloud-account-open:hover,
.cloud-auth-actions button:hover {
    background: #ff40ac;
    color: #fff;
}

#cloud-account-dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 5px solid #ff40ac;
    border-radius: 24px;
    background: #feffe8;
    color: #333;
    box-shadow: 0 12px 36px #4b2c3c55;
}

#cloud-account-dialog::backdrop {
    background: #24152688;
}

.cloud-account-dialog-content {
    position: relative;
    padding: 26px;
}

.cloud-account-dialog-content h2 {
    margin: 0 34px 10px 0;
    color: #ff40ac;
}

.cloud-account-dialog-content label {
    display: block;
    margin: 14px 0 5px;
    font-weight: 700;
}

.cloud-account-dialog-content input {
    box-sizing: border-box;
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #d87cab;
    border-radius: 10px;
    font: inherit;
}

.cloud-auth-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.cloud-dialog-close {
    position: absolute;
    top: 12px;
    right: 14px;
    border: 0;
    background: transparent;
    color: #a72b76;
    font-size: 28px;
    cursor: pointer;
}

.cloud-save-note {
    margin: 18px 0 0;
    color: #67515f;
    font-size: 13px;
    line-height: 1.4;
}

@media (max-width: 520px) {
    #cloud-account-controls {
        flex-direction: column;
    }
}


/* =========================
   INVENTORY
========================= */

#inventory {
    background: #feffe8;

    border: 5px solid #ff40ac;
    border-radius: 30px;

    padding: 20px;

    min-height: 600px;
}

#inventory h2,
#shop h2,
#world-map h2 {
    color: #ff40ac;
    font-size: 24px;
    margin: 0 0 6px;
}

.inventory-subtitle,
.shop-subtitle {
    margin: 0 0 15px;
    font-size: 14px;
    color: #555;
}

#inventory-items {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.inventory-item {
    width: 100%;
    min-width: 0;

    margin: 0;
    padding: 12px 4px;

    background: white;

    border: 3px solid #ff40ac;
    border-radius: 15px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    gap: 5px;

    font-size: 13px;
    overflow-wrap: anywhere;
}

.inventory-item .item-icon {
    font-size: 30px;
}

.inventory-item .item-icon img {
    display: block;
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.inventory-food-item .item-icon { font-size: 38px; }
.inventory-food-item .item-icon img { width: 52px; height: 52px; }

.inventory-item .item-name {
    font-weight: bold;
}

.inventory-item[role="button"] { cursor: pointer; }
.inventory-item[role="button"]:focus-visible { outline: 3px solid #a72b76; outline-offset: 2px; }

.inventory-item .item-quantity {
    font-size: 12px;
    color: #a72b76;
}

.inventory-item.has-quantity-badge {
    position: relative;
}

.inventory-quantity-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 1;
    min-width: 28px;
    padding: 2px 5px;
    border: 1px solid #ff40ac;
    border-radius: 12px;
    background: #fff0fa;
    color: #a72b76;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.inventory-mode-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    z-index: 2;
    display: grid;
    place-items: center;
    min-width: 28px;
    height: 20px;
    margin: 0;
    padding: 2px 5px;
    border: 1px solid #ff40ac;
    border-radius: 12px;
    background: #fff0fa;
    color: #a72b76;
    font-size: 11px;
    line-height: 1.2;
    cursor: pointer;
}

.inventory-mode-badge:hover:not(:disabled) { background: #ffd6ef; }
.inventory-mode-badge:disabled { opacity: 0.45; cursor: not-allowed; }

.inventory-item.equipped {
    background: #ffd6ef;
    border-style: dashed;
}

.accessory-assignment-counts {
    text-align: center;
    line-height: 1.3;
}

.accessory-assignment-controls {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #a72b76;
    font-size: 11px;
    font-weight: bold;
}

.accessory-change-button {
    min-width: 28px;
    margin: 0;
    padding: 2px 7px;
    border-width: 2px;
    font-size: 16px;
    line-height: 1.2;
}

#inventory-message {
    background: white;

    border: 2px solid #ff40ac;
    border-radius: 12px;

    padding: 10px;
    margin: 15px 0 0;

    font-size: 14px;
    min-height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    overflow-wrap: anywhere;
}


/* =========================
   SHOP
========================= */

#shop {
    background: #feffe8;

    border: 5px solid #ff40ac;
    border-radius: 30px;

    padding: 20px;
    min-height: 600px;
}

.shop-wallet {
    background: #fff0fa;

    border: 2px dashed #ff40ac;
    border-radius: 14px;

    padding: 10px;
    margin: 12px 0 15px;

    font-size: 15px;
}

.shop-tabs,
.inventory-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;

    gap: 6px;
    margin-bottom: 15px;
}

.shop-tabs button,
.inventory-tabs button {
    flex: 1 1 140px;

    margin: 0;
    padding: 10px 8px;

    font-size: 14px;
}

.shop-tabs button.selected,
.inventory-tabs button.selected {
    background: #ff40ac;
    color: white;
}

#shop-items,
#lemonberry-items {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;

    align-items: stretch;
}

.shop-item {
    position: relative;
    min-width: 0;

    background: white;

    border: 3px solid #ffc1e5;
    border-radius: 18px;

    padding: 14px 8px;

    display: flex;
    flex-direction: column;
    align-items: center;
}

.shop-item.owned {
    background: #fff5fb;
    border-style: dashed;
}

.shop-item-icon {
    font-size: 38px;
    margin-bottom: 4px;
}

.shop-item-icon img {
    display: block;
    width: 54px;
    height: 54px;
    object-fit: contain;
}

.shop-item h3 {
    font-size: 16px;
    margin: 5px 0;
    overflow-wrap: anywhere;
}

.shop-item p {
    font-size: 13px;
    color: #666;

    margin: 5px 0 12px;
    line-height: 1.4;
}

.shop-buy-button {
    width: 100%;

    margin: auto 0 0;
    padding: 10px 5px;

    font-size: 13px;
    overflow-wrap: anywhere;
}

.shop-buy-button:disabled {
    background: #f5e7ef;
}

.shop-quantity-button {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 42px;
    padding: 8px 12px;
    text-align: center;
}

.shop-quantity-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 28px;
    padding: 3px 6px;
    border: 2px solid #ff40ac;
    border-radius: 14px;
    background: #fff;
    color: #a51c69;
    font-size: 12px;
    font-weight: 700;
}

.shop-quantity-badge[hidden] { display: none; }

#shop-order-controls,
#lemonberry-order-controls {
    width: 100%;
    box-sizing: border-box;
    margin: 12px 0 0;
    padding: 12px 10px;
    border: 3px dotted #ff40ac;
    border-radius: 18px;
    background: #fff8fc;
    text-align: center;
}

#shop-order-total,
#lemonberry-order-total {
    margin: 2px 0 12px;
    font-weight: 700;
    text-align: center;
}

#shop-buy-selected-button,
#lemonberry-buy-selected-button {
    display: block;
    margin: 0 auto;
}

#shop-message,
#lemonberry-message {
    margin: 8px 0 0;
    font-size: 14px;
    text-align: center;
    overflow-wrap: anywhere;
}

#shop-message:empty,
#lemonberry-message:empty {
    display: none;
}

.shop-click-hint {
    margin: 8px 0 0;
    font-size: 13px;
    font-style: italic;
    text-align: center;
}

#collectible-shop-timer {
    margin: 10px 0;
    color: #8b2867;
    font-size: 13px;
    font-weight: bold;
    text-align: center;
}


