html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #0f1220;
    color: #e9eef4;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}

#ui {
    max-width: 1250px;
    margin: 12px auto;
    padding: 12px;
}

#topbar,
#bottombar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #12172a;
    border: 1px solid #212a46;
    border-radius: 10px;
    margin-bottom: 10px;
}


#help {
    opacity: 0.85;
    font-size: 14px;
    margin-top: 8px;
}

.game-wrap {
    position: relative;
    display: inline-block;
}

#game {
    display: block;
    width: 960px;
    height: 600px;
    background: #0b0f1a;
    border: 1px solid #212a46;
    border-radius: 10px;
}

#bottombar input {
    background: #0e1430;
    color: #e9eef4;
    border: 1px solid #2a3560;
    border-radius: 8px;
    padding: 8px 10px;
}

#bottombar button,

.panel button,
.panel button10,
#topbar .actions button {
    background: #1b2552;
    color: #e9eef4;
    border: 1px solid #2a3560;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
}



#bottombar button:hover,
.panel button:hover,
#topbar .actions button:hover {
    filter: brightness(1.1);
}

#stats {
    font-variant-numeric: tabular-nums;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

/* Panels with scrollbars where needed */
#furnace,
#shop,
#potions {
    overflow-y: auto;
    scrollbar-gutter: stable; /* keeps layout steady when scrollbar appears */
}

#inventory .list {
    flex: 1 1 auto;        /* fill remaining height */
    overflow-y: auto;      /* scroll only the list */
    padding-right: 6px;    /* room for scrollbar */
    scrollbar-gutter: stable;
}

.panel {
    position: absolute;
    top: 90px;
    right: 20px;
    bottom: 20px;           /* anchor to bottom so height is capped */
    width: 320px;
    display: flex;
    flex-direction: column;
    background: #0f1530;
    border: 1px solid #24305b;
    border-radius: 10px;
    padding: 10px;
    display: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

.panel .sub {
    opacity: 0.8;
    margin: -2px 0 8px 0;
    font: 12px/1.2 monospace;
}
.panel h3 {
    margin: 6px 0 10px 0;
}

.panel .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 6px 0;
    gap: 6px;
}

.list .row {
    padding: 4px 0;
    border-bottom: 1px dashed #2a3560;
}

/* Chat log */
.chatlog {
    position: absolute;
    left: 10px;
    bottom: 10px;
    width: 240px;
    max-height: 150px;
    padding: 10px 12px;

    background: rgba(8,12,26,0.65);
    border: 0;
    border-radius: 12px;
    box-shadow: none;

    overflow: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.chatlog::-webkit-scrollbar {
    width: 0;
    height: 0;
}
.chatlog > div {
    margin: 2px 0;
    color: #d9e2ff;
    text-shadow: 0 1px 1px rgba(0,0,0,0.35);
}
.chatlog > div:nth-child(odd) {
    color: #cfe1ff;
}

/* ⭐ Favourite item button in inventory */
#inventory .row {
    display: flex;
    align-items: center;
    gap: 6px;
}
#inventory .row .fav {
    width: 20px;
    height: 20px;
    padding: 0;
    line-height: 18px;
    font-size: 14px;
    background: transparent;
    color: #9fb3d1;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    cursor: pointer;
}
#inventory .row .fav.on {
    color: #ffd84a;
    border-color: rgba(255,216,74,0.45);
}
#inventory .row .fav:focus {
    outline: none;
}
#inventory .row .fav:disabled {
    opacity: 0.5;
    cursor: default;
}

/* =============== Trading =============== */

/* Main trade panel */
#tradePanel.panel {
    width: clamp(420px, 30vw, 540px); /* grows on wider screens, never below 420px */
}


#tradePanel .hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#tradePanel .title {
    font: 700 14px system-ui, sans-serif;
    letter-spacing: 0.5px;
}

#tradePanel .sub {
    opacity: 0.8;
    margin: -2px 0 6px 0;
    font: 12px/1.2 monospace;
}

#tradePanel .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#tradePanel .col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    flex: 1 1 0;
}

/* Scrollable “box” areas (offers/inventory) */
#tradePanel .box {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    padding: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 200px;
    scrollbar-gutter: stable;
}

#tradePanel .items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#tradePanel .item {
    display: grid;
    grid-template-columns: 24px 1fr auto auto auto; /* was only two autos before */
    gap: 8px;
    align-items: center;
}
#tradePanel .item > div:nth-child(2) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Be explicit: buttons stay on one line */
#tradePanel .item button,
#tradePanel .foot button,
#tradePanel .pill {
    white-space: nowrap;
}


#tradePanel .item img {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

/* Coins “pill” */
#tradePanel .pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
}

/* Inputs inside trade panel (match your bottom bar inputs) */
#tradePanel input[type="number"],
#tradePanel input[type="text"] {
    background: #0e1430;
    color: #e9eef4;
    border: 1px solid #2a3560;
    border-radius: 8px;
    padding: 6px 8px;
    min-width: 95px;
    font: 12px/1.2 monospace;
}

/* Optional: remove number spinners for a cleaner look */
#tradePanel input[type="number"]::-webkit-outer-spin-button,
#tradePanel input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#tradePanel input[type="number"] {
    -moz-appearance: textfield;
}
#ovenList {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 800px;
    overflow-y: auto;
    scrollbar-width: none;
}
/* Footer */
#tradePanel .foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
#tradePanel .small {
    opacity: 0.75;
    font-size: 11px;
}

/* Buttons already match via .panel button; just add variants used by JS */
.panel button.secondary {
    background: transparent;
    border-color: #3a4661;
}
.panel button.danger {
    background: #3a1e1e;
    border-color: #5c2a2a;
}

/* =============== Trade invite toast & Nearby list =============== */

#tradeInvite,
#tradeNearby {
    position: fixed;
    z-index: 1001;
    background: #12172a;
    color: #e9eef4;
    border: 1px solid #212a46;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    display: none; /* shown by JS */
    font: 12px/1.35 monospace;
}

/* Positions */
#tradeInvite { right: 16px; bottom: 16px; }
#tradeNearby { left: 16px; top: 16px; width: 280px; }

#tradeInvite .row,
#tradeNearby .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

#tradeNearby .row {
    padding: 6px 0;
    border-bottom: 1px dashed #2a3560;
}
#tradeNearby .row:last-child {
    border-bottom: 0;
}
