/* Custom Pixel Font */
@font-face {
    font-family: 'Retro Gaming';
    src: url('assets/fonts/Retro Gaming.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: '04b_30';
    src: url('assets/fonts/04B_30__.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@keyframes logo-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.logo-text {
    font-family: '04b_30', 'Retro Gaming', monospace;
    font-size: 64px;
    color: #ffd700;
    text-shadow: 4px 4px 0px #b8860b, 6px 6px 0px #000000;
    margin-bottom: 20px;
    letter-spacing: 4px;
}

.logo-text span {
    display: inline-block;
    animation: logo-bounce 2.5s infinite ease-in-out;
}

.logo-text span:nth-child(1) {
    animation-delay: 0.1s;
}

.logo-text span:nth-child(2) {
    animation-delay: 0.3s;
}

.logo-text span:nth-child(3) {
    animation-delay: 0.7s;
}

.logo-text span:nth-child(4) {
    animation-delay: 0.2s;
}

.logo-text span:nth-child(5) {
    animation-delay: 0.5s;
}

.logo-text span:nth-child(6) {
    animation-delay: 0.8s;
}

.logo-text span:nth-child(7) {
    animation-delay: 0.4s;
}

.logo-text span:nth-child(8) {
    animation-delay: 0.6s;
}

:root {
    /* DEFAULT: Midnight Gold Theme */
    --bg-tan: #211426;
    --bg-light-tan: #2d1b33;
    --border-dark-brown: #ffd700;
    --border-light-brown: #b8860b;
    --border-highlight: #fff3ab;
    --text-dark: #ffffff;
    --text-main: #ffffff;
    --text-brown: #ffd700;
    --accent-green: #4ade80;
    --accent-blue: #3b82f6;
    --pixel-border: 4px;
    --primary: #ffd700;
    --text-muted: #94a3b8;

    /* Panel Specific Midnight */
    --panel-shadow: 0 0 0 4px #000000, 0 0 30px rgba(255, 215, 0, 0.2), inset 0 0 20px rgba(0, 0, 0, 0.5);
    --inner-shadow-depth: inset 0 0 10px rgba(0, 0, 0, 0.5);

    /* Button/Input Specific Midnight */
    --btn-text: #211426;
    --btn-border: #b8860b;
    --btn-shadow: 0 4px 0px #000;
    --btn-inner: 0 0 0 0 transparent;

    --secondary-btn-bg: #2d1b33;
    --secondary-btn-text: #ffffff;

    --input-bg: #200b14;
    --input-shadow: 0 0 0 1px #cc6f4152, inset 2px 2px 0 0 #564102, inset -2px -2px 0 0 #9A6E1B;

    --bg-paper: #2d1b33;
}

.theme-classic {
    /* Classic Tan Theme */
    --bg-tan: #F6E16D;
    --bg-light-tan: #E7D09F;
    --border-dark-brown: #D5A722;
    --border-light-brown: #F6E16D;
    --border-highlight: #EDE3B3;
    --text-dark: #E54453;
    --text-main: #E54453;
    --text-brown: #B49F40;
    --accent-green: #66BB6A;
    --accent-blue: #D5A722;
    --pixel-border: 4px;
    --primary: #10b981;
    --text-muted: #64748b;

    /* Panel Specific Classic */
    --panel-shadow: 0 0 0 1px var(--border-dark-brown), inset 3px 3px 0 0 var(--border-highlight), inset -3px -3px 0 0 var(--border-light-brown);
    --inner-shadow-depth: inset 2px 2px 0 0 #9d7a54, inset -2px -2px 0 0 var(--border-highlight);

    /* Button Specific Classic */
    --btn-text: #ffffff;
    --btn-border: #065f46;
    --btn-shadow: 2px 2px 0px #000;
    --btn-inner: inset 2px 2px 0 0 rgba(255, 255, 255, 0.4);

    --secondary-btn-bg: #F6E16D;
    --secondary-btn-text: #7b4433;

    --input-bg: #ffffff;
    --input-shadow: inset 2px 2px 0 0 rgba(0, 0, 0, 0.1);

    --bg-paper: #ffffff;
}

/* Global Pixel Art Styling */
* {
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

body {
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background-color: #020617;
    font-family: 'Retro Gaming', monospace;
    color: var(--text-main);

    /* Global non-selectable UI */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Re-enable selection for inputs */
input,
textarea {
    user-select: text;
    -webkit-user-select: text;
}

/* Admin Glow Animation */
.admin-glow {
    animation: admin-glow 1.5s ease-in-out infinite alternate;
    text-shadow: 0 0 5px #b3006e, 0 0 10px #ff6aa8, 0 0 15px #fa1574, 0 0 20px #fa155a;
}

@keyframes admin-glow {
    from {
        text-shadow: 0 0 2px #4e133c, 0 0 4px #4e133c, 0 0 6px #4e133c, 0 0 8px #4e133c, 0 0 10px #4e133c;
    }

    to {
        text-shadow: 0 0 4px #4e133c, 0 0 8px #4e133c, 0 0 12px #4e133c, 0 0 16px #4e133c, 0 0 20px #4e133c, 0 0 24px #4e133c;
    }
}

/* Remove all smooth transitions globally for instant pixel feel */
*,
*::before,
*::after {
    transition: none !important;
}

/* Stardew-style 3D Panel - Creates beveled look */
.stardew-panel {
    background: var(--bg-tan);
    border: var(--pixel-border) solid var(--border-dark-brown);
    box-shadow: var(--panel-shadow);
}

/* Orientation Overlay - Mobile Only & Blocking */
#orientation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #020617;
    z-index: 999999;
    /* Ensure it's above everything */
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    padding: 20px;
    box-sizing: border-box;
    flex-direction: column;
    pointer-events: auto;
    /* Block clicks to layers below */
}

/* --- Collection System Support --- */
#collection-overlay {
    z-index: 1200;
    pointer-events: all;
    backdrop-filter: blur(4px);
    background: rgba(0, 0, 0, 0.4);
}

.collection-scroll-box {
    background: var(--bg-tan);
    border: 4px solid var(--border-dark-brown);
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    height: 450px;
    box-shadow: var(--inner-shadow-depth);
    margin: 15px 0;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.collection-item {
    background: var(--bg-light-tan);
    border: 3px solid var(--border-dark-brown);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    position: relative;
    box-shadow: var(--inner-shadow-depth);
    cursor: pointer;
    transition: transform 0.1s;
}

.collection-item:hover {
    transform: translateY(-1px);
    background: #f8fafc;
}

.collection-item:active {
    transform: translateY(0);
}

.collection-item img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin-bottom: 5px;
    image-rendering: pixelated;
}

.collection-item.locked img {
    filter: grayscale(100%) contrast(0) brightness(0.4);
    opacity: 0.6;
}

.collection-item .item-name {
    font-size: 0.5rem;
    margin-top: 4px;
    color: var(--text-dark);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.collection-item.locked .item-name {
    color: #64748b;
}

.collection-category-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;

    padding-bottom: 5px;
}

.collection-cat-tab {
    background: var(--bg-tan);

    color: var(--text-dark);
    padding: 5px 10px;
    font-size: 0.6rem;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
}

.collection-cat-tab.active {
    background: var(--primary);
    color: var(--btn-text);
}

/* Show only on touch devices in portrait ONCE IN GAME (login & character
   creator work in any orientation, so the landscape requirement must not
   block them). */
@media (pointer: coarse) and (orientation: portrait) {
    body.in-game #orientation-overlay {
        display: flex;
    }
}

/* Also show on small screens in portrait once in game */
@media (max-width: 900px) and (orientation: portrait) {
    body.in-game #orientation-overlay {
        display: flex;
    }
}

.orientation-content {
    animation: pulse 2s infinite;
}

.rotate-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

#orientation-overlay h2 {
    font-family: '04b_30', sans-serif;
    color: #ffd700;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

#orientation-overlay p {
    font-size: 1rem;
    color: #94a3b8;
    max-width: 300px;
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #020617;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease;
}

.loading-content {
    text-align: center;
    width: 300px;
}

.loading-logo {
    margin-bottom: 2rem;
    /*animation: pulse 2s infinite;*/
    display: flex;
    justify-content: center;
}

.loading-logo img {
    width: 64px;
    height: 64px;
    object-fit: contain;
}

.loading-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

#loading-text {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #000c41 0%, #020617 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

#confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 6000;
    /* Extremely high z-index */
    pointer-events: auto;
}

#confirmation-modal.visible {
    display: flex;
}

.login-box {
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 4px;
    text-align: center;
    background: #2d1b33;
    border: 4px solid #ffd700;
    padding: 2rem;
    color: #FFF;
    font-size: 0.6rem;
    font-family: 'Retro Gaming', monospace;
    box-shadow:
        0 0 0 4px #000000,
        0 0 20px rgba(255, 215, 0, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    width: 350px;
    position: relative;
}

.login-box h1 {
    color: #ffffff;
    font-family: 'Retro Gaming', monospace;
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    text-shadow: 2px 2px 0 #000000;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#character-creator-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #85670c 0%, #634c09 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1500;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.creator-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.creator-preview {
    width: 128px;
    height: 128px;
    background: #D4BA8E;
    border: 3px solid var(--border-dark-brown);
    box-shadow: inset 4px 4px 0 0 var(--border-highlight), inset -4px -4px 0 0 var(--border-light-brown);
    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
}

.creator-preview canvas {
    width: 128px;
    height: 128px;
    image-rendering: pixelated;
}

.creator-options {
    width: 100%;
}

.creator-option {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.creator-option label {
    font-size: 0.7rem;
    color: var(--text-dark);
}

#creator-color-input {
    width: 100%;
    height: 40px;
    border: 3px solid var(--border-dark-brown);
    background: var(--bg-tan);
    cursor: pointer;
    box-sizing: border-box;
    padding: 2px;
}

.face-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-tan);
    border: 3px solid var(--border-dark-brown);
    padding: 5px;
}

.face-selector button {
    padding: 5px 10px;
    background: var(--secondary-btn-bg);
    border: 2px solid var(--border-dark-brown);
    cursor: pointer;
    color: var(--secondary-btn-text);
    font-family: inherit;
    font-size: 0.8rem;
    box-shadow: var(--btn-shadow);
}

.face-selector button:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

#face-display {
    flex: 1;
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-dark);
}


input {
    background: var(--input-bg);
    border: 2px solid var(--border-dark-brown);
    border-radius: 0.3rem;
    padding: 0.4rem 0.75rem;
    color: var(--text-main);
    font-size: 1rem;
    font-family: 'Retro Gaming', monospace;
    box-shadow: var(--input-shadow);
    width: 100%;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
    margin-bottom: 1rem;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

button {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    border: 2px solid var(--btn-border);
    border-radius: 0.3rem;
    color: var(--btn-text);
    cursor: pointer;
    font-family: 'Retro Gaming', monospace;
    box-shadow: var(--btn-shadow), var(--btn-inner);
    transition: transform 0.1s, background 0.2s;
}

button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

.error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 1rem;
    min-height: 1.25rem;
}

#game-container {
    display: grid;
    position: relative;
    width: fit-content;
    /* Shrink to fit the columns */
    height: auto;
    margin: 40px auto;
    transform-origin: top center;

    /* Unified Frame Border with Enhanced Bevel */
    background: var(--border-dark-brown);
    border: 4px solid var(--border-dark-brown);
    box-shadow:
        /* External light highlight (top-left) */
        -4px -4px 0 0 var(--border-highlight),
        /* External dark shadow (bottom-right) */
        4px 4px 0 0 #564102,
        /* Main structural border reinforcement */
        0 0 0 4px var(--border-dark-brown),
        /* Inner Bevels */
        inset 4px 4px 0 0 var(--border-highlight),
        inset -4px -4px 0 0 var(--border-light-brown);
    border-radius: 8px;
    overflow: hidden;

    /* Grid Layout */
    grid-template-columns: clamp(200px, 15vw, 300px) 50vw clamp(200px, 15vw, 300px);
    grid-template-rows: auto auto;
    grid-template-areas:
        "left game side"
        "left bar  side";
}

#game-view canvas {
    display: block;
    margin: 0 auto;
    image-rendering: pixelated;
    /* Safari/Chrome */
    image-rendering: crisp-edges;
    /* Firefox */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

#game-view {
    grid-area: game;
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #000;
    margin: 0;
    touch-action: none;
}

/* Large screens (wider than 1920px): let the game column grow beyond 50vw so the
   game scales up, up to a cap (1600px or sized to the viewport height). The frame
   keeps hugging the game (width: fit-content), so panels sit right next to it with
   no dead space inside the frame. */
@media (min-width: 1921px) {
    #game-container {
        grid-template-columns:
            clamp(200px, 15vw, 300px)
            minmax(min(50vw, 960px), min(1600px, calc((100dvh - 120px) * 16 / 9)))
            clamp(200px, 15vw, 300px);
    }
}

#left-panel {
    grid-area: left;
    height: 100%;
    /* Fill the grid height */
    background: var(--bg-tan);
    /* Internal Separator */
    border-right: 3px solid var(--border-dark-brown);
    box-sizing: border-box;
    padding: clamp(0.3rem, 0.5vw, 0.75rem);
    display: flex;
    flex-direction: column;
}

#side-panel {

    grid-area: side;
    height: 100%;
    /* Fill the grid height */
    background: var(--bg-tan);
    /* Internal Separator */
    border-left: 3px solid var(--border-dark-brown);
    box-sizing: border-box;
    padding: clamp(0.3rem, 0.5vw, 0.75rem);
    display: flex;
    flex-direction: column;
}

#player-info {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

#player-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: clamp(0.5rem, 0.8vw, 0.7rem);
    color: var(--text-dark);
    text-align: center;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.4rem;
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    box-shadow: var(--btn-inner);
}

#player-info-content {
    flex: 1;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.4);
    /* Fallback color */
    background-repeat: repeat;
    background-size: auto;
    image-rendering: pixelated;
    padding: 0.5rem;
    border: 2px solid var(--border-dark-brown);
    border-radius: 3px;
    box-shadow: inset 2px 2px 0 0 #9d7a54, inset -2px -2px 0 0 var(--border-highlight);

    /* Allow selection in profile */
    user-select: text;
    -webkit-user-select: text;
}

.player-info-card {
    display: flex;
    flex-direction: column;
    /* align-items: center;  Removed to allow left alignment */
    align-items: stretch;
    gap: 0.75rem;
}

.player-header-flex {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 5px;
}

.player-info-right-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
}

.player-info-sprite {
    width: 64px;
    height: 64px;
    background: #D4BA8E;
    border: 3px solid var(--border-dark-brown);
    border-radius: 8px;
    position: relative;
    box-shadow: inset 2px 2px 0 0 rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.player-info-sprite canvas {
    image-rendering: pixelated;
    display: block;
    position: relative;
    z-index: 1;

}

img.profile-frame-img,
div.profile-frame-img {
    position: absolute;
    top: 54%;
    left: 54%;
    transform: translate(-50%, -50%);
    width: 106px;
    height: 106px;
    z-index: 10;
    pointer-events: none;
    image-rendering: pixelated;
}

div.profile-frame-img.animated {
    background-repeat: no-repeat;
}

@keyframes profile-frame-anim {
    from {
        background-position: 0% 0%;
    }

    to {
        background-position: 100% 0%;
    }
}

.player-info-name {
    font-size: 0.6rem;
    font-weight: normal;
    color: var(--text-dark);
    text-align: center;
}

.player-info-details {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem;
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    box-shadow: inset 1px 1px 0 0 var(--border-highlight), inset -1px -1px 0 0 var(--border-light-brown);
    font-size: clamp(0.5rem, 0.7vw, 0.6rem);
}

.player-info-label {
    color: var(--text-brown);
    font-weight: normal;
}

.player-info-value {
    color: var(--text-dark);
    font-weight: normal;
}


.player-info-close {
    margin-top: 0.8rem;
    padding: 0.5rem;
    background: rgba(239, 68, 68, 0.8);
    border: 3px solid #ef4444;
    color: #ffffff;
    cursor: pointer;
    font-size: 0.55rem;
    font-weight: normal;
    font-family: 'Retro Gaming', monospace;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.8),
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.player-info-close:hover {
    background: rgba(239, 68, 68, 1);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.8),
        inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}



#chat-interface {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

#chat-interface h3 {
    margin: 0 0 0.5rem 0;
    font-size: clamp(0.5rem, 0.8vw, 0.7rem);
    color: var(--text-dark);
    text-align: center;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.4rem;
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    box-shadow: var(--btn-inner);
}

#bottom-bar {
    grid-area: bar;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: var(--bg-light-tan);
    /* Top border to separate from game visual */
    border-top: 3px solid var(--border-dark-brown);
    box-sizing: border-box;
    padding: 8px 15px;
    margin: 0;
    pointer-events: auto;
}

#coin-display {
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 2px;
    padding: 0.4rem 0.8rem;
    color: var(--text-dark);
    font-weight: normal;
    font-size: 0.8rem;
    box-shadow: var(--btn-inner);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#top-controls {
    display: flex;
    gap: 0.8rem;
    align-items: center;
}



#top-controls button {
    width: auto;
    padding: 0.6rem 1rem;
    font-size: 0.6rem;
    background: var(--primary);
    border: 2px solid var(--btn-border);
    color: var(--btn-text);
    cursor: pointer;
    font-family: 'Retro Gaming', monospace;
    box-shadow:
        var(--btn-shadow),
        var(--btn-inner);
    transition: transform 0.1s, background 0.2s;
}

#top-controls button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    /* Consistent rounding */
    box-shadow:
        0 2px 0 0 rgba(0, 0, 0, 0.1),
        inset 1px 1px 0 0 var(--border-highlight),
        inset -1px -1px 0 0 var(--border-light-brown);
    font-size: 0.8rem;
    transition: all 0.1s ease;
}

.shop-item:hover {
    background: var(--bg-light-tan);
    transform: translateX(1px);
    /* Slight slide interaction */
    box-shadow:
        0 2px 0 0 rgba(0, 0, 0, 0.15),
        inset 1px 1px 0 0 #ffffff,
        inset -1px -1px 0 0 var(--border-light-brown);
}

.shop-card {
    background: var(--bg-tan);
    border: var(--pixel-border) solid var(--border-dark-brown);
    border-radius: 6px;
    padding: 5px;
    box-shadow: var(--inner-shadow-depth);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    min-height: 110px;
    transition: transform 0.1s ease;
    pointer-events: auto;
    /* Ensure clickable */
}

#backpack-list .shop-card {
    min-height: auto;
    gap: 0;
}

.shop-card:hover {
    background: var(--bg-light-tan);
    transform: translateY(-1px);
    box-shadow:
        0 4px 0 0 rgba(0, 0, 0, 0.2),
        inset 2px 2px 0 0 #ffffff,
        inset -2px -2px 0 0 var(--border-light-brown);
}

.shop-card-icon {
    width: 100%;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2px;
    position: relative;
}

.shop-card-details {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.shop-card-name {
    font-size: 8px;
    color: var(--text-dark);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.shop-card-price {
    font-size: 8px;
    color: var(--text-brown);
}

.shop-card button {
    width: 100%;
    padding: 4px 0;
    font-size: 8px;

    background: var(--accent-green);
    border: 1px solid #558B2F;
    border-radius: 2px;
    color: white;
    font-family: 'Retro Gaming', monospace;
    cursor: pointer;
    box-shadow:
        0 2px 0 0 #3E7C17,
        inset 1px 1px 0 0 #9CCC65;
    margin-bottom: 2px;
}

.shop-card button:hover {
    background: #689F38;
    transform: translateY(1px);
    box-shadow: 0 1px 0 0 #3E7C17;
}

.shop-card button:active {
    transform: translateY(2px);
    box-shadow: none;
}

.shop-item:last-child {
    margin-bottom: 0;
}

.shop-item button {
    width: auto;
    padding: 0.5rem 0.8rem;
    font-size: 0.55rem;
    background: var(--accent-green);
    border: 1px solid #558B2F;
    border-radius: 2px;
    color: white;

    font-weight: normal;
    font-family: 'Retro Gaming', monospace;
    cursor: pointer;
    box-shadow:
        0 0 0 1px #3E7C17,
        inset 2px 2px 0 0 #9CCC65,
        inset -2px -2px 0 0 #558B2F;
}

.shop-item button:hover {
    background: #689F38;
    box-shadow:
        0 0 0 1px #3E7C17,
        inset 2px 2px 0 0 #AED581,
        inset -2px -2px 0 0 #558B2F;
}

#pet-items .shop-item button {
    background: var(--primary);
}

#pet-items .shop-item b {
    font-size: 0.8rem;
    padding-left: 0.5rem;
}

#pet-overlay .wardrobe-box {
    padding-bottom: 70px;
}



/* Shop Items Scrollable Container */
/* Shop Items Grid Container */
#shop-items,
#inventory-list,
.shop-items {
    height: 220px;
    /* Shorter for compact bottom layout */
    overflow-y: scroll;
    overflow-x: hidden;
    /*margin: 0.75rem 0;*/
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.3);

    /* Grid Layout */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 0.5rem;
    align-content: start;
}

/* Allow shop list to take full width */
#shop-items:has(.shop-item) {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Custom Scrollbar for shop */
#shop-items::-webkit-scrollbar,
.shop-items::-webkit-scrollbar {
    width: 10px;
}

#shop-items::-webkit-scrollbar-track,
.shop-items::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

#shop-items::-webkit-scrollbar-thumb,
.shop-items::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.6);
    border-radius: 5px;
}

#shop-items::-webkit-scrollbar-thumb:hover,
.shop-items::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.8);
}

/* Unified Inventory and Shop Overlays */
#shop-overlay,
#inventory-overlay,
#notification-overlay,
#disconnect-overlay,
#shop-overlay,
#inventory-overlay,
#notification-overlay,
#disconnect-overlay,
#pet-overlay,
#wardrobe-overlay,
#settings-overlay,
#backpack-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Ensure full height for anchoring */
    background: transparent;
    display: flex;
    align-items: flex-end;
    /* Anchored to bottom */
    justify-content: center;
    z-index: 2500;
    padding-bottom: 0;
    pointer-events: none;

    /* Transition setup */
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}



#inventory-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 3000;
}

#shop-overlay.visible,
#notification-overlay.visible,
#disconnect-overlay.visible,
#pet-overlay.visible,
#settings-overlay.visible,
#backpack-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#context-menu,
#portal-menu {
    position: absolute;
    background: var(--bg-tan);
    border: 3px solid var(--border-dark-brown);
    box-shadow:
        0 4px 0 0 rgba(0, 0, 0, 0.2),
        inset 2px 2px 0 0 var(--border-highlight),
        inset -2px -2px 0 0 var(--border-light-brown);
    border-radius: 4px;
    padding: 2px;
    display: flex;
    flex-direction: column;
    z-index: 2000;
    pointer-events: auto;
    min-width: 120px;
}

#ctx-header {
    padding: 8px 10px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-brown);
    font-family: 'Retro Gaming', monospace;
    font-size: 10px;
    text-align: center;
    border-bottom: 2px solid var(--border-light-brown);
    margin-bottom: 2px;
    font-weight: bold;
    text-transform: uppercase;
}

.theme-classic #ctx-header {
    background: var(--bg-light-tan);
    color: var(--text-dark);
    border-bottom: 2px solid var(--border-dark-brown);
}

.theme-classic #context-menu button {
    color: #7b4433;
}

#context-menu button,
#portal-menu button {
    background: transparent;
    border: none;
    text-align: left;
    padding: 6px 10px;
    width: 100%;
    font-family: 'Retro Gaming', monospace;
    font-size: 11px;
    color: var(--text-brown);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

#context-menu button:hover,
#portal-menu button:hover {
    background: rgba(0, 0, 0, 0.05);
}

#context-menu #ctx-pickup {
    color: #ef4444;
}

#context-menu #ctx-cancel,
#portal-menu #portal-cancel {
    color: #64748b;
    border-top: 2px solid var(--border-light-brown);
    margin-top: 2px;
}


.shop-box,
.notification-box {
    background: var(--bg-light-tan);
    padding: 1.5rem;
    border: var(--pixel-border) solid var(--border-dark-brown);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    box-shadow: var(--panel-shadow);
    width: clamp(280px, 90%, 500px);
    max-height: 65vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: -30px;
    /* Force overlap with bottom bar */
    padding-bottom: 36px;
    /* Ensure close button is visible */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#inventory-overlay.visible .shop-box,
#shop-overlay.visible .shop-box,
#notification-overlay.visible .notification-box,
#disconnect-overlay.visible .notification-box,
#pet-overlay.visible .shop-box,
#backpack-overlay.visible .shop-box {
    transform: scale(1) translateY(0);
    pointer-events: auto;
    /* CRITICAL: Re-enable interaction */
}

.shop-box h2 {
    margin: 0 0 0.5rem 0;
    font-size: 0.6rem;
    color: var(--text-dark);
    text-align: center;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.4rem;
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    box-shadow: inset 2px 2px 0 0 var(--border-highlight), inset -2px -2px 0 0 #9d7a54;
    flex-shrink: 0;
}

.shop-box>button {
    margin-top: 5px;
    margin-bottom: 2px;
    padding: 0.3rem 0.6rem;
    font-size: 0.5rem;
    background: #FF3636;
    border: 1px solid #D52222;
    border-radius: 4px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    font-family: 'Retro Gaming', monospace;
    cursor: pointer;
    box-shadow:
        0 0 0 1px #D5223B,
        inset 2px 2px 0 0 #FF697E,
        inset -2px -2px 0 0 #B5343A;
}

.shop-box>button:hover {
    background: #d23b3b;
    box-shadow:
        0 0 0 1px #D5223B,
        inset 2px 2px 0 0 #B5343A,
        inset -2px -2px 0 0 #FF697E;
}

.notification-box {
    text-align: center;
}

.notification-box h2 {
    margin-top: 0;
    color: var(--primary);
}

.notification-box p {
    margin: 1.5rem 0;
    color: var(--text-main);
    line-height: 1.5;
}

/* Enable pointer events on actual UI elements */
#chat-container,
#chat-log,
#coin-display,
#top-controls,
#shop-overlay,
#inventory-bar,
#context-menu,
#portal-menu,
#notification-overlay,
#pet-overlay,
#treasure-chest-overlay,
#emote-bar,
#backpack-overlay {
    pointer-events: auto;
}

#chat-input {
    background: #64542C;
    border: 3px solid #66360B;
    padding: 0.4rem 0.75rem;
    color: #FFF;
    font-size: 0.6rem;
    font-family: 'Retro Gaming', monospace;
    box-shadow:
        0 0 0 1px #cc6f4152, inset 2px 2px 0 0 #564102, inset -2px -2px 0 0 #9A6E1B;
    width: 100%;
    box-sizing: border-box;
}

#chat-log {
    background: var(--bg-light-tan);
    padding: 0.4rem;
    height: 300px;
    margin-bottom: 5px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    /* justify-content: flex-end; Removed to prevent scroll clipping */
    border: 2px solid var(--border-dark-brown);
    border-radius: 3px;
    box-shadow: inset 2px 2px 0 0 #9d7a54, inset -2px -2px 0 0 var(--border-highlight);

    /* Allow selection in chat */
    user-select: text;
    -webkit-user-select: text;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Push messages to bottom when few, allow scroll when many */
#chat-log> :first-child {
    margin-top: auto;
}



.chat-message {
    color: rgb(0, 0, 0);
    font-family: 'Retro Gaming', monospace;
    font-weight: normal;
    margin-bottom: 0.3rem;
    /* Reduced from 0.5rem */
    font-size: 0.8rem;
    /* Reduced from 0.9rem */
    line-height: 1.3;

    display: flex;
    align-items: center;
}

.chat-emote {
    width: 24px;
    height: 24px;
    display: inline-block;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
    margin-left: 5px;
    image-rendering: auto;
}

#emote-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 5px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    border-radius: 2px;
    /* overflow-x: auto; */
}

.emote-btn {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: none;
    border-radius: 4px;
    background-color: transparent;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
    transition: transform 0.1s;
    padding: 0;
    image-rendering: auto;

}

/* Hover effect is defined after individual images to ensure precedence */

/* Individual Emote Images */
.emote-btn:nth-child(1) {
    background-image: url('assets/emotes/Heart.png');
}

.emote-btn:nth-child(2) {
    background-image: url('assets/emotes/angry.png');
}

.emote-btn:nth-child(3) {
    background-image: url('assets/emotes/cheeks.png');
}

.emote-btn:nth-child(4) {
    background-image: url('assets/emotes/happy.png');
}

.emote-btn:nth-child(5) {
    background-image: url('assets/emotes/hmm.png');
}

.emote-btn:nth-child(6) {
    background-image: url('assets/emotes/sad.png');
}

.emote-btn:nth-child(7) {
    background-image: url('assets/emotes/skull.png');
}

.emote-btn:nth-child(8) {
    background-image: url('assets/emotes/tounge.png');
}

.emote-btn:hover {
    transform: scale(1.2);
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-color: transparent;
}

/* Helper classes for chat log rendering */
.emote-0 {
    background-image: url('assets/emotes/Heart.png');
}

.emote-1 {
    background-image: url('assets/emotes/angry.png');
}

.emote-2 {
    background-image: url('assets/emotes/cheeks.png');
}

.emote-3 {
    background-image: url('assets/emotes/happy.png');
}

.emote-4 {
    background-image: url('assets/emotes/hmm.png');
}

.emote-5 {
    background-image: url('assets/emotes/sad.png');
}

.emote-6 {
    background-image: url('assets/emotes/skull.png');
}

.emote-7 {
    background-image: url('assets/emotes/tounge.png');
}

.chat-message b {
    color: #000000;
    margin-right: 0.5rem;
}

/* Custom Scrollbar */
#chat-log::-webkit-scrollbar {
    width: 8px;
}

#chat-log::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

#chat-log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Dialogue Overlay */
#dialogue-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    z-index: 2600;
    /* Above shop */
    pointer-events: auto;
}

.dialogue-choice-btn {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 10px 15px;
    background: #4ade80;
    border: 2px solid #166534;
    border-radius: 6px;
    color: #064e3b;
    font-family: 'Retro Gaming', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: center;
    transition: transform 0.1s, background 0.2s;
    box-shadow: inset 1px 1px 0 0 rgba(255, 255, 255, 0.4), 2px 2px 0 0 rgba(0, 0, 0, 0.2);
}

.dialogue-choice-btn:hover {
    background: #86efac;
    transform: scale(1.02);
}

.dialogue-choice-btn:active {
    transform: scale(0.98);
    box-shadow: inset -1px -1px 0 0 rgba(255, 255, 255, 0.4);
}

/* Toast System */
#toast-container {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    z-index: 9999;
    /* Above everything in game-view */
    pointer-events: none;
    max-width: 300px;
}

.toast {
    background: #3e2723;
    /* Darker brown for pixel feel */
    color: #fff;
    padding: 10px 16px;
    font-family: 'Retro Gaming', monospace;
    font-size: 11px;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;

    /* Pixel Border */
    border: 3px solid #1a0f0d;
    box-shadow:
        inset 2px 2px 0 0 rgba(255, 255, 255, 0.1),
        inset -2px -2px 0 0 rgba(0, 0, 0, 0.3),
        4px 4px 0 0 rgba(0, 0, 0, 0.2);

    animation: toast-slide-in 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
    position: relative;
}

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.toast-fade-out {
    animation: toast-slide-out 0.4s ease forwards;
}

@keyframes toast-slide-out {
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(30px);
    }
}

.shop-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.shop-item-sprite {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    padding: 2px;
}

#wardrobe-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 60%;
    height: 100%;
    z-index: 2700;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

#wardrobe-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.wardrobe-box {
    background: var(--bg-light-tan);
    border: var(--pixel-border) solid var(--border-dark-brown);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 1.5rem;
    box-shadow: var(--panel-shadow);
    width: 90%;
    max-height: 50vh;
    overflow-y: hidden;
    transform: translateY(30px);
    margin-bottom: -30px;
    padding-bottom: 40px;
    /* Unified padding */
}

#wardrobe-overlay.visible .wardrobe-box,
#shop-overlay.visible .shop-box,
#pet-overlay.visible .shop-box,
#inventory-overlay.visible .shop-box,
#settings-overlay.visible .settings-box,
#home-settings-overlay.visible .settings-box {
    transform: translateY(0);
}

#home-settings-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2700;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    /* Add semi-transparent backdrop */
}

#home-settings-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#cash-shop-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2700;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cash-shop-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

#cash-shop-overlay.visible .wardrobe-box {
    transform: translateY(0);
    /* Override wardrobe-box defaults to look like a centered window */
    border-bottom: var(--pixel-border) solid var(--border-dark-brown);
    border-radius: 8px;
    margin-bottom: 0;
    max-height: 80%;
    overflow-y: auto;
    padding-bottom: 1.5rem;
}

#wardrobe-overlay.visible .wardrobe-box {
    transform: scale(1) translateY(0);
}

.wardrobe-box h2 {
    margin: 0 0 0.5rem 0;
    font-size: 0.8rem;
    color: var(--text-dark);
    text-align: center;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.4rem;
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    box-shadow: inset 2px 2px 0 0 var(--border-highlight), inset -2px -2px 0 0 #9d7a54;
}

.wardrobe-premium-container {
    display: flex;
    height: 100%;
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.5);
    gap: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 10px;
    box-sizing: border-box;
    image-rendering: auto;
    /* Smooth out non-pixel elements */
}

.wardrobe-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 5px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    border: 2px solid var(--border-dark-brown);
    box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.5);
}

.wardrobe-sidebar .wardrobe-tab {
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px !important;
    border: 3px solid var(--border-dark-brown) !important;
    background: var(--bg-tan) !important;
    font-size: 1.4rem;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 1px 0 #000 !important;
    cursor: pointer;
    position: relative;
    z-index: 5;
}

.wardrobe-sidebar .wardrobe-tab:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

.wardrobe-sidebar .wardrobe-tab.active {
    background: var(--primary) !important;
    transform: translateX(1px);
    box-shadow: -1px 1px 0 #000 !important;
    border-color: #fff !important;
    z-index: 10;
}

.wardrobe-main {
    flex: 1;
    display: flex;
    gap: 15px;
    height: 100%;
}

.wardrobe-preview-premium {
    width: 150px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.preview-stage {
    flex: 1;
    background: radial-gradient(circle at center, rgba(255, 215, 0, 0.4) 0%, rgba(0, 0, 0, 0.6) 100%);
    border: 3px solid var(--border-dark-brown);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 25px rgba(0, 0, 0, 0.8), 0 5px 15px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.preview-stage::after {
    content: '';
    position: absolute;
    bottom: 25px;
    width: 60px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    filter: blur(5px);
}

#wardrobe-canvas {
    width: 100px;
    height: 100px;
    z-index: 2;
    image-rendering: pixelated;
}

.current-outfit-modern {
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--border-dark-brown);
    border-radius: 8px;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.outfit-slot {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 6px 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 215, 0, 0.1);
    border-radius: 4px;
    height: 52px;
    /* Fixed height to always be the same size */
    text-align: center;
    box-sizing: border-box;
}

.slot-label {
    color: #94a3b8;
    font-weight: 800;
    font-size: 0.5rem;
    margin-bottom: 2px;
    text-transform: uppercase;
    line-height: 1;
}

.slot-value {
    color: #ffd700;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
    font-size: 0.7rem;
    /* Updated to 0.7rem as requested */
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.wardrobe-grid-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 300px;
}

.wardrobe-grid-premium {
    /*flex: 1;*/
    height: 300px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 12px;
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid var(--border-dark-brown);
    border-radius: 12px;
    padding: 15px;
    overflow-y: auto;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.6);
}

.wardrobe-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2%;
    border-bottom: 3px solid var(--border-dark-brown);
    position: relative;
    z-index: 10;
}

.wardrobe-tab {
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-bottom: none;
    padding: 0.5rem 1rem;
    color: var(--text-dark);
    font-weight: normal;
    font-size: 0.6rem;
    cursor: pointer;
    font-family: 'Retro Gaming', monospace;
    margin-bottom: -15px;
    /* Tighter integration */
    width: auto;
    box-shadow: var(--btn-inner);
    position: relative;
    z-index: 11;
}

.wardrobe-tab:hover {
    background: var(--bg-light-tan);
    box-shadow: var(--btn-inner);
}

.wardrobe-tab.active {
    background: var(--bg-light-tan);
    border-bottom: 3px solid var(--bg-light-tan);
    box-shadow: var(--btn-inner);
    z-index: 12;
}

.wardrobe-radius-top {
    border-radius: 8px 8px 0 0 !important;
}

/* Upside down tabs specifically for inventory sub-categories */
#inventory-tabs {
    border-top: 3px solid var(--border-dark-brown) !important;
    border-bottom: none !important;
    margin-bottom: 0 !important;
    margin-top: 5px;
}

#inventory-tabs .wardrobe-tab {
    border-radius: 0 0 8px 8px !important;
    border-top: none !important;
    border-bottom: 2px solid var(--border-dark-brown) !important;
    margin-top: -3px !important;
    margin-bottom: 0 !important;
}

#inventory-tabs .wardrobe-tab.active {
    background: var(--bg-light-tan) !important;
    border-top: 3px solid var(--bg-light-tan) !important;
    border-bottom: 2px solid var(--border-dark-brown) !important;
}

.wardrobe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    height: 100%;
    min-height: 200px;
    max-height: 400px;
    overflow-y: scroll;
    padding: 0.5rem;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.3);

}


.wardrobe-item {
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    padding: 4px;
    box-shadow:
        0 2px 0 0 rgba(0, 0, 0, 0.2),
        inset 2px 2px 0 0 var(--border-highlight),
        inset -2px -2px 0 0 var(--border-light-brown);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    aspect-ratio: 1 / 1;
    transition: transform 0.1s ease;
    position: relative;
}

.item-count-badge {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: #2d1b33;
    color: #ffd700;
    font-size: 8px;
    padding: 1px 3px;
    border: 1px solid #ffd700;
    border-radius: 2px;
    pointer-events: none;
    z-index: 5;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
}

.wardrobe-item:hover {
    background: var(--bg-light-tan);
    box-shadow: inset 1px 1px 0 0 #ffffff, inset -1px -1px 0 0 var(--border-light-brown);
}

.wardrobe-item.equipped {
    background: var(--accent-green);
    border-color: #558B2F;
    border-radius: 0.3rem;
    border: 2px solid #558B2F;
    box-shadow:
        0 0 0 1px #3E7C17,
        inset 2px 2px 0 0 #9CCC65,
        inset -2px -2px 0 0 #558B2F;
}

.wardrobe-item-preview {
    width: 50px;

    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
}

.wardrobe-item-preview canvas {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.wardrobe-item-name {
    font-size: 8px;
    color: var(--text-dark);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    margin-top: 2px;
}

.wardrobe-item-status {
    font-size: 0.45rem;
    color: var(--accent-green);
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wardrobe-close-btn {
    margin-top: 0.5rem;
    padding: 0.2rem 0.5rem;
    font-size: 0.5rem;
    background: #FF3636;
    border: 1px solid #D52222;
    border-radius: 4px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    font-family: 'Retro Gaming', monospace;
    cursor: pointer;
    box-shadow:
        0 0 0 1px #D5223B,
        inset 2px 2px 0 0 #FF697E,
        inset -2px -2px 0 0 #B5343A;
}

.wardrobe-close-btn:hover {
    background: #d23b3b;
    box-shadow:
        0 0 0 1px #D5223B,
        inset 2px 2px 0 0 #B5343A,
        inset -2px -2px 0 0 #FF697E;
}

/* Scrollbar for wardrobe grid */
.wardrobe-grid::-webkit-scrollbar {
    width: 8px;
}

.wardrobe-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.wardrobe-grid::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.4);
    border-radius: 4px;
}

.wardrobe-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.6);
}

/* TIC TAC TOE OVERLAY STYLES */
#tictactoe-overlay {
    display: none;
    z-index: 1000;
    /* Ensure it's on top */
}

#tictactoe-overlay.visible {
    display: flex;
}

#tictactoe-overlay .game-box {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(8px);
    width: auto;
    max-width: 90%;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    /* Allow interaction */
}

#ttt-status {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
    min-height: 1.5em;
}

#ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    border-radius: 0.5rem;
}

.ttt-cell {
    background: rgba(30, 41, 59, 0.9);
    border-radius: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    color: white;
}

.ttt-cell:hover {
    background: rgba(51, 65, 85, 0.9);
}

.ttt-cell.x {
    color: #ef4444;
    /* Red */
}

.ttt-cell.o {
    color: #3b82f6;
    /* Blue */
}

.ttt-cell.winner {
    background: rgba(16, 185, 129, 0.3);
    /* Green tint */
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
    border: 2px solid #10b981;
}

/* Ensure actions buttons in notifications are spaced nicely */
#notification-actions button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s;
}

#notification-actions button:hover {
    transform: scale(1.05);
}

/* ==================== SERVER ANNOUNCEMENT ==================== */
#server-announcement-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10000;
}

.announcement-content {
    background: transparent;
    padding: 40px 60px;

    max-width: 80%;
    text-align: center;
}

#announcement-text {
    font-family: 'Retro Gaming', monospace;
    font-size: 32px;
    color: #fff;
    text-shadow:
        3px 3px 0 rgba(0, 0, 0, 0.5),
        -1px -1px 0 rgba(0, 0, 0, 0.3);
    margin: 0;
    letter-spacing: 2px;
}

/* Animation States */
.announcement-hidden {
    opacity: 0;
    transform: scale(0.8);
}

.announcement-fade-in {
    animation: announcementFadeIn 0.5s ease-out forwards !important;
}

.announcement-fade-out {
    animation: announcementFadeOut 0.5s ease-in forwards !important;
}

@keyframes announcementFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes announcementFadeOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

    to {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
}

/* ==================== PLAYER INFO BIO SECTION ==================== */
.player-info-bio-section {
    margin: -20px 0;
    padding: 0px;
    background: rgba(0, 0, 0, 0);
    border-radius: 4px;
    width: 100%;
}

.player-info-bio-label {
    font-size: 0.65rem;
    color: var(--text-brown);
    font-weight: bold;
    margin-bottom: 4px;
}

.player-info-bio {
    font-size: 0.7rem;
    color: #475569;
    font-style: italic;
    line-height: 1.3;
    min-height: 60px;
    margin-bottom: 6px;
    padding: 8px;
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    word-wrap: break-word;
    box-sizing: border-box;
}

.player-info-bio-edit {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    font-family: 'Retro Gaming', monospace;
    font-size: 0.75rem;
    color: #475569;
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 8px;
}

.player-info-bio-edit:focus {
    outline: none;
    border-color: var(--accent-green);
}

.player-info-edit-btn,
.player-info-save-btn,
.player-info-cancel-btn {
    padding: 0px 8px;
    font-family: 'Retro Gaming', monospace;
    font-size: 0.55rem;
    border: 2px solid var(--border-dark-brown);
    background: var(--bg-tan);
    color: var(--text-brown);
    cursor: pointer;
    margin-right: 5px;
    border-radius: 3px;

    width: 25%;
    height: 17px;
}

.player-info-edit-btn:hover {
    background: var(--border-light-brown);
}

.player-info-save-btn {
    background: var(--accent-green);
    color: white;
    border-color: #4ade80;
}

.player-info-save-btn:hover {
    background: #4ade80;
}

.player-info-cancel-btn {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
}

.player-info-cancel-btn:hover {
    background: #dc2626;
}

/* Main Menu Dropdown */
#menu-container {
    display: flex;
    flex-direction: column;
}

#main-menu-dropdown {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    position: absolute;
    bottom: 100%;
    /* Open upwards */
    left: 0;
    margin-bottom: 10px;
    /* Space from button */
    background: var(--bg-light-tan);
    border: var(--pixel-border) solid var(--border-dark-brown);
    padding: 12px;
    gap: 8px;
    z-index: 5000;
    box-shadow: var(--panel-shadow);

    /* Shadow on top-right */
    min-width: 160px;

    /* Animation Initial State */
    opacity: 0;
    transform: scale(0);
    transform-origin: bottom left;
    /* Scale from bottom */
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

#main-menu-dropdown.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

#main-menu-dropdown button {
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    /* Taller buttons for grid */
}

/* Ensure dropdown buttons have same style as top buttons */
#main-menu-dropdown button {
    background: var(--primary);
    border: 2px solid var(--btn-border);
    color: var(--btn-text);
    font-family: 'Retro Gaming', monospace;
    font-size: 0.65rem;
    padding: 0.8rem 1rem;
    cursor: pointer;
    box-shadow: var(--btn-inner);
    transition: transform 0.1s !important;
}

#main-menu-dropdown button:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

/* Tic-Tac-Toe Styles */
.game-box {
    background: var(--bg-tan);
    border: 4px solid var(--border-dark-brown);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3), inset 4px 4px 0 0 var(--border-highlight);
    width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.game-box h2 {
    margin: 0;
    font-family: 'Retro Gaming', monospace;
    color: var(--text-brown);
    font-size: 1.2rem;
}

#ttt-status {
    font-family: 'Retro Gaming', monospace;
    font-size: 0.8rem;
    height: 1.2rem;
}

#ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    background: var(--border-dark-brown);
    padding: 8px;
    border-radius: 4px;
    width: 180px;
    height: 180px;
}

.ttt-cell {
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-family: 'Retro Gaming', monospace;
    cursor: pointer;
    color: var(--text-dark);
    transition: all 0.1s ease;
    user-select: none;
}

.ttt-cell:hover:not(.taken) {
    background: #f0e0c0;
    transform: scale(1.05);
}

.ttt-cell.taken {
    cursor: default;
}

/* --- Pet Card System --- */
#pet-items {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    gap: 15px !important;
    padding: 15px !important;
    background: #4E3E1C !important;
    /* Dark brown inset background */
    border: 3px solid #3d351b !important;
    border-radius: 4px !important;
    box-shadow: inset 4px 4px 10px rgba(0, 0, 0, 0.5) !important;
    overflow-y: auto !important;
}

.pet-card {
    background: #E7D09F !important;
    /* bg-light-tan */
    border: 3px solid #D5A722 !important;
    /* border-dark-brown */
    border-radius: 8px !important;
    padding: 10px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 8px !important;
    position: relative !important;
    cursor: pointer !important;
    box-shadow:
        0 4px 0 0 rgba(0, 0, 0, 0.3),
        inset 0 0 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s ease !important;
}

.pet-card:hover {
    transform: translateY(-1px) !important;
    background: var(--bg-light-tan) !important;
}

.pet-card.equipped {
    background: #66BB6A !important;
    border-color: #558B2F !important;
    box-shadow:
        0 4px 0 0 rgba(0, 0, 0, 0.3),
        inset 2px 2px 0 0 #AED581,
        inset -2px -2px 0 0 #558B2F !important;
}

.pet-card-preview {
    width: 64px !important;
    height: 64px !important;
    background: #F6E16D !important;
    border: 2px solid #D5A722 !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.pet-card-info {
    text-align: center !important;
    width: 100% !important;
}

.pet-card-name {
    font-size: 11px !important;
    font-weight: 800 !important;
    color: #E54453 !important;
    margin-bottom: 2px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.pet-card-type {
    font-size: 9px !important;
    color: #B49F40 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.1em !important;
}

.pet-card-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
}

/* Settings Sheet UI */
.settings-box {
    background: var(--bg-tan);
    border: 3px solid var(--border-dark-brown);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    padding: 1rem;
    box-shadow:
        -4px 0 0 -2px rgba(0, 0, 0, 0.2),
        4px 0 0 -2px rgba(0, 0, 0, 0.2),
        inset 3px 3px 0 0 var(--border-highlight),
        inset -3px 0 0 0 var(--border-light-brown);
    width: clamp(300px, 90%, 550px);
    height: 50vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: -30px;
    padding-bottom: 40px;
    /* Space for close btn */
    transform: translateY(30px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.settings-box h2 {
    margin: 0 0 1rem 0;
    font-size: 0.8rem;
    color: var(--text-dark);
    text-align: center;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.5rem;
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    box-shadow: inset 2px 2px 0 0 var(--border-highlight), inset -2px -2px 0 0 #9d7a54;
}

.settings-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 3px solid var(--border-dark-brown);
    padding-bottom: 0px;
}

.settings-tab {
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-bottom: none;
    padding: 0.5rem 1rem;
    color: var(--text-dark);
    font-size: 0.6rem;
    cursor: pointer;
    font-family: 'Retro Gaming', monospace;
    margin-bottom: -15px;
    /* Merge with line */
    width: auto;
    box-shadow: inset 1px 1px 0 0 var(--border-highlight), inset -1px -1px 0 0 var(--border-light-brown);
    z-index: 1;
    /* Behind active */
}

.settings-tab.active {
    background: var(--bg-light-tan);
    border-bottom: 3px solid var(--bg-light-tan);
    box-shadow: inset 2px 2px 0 0 #ffffff, inset -2px -2px 0 0 var(--border-light-brown);
    z-index: 2;
    /* On top */
}


.settings-content {
    background: rgba(0, 0, 0, 0.05);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
    box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.1);
    color: var(--text-dark);
}

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

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

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.6rem;
    color: var(--text-brown);
    border-bottom: 1px solid var(--border-light-brown);
    padding-bottom: 0.2rem;
    text-transform: uppercase;
}

/* --- Custom Form Inputs --- */
.volume-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-control span {
    font-size: 0.6rem;
    color: var(--text-dark);
    min-width: 30px;
    text-align: right;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
}

/* Track */
input[type="range"]::-webkit-slider-runnable-track {
    background: var(--border-dark-brown);
    height: 8px;
    border: 2px solid var(--border-dark-brown);
    border-radius: 0;
    /* Boxy */
    box-shadow: inset 1px 1px 0 0 rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-track {
    background: var(--border-dark-brown);
    height: 8px;
    border: 2px solid var(--border-dark-brown);
    border-radius: 0;
    box-shadow: inset 1px 1px 0 0 rgba(0, 0, 0, 0.2);
}

/* Thumb */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    margin-top: -6px;
    /* Center on track */
    background: var(--text-dark);
    /* Red thumb */
    height: 16px;
    width: 10px;
    border: 2px solid #991b1b;
    border-radius: 0;
    /* Pixel look */
    box-shadow: inset 1px 1px 0 0 #fca5a5;
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #ef4444;
}

input[type="range"]::-moz-range-thumb {
    background: var(--text-dark);
    height: 16px;
    width: 10px;
    border: 2px solid #991b1b;
    border-radius: 0;
    box-shadow: inset 1px 1px 0 0 #fca5a5;
    cursor: pointer;
}

.checkbox-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.7rem;
    color: var(--text-dark);
    cursor: pointer;
    background: var(--bg-light-tan);
    padding: 0.5rem;
    border: 2px solid var(--border-dark-brown);
    box-shadow: inset 1px 1px 0 0 var(--border-highlight);
}

.checkbox-label input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--bg-tan);
    margin: 0;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-dark-brown);
    display: grid;
    place-content: center;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"]::before {
    content: "";
    width: 8px;
    height: 8px;
    transform: scale(0);
    background-color: var(--text-dark);
    transition: transform 0.1s ease;
    box-shadow: inset 1px 1px 0 0 #fca5a5;
}

.checkbox-label input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.settings-close-btn {
    margin-top: 10px;
    padding: 0.4rem;
    font-size: 0.6rem;
    background: #FF3636;
    border: 1px solid #D52222;
    border-radius: 4px;
    color: #fff;
    cursor: pointer;
    font-family: 'Retro Gaming', monospace;
    width: 100%;
    box-shadow: 0 2px 0 0 #B5343A;
}

.settings-close-btn:hover {
    background: #d23b3b;
}

.pet-card-actions button {
    height: auto !important;
    padding: 6px 4px !important;
    font-size: 10px !important;
    line-height: 1 !important;
}

.pet-btn-equip {
    background: var(--primary) !important;
    color: #211426 !important;
}

.pet-card.equipped .pet-btn-equip {
    background: #4ade80 !important;
    color: #064e3b !important;
    opacity: 1 !important;
}

.pet-btn-group {
    display: flex !important;
    gap: 4px !important;
}

.pet-btn-group button {
    flex: 1 !important;
    padding: 4px 2px !important;
    font-size: 9px !important;
}

.pet-btn-release {
    background: #ef4444 !important;
    color: white !important;
    border-color: #b91c1c !important;
    box-shadow: 0 2px 0 0 #7f1d1d, inset 1px 1px 0 0 #f87171 !important;
}

/* World Status Menu */
#world-status {
    margin-bottom: 0.75rem;
    background: #2d1b33;
    /* Deep purple matching login */
    border: 3px solid #ffd700;
    /* Gold */
    padding: 0.6rem 0.8rem;
    border-radius: 4px;

    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    user-select: none;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid rgba(255, 215, 0, 0.15);
    padding-bottom: 0.2rem;
}

.status-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.status-label {
    font-size: 0.5rem;
    color: #ffd700;
    opacity: 0.9;
    font-weight: bold;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.status-value {
    font-size: 0.65rem;
    color: #fff;
    font-family: 'Retro Gaming', monospace;
    text-shadow: 2px 2px 0 #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    text-align: right;
}

#current-room-name {
    color: #5eead4;
    /* Teal for location to contrast */
}

#current-game-time {
    color: #fbbf24;
    /* Amber for time */
}

/* Treasure Chest Lootbox Style */
.treasure-panel {
    max-width: 400px;
    width: 90%;
    background: #4a3052 !important;
    /* Deep dark purple */
    border: 4px solid #ffd700 !important;
    text-align: center;
    position: relative;
    padding: 30px !important;
}

.treasure-title {
    font-size: 24px;
    color: #ffd700;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 20px;
}

.treasure-display {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #ffd700;
    padding: 40px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

#reward-display {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    pointer-events: none;
}

#reward-item-img {
    width: 128px;
    height: 128px;
    object-fit: contain;
    image-rendering: pixelated;
    animation: loot-reveal 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#reward-text {
    color: #fff;
    font-size: 16px;
    margin-top: 32px;
    text-shadow: 2px 2px 0 #000;
    font-family: 'Retro Gaming', monospace;
    opacity: 0;
    animation: fade-in 0.5s 0.8s forwards;
}

@keyframes loot-reveal {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }

    100% {
        transform: scale(1.2) rotate(0deg);
        opacity: 1;
    }
}

@keyframes fade-in {
    to {
        opacity: 1;
    }
}

#treasure-chest-img {
    width: 200px;
    height: 200px;
    object-fit: contain;
    image-rendering: pixelated;
}

.treasure-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.pixel-button.premium {
    background: #ffd700;
    color: #4a3052;
    border: none;
    padding: 12px 24px;
    font-family: 'Retro Gaming', monospace;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #b8860b;
    transition: all 0.1s;
}

.pixel-button.premium:hover {
    background: #ffed4a;
    transform: translateY(-1px);
    box-shadow: 0 6px 0 #b8860b;
}

.pixel-button.premium:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #b8860b;
}

.pixel-button.premium:disabled {
    background: #94a3b8;
    color: #64748b;
    box-shadow: 0 4px 0 #475569;
    cursor: not-allowed;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background: #FF3636;
    border: 2px solid #D52222;
    color: white;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    font-family: Arial, sans-serif;
    /* Standard X look */
    font-weight: bold;
    box-shadow: 0 2px 0 0 #B5343A, inset 1px 1px 0 0 #FF697E;
    transition: all 0.1s;
    line-height: 1;
    padding: 0;
    z-index: 1000;
}

.close-btn:hover {
    transform: scale(1.1);
    background: #ff5252;
}

.close-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 0 #B5343A;
}

/* Global Overlay Style */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    z-index: 2500;
}

.overlay.visible {
    display: flex !important;
}

/* --- MOBILE & FULLSCREEN REFINEMENTS --- */

body.fullscreen #game-container {
    margin: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    grid-template-columns: 0 100% 0 !important;
    grid-template-areas:
        '. game .'
        '. bar  .' !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 1000 !important;
    display: grid !important;
}

body.fullscreen #left-panel,
body.fullscreen #side-panel {
    display: none !important;
}

body.fullscreen #game-view {
    aspect-ratio: auto !important;
    height: calc(100dvh - 60px) !important;
}

/* iOS Specific Overrides */
html,
body {
    background: #020617;
    /* Match game background */
}

/* Ensure the app fills the safe area on iPhone */
@media (pointer: coarse) {
    body {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }
}


#bottom-bar {
    grid-area: bar;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tan);
    padding: 10px 20px;

    box-sizing: border-box;
    width: 100%;
}

/* --- VIRTUAL JOYSTICK (mobile) --- */
/* The overlay covers the whole screen but lets touches pass through except on
   the joystick base itself, so taps elsewhere still reach the game canvas. */
#mobile-controls {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1500;               /* above game + bottom bar, below UI panels */
    pointer-events: none;
    touch-action: none;
}

#joystick-container {
    position: absolute;
    left: calc(env(safe-area-inset-left, 0px) + 24px);
    bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    width: 160px;
    height: 160px;
    touch-action: none;
}

#joystick-base {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.10), rgba(8, 10, 18, 0.50));
    border: 2px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 0 28px rgba(0, 0, 0, 0.55);
    pointer-events: auto;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#joystick-stick {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 72px;
    height: 72px;
    margin: -36px 0 0 -36px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.95), rgba(178, 178, 196, 0.75));
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    opacity: 0.95;
    pointer-events: none;
    will-change: transform;
}

@media (max-width: 480px) {
    #joystick-container {
        width: 140px;
        height: 140px;
    }
    #joystick-stick {
        width: 60px;
        height: 60px;
        margin: -30px 0 0 -30px;
    }
}

/* In fullscreen the bottom bar sits at the very bottom; tuck the joystick
   above it so it is not hidden underneath. */
body.fullscreen #joystick-container {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 76px);
}

body.fullscreen #bottom-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 60px !important;
    z-index: 1001 !important;
    border: none !important;
    border-top: 3px solid var(--border-dark-brown) !important;
    padding: 0 15px !important;
}


@media (max-width: 900px) {
    body.fullscreen #game-view {
        height: calc(100dvh - 50px) !important;
    }

    body.fullscreen #bottom-bar {
        height: 50px !important;
    }
}


/* Login & Creator Mobile Scaling */
@media (max-width: 900px) {
    .logo-text {
        font-size: 32px !important;
        margin-bottom: 5px !important;
        letter-spacing: 2px !important;
    }

    .login-box {
        width: 85% !important;
        max-width: 300px !important;
        padding: 1rem !important;
        margin: 10px auto !important;
    }

    .login-box h1 {
        font-size: 0.85rem !important;
        margin-bottom: 0.8rem !important;
    }

    .creator-preview,
    .creator-preview canvas {
        width: 80px !important;
        height: 80px !important;
    }

    .creator-content {
        gap: 10px !important;
    }

    .creator-option label {
        font-size: 0.6rem !important;
    }

    input {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.8rem !important;
        margin-bottom: 0.6rem !important;
    }

    button {
        padding: 0.6rem !important;
        font-size: 0.7rem !important;
    }
}

/* Short / landscape phones: keep the creator side-by-side so everything fits
   on one screen (portrait phones get the compact column above). */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
    .creator-content {
        flex-direction: row !important;
        align-items: center !important;
        gap: 16px !important;
        margin-bottom: 10px !important;
    }

    .creator-options {
        width: 200px !important;
    }

    .logo-text {
        font-size: 22px !important;
        margin-bottom: 0 !important;
    }

    #character-creator-overlay,
    #login-overlay {
        padding: 10px !important;
    }
}

/* Small phones in portrait: keep everything visible with a modest gap. */
@media (max-width: 480px) and (orientation: portrait) {
    .creator-content {
        gap: 6px !important;
        margin-bottom: 10px !important;
    }

    .creator-option {
        margin-bottom: 8px !important;
    }

    .login-box {
        width: 92% !important;
        padding: 0.8rem !important;
    }
}


@media (max-width: 900px) {
    #face-display {
        font-size: 0.6rem !important;
    }
}

/* Community Section Layout */
.community-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 50% / 50% */
    gap: 20px;
    align-items: start;
}

#discord-section {
    text-align: center;
}

.forum-side,
.discord-side {
    padding: 10px;
    box-sizing: border-box;
}

.section-title {
    margin: -10px -10px 10px -10px;
    /* Pull it to the edges of padding */
    font-size: 0.8rem;
    color: var(--text-dark);
    text-align: center;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.5rem;
    background: var(--bg-light-tan);
    border-bottom: 2px solid var(--border-dark-brown);
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    box-shadow: inset 2px 2px 0 0 var(--border-highlight), inset -2px -2px 0 0 #9d7a54;
    font-family: 'Retro Gaming', monospace;
}

#forum-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 600px;
}

.discord-embed-container {
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    overflow: hidden;
    background: #23272a;
}

@media (max-width: 1000px) {
    .community-grid {
        grid-template-columns: 1fr;
        /* Stack on small screens */
    }
}

#forum-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    border: 1px solid var(--border-dark-brown);
}

#forum-message-input {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    background: var(--input-bg);
    color: var(--text-main);
    box-shadow: var(--input-shadow);
    font-family: 'Retro Gaming', monospace;
    font-size: 0.8rem;
    resize: none;
    box-sizing: border-box;
    image-rendering: auto;
    /* Smoother text */
}

#forum-posts-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 5px;
}

.forum-post {
    background: var(--bg-paper);
    color: var(--text-main);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    padding: 10px;
    box-shadow: var(--btn-inner);
    position: relative;
}

.forum-post-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.7rem;
    border-bottom: 1px dashed var(--border-dark-brown);
    padding-bottom: 3px;
}

.forum-post-user {
    font-weight: bold;
    color: var(--text-dark);
}

.forum-post-time {
    color: #94a3b8;
}

.forum-post-content {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    line-height: 1.4;
    word-wrap: break-word;
    color: #333;
}

.pixel-button {
    background: var(--primary);
    color: var(--btn-text);
    border: 3px solid var(--btn-border);
    padding: 10px 15px;
    font-family: 'Retro Gaming', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    box-shadow: var(--btn-shadow);
}

.pixel-button:active {
    box-shadow: none;
    transform: translate(2px, 2px);
}

#forum-posts-list::-webkit-scrollbar {
    width: 8px;
}

#forum-posts-list::-webkit-scrollbar-track {
    background: var(--bg-light-tan);
}

#forum-posts-list::-webkit-scrollbar-thumb {
    background: var(--border-dark-brown);
    border-radius: 4px;
}

.discord-emoji {
    height: 1.4rem;
    vertical-align: middle;
    margin: 0 2px;
}

.pixel-panel {
    background: var(--bg-light-tan);
    border: var(--pixel-border) solid var(--border-dark-brown);
    box-shadow: var(--panel-shadow);
    border-radius: 8px;
}

#friends-panel {
    width: 100%;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
    overflow: hidden;
    flex: 1.2;
    /* Slightly more space than player info */
}

/* Local override to fix "too large border" if pixel-panel is still present */
#friends-panel.pixel-panel {
    border-width: 2px;
}

#friends-panel h3 {
    margin: 0 0 0.5rem 0;
    font-size: clamp(0.5rem, 0.8vw, 0.7rem);
    color: var(--text-dark);
    text-align: center;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.4rem;
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    box-shadow: var(--btn-inner);
}

.social-tab-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    position: relative;
    z-index: 5;
}

#social-tabs {
    gap: 4px !important;
    margin-bottom: -2px !important;
    /* Overlap the list container top border */
    border-bottom: none !important;
    z-index: 10 !important;
}

#social-tabs .wardrobe-tab {
    border-width: 2px;
    margin-bottom: 0;
    transition: all 0.2s ease;
    border-radius: 8px 8px 0 0;
    border-bottom: none !important;
}

#social-tabs .wardrobe-tab.active {
    background: var(--bg-light-tan);
    border-bottom: 2px solid var(--bg-light-tan) !important;
    /* Mask the border below */
    z-index: 11;
    opacity: 1;
    filter: none;
}

#social-tabs .wardrobe-tab:not(.active) {
    background: var(--bg-tan);
    opacity: 0.8;
    filter: brightness(0.9);
}

#friends-list-container,
#group-list-container {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-light-tan);
    padding: 0.5rem;
    border: 2px solid var(--border-dark-brown);
    border-radius: 3px;
    box-shadow: inset 2px 2px 0 0 #9d7a54, inset -2px -2px 0 0 var(--border-highlight);
    max-height: 400px;
}

#pending-friends-list {
    margin-bottom: 8px;
}

.pending-request-box {
    background: rgba(251, 191, 36, 0.1);
    padding: 8px;
    margin-bottom: 8px;
    border: 2px solid #fbbf24;
    border-radius: 4px;
    box-shadow: inset 1px 1px 0 0 rgba(255, 255, 255, 0.1);
}

.pending-request-title {
    font-size: 0.55rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.pending-request-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    margin-bottom: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px 6px;
    border-radius: 2px;
}

.pending-request-item span {
    color: #fff;
    font-family: 'Retro Gaming', monospace;
}

.friend-item {
    display: flex;
    align-items: center;
    padding: 8px;
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    margin-bottom: 6px;
    box-shadow: inset 1px 1px 0 0 var(--border-highlight), inset -1px -1px 0 0 var(--border-light-brown);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.1s ease;
}

.friend-item:hover {
    background: var(--bg-light-tan);
    transform: translateX(2px);
}

.friend-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 10px;
    border: 1px solid rgba(0, 0, 0, 0.3);
}

.friend-status-dot.online {
    background: #22c55e;
    box-shadow: 0 0 5px #22c55e;
}

.friend-status-dot.offline {
    background: #64748b;
}

.friend-name {
    font-size: 0.7rem;
    color: #fff;
    flex: 1;
    text-shadow: 1px 1px 0 #000;
}

.friend-item.offline .friend-name {
    color: #94a3b8;
}

.friend-actions {
    display: flex;
    gap: 4px;
}

.friend-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    transition: transform 0.1s ease;
}

.friend-action-btn:hover {
    transform: scale(1.2);
}

#refresh-friends-btn,
#leave-group-btn {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    font-size: 0.6rem;
    background: var(--primary);
    border: 2px solid var(--btn-border);
    border-radius: 4px;
    color: var(--btn-text);
    cursor: pointer;
    font-family: 'Retro Gaming', monospace;
    box-shadow: var(--btn-shadow);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#leave-group-btn {
    background: #ef4444;
    border-color: #dc2626;
}

#refresh-friends-btn:hover {
    filter: brightness(1.1);
}

#refresh-friends-btn:active {
    transform: translateY(2px);
    box-shadow: none;
}

/* Unified Inventory Tabs */
.inventory-tab-pane {
    display: none;
}

.inventory-tab-pane.active {
    display: block;
}

.main-inventory-tabs {
    pointer-events: auto !important;
}

.main-inventory-tabs .wardrobe-tab {
    font-size: 0.85rem;
    padding: 0px 16px;
    margin-bottom: 0px;
    /* Fix clickability/overlap issue */
    border-radius: 8px 8px 0 0;
    border-bottom: none !important;

    transition: transform 0.1s ease;
    pointer-events: auto !important;
    cursor: pointer !important;
}

.main-inventory-tabs .wardrobe-tab.active {
    transform: scale(1.01);
    border-bottom: 2px solid var(--bg-light-tan) !important;
    z-index: 10;
}

/* ================================== */
/* FISHING MINIGAME STYLES            */
/* ================================== */

#fishing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 500;
}

#fishing-overlay>div {
    pointer-events: auto;
}

/* Power Meter - Casting */
#fishing-power-meter {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.power-meter-container {
    background: rgba(0, 0, 0, 0);
    border: 4px solid #ffd90000;
    border-radius: 8px;
    padding: 20px 30px;
    text-align: center;

}

.power-meter-label {
    color: #ffffff;
    font-family: 'Retro Gaming', monospace;
    font-size: 0.9rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    text-shadow: 2px 2px 0 #000;
}

.power-meter-bar {
    width: 200px;
    height: 20px;
    background: #1a1a2e;
    border: 3px solid #4a4a6e;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.power-meter-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
    border-radius: 2px;
    transition: width 0.05s linear;
}

/* Reel Minigame */
#fishing-reel-game {
    position: absolute;
    top: 50%;
    right: 100px;
    transform: translateY(-50%);
}

.reel-container {
    background: rgba(0, 0, 0, 0.95);
    border: 4px solid #ffd700;
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4), inset 0 0 15px rgba(0, 0, 0, 0.5);
    min-width: 120px;
}

.reel-title {
    color: #ffd700;
    font-family: '04b_30', 'Retro Gaming', monospace;
    font-size: 0.7rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 #000;
    letter-spacing: 1px;
}

.reel-bar-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.reel-bar {
    width: 30px;
    height: 300px;
    background: linear-gradient(180deg, #0a1628 0%, #1a2d4a 50%, #0a1628 100%);
    border: 3px solid #3b82f6;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8), 0 0 10px rgba(59, 130, 246, 0.3);
}

.fish-zone {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 30px;
    background: transparent;
    border-radius: 4px;
    transition: top 0.05s ease-out;
    z-index: 10;
    /* Render on top of catcher */
}

.fish-zone::after {
    content: '🐟';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    filter: drop-shadow(0 0 2px #000);
}

.catcher-bar {
    position: absolute;
    left: 2px;
    right: 2px;
    height: 50px;
    background: linear-gradient(180deg, rgba(34, 197, 94, 0.9) 0%, rgba(22, 163, 74, 0.8) 100%);
    border: 2px solid #4ade80;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.6), inset 0 0 5px rgba(255, 255, 255, 0.2);
    transition: top 0.03s linear;
    z-index: 5;
}

.catcher-bar::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 2px;
}

/* Progress Bar */
.reel-progress-bar {
    width: 12px;
    height: 300px;
    background: #1a1a2e;
    border: 3px solid #4a4a6e;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
    position: relative;
}

.reel-progress-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0%;
    background: linear-gradient(0deg, #22c55e 0%, #4ade80 50%, #86efac 100%);
    border-radius: 3px;
    transition: height 0.1s linear;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
}

/* Rarity-based progress colors */
.reel-progress-fill.common {
    background: linear-gradient(0deg, #9ca3af 0%, #d1d5db 100%);
}

.reel-progress-fill.uncommon {
    background: linear-gradient(0deg, #22c55e 0%, #4ade80 100%);
}

.reel-progress-fill.rare {
    background: linear-gradient(0deg, #3b82f6 0%, #60a5fa 100%);
}

.reel-progress-fill.epic {
    background: linear-gradient(0deg, #a855f7 0%, #c084fc 100%);
}

.reel-progress-fill.legendary {
    background: linear-gradient(0deg, #f59e0b 0%, #fbbf24 100%);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.8);
}

.reel-hint {
    color: #94a3b8;
    font-family: 'Retro Gaming', monospace;
    font-size: 0.5rem;
    margin-top: 10px;
    text-transform: uppercase;
}

/* Fishing Result */
#fishing-result {
    position: absolute;
    top: 15%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: result-pop 0.3s ease-out;
}

@keyframes result-pop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.result-container {
    background: rgba(0, 0, 0, 0);
    border: 4px solid #ffd90000;
    border-radius: 12px;
    padding: 30px 50px;
    text-align: center;

}

.result-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 15px;
    image-rendering: pixelated;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;

}

.result-text {
    color: #ffffff;
    font-family: 'Retro Gaming', monospace;
    font-size: 1rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 0 #000;
}

.result-rarity {
    font-family: '04b_30', 'Retro Gaming', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 5px 15px;
    border-radius: 4px;
    display: inline-block;
}

.result-rarity.common {
    color: #9ca3af;
}

.result-rarity.uncommon {
    color: #4ade80;
}

.result-rarity.rare {
    color: #60a5fa;
}

.result-rarity.epic {
    color: #c084fc;
}

.result-rarity.legendary {
    color: #fbbf24;
    text-shadow: 0 0 10px #f59e0b;
    animation: legendary-glow 1s ease-in-out infinite alternate;
}

@keyframes legendary-glow {
    from {
        text-shadow: 0 0 5px #f59e0b, 0 0 10px #f59e0b;
    }

    to {
        text-shadow: 0 0 15px #f59e0b, 0 0 30px #fbbf24;
    }
}

/* Fish Alert (exclamation mark) - rendered via Phaser */
.fish-alert {
    animation: alert-bounce 0.3s ease-out infinite alternate;
}

@keyframes alert-bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-5px);
    }
}

/* Waiting Indicator */
#fishing-waiting {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.waiting-container {
    background: rgba(0, 0, 0, 0.85);
    border: 4px solid #3b82f6;
    border-radius: 12px;
    padding: 25px 40px;
    text-align: center;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
}

.waiting-bobber {
    display: block;
    width: 64px;
    height: 64px;
    margin: 0 auto;
    image-rendering: pixelated;
}

.waiting-bobber img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    animation: bobber-float 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

@keyframes bobber-float {

    0%,
    100% {
        transform: translateY(0) rotate(-5deg);
    }

    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

.waiting-text {
    color: #60a5fa;
    font-family: 'Retro Gaming', monospace;
    font-size: 0.9rem;
    margin-top: 15px;
    text-shadow: 2px 2px 0 #000;
}

.waiting-dots {
    margin-top: 10px;
}

.waiting-dots span {
    color: #60a5fa;
    font-size: 1.5rem;
    animation: dot-pulse 1.4s infinite;
    opacity: 0;
}

.waiting-dots span:nth-child(1) {
    animation-delay: 0s;
}

.waiting-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.waiting-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dot-pulse {

    0%,
    60%,
    100% {
        opacity: 0;
    }

    30% {
        opacity: 1;
    }
}

/* Fishing Alert UI - FISH BITE! */
#fishing-alert {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.alert-container {
    background: rgba(220, 38, 38, 0.95);
    border: 6px solid #fbbf24;
    border-radius: 16px;
    padding: 20px 50px;
    text-align: center;
    animation: alert-pulse 0.15s ease-in-out infinite alternate;
    box-shadow:
        0 0 40px rgba(251, 191, 36, 0.8),
        0 0 80px rgba(220, 38, 38, 0.6),
        inset 0 0 20px rgba(0, 0, 0, 0.3);
}

@keyframes alert-pulse {
    from {
        transform: scale(1);
        box-shadow:
            0 0 40px rgba(251, 191, 36, 0.8),
            0 0 80px rgba(220, 38, 38, 0.6);
    }

    to {
        transform: scale(1.05);
        box-shadow:
            0 0 60px rgba(251, 191, 36, 1),
            0 0 100px rgba(220, 38, 38, 0.8);
    }
}

.alert-exclamation {
    font-size: 80px;
    font-family: '04b_30', 'Retro Gaming', monospace;
    color: #fef08a;
    text-shadow:
        4px 4px 0 #000,
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000;
    line-height: 1;
    animation: exclamation-bounce 0.2s ease-in-out infinite alternate;
}

@keyframes exclamation-bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(-8px);
    }
}

.alert-text {
    font-family: '04b_30', 'Retro Gaming', monospace;
    font-size: 1.2rem;
    color: #ffffff;
    text-shadow: 2px 2px 0 #000;
    margin-top: 10px;
    letter-spacing: 2px;
}

/* Edit Mode Inventory */
#edit-inventory-overlay {
    position: absolute;
    bottom: 0px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    max-width: 90vw;
    z-index: 2000;
    pointer-events: auto;
}

.edit-inventory-panel {
    height: 150px;
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--bg-tan);
    border: 4px solid var(--border-dark-brown);
    box-shadow: var(--panel-shadow);
}

.edit-inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
    border-bottom: 2px solid var(--border-light-brown);
    padding-bottom: 5px;
}

.edit-inventory-tabs {
    display: flex;
    gap: 5px;
}

.edit-inventory-tab {
    width: auto;
    padding: 4px 10px;
    font-size: 0.6rem;
    background: var(--bg-light-tan);
    color: var(--text-dark);
    font-family: 'Retro Gaming', monospace;
    cursor: pointer;
}

.edit-inventory-tab.active {
    background: var(--primary);
    color: var(--btn-text);
}

.edit-inventory-close {
    width: auto;
    padding: 4px 15px;
    font-size: 0.7rem;
    background: #10b981;
    color: white;
    font-weight: bold;
    font-family: 'Retro Gaming', monospace;
    cursor: pointer;
    border: 2px solid #065f46;
    box-shadow: 2px 2px 0 #000;
}

.edit-inventory-grid {
    flex: 1;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 5px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark-brown) transparent;
}

.edit-inventory-grid::-webkit-scrollbar {
    height: 6px;
}

.edit-inventory-grid::-webkit-scrollbar-thumb {
    background: var(--border-dark-brown);
}

.edit-inventory-item {
    min-width: 64px;
    height: 64px;
    background: var(--bg-light-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.edit-inventory-item:hover {
    background: var(--border-highlight);
    border-color: var(--primary);
}

.edit-inventory-item img {
    max-width: 48px;
    max-height: 48px;
    image-rendering: pixelated;
}

.edit-inventory-item .count {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.5rem;
    padding: 1px 3px;
    border-radius: 2px;
}

#edit-menu-toggle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 30px;
    background: var(--bg-tan);
    border: 4px solid var(--border-dark-brown);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: var(--text-brown);
    font-family: 'Retro Gaming', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 2001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 5px;
    box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.2);
}

#edit-inventory-overlay {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#edit-inventory-overlay.minimized {
    transform: translateX(-50%) translateY(150px);
    /* Height of panel */
}

#edit-inventory-overlay.minimized #edit-menu-toggle {
    transform: translateX(-50%) rotate(180deg);
    padding-bottom: 0px;
    padding-top: 5px;
}

/* Pet Battle UI Locking */
body.in-pet-battle #bottom-bar,
body.in-pet-battle #left-panel {
    pointer-events: none;
    opacity: 0.5;
    filter: grayscale(100%);
}

/* --- MOBILE UI PANELS (small screens) --- */
@media (max-width: 900px) {

    /* Panels fill the width and use most of the screen height */
    #wardrobe-overlay,
    #cash-shop-overlay {
        width: 100% !important;
    }

    .wardrobe-box,
    .settings-box,
    .shop-box {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 72vh !important;
        height: auto !important;
        min-height: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-radius: 8px 8px 0 0 !important;
    }

    /* The panels below have internal scroll panes, so the box itself must
       never scroll - otherwise the Close/X button is pushed out of view.
       Make the box a flex column; the pane grows + scrolls by itself. */
    #wardrobe-overlay .wardrobe-box,
    #cash-shop-overlay .wardrobe-box,
    #collection-overlay .wardrobe-box,
    #pet-overlay .wardrobe-box,
    #inventory-overlay .wardrobe-box,
    #backpack-overlay .shop-box {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        overflow: hidden !important;
    }

    /* Grid/list panes inside the panels fill the space and scroll internally */
    .wardrobe-box > .wardrobe-grid,
    .wardrobe-box > .collection-scroll-box,
    .wardrobe-box > .shop-items,
    .shop-box > #shop-items {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Settings panels scroll the whole window instead (no dedicated pane) */
    #home-settings-overlay .settings-box,
    #settings-overlay .settings-box {
        overflow-y: auto !important;
    }

    /* Keep centered windows (cash shop / collection) from looking full-bleed */
    #cash-shop-overlay .wardrobe-box,
    #collection-overlay .wardrobe-box {
        width: 96vw !important;
        max-width: 96vw !important;
        border-radius: 8px !important;
        max-height: 70vh !important;
    }

    /* Bottom-anchored panels clear the on-screen bar + home indicator */
    #shop-overlay .shop-box,
    #inventory-overlay .wardrobe-box,
    #pet-overlay .wardrobe-box,
    #wardrobe-overlay .wardrobe-box,
    #settings-overlay .settings-box,
    #backpack-overlay .shop-box {
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 70px) !important;
    }

    /* Wide, easy-to-tap Close buttons pinned to the bottom of panels */
    .wardrobe-box .wardrobe-close-btn,
    .settings-box .wardrobe-close-btn,
    #shop-overlay .shop-box button:last-child,
    #backpack-overlay .shop-box button:last-child {
        margin-top: auto !important;
        flex-shrink: 0;
        align-self: stretch;
        padding: 0.7rem 1rem !important;
        font-size: 0.8rem !important;
    }

    /* Shop / inventory lists: taller + touch-friendly grid */
    #shop-items,
    #inventory-list,
    #backpack-list,
    .shop-items {
        height: 36vh !important;
        max-height: 36vh !important;
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
        gap: 0.6rem;
        -webkit-overflow-scrolling: touch;
    }

    #inventory-list {
        display: grid;
    }

    .shop-item {
        min-height: 58px;
        padding: 0.9rem 1rem;
        font-size: 0.9rem;
    }

    .shop-item button {
        min-height: 44px;
        min-width: 64px;
    }

    .shop-card {
        min-height: 120px;
    }

    /* X/close buttons: 44x44 minimum touch target */
    .close-btn,
    .settings-close-btn {
        width: 44px !important;
        height: 44px !important;
        font-size: 22px !important;
    }

    .edit-inventory-close {
        min-height: 44px;
        font-size: 0.9rem;
    }

    /* The notch-safe padding belongs to the TOP of the screen, not the bottom
   bar menu. Zero it so the Menu button lines up with the other bar buttons. */
    #menu-container {
        padding: 0 !important;
    }

    /* Modals (sell quantity / confirm) only carry inline width, so force-fit
       them to small screens with comfortable tap targets */
    #confirmation-modal .login-box,
    #sell-quantity-modal .login-box {
        width: 92vw !important;
        max-width: 92vw !important;
        padding: 20px !important;
        max-height: 82vh;
        overflow-y: auto;
    }

    #sell-quantity-modal button,
    #sell-quantity-modal input[type="number"] {
        min-height: 44px;
    }
}

/* Portrait phones: bottom-anchored panels must stay fully inside the visible
   game area (the fullscreen game view ends above the 50px bottom bar). The
   desktop styles use transform/margin tricks & content-box bottom padding that
   shove panels ~30-60px past the bottom edge, clipping list rows + Close. */
@media (max-width: 900px) and (orientation: portrait) {
    .wardrobe-box,
    .shop-box,
    .settings-box {
        box-sizing: border-box !important;
        transform: none !important;
        margin-bottom: 0 !important;
        max-height: calc(100dvh - 56px) !important;
        height: auto !important;
    }

    /* Bottom-anchored panels: neutralize the extra 70px bottom padding that
       pushed them past the visible area (must match ID selectors to win). */
    #inventory-overlay .wardrobe-box,
    #shop-overlay .shop-box,
    #pet-overlay .wardrobe-box,
    #wardrobe-overlay .wardrobe-box,
    #settings-overlay .settings-box,
    #backpack-overlay .shop-box {
        max-height: calc(100dvh - 56px) !important;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    }

    /* Keep the centered windows (cash shop / collection) readable too. */
    #cash-shop-overlay .wardrobe-box,
    #collection-overlay .wardrobe-box {
        max-height: 82vh !important;
    }
}

/* Mobile: bottom bar buttons must fit the fixed (50-60px) bar instead of
   overflowing it; toggle buttons keep a real 44px touch target. */
@media (max-width: 900px) {
    #bottom-bar {
        padding: 0 8px !important;
    }

    #top-controls {
        gap: 6px !important;
        min-width: 0 !important;
    }

    #top-controls button {
        height: 40px !important;
        padding: 0 0.55rem !important;
        font-size: 0.5rem !important;
        line-height: 1 !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex-shrink: 1 !important;
    }

    #coin-display {
        font-size: 0.7rem !important;
        padding: 0.3rem 0.6rem !important;
        white-space: nowrap !important;
    }
}

/* NPC dialogue must fit short screens (landscape phones): narrower box, an
   internal scroll for the option buttons, and reasonable tap sizes. */
@media (max-width: 900px) {
    #dialogue-overlay .shop-box {
        width: min(94vw, 430px) !important;
        max-width: 94vw !important;
        max-height: calc(100dvh - 60px) !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        border-radius: 8px !important;
        border-bottom: var(--pixel-border) solid var(--border-dark-brown) !important;
        margin-bottom: 0 !important;
        padding: 1rem !important;
    }

    #dialogue-overlay #dialogue-text {
        font-size: 0.95rem !important;
        margin: 10px 0 !important;
        overflow-y: auto !important;
        flex: 0 0 auto !important;
        max-height: 22vh !important;
    }

    /* Option buttons live here: the only scrollable region of the panel */
    #dialogue-actions {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 10px !important;
    }

    .dialogue-choice-btn {
        min-height: 44px !important;
        margin: 6px 0 !important;
        padding: 8px 12px !important;
        font-size: 0.75rem !important;
    }

    #dialogue-portrait {
        width: 64px !important;
        height: 64px !important;
        flex-shrink: 0 !important;
    }

    #dialogue-close {
        min-height: 44px !important;
        flex-shrink: 0 !important;
    }
}

@media (pointer: coarse) {
    .close-btn,
    .settings-close-btn {
        width: 44px !important;
        height: 44px !important;
    }
}

/* --- MOBILE SIDE-MENU DRAWERS (chat / social / player info) ---
   The desktop left/side panels are hidden in fullscreen on phones. These
   bottom sheets give mobile players the same features without eating the
   play area: hidden by default, slide up over the game when tapped. */

.mobile-drawer-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    z-index: 2900;
}

.mobile-drawer-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.mobile-drawer {
    background: color-mix(in srgb, var(--bg-light-tan) 88%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    border: var(--pixel-border) solid var(--border-dark-brown);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    box-shadow: var(--panel-shadow);
    width: 100%;
    height: 45dvh;
    max-height: 45dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-sizing: border-box;
}

.mobile-drawer-overlay.visible .mobile-drawer {
    transform: translateY(0);
}

.mobile-drawer-handle {
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--border-light-brown);
    margin: 8px auto 2px auto;
    flex-shrink: 0;
}

.mobile-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px 8px 16px;
    flex-shrink: 0;
}

.mobile-drawer-header h2 {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-dark);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.mobile-drawer-header .close-btn {
    position: static;
}

.mobile-drawer-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: rgba(0, 0, 0, 0.35);
    margin: 0 12px;
    padding: 8px;
    border-radius: 6px;
}

.mobile-emote-bar {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 10px 12px 4px 12px;
    flex-shrink: 0;
}

.mobile-emote-bar .emote-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
}

.mobile-chat-input-row {
    display: flex;
    gap: 8px;
    padding: 8px 12px 12px 12px;
    flex-shrink: 0;
}

.mobile-chat-input-row input {
    flex: 1;
    min-width: 0;
    background: var(--bg-tan);
    border: 3px solid var(--border-dark-brown);
    color: var(--text-dark);
    padding: 12px 14px;
    font-size: 0.9rem;
    font-family: 'Retro Gaming', monospace;
    border-radius: 6px;
    box-sizing: border-box;
    height: 50px;
}

.mobile-chat-input-row button,
#mobile-refresh-friends-btn,
#mobile-leave-group-btn {
    background: var(--primary);
    border: 2px solid var(--btn-border);
    color: var(--btn-text);
    font-family: 'Retro Gaming', monospace;
    font-size: 0.65rem;
    cursor: pointer;
    box-shadow: var(--btn-inner);
    border-radius: 6px;
    padding: 0;
    min-width: 0;
    flex-shrink: 0;
}

/* The send button is a compact square beside the larger input */
#mobile-chat-send {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

#mobile-refresh-friends-btn,
#mobile-leave-group-btn {
    min-height: 44px;
    margin: 8px 12px;
    padding: 0 14px;
}

.mobile-drawer-tab {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#mobile-friends-list-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 12px;
}

#mobile-pending-friends-list {
    max-height: 30%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 12px;
}

#mobile-refresh-friends-btn,
#mobile-leave-group-btn {
    flex-shrink: 0;
    min-height: 44px;
    margin: 8px 12px;
}

#mobile-group-list-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 12px;
}

.mobile-drawer-player-info {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 12px 12px 12px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 6px;
    box-sizing: border-box;
}

/* Player info content already styled for the desktop sidebar; make sure it
   fills the drawer and its Close button stays reachable. */
.mobile-drawer-player-info .player-info-card {
    padding: 12px;
}

.mobile-drawer-player-info .player-info-close {
    width: auto;
    display: block;
    margin: 10px auto;
    min-width: 40%;
}

/* Chat + Social icons float over the game (hidden on desktop) */
#mobile-float-icons {
    display: none;
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    right: 10px;
    gap: 8px;
    flex-direction: column;
    z-index: 1500;
}

#mobile-float-icons button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-dark-brown);
    background: color-mix(in srgb, var(--bg-tan) 55%, transparent);
    color: var(--text-dark);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--btn-inner);
    padding: 0;
    pointer-events: auto;
}

#mobile-float-icons button:active {
    transform: scale(0.9);
    filter: brightness(1.2);
}

#mobile-world-status {
    display: none;
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tan);
    border: 2px solid var(--border-dark-brown);
    border-radius: 999px;
    box-shadow: var(--btn-inner);
    padding: 6px 14px;
    font-size: 0.6rem;
    color: var(--text-dark);
    white-space: nowrap;
    z-index: 1500;
    pointer-events: none;
}

/* Show the floating icons on mobile */
@media (max-width: 900px) {
    #mobile-float-icons {
        display: flex;
    }

    #mobile-world-status {
        display: block;
    }
}
