* {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background-image: url('/assets/images/generic-background.svg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: relative;
}

main {
    width: 100%;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4rem;
    box-sizing: border-box;
}

.header-section {
    position: fixed;
    top: 7rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    gap: 2rem;
    z-index: 100;
}

.header-section h1 {
    color: var(--color-navy);
    font-family: var(--font-title);
    font-weight: var(--title-weight);
    font-size: 2.5rem;
    margin: 0;
}

.user-stats {
    margin-top: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--color-white-shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 1rem;
    border: 1px solid var(--color-white);
}

.user-stats .level,
.user-stats .coins {
    color: var(--color-navy);
    font-family: var(--font-subtitle);
    font-weight: var(--subtitle-weight);
}

.user-stats .coin-icon {
    width: 1.2rem;
    height: 1.2rem;
}

.avatar-layers {
    position: relative;
    width: 100%;
    height: 100%;
}

.avatar-preview {
    width: min(35vw, calc(95vh * 3/5));
    aspect-ratio: 3/5;
}

.avatar-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/*Store components */
.store-container {
    position: relative;
    width: min(95vw, calc(90vh * 4/3));
    aspect-ratio: 4/3;
    margin-top: 0;
}

.store-part {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

.store-content {
    background: var(--color-white);
    opacity: 0.95;
    top: 13.303%;
    left: 9.7565%;
    width: 80.947%;
    height: 53.213%;
    z-index: 2;
    display: flex;
    flex-direction: row;
    padding-top: 5%;
    position: relative;
    overflow: hidden;
}

.store-back {z-index: 1;}
.store-base {z-index: 3;}
.store-roof {z-index: 4;}

/*layout components */
.layout-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    max-width: 1800px;
    align-items: flex-start;
    justify-content: center;
    position: relative;
    bottom: -10vh;
}

.display-section {
    overflow-y: auto;
    padding: 16px 16px 20% 10%;
    height: 70%;
    width: 90%;
    position: absolute;
}

/* Controls Section */
.controls-section {
    background: var(--color-white);
    opacity: 0.95;
    display: flex;
    flex-direction: column;
    position: absolute;
    height: calc(100% - 16px);
    width: 64px;
    z-index: 10;
    justify-content: center;
}

.category-tabs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    width: 64px;
}

.tab {
    padding: 8px;
    border: none;
    background: var(--color-white);
    opacity: 0.9;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-icon {
    width: 32px;
    height: 32px;
    filter: brightness(50%);
}

.tab:hover {
    background: var(--color-white-shadow);
    transform: translateY(-1px);
}

.tab.active {
    background: var(--color-navy-accent);
    transform: translateY(-1px);
}

.tab:hover .tab-icon {
    opacity: 0.4;
}

.tab.active .tab-icon {
    opacity: 0.8;
}

.owned-toggle {
    margin-bottom: 16px;
    border: none;
    background: var(--color-white);
    opacity: 0.9;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    color: var(--color-navy);
}

/* Items Section */
.item-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 24px;
    padding: 16px;
    margin: 0;
}

.item-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px;
    border-radius: 6px;
    background: var(--color-white);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.3s, background-color 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}

.item-card:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 8px var(color-black-shadow);
}

.item-card.equipped {
    border-color: var(--color-green);
    background-color: #f0fff4;
    opacity: 0.8;
    cursor: default;
    transform: none;
}

.item-card.equipped:hover {
    transform: none;
    box-shadow: none;
}

/* Purchase error message styling */
/* Only show error when user tries to buy without enough coins */
.item-card .purchase-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--color-red);
    color: var(--color-white);
    padding: 8px 16px;
    border-radius: 4px;
    animation: fadeInOut 2s ease-in-out;
    z-index: 10;
    font-size: 0.9em;
    font-weight: bold;
}

.item-image-container {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: 6px;
    background-color: var(--color-light-grey);
}

.item-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.item-name {
    font-family: var(--font-body);
    font-weight: var(--body-weight);
    font-size: 14px;
    text-align: center;
    margin: 4px 0;
}

.item-price, .item-status {
    font-size: 14px;
    padding: 4px 10px;
    border-radius: 12px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, color 0.3s;
}

.item-price {
    background-color: var(--color-light-grey);
    color: var(--color-grey);
}

.item-status {
    background-color: #e6f7ff;
    color: var(--color-navy);
}

.item-card.equipped .item-status {
    background-color: #d4edda;
    color: var(--color-green);
    font-weight: bold;
}

.coin-icon {
    width: 16px;
    height: 16px;
    margin-left: 4px;
}

.item-actions {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 4px;
}

.purchase-button, .equip-button {
    font-family: var(--font-subtitle);
    font-weight: var(--subtitle-weight);
    border: none;
    border-radius: 14px;
    font-size: 14px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s, color 0.2s;
}

.purchase-button {
    background-color: var(--color-yellow);
    color: var(--color-black);
}

.purchase-button:hover {
    background-color: #ffca2c;
    transform: translateY(-1px);
}

.purchase-button:active {
    transform: translateY(0);
}

.equip-button {
    background-color: var(--color-navy);
    color: var(--color-white);
}

.equip-button:hover {
    background-color: var(--color-navy-accent);
    transform: translateY(-1px);
}

.equip-button:active {
    transform: translateY(0);
}

/* hide equipped buttons for non-hat/shoe items (they can't be unequipped) */
.item-card:not([data-category="hats"]):not([data-category="shoes"]) .equip-button.equipped {
    display: none;
}

.equip-button.equipped {
    background-color: var(--color-red);
}

.equip-button.equipped:hover {
    background-color: var(--color-red);
}

/*Mobile alterations */
@media (orientation: portrait) {
    .header-section {
        flex-direction: column;
        align-items: center;
        top: 5rem;
        padding: 0 1rem;
    }

    .header-section h1 {
        font-size: 2rem;
    }

    .avatar-preview {
        width: min(60vw, calc(45vh * 3/5));
        z-index: 10;
        margin-bottom: -16vh;
    }

    .store-container {
        width: 100vw;
        aspect-ratio: 1406/1966;
        margin-top: 0;
        z-index: 5;
        position: relative;
    }

    .store-content {
        left: calc(120 / 1406 * 100%);
        top: calc(320.83 / 1965.78 * 100%);
        width: calc(1166 / 1406 * 100%);
        height: calc(1275.96 / 1965.78 * 100%);
    }

    .store-back { content: url('/assets/pages/store/market/mobile-store-back.svg'); }
    .store-base { content: url('/assets/pages/store/market/mobile-store-base.svg'); }
    .store-roof { content: url('/assets/pages/store/market/mobile-store-roof.svg'); }

    .layout-wrapper {
        flex-direction: column;
        gap: 10px;
    }

    .item-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }
}

/* Footer */
.site-footer {
    bottom: 0;
    padding-top: 5rem;
}

