

body.has-mobile-controls .top-buttons-container {
    top: 6px !important;
    right: 6px !important;
    gap: 6px !important;
}

.top-buttons-container,
.top-buttons-container button,
.top-buttons-container .btn-setting,
.top-buttons-container .btn-donate-cart {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
}

.setting-dropdown {
    z-index: 1100;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.setting-item {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-box-sizing: border-box;
    image-rendering: pixelated;  
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    -webkit-font-smoothing: antialiased;
}

button, input, select {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    background: #1a0f08;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    -ms-touch-action: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(ellipse at center, #2a1a10 0%, #0a0503 100%);
    position: fixed;
    inset: 0;
    overscroll-behavior: none;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(60, 30, 10, 0.3) 0,
            rgba(60, 30, 10, 0.3) 2px,
            transparent 2px,
            transparent 8px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(40, 20, 8, 0.2) 0,
            rgba(40, 20, 8, 0.2) 1px,
            transparent 1px,
            transparent 16px
        );
    pointer-events: none;
    z-index: 0;
}

.game-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    padding: 0;
    margin: 0;
    overflow: hidden;
    touch-action: none;
    -ms-touch-action: none;
    overscroll-behavior: none;
}

#gameCanvas {
    background: #000;
    border: 3px solid #7a4e27;
    box-shadow:
        inset 0 0 0 2px #3a2010,
        0 0 24px rgba(0, 0, 0, 0.6);
    display: block;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    outline: none;
    touch-action: none;
    -ms-touch-action: none;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

body.has-mobile-controls #gameCanvas {
    border: 1px solid rgba(214, 165, 92, 0.4);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8), 0 0 15px rgba(214, 165, 92, 0.15);
    border-radius: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    touch-action: none;
    -ms-touch-action: none;
    overscroll-behavior: none;
}

/* Leaderboard: compact tabs and readable player cards on narrow screens. */
.leaderboard-tabs {
    overflow-x: auto;
    scrollbar-width: thin;
}

.leaderboard-player-name {
    appearance: none;
    border: 0;
    padding: 2px 0;
    background: transparent;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-align: left;
    text-decoration: underline;
    text-decoration-color: rgba(211, 84, 0, 0.4);
    text-underline-offset: 3px;
}

.leaderboard-player-name:hover,
.leaderboard-player-name:focus-visible {
    color: #d35400 !important;
    text-decoration-color: currentColor;
    outline: none;
}

.player-profile-viewer {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: grid;
    place-items: center;
    padding: 18px;
    visibility: hidden;
    pointer-events: none;
}

.player-profile-viewer.is-open,
.player-profile-viewer.is-closing {
    visibility: visible;
    pointer-events: auto;
}

.player-profile-viewer.is-open .player-profile-viewer__backdrop,
.player-profile-viewer.is-open .player-profile-card {
    opacity: 1;
}

.player-profile-viewer.is-open .player-profile-card {
    transform: scale(1) translateY(0);
}

.player-profile-close {
    position: absolute;
    z-index: 2;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    font-size: 27px;
    line-height: 32px;
    cursor: pointer;
}

.player-profile-close:hover,
.player-profile-close:focus-visible {
    background: rgba(211, 84, 0, 0.85);
    outline: 2px solid rgba(255, 255, 255, 0.75);
}

.player-profile-status {
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 800;
    color: #f2d28b;
}

.player-profile-status--error { color: #ff9c91; }

.player-profile-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #f2c45c;
    border-radius: 50%;
    animation: player-profile-spin 700ms linear infinite;
}

@keyframes player-profile-spin { to { transform: rotate(360deg); } }

.player-profile-viewer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 17, 14, 0.68);
    backdrop-filter: blur(9px);
    opacity: 0;
    transition: opacity 200ms ease;
}

.player-profile-card {
    position: relative;
    width: min(640px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
    overflow: auto;
    padding: 24px 26px;
    border: 3px solid #8b5628;
    border-radius: 24px;
    background: #fcf6e8;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    color: #4a321a;
    opacity: 0;
    transform: scale(0.94) translateY(12px);
    transition: opacity 200ms ease, transform 200ms ease;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.player-profile-close {
    position: absolute;
    z-index: 99;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 12px;
    background: #a42c23;
    color: #ffffff;
    font-size: 20px;
    font-weight: bold;
    line-height: 38px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease;
}

.player-profile-close:hover,
.player-profile-close:focus-visible {
    background: #c0392b;
    transform: scale(1.05);
}

.profile-modal-layout {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 22px;
    align-items: start;
}

.profile-modal-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.profile-avatar-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #9bcf70 0%, #5b984b 58%, #3b6f38 100%);
    border: 2.5px solid #8b5628;
    border-radius: 18px;
    padding: 10px 6px;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.25), 0 4px 10px rgba(0, 0, 0, 0.15);
}

.profile-avatar-wrapper::before {
    content: '';
    position: absolute;
    bottom: 8px;
    width: 120px;
    height: 24px;
    border-radius: 50%;
    background: rgba(30, 67, 27, 0.45);
    box-shadow: 0 0 0 6px rgba(214, 239, 130, 0.15);
    z-index: 1;
}

#publicPlayerAvatar {
    position: relative;
    z-index: 2;
    width: 180px;
    height: 150px;
    display: block;
    image-rendering: pixelated;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.profile-visual-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-v-card {
    padding: 10px 12px;
    background: #fff;
    border: 1.5px solid #e0d2b4;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.profile-v-label {
    font-size: 11.5px;
    font-weight: 700;
    color: #8c5737;
}

.profile-v-val {
    font-size: 13.5px;
    font-weight: 800;
    color: #5a3818;
}

.profile-v-val.is-active {
    color: #27ae60;
}

.profile-modal-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-header-info {
    border-bottom: 2px solid #e6d7b8;
    padding-bottom: 12px;
}

.player-profile-kicker {
    display: block;
    color: #e67e22;
    font-size: 11.5px;
    font-weight: 900;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.profile-display-name {
    margin: 4px 36px 4px 0;
    color: #6e2716;
    font-size: 26px;
    font-weight: 900;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.player-profile-uid {
    color: #8c5737;
    font-size: 12.5px;
    font-weight: 700;
}

.player-profile-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 0;
}

.profile-detail-item {
    padding: 12px 16px;
    border: 1.5px solid #e0d2b4;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
}

.profile-detail-item dt {
    color: #8c5737;
    font-size: 11.5px;
    font-weight: 700;
}

.profile-detail-item dd {
    margin: 4px 0 0;
    color: #3a2410;
    font-size: 14.5px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.profile-detail-item dd.highlight-level {
    color: #d35400;
    font-size: 17px;
    font-weight: 900;
}

@media (max-width: 540px) {
    .player-profile-viewer { padding: 10px; }
    .player-profile-card {
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
        padding: 20px 16px 18px;
        border-radius: 18px;
    }
    .profile-modal-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .profile-avatar-wrapper { margin: 0 auto; }
    .profile-header-info { text-align: center; }
    .profile-display-name { margin-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .player-profile-card,
    .player-profile-viewer__backdrop { transition: none; }
}

@media (max-width: 600px) {
    #leaderboardModalOverlay .notice-modal-card {
        width: calc(100vw - 16px) !important;
        max-width: none !important;
    }

    .leaderboard-tabs {
        flex-wrap: nowrap !important;
        padding: 8px 8px 0 !important;
        gap: 4px !important;
    }

    .leaderboard-tab-btn {
        flex: 0 0 auto !important;
        min-width: 106px !important;
        min-height: 42px;
        padding: 7px 9px !important;
        font-size: 11.5px !important;
        white-space: normal;
    }

    #leaderboardListContainer {
        padding: 10px 8px !important;
    }

    .leaderboard-row {
        align-items: flex-start !important;
        padding: 10px !important;
        gap: 8px !important;
    }

    .leaderboard-player {
        gap: 8px !important;
        overflow: hidden;
    }

    .leaderboard-player > div:last-child {
        min-width: 0;
    }

    .leaderboard-meta {
        overflow-wrap: anywhere;
        line-height: 1.3;
    }

    .leaderboard-value {
        max-width: 42%;
        overflow-wrap: anywhere;
    }
}

#gameCanvas:focus {
    box-shadow:
        inset 0 0 0 2px #8b5a2b,
        0 0 40px rgba(255, 200, 80, 0.4),
        0 4px 0 #2a1808;
}

body:not(.game-started) .top-buttons-container {
    display: none !important;
}

body.has-mobile-controls:not(.game-started) .top-buttons-container {
    display: none !important;
}

body:not(.game-started) .game-wrapper,
body:not(.game-started) #mobileControls,
body:not(.game-started) #alertBannerOverlay {
    visibility: hidden !important;
    display: none !important;
}

.top-buttons-container {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 14px;
}

.setting-container {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

#mobileFeaturePanel {
    display: none !important;
}

body.has-mobile-controls .top-buttons-container {
    display: flex !important;
    position: fixed !important;
    top: 10px !important;
    right: 10px !important;
    z-index: 1000 !important;
    gap: 8px !important;
}

body.has-mobile-controls .setting-container {
    display: flex !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
}

.gold-display-box {
    height: 44px;
    padding: 0 16px;
    background: rgba(40, 30, 20, 0.9);
    border: 2px solid #8b5a2b;
    border-radius: 22px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.gold-icon {
    font-size: 18px;
}

.gold-amount {
    color: #ffe066;
    font-weight: 700;
    font-size: 16px;
}

.gold-unit {
    color: #ffffff;
    font-weight: 600;
    font-size: 14px;
}

.btn-setting {
    width: 44px;
    height: 44px;
    background: rgba(40, 30, 20, 0.85);
    border: 2px solid #8b5a2b;
    border-radius: 8px;
    color: #ffe066;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.btn-setting:hover {
    background: rgba(70, 50, 30, 0.95);
    border-color: #ffe066;
    transform: scale(1.1);
}

.setting-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    background: rgba(35, 25, 15, 0.95);
    border: 2px solid #8b5a2b;
    border-radius: 8px;
    padding: 6px 0;
    min-width: 250px;
    width: max-content;
    max-width: 90vw;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    max-height: calc(100dvh - 70px);
    overflow-y: auto;
}

.setting-fps {
    padding: 9px 16px 10px;
    border-top: 1px solid rgba(139, 90, 43, 0.45);
    color: #fff0b8;
}

.setting-fps-title {
    margin-bottom: 7px;
    font-size: 13.5px;
    font-weight: 800;
}

.setting-fps-options {
    display: flex;
    align-items: center;
    gap: 6px;
}

.setting-fps-option {
    width: 58px;
    height: 32px;
    padding: 0;
    border: 1.5px solid #8b5a2b;
    border-radius: 6px;
    background: rgba(20, 14, 8, 0.75);
    color: #fff0b8;
    font: 800 13px system-ui, sans-serif;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.setting-fps-option.active {
    border-color: #ffe066;
    background: #8b5628;
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255, 224, 102, 0.35);
}

.setting-fps-warning {
    width: 210px;
    margin-top: 7px;
    color: #ffca6b;
    font-size: 10.5px;
    line-height: 1.35;
    white-space: normal;
}

.setting-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 8px 16px;
    border-bottom: 1px solid rgba(139, 90, 43, 0.5);
    color: #FFF0B8;
    font-weight: 700;
    font-size: 14px;
}

.setting-close-btn {
    background: rgba(220, 50, 50, 0.25);
    border: 1px solid rgba(255, 100, 100, 0.6);
    color: #ff9999;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.setting-close-btn:hover {
    background: #e74c3c;
    color: #ffffff;
    transform: scale(1.1);
}

.setting-dropdown.hidden {
    display: none;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: #ffe066;
    font-size: 13.5px;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.1s, opacity 0.15s, color 0.15s;
    outline: none;
    background: transparent !important;
    -webkit-tap-highlight-color: transparent;
}

.setting-item:hover,
.setting-item:active,
.setting-item:focus {
    background: rgba(139, 90, 43, 0.4) !important;
    outline: none;
}

.setting-item.is-off {
    color: #a89454 !important;
    opacity: 0.75;
}

.setting-item.is-off .setting-icon {
    filter: grayscale(80%);
}

.setting-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.setting-toggle-row {
    justify-content: flex-start;
}
.setting-toggle-row .setting-text {
    flex: 1;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 42px;
    min-width: 42px;
    height: 22px;
    margin-left: auto;
    cursor: pointer;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #555;
    border-radius: 22px;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.4);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    left: 2px;
    top: 2px;
    width: 18px;
    height: 18px;
    background: #ccc;
    border-radius: 50%;
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 0 8px rgba(46,204,113,0.4);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.setting-toggle-row.is-off .setting-text {
    color: #a89454 !important;
    opacity: 0.75;
}
.setting-toggle-row.is-off .setting-icon {
    filter: grayscale(80%);
    opacity: 0.75;
}

.loading-screen {
    position: fixed;
    inset: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999999;
    transition: opacity 0.5s ease;
    overflow: hidden;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.loading-text {
    font-size: clamp(16px, 4vw, 22px);
    font-weight: bold;
    margin-bottom: 12px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    font-family: inherit;
    text-align: center;
    animation: slideInLeft 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    opacity: 0;
}

.loading-text:nth-child(1) {
    animation-delay: 0.1s;
    font-size: clamp(20px, 5vw, 26px);
}

.loading-text:nth-child(2) {
    animation-delay: 0.35s;
    color: #333333 !important;
}

.loading-text:nth-child(3) {
    animation-delay: 0.6s;
    color: #666666 !important;
    margin-bottom: 24px;
}

@keyframes slideInLeft {
    0% {
        opacity: 0;
        transform: translateX(-100px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.loading-bar {
    width: 280px;
    height: 18px;
    background: #e0e0e0;
    border: 2.5px solid #27ae60;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    padding: 2px;
}

.loading-bar-inner {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #2ecc71, #27ae60, #1abc9c);
    border-radius: 6px;
    transition: width 0.1s linear;
}

.fps-counter {
    position: fixed;
    top: 8px;
    right: 8px;
    color: #ffe066;
    background: rgba(0,0,0,0.7);
    padding: 4px 8px;
    font-size: 11px;
    z-index: 50;
    display: none;
}

.fps-counter.show {
    display: block;
}

.alert-banner-overlay {
    position: fixed;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: min(90%, 640px);
    height: 36px;
    background: rgba(20, 14, 8, 0.85);
    color: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
    overflow: hidden;
    z-index: 60;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.alert-banner-overlay.show {
    opacity: 1;
}

.alert-banner-track {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
}

.alert-banner-message {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    
    transform: translateX(100%);
    animation: alert-marquee 12s linear forwards;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.2px;
    will-change: transform;
}

.alert-banner-message .alert-text {
    color: #ffffff;
}

.alert-banner-message .alert-label {
    color: #ff5252;
    font-weight: 700;
    margin-right: 4px;
}

@keyframes alert-marquee {
    0% {
        transform: translateX(100%);
    }
    100% {
        
        transform: translateX(calc(-100% - 0px));
    }
}

@media (max-width: 600px) {
    .alert-banner-overlay {
        top: 8px;
        height: 32px;
        border-radius: 18px;
    }
    .alert-banner-message {
        font-size: 12px;
    }
}

.save-slot-overlay {
    position: fixed;
    inset: 0;
    background: #0a0503;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 190;
}

.save-slot-overlay.hidden {
    display: none;
}

.save-slot-box {
    background: #3d2414;
    border: 4px solid #8b5a2b;
    box-shadow:
        inset 0 0 0 2px #5a3818,
        0 10px 30px rgba(0, 0, 0, 0.8);
    padding: 28px 32px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 520px;
    max-width: 94vw;
    color: #ffe066;
    text-align: center;
}

.save-slot-title {
    font-size: 20px;
    letter-spacing: 1.5px;
    text-shadow: 2px 2px 0 #1a0f08;
    margin-bottom: 4px;
}

.save-slot-subtitle {
    color: #d4b137;
    font-size: 12px;
    margin-bottom: 20px;
}

.save-slot-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.save-slot-item {
    background: #25140b;
    border: 3px solid #5a3818;
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.save-slot-item:hover {
    border-color: #d4b137;
    background: #2e1a0e;
    transform: translateY(-1px);
}

.save-slot-item.has-save {
    border-color: #6c421e;
}

.save-slot-item.empty-slot {
    border-style: dashed;
    opacity: 0.7;
}

.save-slot-item.empty-slot:hover {
    opacity: 1;
}

.save-slot-avatar {
    width: 40px;
    height: 52px;
    flex-shrink: 0;
    image-rendering: pixelated;
    display: flex;
    justify-content: center;
    align-items: center;
}

.save-slot-avatar canvas {
    width: 36px;
    height: 48px;
    image-rendering: pixelated;
}

.save-slot-avatar .empty-icon {
    font-size: 32px;
    opacity: 0.4;
}

.save-slot-info {
    flex: 1;
    text-align: left;
}

.save-slot-name {
    font-size: 15px;
    font-weight: bold;
    color: #ffffff;
    margin-bottom: 4px;
}

.save-slot-details {
    font-size: 11px;
    color: #d4b137;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.save-slot-details .detail-tag {
    background: rgba(108, 66, 30, 0.5);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
}

.save-slot-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.save-slot-btn {
    padding: 8px 16px;
    border: 2px solid;
    border-radius: 6px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.save-slot-btn-play {
    background: linear-gradient(180deg, #6cb85a 0%, #3d8024 100%);
    border-color: #82d868;
    color: #ffffff;
    box-shadow: 0 3px 0 #204810;
}

.save-slot-btn-play:hover {
    background: linear-gradient(180deg, #7cd06a 0%, #46942a 100%);
    transform: translateY(-1px);
}

.save-slot-btn-play:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #204810;
}

.save-slot-btn-new {
    background: linear-gradient(180deg, #5a8ab8 0%, #2d5a80 100%);
    border-color: #68a8d8;
    color: #ffffff;
    box-shadow: 0 3px 0 #103858;
}

.save-slot-btn-new:hover {
    background: linear-gradient(180deg, #6a9ac8 0%, #3a6a90 100%);
    transform: translateY(-1px);
}

.save-slot-btn-new:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #103858;
}

.save-slot-btn-delete {
    background: linear-gradient(180deg, #b83838 0%, #882020 100%);
    border-color: #d84848;
    color: #ffffff;
    padding: 8px 12px;
    box-shadow: 0 3px 0 #400808;
}

.save-slot-btn-delete:hover {
    background: linear-gradient(180deg, #c84848 0%, #983030 100%);
    transform: translateY(-1px);
}

.save-slot-btn-delete:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #400808;
}

.save-slot-empty-label {
    color: #8c6b47;
    font-size: 14px;
    font-style: italic;
}

.char-modal-overlay {
    position: fixed;
    inset: 0;
    background: #0a0503;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.char-modal-overlay.hidden {
    display: none;
}

.char-modal-box {
    background: #3d2414;
    border: 4px solid #8b5a2b;
    box-shadow:
        inset 0 0 0 2px #5a3818,
        0 10px 30px rgba(0, 0, 0, 0.8);
    padding: 24px 32px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 420px;
    max-width: 90vw;
    color: #ffe066;
    text-align: center;
}

.char-modal-title {
    font-size: 20px;
    letter-spacing: 1.5px;
    text-shadow: 2px 2px 0 #1a0f08;
    margin-bottom: 4px;
}

.char-modal-subtitle {
    color: #d4b137;
    font-size: 12px;
    margin-bottom: 20px;
}

.char-input-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 18px;
}

.char-input-group label {
    font-size: 12px;
    color: #ffe066;
    margin-bottom: 6px;
    font-weight: bold;
}

.char-input-group input {
    width: 100%;
    padding: 10px 14px;
    background: #1f120a;
    border: 2px solid #6c421e;
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    border-radius: 4px;
    outline: none;
}

.char-input-group input:focus {
    border-color: #ffe066;
}

.char-select-title {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 12px;
    align-self: flex-start;
}

.char-options {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    margin-bottom: 24px;
}

.char-card {
    flex: 1;
    background: #25140b;
    border: 3px solid #5a3818;
    border-radius: 6px;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.char-card:hover {
    border-color: #d4b137;
    transform: translateY(-2px);
}

.char-card.active {
    background: #4a2d18;
    border-color: #ffe066;
    box-shadow: 0 0 12px rgba(255, 224, 102, 0.4);
}

.char-preview {
    width: 36px;
    height: 48px;
    margin-bottom: 8px;
    image-rendering: pixelated;
    background-repeat: no-repeat;
    background-position: center;
}

.char-label {
    font-size: 12px;
    color: #fff;
}

.btn-start-game {
    width: 100%;
    padding: 12px;
    background: linear-gradient(180deg, #6cb85a 0%, #3d8024 100%);
    border: 2px solid #82d868;
    color: #ffffff;
    font-family: inherit;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 1px;
    border-radius: 6px;
    cursor: pointer;
    text-shadow: 1px 1px 0 #1a400e;
    box-shadow: 0 4px 0 #204810;
    transition: all 0.15s ease;
}

.char-modal-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.char-modal-actions .btn-start-game {
    margin: 0;
}

.btn-back-save-slots {
    min-width: 112px;
    padding: 11px 18px;
    border: 2px solid #8b5628;
    border-radius: 8px;
    background: linear-gradient(180deg, #fff0c8 0%, #e6c58d 100%);
    color: #5a3218;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
    box-shadow: 0 3px 7px rgba(0, 0, 0, 0.28);
}

.btn-back-save-slots:hover,
.btn-back-save-slots:active {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.btn-start-game:hover {
    background: linear-gradient(180deg, #7cd06a 0%, #46942a 100%);
    transform: translateY(-1px);
}

.btn-start-game:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #204810;
}

.inv-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 7, 4, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1100;
}

.inv-modal-overlay.hidden {
    display: none;
}

.inv-modal-box {
    background: #d8aa68;
    border: 5px solid #4a2810;
    box-shadow:
        inset 0 0 0 3px #8b5628,
        0 15px 40px rgba(0,0,0,0.9);
    border-radius: 12px;
    width: 880px;
    max-width: 96vw;
    height: 88vh;
    max-height: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    user-select: none;
    z-index: 1000;
    overflow: hidden;
    box-sizing: border-box;
}

.inv-scrollable {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    margin-top: 8px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.inv-modal-box::-webkit-scrollbar,
.inv-scrollable::-webkit-scrollbar {
    width: 8px;
}
.inv-modal-box::-webkit-scrollbar-track,
.inv-scrollable::-webkit-scrollbar-track {
    background: #2a1808;
    border-radius: 4px;
}
.inv-modal-box::-webkit-scrollbar-thumb,
.inv-scrollable::-webkit-scrollbar-thumb {
    background: #8b5a2b;
    border-radius: 4px;
}
.inv-modal-box::-webkit-scrollbar-thumb:hover,
.inv-scrollable::-webkit-scrollbar-thumb:hover {
    background: #b8881a;
}

.inv-header {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.inv-header-tools {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 5;
}

.inv-capacity-box-mini {
    background: #4a2f0f !important;
    border: 2px solid #ffe066 !important;
    border-radius: 8px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
    font-weight: 900 !important;
    color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
}

.inv-sort-btn {
    min-height: 28px;
    padding: 4px 9px;
    border: 2px solid #ffe066;
    border-radius: 8px;
    background: linear-gradient(180deg, #4f8c35 0%, #2f6825 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    white-space: nowrap;
}

.inv-sort-btn:hover {
    filter: brightness(1.12);
}

.inv-sort-btn:active {
    transform: translateY(1px);
}

.inv-title-badge {
    background: linear-gradient(180deg, #9c6c3c 0%, #684220 100%);
    border: 3px solid #36200c;
    border-radius: 8px;
    padding: 6px 40px;
    box-shadow: 0 4px 0 #241406;
    display: flex;
    align-items: center;
    gap: 12px;
}

.inv-title-text {
    color: #ffffff;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 #241406;
}

.inv-close-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 38px;
    height: 38px;
    background: linear-gradient(180deg, #d84848 0%, #a82828 100%);
    border: 3px solid #ffffff;
    color: #ffffff;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 0 #581010;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.1s;
}

.inv-close-btn:hover {
    transform: scale(1.08);
}

.inv-content-grid {
    display: flex;
    width: 100%;
    gap: 12px;
    margin-bottom: 12px;
}

.inv-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.inv-category-tag {
    background: linear-gradient(180deg, #486828 0%, #2e4418 100%);
    border: 2px solid #1a2c0c;
    border-radius: 4px;
    padding: 4px 24px;
    color: #ffffff;
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 8px;
    box-shadow: 0 2px 0 #121e08;
}

.inv-category-tag.crop-tag {
    background: linear-gradient(180deg, #885428 0%, #583414 100%);
}

.inv-divider {
    width: 3px;
    background: #684220;
    margin: 30px 4px 0 4px;
    border-radius: 2px;
}

.inv-slots-grid {
    background: #3a2212;
    border: 3px solid #24140a;
    border-radius: 8px;
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.6);
}

.inv-slot {
    width: 70px;
    height: 70px;
    background: #28160c;
    border: 2px solid #58361e;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
}

.inv-slot:hover {
    border-color: #f8c840;
    background: #381e10;
}

.inv-slot.selected {
    border: 3px solid #ffe066;
    background: #482814;
    box-shadow: 0 0 10px rgba(255, 224, 102, 0.5);
}

.inv-slot.reorder-source {
    border: 3px solid #ff8a3d;
    background: #5a3018;
    box-shadow: 0 0 14px rgba(255, 138, 61, 0.7);
    animation: invReorderPulse 1s ease-in-out infinite;
    opacity: 0.5;
}

.inv-slot.drag-target {
    border: 3px dashed #ff8a3d;
    background: #4a2810;
    transform: scale(1.05);
}

.inv-slots-grid.reorder-mode .inv-slot:not(.empty):not(.reorder-source) {
    border: 2px dashed #ff8a3d;
    background: #2a1a10;
    cursor: grab;
}

.inv-slots-grid.reorder-mode .inv-slot:not(.empty):not(.reorder-source):hover {
    border: 3px solid #ff8a3d;
    background: #4a2810;
}

@keyframes invReorderPulse {
    0%, 100% { box-shadow: 0 0 14px rgba(255, 138, 61, 0.7); transform: scale(1); }
    50%      { box-shadow: 0 0 22px rgba(255, 138, 61, 1.0); transform: scale(1.04); }
}

.inv-reorder-toast {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 12, 6, 0.92);
    color: #ffe066;
    border: 2px solid #ff8a3d;
    border-radius: 8px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 700;
    z-index: 1100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    white-space: nowrap;
    animation: invReorderToastIn 0.25s ease-out;
}

@keyframes invReorderToastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.inv-slot-icon {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
    display: flex;
    justify-content: center;
    align-items: center;
}

.inv-slot-icon canvas {
    width: 40px;
    height: 40px;
}

.inv-slot-label {
    font-size: 11px;
    color: #ffffff;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.1;
}

.inv-slot-count {
    font-size: 12px;
    font-weight: bold;
    color: #ffe066;
}

.inv-slot.empty::after {
    content: '+';
    font-size: 20px;
    color: #58361e;
}

.inv-footer-panel {
    display: flex;
    width: 100%;
    gap: 10px;
    margin-bottom: 12px;
}

.inv-capacity-box {
    width: 140px;
    background: #3a2212;
    border: 3px solid #24140a;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.5);
}

.backpack-icon {
    font-size: 28px;
}

.capacity-label {
    font-size: 11px;
    color: #d4b137;
}

.capacity-value {
    font-size: 16px;
    font-weight: bold;
    color: #ffe066;
}

.inv-item-detail {
    flex: 1;
    background: #f4e8c8;
    border: 3px solid #886030;
    border-radius: 8px;
    padding: 10px 14px;
    display: none;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.detail-icon {
    width: 44px;
    height: 44px;
    background: #d8c090;
    border: 2px solid #886030;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

.detail-icon canvas {
    width: 40px;
    height: 40px;
}

.detail-title {
    font-size: 14px;
    font-weight: bold;
    color: #4a2810;
    margin-bottom: 2px;
}

.detail-desc {
    font-size: 11px;
    color: #5c3818;
    margin: 0 0 1px 0;
}

.detail-time {
    font-size: 11px;
    color: #5c3818;
    margin-top: 0;
}

.time-green {
    color: #2e7a18;
    font-weight: bold;
}

.inv-bottom-shortcuts {
    display: flex;
    justify-content: center;
    gap: 16px;
    width: 100%;
}

.shortcut-item {
    background: #25140b;
    border: 2px solid #4a2810;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 11px;
    color: #d4b137;
    display: flex;
    align-items: center;
    gap: 6px;
}

.shortcut-item strong {
    background: #4a2810;
    color: #ffe066;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
}

.inv-hotbar-section {
    width: 100%;
    margin-bottom: 10px;
}

.inv-hotbar-title {
    font-size: 12px;
    font-weight: bold;
    color: #ffe066;
    text-align: center;
    margin-bottom: 6px;
}

.inv-hotbar-toolbar {
    position: relative;
    width: fit-content;
    margin: 0 auto;
    padding-top: 32px;
}

.inv-trash-btn {
    position: absolute;
    top: 0;
    right: 9px;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 2px solid #7b291f;
    border-radius: 5px;
    background: #b83a2e;
    color: #fff;
    box-shadow: 0 2px 0 #541810;
    font-size: 15px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    z-index: 4;
}

.inv-trash-btn:hover,
.inv-trash-btn:focus-visible,
.inv-trash-btn.drag-target {
    background: #e24b3b;
    border-color: #ffd2c8;
    box-shadow: 0 0 10px rgba(226, 75, 59, 0.8);
    outline: none;
}

.inv-trash-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #541810;
}

.inv-hotbar-grid {
    display: flex;
    justify-content: center;
    gap: 8px;
    background: #24140a;
    border: 2px solid #4a2810;
    border-radius: 8px;
    padding: 10px;
    min-height: 60px;
    width: fit-content !important;
    margin: 0 auto !important;
}

.inv-hotbar-slot {
    width: 50px;
    height: 50px;
    background: #1a0f08;
    border: 2px dashed #5a3818;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

.inv-hotbar-slot:hover {
    border-color: #ffe066;
    background: #3a2010;
    transform: translateY(-2px);
}

.inv-hotbar-slot:active {
    transform: scale(0.95);
}

.inv-hotbar-slot.drag-over {
    border-color: #ffe066;
    background: #3a2010;
}

.inv-hotbar-slot.dragging {
    border-color: #ff8a3d;
    border-style: solid;
    background: #5a3018;
    box-shadow: 0 0 14px rgba(255, 138, 61, 0.8);
    transform: scale(1.05);
    transition: none;
    z-index: 5;
}

.inv-hotbar-slot.drag-target {
    border-color: #ff8a3d;
    border-style: dashed;
    background: #4a2810;
    transform: scale(1.05);
}

.inv-hotbar-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%) scale(1.08);
    background: #5a3018;
    border: 3px solid #ff8a3d;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0.95;
    overflow: hidden;
}

.inv-hotbar-slot .slot-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 9px;
    font-weight: bold;
    color: #ffe066;
    z-index: 10;
}

.inv-hotbar-slot .slot-icon {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.inv-hotbar-slot .slot-icon canvas {
    width: 32px !important;
    height: 32px !important;
    display: block !important;
}

.inv-hotbar-slot .slot-name {
    font-size: 8px;
    color: #d4b137;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 90% !important;
    text-align: center !important;
    margin-top: 1px !important;
}

.inv-hotbar-hint {
    font-size: 10px;
    color: #888;
    text-align: center;
    display: block;
    margin-top: 4px;
}

@media (max-width: 1024px) {
    .inv-hotbar-toolbar {
        padding-top: 0;
        padding-right: 34px;
    }

    .inv-trash-btn {
        top: 50%;
        right: 2px;
        width: 26px;
        height: 26px;
        line-height: 22px;
        -webkit-transform: translateY(-50%);
        transform: translateY(-50%);
    }

    .inv-trash-btn:active {
        -webkit-transform: translateY(calc(-50% + 1px));
        transform: translateY(calc(-50% + 1px));
    }
}

.inv-draggable-grid {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    background: #24140a;
    border: 2px solid #4a2810;
    border-radius: 8px;
    padding: 10px;
}

.inv-draggable-item {
    width: 48px;
    height: 48px;
    background: #2a1808;
    border: 2px solid #5a3818;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: all 0.1s;
}

.inv-draggable-item:hover {
    border-color: #ffe066;
    background: #3a2010;
}

.inv-draggable-item:active {
    cursor: grabbing;
}

.inv-draggable-item .drag-icon {
    width: 28px;
    height: 28px;
}

.inv-draggable-item .drag-name {
    font-size: 8px;
    color: #d4b137;
}

.inv-draggable-item .drag-name {
    font-size: 9px;
    color: #d4b137;
}

@media (max-width: 1024px) {
    .btn-setting { width: 44px; height: 44px; font-size: 20px; }

    .setting-dropdown {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90vw !important;
        max-width: 330px !important;
        max-height: 82vh !important;
        max-height: 82dvh !important;
        overflow-y: auto !important;
        border-radius: 14px !important;
        border: 3px solid #8b5a2b !important;
        box-shadow: 0 12px 35px rgba(0,0,0,0.85) !important;
        padding: 4px 0 !important;
        z-index: 1200 !important;
        -webkit-overflow-scrolling: touch;
    }

    .setting-header {
        padding: 10px 14px !important;
        font-size: 15px !important;
        position: sticky !important;
        top: 0 !important;
        background: #23190f !important;
        z-index: 10 !important;
    }

    .setting-item {
        padding: 11px 16px !important;
        font-size: 13.5px !important;
    }

    .event-modal-card,
    .notice-modal-card,
    .help-modal-card,
    .map-modal-card,
    .save-slot-box,
    .char-modal-box { 
        width: 96vw !important; 
        max-width: 98vw !important; 
        max-height: 85vh !important;
        max-height: 85dvh !important;
        padding: 12px 10px !important;
        overflow-y: auto !important;
        border-radius: 16px !important;
    }

    .save-slot-item {
        padding: 10px 12px !important;
        gap: 10px !important;
    }

    .save-slot-avatar { width: 32px; height: 42px; }
    .save-slot-avatar canvas { width: 28px; height: 38px; }
    .save-slot-name { font-size: 13px; }
    .save-slot-details { font-size: 10px; gap: 6px; }
    .save-slot-btn { padding: 6px 10px; font-size: 10px; }

    .event-modal-head,
    .notice-modal-head {
        margin-bottom: 10px !important;
        gap: 8px !important;
    }

    .event-head-icon,
    .notice-head-icon {
        width: 42px !important;
        height: 42px !important;
        font-size: 22px !important;
    }

    .event-main-title,
    .notice-main-title {
        font-size: 16px !important;
    }

    .event-sub-title,
    .notice-sub-title {
        font-size: 11px !important;
    }

    .event-body-scroll,
    .notice-body-scroll {
        padding: 6px 2px !important;
        max-height: calc(90vh - 130px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .event-card-box {
        padding: 10px 12px !important;
        gap: 10px !important;
        border-radius: 12px !important;
    }

    .event-card-avatar {
        width: 44px !important;
        height: 44px !important;
        font-size: 22px !important;
    }

    .event-item-title {
        font-size: 13.5px !important;
    }

    .event-item-desc {
        font-size: 11px !important;
    }

    .help-sign {
        font-size: 14px !important;
        padding: 6px 16px !important;
    }

    .help-steps {
        gap: 8px !important;
        margin-top: 10px !important;
    }

    .help-step {
        padding: 8px 10px !important;
        gap: 8px !important;
        border-radius: 10px !important;
    }

    .help-num {
        width: 24px !important;
        height: 24px !important;
        font-size: 12px !important;
    }

    .help-icon {
        font-size: 22px !important;
    }

    .help-title {
        font-size: 13.5px !important;
    }

    .help-desc {
        font-size: 11px !important;
    }

    .help-tip {
        padding: 8px 10px !important;
        font-size: 11px !important;
        margin-top: 10px !important;
    }

    .inv-modal-box { 
        width: 96vw !important; 
        max-width: 98vw !important; 
        height: 75vh !important;
        max-height: 75vh !important;
        padding: 6px 6px !important; 
    }
    .inv-header {
        margin-bottom: 4px !important;
    }
    .inv-title-badge {
        padding: 4px 18px !important;
    }
    .inv-title-text {
        font-size: 15px !important;
        letter-spacing: 1px !important;
    }
    .inv-close-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 15px !important;
        top: -4px !important;
        right: -4px !important;
    }
    .inv-tab-content-wrapper {
        overflow: hidden !important;
    }
    .inv-scrollable {
        flex: 0 1 auto !important;
        min-height: 60px !important;
        max-height: 30vh !important;
        overflow-y: auto !important;
    }
    .inv-content-grid { 
        flex-direction: column !important; 
        gap: 6px !important;
        margin-bottom: 6px !important;
    }
    .inv-divider { display: none !important; }
    .inv-category-tag {
        padding: 2px 12px !important;
        font-size: 11px !important;
        margin-bottom: 4px !important;
    }
    .inv-slots-grid {
        gap: 5px !important;
        padding: 6px !important;
    }
    .inv-slot {
        width: 52px !important;
        height: 52px !important;
    }
    .inv-slot-icon, .inv-slot-icon canvas {
        width: 32px !important;
        height: 32px !important;
    }
    .inv-slot-label {
        display: none !important;
    }
    .inv-slot-count {
        font-size: 10px !important;
        bottom: 2px !important;
        right: 4px !important;
    }
    .inv-hotbar-section {
        margin-bottom: 4px !important;
    }
    .inv-hotbar-title {
        font-size: 10px !important;
        margin-bottom: 2px !important;
    }
    .inv-hotbar-grid {
        gap: 4px !important;
        padding: 4px !important;
        overflow-x: auto !important;
        justify-content: flex-start !important;
        min-height: 40px !important;
        -webkit-overflow-scrolling: touch;
    }
    .inv-hotbar-slot {
        width: 36px !important;
        height: 36px !important;
        flex-shrink: 0 !important;
    }
    .inv-footer-panel { 
        flex-direction: row !important; 
        gap: 6px !important;
        margin-bottom: 4px !important;
    }
    .inv-capacity-box { 
        flex: 1 !important; 
        padding: 4px 6px !important;
        justify-content: center !important;
    }
    .inv-item-detail {
        padding: 6px 10px !important;
        gap: 8px !important;
    }
    .detail-icon {
        width: 36px !important;
        height: 36px !important;
    }
    .detail-icon canvas {
        width: 32px !important;
        height: 32px !important;
    }
    .detail-title {
        font-size: 12px !important;
    }
    .detail-desc, .detail-time {
        font-size: 10px !important;
    }
    .inv-bottom-shortcuts {
        display: none !important;
    }
    .inv-hotbar-hint {
        display: none !important;
    }
    .shortcut-item {
        padding: 4px 8px !important;
        font-size: 10px !important;
    }
    .game-wrapper { padding: 0; }
    #gameCanvas {
        border-width: 2px;
        max-height: 100vh;
        max-height: 100dvh;
        max-height: var(--game-viewport-height, 100dvh);
    }
    .fps-counter { font-size: 10px; top: 4px; right: 4px; }
}

@media (max-height: 550px) {
    
    .setting-dropdown {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 85vw !important;
        max-width: 320px !important;
        max-height: 88vh !important;
        max-height: 88dvh !important;
        overflow-y: auto !important;
        padding: 2px 0 !important;
        border-radius: 10px !important;
        border: 2px solid #8b5a2b !important;
        box-shadow: 0 8px 25px rgba(0,0,0,0.9) !important;
    }

    .setting-header {
        padding: 5px 10px !important;
        font-size: 13px !important;
    }

    .setting-close-btn {
        width: 22px !important;
        height: 22px !important;
        font-size: 12px !important;
    }

    .setting-item {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }

    .setting-icon {
        font-size: 15px !important;
        width: 20px !important;
    }

    .event-modal-card,
    .notice-modal-card,
    .help-modal-card,
    .map-modal-card,
    .char-modal-box,
    .inv-modal-box {
        width: 96vw !important;
        max-width: 98vw !important;
        max-height: 75vh !important;
        padding: 6px 10px !important;
        border-radius: 12px !important;
    }

    .event-modal-head,
    .notice-modal-head {
        margin-bottom: 4px !important;
        gap: 6px !important;
    }

    .event-head-icon,
    .notice-head-icon {
        width: 32px !important;
        height: 32px !important;
        font-size: 16px !important;
    }

    .event-main-title,
    .notice-main-title {
        font-size: 14px !important;
    }

    .event-sub-title,
    .notice-sub-title {
        display: none !important;
    }

    .event-body-scroll,
    .notice-body-scroll {
        padding: 4px 2px !important;
        max-height: calc(94vh - 80px) !important;
        overflow-y: auto !important;
    }

    .event-card-box {
        padding: 6px 10px !important;
        gap: 8px !important;
        margin-bottom: 6px !important;
        border-radius: 10px !important;
    }

    .event-card-avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 18px !important;
    }

    .event-item-title {
        font-size: 12px !important;
    }

    .event-item-desc {
        font-size: 10.5px !important;
    }

    .event-modal-foot,
    .notice-modal-foot {
        margin-top: 4px !important;
    }

    .btn-event-confirm,
    .btn-notice-confirm {
        padding: 5px 20px !important;
        font-size: 12px !important;
        border-radius: 8px !important;
    }

    .inv-header {
        margin-bottom: 2px !important;
    }

    .inv-title-badge {
        padding: 2px 14px !important;
    }

    .inv-title-text {
        font-size: 13px !important;
    }

    .inv-close-btn {
        width: 26px !important;
        height: 26px !important;
        font-size: 13px !important;
        top: -2px !important;
        right: -2px !important;
    }
    .inv-tab-content-wrapper {
        overflow: hidden !important;
    }
    .inv-scrollable {
        flex: 0 1 auto !important;
        min-height: 60px !important;
        max-height: 30vh !important;
        overflow-y: auto !important;
    }

    .inv-content-grid {
        gap: 4px !important;
        margin-bottom: 4px !important;
    }

    .inv-category-tag {
        padding: 1px 8px !important;
        font-size: 10px !important;
        margin-bottom: 2px !important;
    }

    .inv-slots-grid {
        gap: 4px !important;
        padding: 4px !important;
    }

    .inv-slot {
        width: 44px !important;
        height: 44px !important;
    }

    .inv-slot-icon, .inv-slot-icon canvas {
        width: 26px !important;
        height: 26px !important;
    }

    .inv-slot-count {
        font-size: 9px !important;
    }

    .inv-hotbar-section {
        margin-bottom: 4px !important;
    }

    .inv-hotbar-title {
        font-size: 10px !important;
        margin-bottom: 2px !important;
    }

    .inv-hotbar-grid {
        gap: 3px !important;
        padding: 4px !important;
        min-height: 40px !important;
    }

    .inv-hotbar-slot {
        width: 34px !important;
        height: 34px !important;
    }

    .inv-footer-panel {
        flex-direction: row !important;
        margin-bottom: 4px !important;
        gap: 4px !important;
    }

    .inv-capacity-box {
        flex: 1 !important;
        padding: 4px 8px !important;
    }

    .capacity-label {
        font-size: 9px !important;
    }

    .capacity-value {
        font-size: 13px !important;
    }

    .inv-item-detail {
        padding: 4px 8px !important;
    }

    .detail-icon {
        width: 28px !important;
        height: 28px !important;
    }

    .detail-icon canvas {
        width: 24px !important;
        height: 24px !important;
    }

    .detail-title {
        font-size: 11px !important;
    }

    .detail-desc, .detail-time {
        font-size: 9px !important;
    }

    .help-sign {
        font-size: 13px !important;
        padding: 4px 12px !important;
    }

    .help-banner {
        font-size: 10px !important;
        padding: 3px 8px !important;
    }

    .help-steps {
        gap: 4px !important;
        margin-top: 6px !important;
    }

    .help-step {
        padding: 4px 8px !important;
        gap: 6px !important;
    }

    .help-num {
        width: 20px !important;
        height: 20px !important;
        font-size: 11px !important;
    }

    .help-icon {
        font-size: 18px !important;
    }

    .help-title {
        font-size: 12px !important;
    }

    .help-desc {
        font-size: 10px !important;
    }

    .help-tip {
        padding: 4px 8px !important;
        font-size: 10px !important;
        margin-top: 6px !important;
    }
}

#mobileControls {
    display: none;
    touch-action: manipulation;
}

#mobileJoystickZone {
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@media (max-width: 1024px) {
    #mobileControls {
        display: block !important;
    }
    /* Canvas đã resize tự động theo tỉ lệ 16:9 của viewport trong JS */
    .char-modal-box {
        max-width: 98vw;
    }
    .inv-modal-box {
        max-width: 99vw;
    }
}

#alertBannerOverlay {
    position: fixed !important;
    top: 8px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: min(50vw, 480px) !important;
    max-width: calc(100vw - 320px) !important;
    height: 32px !important;
    background: rgba(18, 12, 6, 0.88) !important;
    border: 1.5px solid #8b5a2b !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    z-index: 900 !important;
    pointer-events: none !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5) !important;
    backdrop-filter: blur(4px) !important;
    display: flex !important;
    align-items: center !important;
}

body.has-mobile-controls #alertBannerOverlay {
    top: 6px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    width: min(55vw, 380px) !important;
    max-width: calc(100vw - 220px) !important;
    height: 28px !important;
    overflow: hidden !important;
}

@media (max-width: 1024px) and (orientation: landscape) {
    /* Canvas đã được resize tự động theo tỉ lệ 16:9 của viewport trong resizeCanvas().
       Chỉ giữ các style thẩm mỹ; KHÔNG giới hạn max-height/max-width ở đây. */
    body.has-mobile-controls #gameCanvas {
        border-radius: 6px;
    }
    #gameCanvas {
        border-radius: 6px;
    }

    body.has-mobile-controls .top-buttons-container {
        top: calc(8px + env(safe-area-inset-top, 0px)) !important;
        right: calc(8px + env(safe-area-inset-right, 0px)) !important;
        gap: 6px !important;
    }

    body.has-mobile-controls .top-buttons-container .btn-setting {
        width: 40px !important;
        height: 40px !important;
        border-radius: 8px !important;
        font-size: 19px !important;
    }

    body.has-mobile-controls .top-buttons-container .btn-tabs-toggle {
        font-size: 14px !important;
    }

    body.has-mobile-controls .top-buttons-container .setting-badge-dot {
        top: -5px !important;
        right: -6px !important;
        min-width: 13px !important;
        padding: 1px 4px !important;
        font-size: 9px !important;
    }
    
    #mobileJoystickZone {
        bottom: calc(35px + env(safe-area-inset-bottom, 0px)) !important;
        left: calc(55px + env(safe-area-inset-left, 0px)) !important;
        touch-action: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
    }
    
    #mobileActionZone {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        right: calc(16px + env(safe-area-inset-right, 0px)) !important;
        display: flex !important;
        flex-direction: column-reverse !important;
        gap: 8px !important;
        align-items: center !important;
    }
    
    #mobileFeaturePanel {
        top: calc(10px + env(safe-area-inset-top, 0px)) !important;
        right: calc(10px + env(safe-area-inset-right, 0px)) !important;
    }
    
    body.has-mobile-controls #alertBannerOverlay {
        top: 6px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: min(50%, 350px) !important;
        height: 26px !important;
    }
}

.popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 5, 3, 0.75);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.popup-overlay.hidden {
    display: none;
}

.popup-box {
    background: #3d2414;
    border: 4px solid #8b5a2b;
    box-shadow: inset 0 0 0 2px #5a3818, 0 10px 30px rgba(0,0,0,0.8);
    border-radius: 10px;
    padding: 20px 28px;
    min-width: 300px;
    max-width: 400px;
    text-align: center;
}

.popup-message {
    color: #ffffff;
    font-size: 14px;
    margin-bottom: 18px;
    line-height: 1.5;
}

.popup-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.popup-btn {
    padding: 8px 20px;
    border: 2px solid;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
}

.popup-btn-cancel {
    background: #5a3818;
    border-color: #8b5a2b;
    color: #ffe066;
}

.popup-btn-cancel:hover {
    background: #6b4423;
}

.popup-btn-confirm {
    background: linear-gradient(180deg, #d84848 0%, #a82828 100%);
    border-color: #ff6b6b;
    color: #ffffff;
    box-shadow: 0 3px 0 #581010;
}

.popup-btn-confirm:hover {
    background: linear-gradient(180deg, #e85858 0%, #b83838 100%);
    transform: translateY(-1px);
}

.popup-btn-ok {
    background: linear-gradient(180deg, #6cb85a 0%, #3d8024 100%);
    border-color: #82d868;
    color: #ffffff;
    box-shadow: 0 3px 0 #204810;
}

.popup-btn-ok:hover {
    background: linear-gradient(180deg, #7cd06a 0%, #46942a 100%);
    transform: translateY(-1px);
}

.setting-container {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-event {
    width: 44px;
    height: 44px;
    background: rgba(160, 40, 30, 0.85);
    border: 2px solid #e84438;
    border-radius: 8px;
    color: #ffe066;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.15s ease;
}

.btn-event:hover {
    background: rgba(190, 50, 40, 0.95);
    border-color: #ffe066;
    transform: scale(1.1);
}

.event-badge-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ffaa00;
    color: #2b1808;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 10px;
    border: 1px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    animation: pulseBadge 1.5s infinite;
}

.event-hot-tag {
    background: #ffaa00;
    color: #2b1808;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
}

.setting-badge-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #e83838;
    color: #ffffff;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    border: 1px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    animation: pulseBadge 1.5s infinite;
}

@keyframes pulseBadge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.notice-new-tag {
    background: #e83838;
    color: #ffffff;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: auto;
}

.notice-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 25, 12, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.notice-modal-overlay.hidden {
    display: none;
}

/* ===== BẢNG THÔNG BÁO CẬP NHẬT GỖ & CUỘN GIẤY ===== */
.notice-parchment-card {
    position: relative;
    width: 680px;
    max-width: 95vw;
    height: 82vh;
    height: 82dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
    user-select: none;
    box-sizing: border-box;
}

.notice-wood-header {
    width: 100%;
    background: linear-gradient(180deg, #7a4b27 0%, #523117 100%);
    border: 3px solid #3d210d;
    border-radius: 18px 18px 10px 10px;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 6px 16px rgba(0, 0, 0, 0.5);
    padding: 14px 20px;
    text-align: center;
    position: relative;
    z-index: 10;
    box-sizing: border-box;
    flex-shrink: 0;
}

.notice-wood-header::before, .notice-wood-header::after {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background: #3d210d;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3), inset 0 -1px 2px rgba(0,0,0,0.8);
}
.notice-wood-header::before { left: 14px; }
.notice-wood-header::after { right: 14px; }

.notice-wood-title {
    color: #ffeed3;
    font-size: 26px;
    font-weight: 900;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    text-shadow: 2px 2px 4px #261103, 0 0 10px rgba(0,0,0,0.5);
}

.notice-wood-sub {
    color: #d1b191;
    font-size: 13px;
    font-weight: 600;
    margin: 4px 0 0 0;
    font-style: italic;
    text-shadow: 1px 1px 2px #261103;
}

.notice-wood-close {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 34px;
    height: 34px;
    background: linear-gradient(180deg, #c0392b 0%, #962d22 100%);
    border: 2px solid #5c1811;
    color: #ffffff;
    border-radius: 50%;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
    transition: transform 0.15s ease;
    z-index: 20;
}

.notice-wood-close:hover {
    transform: scale(1.1);
}

.notice-parchment-body {
    width: 100%;
    background: #e8d7b5;
    background-image: 
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.05)),
        linear-gradient(180deg, #e4d0a9 0%, #eddab6 50%, #dfc89d 100%);
    border: 4px solid #5a371c;
    border-top: none;
    border-radius: 0 0 22px 22px;
    box-shadow: inset 0 0 30px rgba(90, 55, 28, 0.35), 0 15px 35px rgba(0, 0, 0, 0.5);
    padding: 16px 14px 16px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 768px) {
    .notice-parchment-card {
        width: 95vw !important;
        max-width: 95vw !important;
        height: 90vh !important;
        height: 90dvh !important;
    }
    .notice-wood-header {
        padding: 8px 32px 8px 10px !important;
    }
    .notice-wood-title {
        font-size: 15px !important;
        letter-spacing: 0.5px !important;
    }
    .notice-wood-sub {
        font-size: 9.5px !important;
        margin-top: 2px !important;
    }
    .notice-wood-close {
        right: 4px !important;
        top: 4px !important;
        width: 28px !important;
        height: 28px !important;
        font-size: 13px !important;
    }
    .notice-parchment-body {
        padding: 10px 8px 10px 8px !important;
    }
    .notice-body-scroll {
        padding-bottom: 60px !important;
        min-height: 0 !important;
    }
    .notice-version-box {
        padding: 10px !important;
        margin-bottom: 12px !important;
    }
    .ver-pill-main, .ver-pill-new {
        font-size: 10.5px !important;
        padding: 3px 8px !important;
    }
    .notice-ver-date {
        font-size: 10.5px !important;
    }
    .notice-ver-heading {
        font-size: 14px !important;
        margin: 8px 0 10px 0 !important;
    }
    .notice-item-row {
        font-size: 12px !important;
        padding: 3px 4px !important;
    }
    .notice-item-row.notice-section-header .notice-item-content strong {
        font-size: 12.5px !important;
    }
    .btn-wood-confirm {
        font-size: 13px !important;
        padding: 6px 24px !important;
    }
}

/* XỬ LÝ ĐẶC BIỆT CHO MÀN HÌNH NGANG (MOBILE LANDSCAPE) */
@media (max-height: 500px) and (orientation: landscape) {
    /* 1. KHUNG CHUNG BẢNG MODAL TRÊN MÀN HÌNH NGANG */
    .event-modal-card {
        width: 90vw !important;
        max-width: 620px !important;
        max-height: 94vh !important;
        max-height: 94dvh !important;
        padding: 8px 12px 10px 12px !important;
        border-radius: 14px !important;
    }

    .event-modal-head {
        padding-bottom: 6px !important;
        margin-bottom: 6px !important;
    }

    .event-main-title {
        font-size: 15px !important;
        letter-spacing: 0.5px !important;
    }

    .event-sub-title {
        display: none !important; /* Ẩn dòng tiêu đề phụ trên màn hình ngang để tối đa chiều cao nội dung */
    }

    .event-head-close {
        width: 28px !important;
        height: 28px !important;
        font-size: 14px !important;
    }

    .event-body-scroll {
        max-height: calc(94vh - 85px) !important;
        max-height: calc(94dvh - 85px) !important;
        padding: 6px 8px !important;
    }

    .event-modal-foot {
        margin-top: 6px !important;
        padding-top: 4px !important;
    }

    .btn-event-confirm {
        padding: 5px 22px !important;
        font-size: 12px !important;
    }

    /* 2. HỒ SƠ NHÂN VẬT (PROFILE) */
    .profile-main-card {
        padding: 8px !important;
        gap: 6px !important;
    }
    .profile-avatar-box {
        width: 50px !important;
        height: 50px !important;
        font-size: 26px !important;
    }
    .profile-name-text {
        font-size: 14px !important;
    }
    .profile-id-badge {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }
    .btn-profile-action {
        font-size: 10px !important;
        padding: 3px 7px !important;
    }
    .profile-stat-box {
        padding: 6px 10px !important;
    }
    .profile-stat-val {
        font-size: 13px !important;
    }

    /* 3. SỰ KIỆN NÔNG TRẠI (EVENT) */
    .event-card-box {
        padding: 8px 10px !important;
        margin-bottom: 8px !important;
        gap: 8px !important;
    }
    .event-card-avatar {
        width: 36px !important;
        height: 36px !important;
        font-size: 18px !important;
    }
    .event-item-title {
        font-size: 13px !important;
    }
    .event-item-desc {
        font-size: 11px !important;
        line-height: 1.3 !important;
    }

    /* 4. HỘP THƯ (MAILBOX) */
    #mailboxModalOverlay .event-modal-card {
        position: relative !important;
        bottom: auto !important;
        margin: auto !important;
        height: 94vh !important;
        height: 94dvh !important;
        border-radius: 14px !important;
    }
    .mailbox-toolbar {
        padding: 4px 8px !important;
        margin-bottom: 6px !important;
    }
    .mailbox-count {
        font-size: 11px !important;
    }
    .mailbox-actions button {
        padding: 4px 8px !important;
        font-size: 10.5px !important;
    }
    .mailbox-item {
        padding: 8px 10px !important;
        margin-bottom: 6px !important;
    }
    .mail-title {
        font-size: 12.5px !important;
    }
    .mail-desc {
        font-size: 11px !important;
    }
    #mailboxList {
        max-height: calc(94vh - 100px) !important;
        max-height: calc(94dvh - 100px) !important;
    }

    /* 5. DANH SÁCH THỜI TIẾT (WEATHER) */
    #weatherModalOverlay .event-card-box {
        padding: 6px 8px !important;
    }

    /* 6. THÀNH TỰU NÔNG TRẠI (ACHIEVEMENT) */
    .achievement-item {
        padding: 6px 10px !important;
        margin-bottom: 6px !important;
    }
    .achieve-title {
        font-size: 12.5px !important;
    }
    .achieve-desc {
        font-size: 10.5px !important;
    }
    .achieve-reward {
        font-size: 11px !important;
    }
    .btn-achieve-claim {
        padding: 4px 10px !important;
        font-size: 11px !important;
    }

    /* BẢNG THÔNG BÁO CẬP NHẬT GỖ & CUỘN GIẤY */
    .notice-parchment-card {
        width: 88vw !important;
        max-width: 580px !important;
        height: 94vh !important;
        height: 94dvh !important;
    }
    .notice-wood-header {
        padding: 4px 30px 4px 10px !important;
    }
    .notice-wood-title {
        font-size: 13px !important;
        letter-spacing: 0.3px !important;
    }
    .notice-wood-sub {
        display: none !important;
    }
    .notice-wood-close {
        right: 4px !important;
        top: 2px !important;
        width: 24px !important;
        height: 24px !important;
        font-size: 11px !important;
    }
    .notice-parchment-body {
        padding: 6px 8px 6px 8px !important;
    }
    .notice-body-scroll {
        padding-bottom: 45px !important;
    }
    .notice-version-box {
        padding: 8px !important;
        margin-bottom: 8px !important;
    }
    .notice-ver-heading {
        font-size: 12.5px !important;
        margin: 4px 0 6px 0 !important;
    }
    .notice-item-row {
        font-size: 11px !important;
        padding: 2px 4px !important;
    }
    .notice-parchment-foot {
        margin-top: 4px !important;
    }
    .btn-wood-confirm {
        font-size: 11.5px !important;
        padding: 4px 18px !important;
    }
}

.notice-body-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    width: 100%;
    padding-right: 6px;
    padding-bottom: 50px;
    box-sizing: border-box;
}

.notice-body-scroll::-webkit-scrollbar {
    width: 8px;
}
.notice-body-scroll::-webkit-scrollbar-track {
    background: #cbb48b;
    border-radius: 4px;
}
.notice-body-scroll::-webkit-scrollbar-thumb {
    background: #7a4b27;
    border-radius: 4px;
}

/* KHUNG PHIÊN BẢN GIẤY CUỘN */
.notice-version-box {
    background: rgba(255, 248, 230, 0.5);
    border: 1px dashed #b8986a;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.notice-version-box.current-version {
    background: rgba(255, 252, 242, 0.85);
    border: 1.5px solid #a68453;
    box-shadow: 0 2px 10px rgba(120, 85, 45, 0.15);
}

.notice-ver-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.notice-ver-pills {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ver-pill-main {
    background: #23522d;
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
    padding: 5px 14px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ver-pill-new {
    background: #2e7d32;
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.notice-ver-date {
    font-size: 13px;
    font-weight: 700;
    color: #6b553e;
}

.notice-ver-heading {
    font-size: 17px;
    font-weight: 900;
    color: #8b0000;
    text-align: center;
    margin: 12px 0 16px 0;
}

.notice-item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notice-item-row {
    font-size: 14.5px;
    color: #3b2816;
    line-height: 1.6;
    font-weight: 600;
    padding: 4px 8px;
}

.notice-item-row.notice-section-header {
    background: rgba(220, 195, 155, 0.45);
    border: 1px solid rgba(175, 145, 100, 0.3);
    border-radius: 10px;
    padding: 10px 16px;
    text-align: center;
    margin: 12px 0 6px 0;
}

.notice-item-row.notice-section-header .notice-item-content strong {
    color: #1c4d28;
    font-size: 16px;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.notice-item-row.notice-category-title {
    padding-top: 8px;
}

.notice-item-row.notice-category-title .notice-item-content strong {
    color: #8b0000;
    font-size: 15px;
    font-weight: 900;
}

.notice-parchment-foot {
    margin-top: 10px;
    width: 100%;
    display: flex;
    justify-content: center;
    flex-shrink: 0;
    z-index: 15;
}

.btn-wood-confirm {
    background: linear-gradient(180deg, #4d8036 0%, #2f5420 100%);
    border: 3px solid #1c3612;
    color: #ffeed3;
    font-size: 18px;
    font-weight: 900;
    padding: 10px 48px;
    border-radius: 14px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3);
    text-shadow: 1px 1px 3px #12240b;
    transition: all 0.15s ease;
}

.btn-wood-confirm:hover {
    transform: scale(1.05);
    background: linear-gradient(180deg, #59943f 0%, #366125 100%);
}

.notice-modal-card {
    background: #fbf9f4;
    border: 1px solid #e2ddd0;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
    border-radius: 24px;
    padding: 28px 32px;
    width: 740px;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    user-select: none;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.notice-modal-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.notice-head-icon {
    width: 54px;
    height: 54px;
    background: #e6f3e3;
    border: 1px solid #d4e7d0;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 26px;
    flex-shrink: 0;
}

.notice-head-titles {
    flex: 1;
}

.notice-main-title {
    font-size: 23px;
    font-weight: 800;
    color: #244b1c;
    margin: 0;
    letter-spacing: 0.2px;
}

.notice-sub-title {
    font-size: 13px;
    color: #72876d;
    margin: 2px 0 0 0;
    font-weight: 500;
}

.notice-head-close {
    background: #345d2c;
    border: none;
    color: #ffffff;
    border-radius: 12px;
    width: 38px;
    height: 38px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

.notice-head-close:hover {
    background: #254720;
    transform: scale(1.06);
}

.notice-body-scroll {
    overflow-y: auto;
    max-height: 60vh;
    padding-right: 6px;
}

.notice-body-scroll::-webkit-scrollbar {
    width: 8px;
}
.notice-body-scroll::-webkit-scrollbar-track {
    background: #eae5d8;
    border-radius: 4px;
}
.notice-body-scroll::-webkit-scrollbar-thumb {
    background: #a5b89f;
    border-radius: 4px;
}

.notice-version-box.current-version {
    background: #fdfcf9;
    border: 1.5px solid #e2e8db;
    border-radius: 18px;
    padding: 22px 24px;
}

.notice-ver-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notice-ver-pills {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ver-pill-main {
    background: #265522;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 10px;
}

.ver-pill-new {
    background: #387b32;
    color: #ffffff;
    font-size: 11.5px;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 10px;
}

.notice-ver-date {
    font-size: 13px;
    font-weight: 600;
    color: #82957c;
}

.notice-ver-heading {
    font-size: 16.5px;
    font-weight: 800;
    color: #c0392b;
    margin-top: 18px;
    margin-bottom: 14px;
}

.notice-item-list {
    display: flex;
    flex-direction: column;
    border: 1px solid #eaf0e6;
    border-radius: 12px;
    background: #ffffff;
    overflow: hidden;
}

.notice-item-row {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f5ec;
}

.notice-item-row.notice-section-header {
    background: #eef6ea;
    border-bottom: 2px solid #d2e4cb;
    text-align: center;
    padding: 14px 20px;
}

.notice-item-row.notice-section-header .notice-item-content strong {
    color: #1a4314;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.notice-item-row.notice-category-title {
    background: #fffafa;
    padding-top: 14px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #fecaca;
}

.notice-item-row.notice-category-title .notice-item-content strong {
    color: #d9381e;
    font-size: 15.5px;
    font-weight: 800;
}

.notice-item-row.notice-footer-thank {
    background: #fffdf5;
    text-align: center;
    padding: 16px 20px;
}

.notice-item-row.notice-footer-thank .notice-item-content {
    color: #8c5737;
    font-size: 14.5px;
    font-weight: 600;
}

.notice-item-row:last-child {
    border-bottom: none;
}

.notice-item-content {
    font-size: 15px;
    color: #24381e;
    line-height: 1.6;
    flex: 1;
    font-weight: 500;
}

.notice-item-content strong {
    color: #16300f;
    font-weight: 800;
    font-size: 15.5px;
}

.tag-code {
    background: #fbf3d5;
    border: 1px solid #e8dcad;
    color: #5c4b18;
    padding: 2px 7px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    margin: 0 3px;
    display: inline-block;
}

.tag-code.tag-green {
    background: #e5f4df;
    border: 1px solid #c4e4b8;
    color: #2e6623;
}

.notice-version-collapse {
    background: #f6f2e7;
    border: 1px solid #e5dfce;
    border-radius: 14px;
    padding: 14px 20px;
    font-weight: 700;
    font-size: 14px;
    color: #433922;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.notice-version-collapse:hover {
    background: #ede7d8;
}

.collapse-ver-right {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #827862;
    font-size: 13px;
    font-weight: 600;
}

.collapse-arrow {
    font-size: 14px;
    font-weight: bold;
    color: #387b32;
}

.notice-modal-foot {
    display: flex;
    justify-content: center;
    margin-top: 22px;
}

.btn-notice-confirm {
    background: linear-gradient(180deg, #5da944 0%, #3e8127 100%);
    border: none;
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    padding: 12px 54px;
    border-radius: 14px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(62, 129, 39, 0.35);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-notice-confirm:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(62, 129, 39, 0.45);
}

.btn-notice-confirm:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(62, 129, 39, 0.3);
}

.check-icon {
    font-size: 15px;
}

.event-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 15, 10, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.event-modal-overlay.hidden {
    display: none;
}

.event-modal-card {
    background: #fcf6e8;
    border: 1px solid #e0d2b4;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    border-radius: 24px;
    padding: 26px 30px;
    width: 740px;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    user-select: none;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

.event-modal-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    position: relative;
}

.event-head-icon {
    width: 56px;
    height: 56px;
    background: #f5edd6;
    border: 1px solid #dccaa8;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    flex-shrink: 0;
}

.event-head-titles {
    flex: 1;
    text-align: center;
    padding: 0 44px;
    box-sizing: border-box;
}

.event-main-title {
    font-size: 22px;
    font-weight: 800;
    color: #6e2716;
    margin: 0;
    letter-spacing: 0.3px;
}

.event-sub-title {
    font-size: 13px;
    color: #8c5737;
    margin: 3px 0 0 0;
    font-weight: 500;
}

.event-head-close {
    background: #a42c23;
    border: none;
    color: #ffffff;
    border-radius: 12px;
    width: 38px;
    height: 38px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    position: absolute;
    right: 0;
    top: 0;
    z-index: 99 !important;
}

.event-head-close:hover {
    background: #882018;
    transform: scale(1.06);
}

.event-body-scroll {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 58vh;
    padding-right: 6px;
    padding-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}

.event-body-scroll::-webkit-scrollbar {
    width: 8px;
}
.event-body-scroll::-webkit-scrollbar-track {
    background: #ebdcc2;
    border-radius: 4px;
}
.event-body-scroll::-webkit-scrollbar-thumb {
    background: #b59b72;
    border-radius: 4px;
}

.event-card-box {
    background: #ffffff;
    border-radius: 18px;
    padding: 18px 20px;
    display: flex;
    gap: 16px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.05);
}

.event-card-box.card-red {
    border: 1.5px solid #d95e46;
}

.event-card-box.card-blue {
    border: 1.5px solid #4a8ed4;
}

.event-card-box.card-gold {
    border: 1.5px solid #d4a638;
}

.event-card-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
    flex-shrink: 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.avatar-harvest {
    border: 3px solid #6ab5b5;
    background: #e0f2f1;
}

.avatar-water {
    border: 3px solid #90caf9;
    background: #e3f2fd;
}

.avatar-market {
    border: 3px solid #a5d6a7;
    background: #e8f5e9;
}

.event-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.event-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.event-status-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 12px;
}

.event-card-badges {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.event-type-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid rgba(110, 39, 22, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: #5a321a;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.pill-ongoing {
    background: #e05436;
    color: #ffffff;
}

.pill-upcoming {
    background: #d4a028;
    color: #ffffff;
}

.event-date-text {
    font-size: 12px;
    font-weight: 700;
}

.text-red {
    color: #a33e28;
}

.text-blue {
    color: #2b6cb0;
}

.text-gold {
    color: #9c6c18;
}

.event-item-title {
    font-size: 16px;
    font-weight: 800;
    color: #3b2014;
    margin: 8px 0 4px 0;
}

.event-item-desc {
    font-size: 12.5px;
    color: #5a4033;
    line-height: 1.48;
    margin: 0;
}

.event-rewards-bar {
    background: #fbf3e0;
    border: 1px dashed #d8c29d;
    border-radius: 10px;
    padding: 8px 14px;
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    flex-wrap: wrap;
}

.reward-bar-label {
    font-weight: 800;
    color: #4a2810;
}

.reward-pill-item {
    font-size: 13px;
    font-weight: 800;
    padding: 4px 12px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.pill-green {
    background: #eef9f1;
    color: #1e7e34;
    border: 1.5px solid #27ae60;
}

.pill-gold {
    background: #fffdf0;
    color: #b7791f;
    border: 1.5px solid #d69e2e;
}

.pill-blue {
    background: #f0f7ff;
    color: #1d6fce;
    border: 1.5px solid #3182ce;
}

.pill-olive {
    background: #507b22;
    color: #ffffff;
}

.pill-darkgreen {
    background: #3e6d24;
    color: #ffffff;
}

.event-modal-foot {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

.btn-event-confirm {
    background: linear-gradient(180deg, #5da944 0%, #3e8127 100%);
    border: none;
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    padding: 12px 52px;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(62, 129, 39, 0.35);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.15s ease;
}

.btn-event-confirm:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(62, 129, 39, 0.45);
}

.btn-event-confirm:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(62, 129, 39, 0.3);
}

.arrow-icon {
    font-size: 16px;
}

.help-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 10, 5, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1200;
}

.help-modal-overlay.hidden {
    display: none;
}

.help-modal-card {
    position: relative;
    width: 620px;
    max-width: 92vw;
    max-height: 90vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: #fcf6e8;
    border: 1px solid #e0d2b4;
    border-radius: 24px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    padding: 26px 30px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    color: #2b1808;
    box-sizing: border-box;
}

.help-sign {
    font-size: 20px;
    font-weight: 800;
    color: #6e2716;
    text-align: center;
    margin-bottom: 6px;
    padding-right: 36px;
    letter-spacing: 0.3px;
}

.help-close-btn {
    position: absolute;
    top: 22px;
    right: 24px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 12px;
    background: #a42c23;
    color: #ffffff;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.help-close-btn:hover {
    background: #882018;
    transform: scale(1.06);
}

.help-banner {
    margin: 12px 0 18px;
    background: #e8f5e9;
    border: 1.5px solid #a5d6a7;
    border-radius: 14px;
    color: #2e6623;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    padding: 10px 14px;
}

.help-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.help-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #ebdcc2;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.help-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 15px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.help-num-1 { background: #4caf50; }
.help-num-2 { background: #42a5f5; }
.help-num-3 { background: #ffa726; }
.help-num-4 { background: #ab47bc; }
.help-num-5 { background: #26a69a; }

.help-icon {
    width: 44px;
    height: 44px;
    border: 1px solid #dccaa8;
    border-radius: 12px;
    background: #fdfcf9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.help-text {
    flex: 1;
}

.help-title {
    color: #3b2014;
    font-size: 15px;
    font-weight: 800;
    margin-bottom: 2px;
}

.help-desc {
    color: #5a4033;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.45;
}

.help-desc b {
    color: #2e6623;
    background: #e8f5e9;
    border: 1px solid #c4e4b8;
    border-radius: 6px;
    padding: 1px 6px;
    font-weight: 700;
}

.help-tip {
    margin-top: 18px;
    background: #fbf3e0;
    border: 1px dashed #d8c29d;
    border-radius: 14px;
    color: #5a321a;
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
    padding: 12px 14px;
    line-height: 1.45;
}

.help-tip b {
    color: #a33e28;
}

.map-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(12, 8, 4, 0.72);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1300;
}

.map-modal-overlay.hidden {
    display: none;
}

.map-modal-card {
    position: relative;
    width: 820px;
    max-width: 96vw;
    background: #fdf3df;
    border: 4px solid #b87a38;
    border-radius: 26px;
    box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), inset 0 0 0 3px #f7e0b5;
    padding: 30px 28px 20px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    color: #2b1808;
    box-sizing: border-box;
}

.map-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: absolute;
    top: -24px;
    left: 20px;
    right: 20px;
    pointer-events: none;
}

.map-sign-badge {
    pointer-events: auto;
    background: linear-gradient(180deg, #5ba83c 0%, #3a7522 100%);
    border: 3px solid #75c052;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border-radius: 18px;
    padding: 6px 24px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 2px rgba(0,0,0,0.4);
}

.map-close-btn {
    pointer-events: auto;
    position: absolute;
    right: -6px;
    top: 0;
    width: 44px;
    height: 44px;
    border: 3px solid #ffffff;
    border-radius: 14px;
    background: linear-gradient(180deg, #ea4e42 0%, #b8261b 100%);
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(184, 38, 27, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease;
}

.map-close-btn:hover {
    transform: scale(1.08);
    filter: brightness(1.1);
}

.map-modal-body {
    position: relative;
    margin-top: 14px;
    background: #507d2a;
    border: 4px solid #b87a38;
    border-radius: 18px;
    padding: 8px;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 3px 8px rgba(0,0,0,0.3);
}

.map-canvas-container {
    border-radius: 12px;
    overflow: hidden;
    background: #488a38;
    display: flex;
    justify-content: center;
    align-items: center;
}

#minimapCanvas {
    display: block;
    border-radius: 10px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.map-controls-right {
    position: absolute;
    right: -24px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.map-ctrl-btn {
    width: 46px;
    height: 46px;
    background: #fcf1d8;
    border: 3px solid #8c5828;
    border-radius: 14px;
    color: #4a2c11;
    font-size: 24px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.15s ease;
}

.map-ctrl-btn:hover {
    background: #ffffff;
    transform: scale(1.08);
    border-color: #633c16;
}

.map-modal-footer {
    margin-top: 16px;
    background: #f7e6c5;
    border: 2px dashed #cca068;
    border-radius: 16px;
    padding: 12px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-around;
    gap: 12px;
    font-size: 13px;
    font-weight: 700;
    color: #4a2c11;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.dot-player {
    background: #25d366;
    animation: pulseDot 1.2s infinite ease-in-out;
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.75; }
}

@media (max-width: 900px) or (max-height: 700px) {
    .map-modal-card {
        padding: 16px 12px 10px;
        max-height: 96vh;
        max-width: 98vw;
        display: flex;
        flex-direction: column;
        overflow-y: auto;
    }
    .map-modal-head {
        position: relative;
        top: 0;
        left: 0;
        right: 0;
        margin-bottom: 6px;
        pointer-events: auto;
    }
    .map-sign-badge {
        padding: 4px 12px;
        font-size: 14px;
        border-radius: 12px;
        border-width: 2px;
    }
    .map-close-btn {
        position: relative;
        right: 0;
        top: 0;
        width: 32px;
        height: 32px;
        font-size: 16px;
        border-radius: 10px;
        border-width: 2px;
    }
    .map-modal-body {
        margin-top: 4px;
        padding: 4px;
    }
    #minimapCanvas {
        max-width: 100%;
        max-height: 52vh;
        width: auto;
        height: auto;
        object-fit: contain;
    }
    .map-controls-right {
        right: 8px;
        top: 12px;
        transform: none;
        gap: 6px;
    }
    .map-ctrl-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
        border-radius: 10px;
        border-width: 2px;
    }
    .map-modal-footer {
        margin-top: 8px;
        padding: 8px 10px;
        gap: 6px;
        font-size: 11px;
    }
    .legend-icon {
        font-size: 14px;
    }
}

.inv-tab-bar {
    display: flex;
    gap: 0;
    width: 100%;
    margin-top: 14px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 3px 8px rgba(0,0,0,0.25);
    border: 2px solid #4a2810;
    flex-shrink: 0;
}

.inv-tab-btn {
    flex: 1;
    -webkit-flex: 1;
    padding: 10px 8px;
    background: #8b5628;
    color: #ffe4a8;
    border: none;
    cursor: pointer;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    transition: all 0.2s;
    white-space: nowrap;
    text-align: center;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.inv-tab-btn:hover {
    background: #a06838;
    color: #ffffff;
}

.inv-tab-btn.active {
    background: linear-gradient(180deg, #d4a017 0%, #b8881a 100%);
    color: #2a1808;
    box-shadow: inset 0 0 0 2px #ffe066, 0 2px 4px rgba(0,0,0,0.2);
}

.inv-tab-btn + .inv-tab-btn {
    border-left: 2px solid #4a2810;
}

.inv-stats-section {
    width: 100%;
    height: 100%;
    padding: 4px 10px 6px 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.inv-stats-title {
    text-align: center;
    color: #4a2810;
    font-size: 16px;
    font-weight: 800;
    padding: 6px 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.inv-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 4px 6px 4px 6px;
}

.stat-card {
    background: linear-gradient(180deg, #fff4d4 0%, #ffe4a8 100%);
    border: 2px solid #8b5628;
    border-radius: 10px;
    padding: 10px 6px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.15s, box-shadow 0.15s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.25);
}

.stat-icon {
    font-size: 24px;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 800;
    color: #4a2810;
    line-height: 1.2;
    word-break: break-all;
}

.stat-label {
    font-size: 10px;
    color: #5a3818;
    font-weight: 600;
    margin-top: 2px;
    line-height: 1.2;
    min-height: 24px;
}

@media (max-width: 900px) {
    .inv-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .inv-tab-btn {
        padding: 8px 4px;
        font-size: 11px;
        letter-spacing: 0;
    }
    .donate-tab-btn {
        white-space: nowrap;
        font-size: 12px !important;
    }
    .inv-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .stat-value { font-size: 16px; }
    .stat-icon { font-size: 20px; }
}

.inv-tab-content-wrapper {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 8px;
    -webkit-overflow-scrolling: touch;
}

.inv-titles-section {
    width: 100%;
    height: 100%;
    padding: 4px 10px 6px 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.inv-titles-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.title-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    background: linear-gradient(180deg, #fff4d4 0%, #ffe4a8 100%);
    border-radius: 10px;
    padding: 10px 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    transition: transform 0.15s, box-shadow 0.15s;
}

.title-card.title-locked {
    background: linear-gradient(180deg, #e8e0d0 0%, #d0c8b8 100%);
}

.title-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.title-card-icon {
    font-size: 36px;
    line-height: 1;
    text-align: center;
}

.title-card-body {
    min-width: 0;
}

.title-card-name {
    font-size: 14px;
    font-weight: 800;
    color: #3a2410;
    line-height: 1.2;
    margin-bottom: 2px;
}

.title-card-desc {
    font-size: 11px;
    color: #5a3818;
    line-height: 1.3;
    margin-bottom: 3px;
}

.title-card-reward {
    font-size: 10px;
    color: #aa7820;
    font-weight: 700;
    line-height: 1.2;
}

.title-card-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

.btn-equip-title,
.btn-unequip-title {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    pointer-events: auto;
}

.btn-equip-title:hover,
.btn-unequip-title:hover {
    filter: brightness(1.1);
    transform: scale(1.04);
}

.btn-equip-title:active,
.btn-unequip-title:active {
    transform: scale(0.96);
}

@media (max-width: 600px) {
    .inv-titles-section {
        padding: 4px 10px 6px 10px;
    }
    .title-card {
        grid-template-columns: 44px 1fr auto;
        padding: 8px 10px;
        gap: 8px;
    }
    .title-card-icon {
        font-size: 30px;
    }
    .title-card-name {
        font-size: 13px;
    }
    .title-card-desc {
        font-size: 10px;
    }
    .title-card-reward {
        font-size: 9px;
    }
}

#mobileFeatureList {
    width: -webkit-max-content !important;
    width: max-content !important;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
}

.mc-feature-btn {
    -webkit-appearance: none !important;
    appearance: none !important;
    -webkit-box-sizing: border-box !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
}

.inv-tab-btn, .setting-item, .title-filter-btn {
    -webkit-appearance: none !important;
    appearance: none !important;
    -webkit-text-size-adjust: 100%;
}

.inv-profile-section {
    width: 100%;
    height: 100%;
    padding: 4px 10px 6px 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.profile-main-card {
    background: linear-gradient(180deg, #fff4d4 0%, #ffe4a8 100%);
    border: 2px solid #8b5628;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Profile showcase: the character is the focal point, while existing data stays on the right. */
.profile-main-card {
    display: grid;
    grid-template-columns: minmax(210px, 40%) minmax(0, 60%);
    align-items: stretch;
}

.profile-showcase {
    grid-row: 1 / span 3;
    min-height: 330px;
    position: relative;
    overflow: hidden;
    border: 2px solid #8b5628;
    border-radius: 14px;
    background: linear-gradient(180deg, #9bcf70 0%, #5b984b 58%, #3b6f38 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 16px 10px 12px;
    box-sizing: border-box;
}

.profile-showcase-heading {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-align: center;
}

.profile-showcase-title {
    max-width: 100%;
    color: #fff4c7;
    font-size: 14px;
    font-weight: 900;
    line-height: 1.2;
    text-align: center;
    overflow-wrap: anywhere;
    text-shadow: 0 2px 3px #3a2410;
    animation: profileTitleShimmer 2.4s ease-in-out infinite;
}

.profile-showcase-name {
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 2px 3px rgba(42, 28, 12, 0.9);
}

.profile-stage {
    width: 100%;
    min-height: 220px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-stage canvas {
    position: relative;
    z-index: 2;
    width: 180px;
    height: 220px;
    image-rendering: pixelated;
    transform: scale(0.9);
    animation: profileCharacterIntro 0.45s ease-out forwards;
}

.profile-stage-glow {
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 239, 137, 0.28);
    filter: blur(14px);
    animation: profileAuraPulse 2.2s ease-in-out infinite;
}

.profile-stage-ground {
    position: absolute;
    bottom: 16px;
    width: 145px;
    height: 32px;
    border-radius: 50%;
    background: rgba(30, 67, 27, 0.42);
    box-shadow: 0 0 0 8px rgba(214, 239, 130, 0.12);
}

.profile-rotate-btn {
    position: absolute;
    top: 50%;
    z-index: 5;
    width: 34px;
    height: 42px;
    transform: translateY(-50%);
    border: 2px solid #f4d878;
    border-radius: 8px;
    background: rgba(48, 72, 29, 0.82);
    color: #fff6c7;
    font-size: 22px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.28);
}
.profile-rotate-left { left: 4px; }
.profile-rotate-right { right: 4px; }
.profile-rotate-btn:hover { background: rgba(68, 105, 38, 0.95); }
.profile-rotate-btn:active { transform: translateY(-50%) scale(0.92); }

.profile-pet-idle {
    position: absolute;
    z-index: 3;
    display: none;
    filter: drop-shadow(0 4px 2px rgba(0,0,0,0.25));
    animation: profilePetIdle 1.8s ease-in-out infinite;
}

.profile-showcase-tags { display: none; }
.profile-showcase-tags span { background: rgba(46, 36, 15, 0.76); color: #fff0b0; border: 1px solid #d9b65e; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 800; text-align: center; }
.profile-equipped-list, .profile-meta-grid { display: grid; gap: 7px; margin-top: 10px; }
.profile-equipped-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.profile-equipped-list div, .profile-meta-grid div { background: rgba(255,255,255,0.52); border: 1px solid #d8b47c; border-radius: 8px; padding: 7px 8px; min-width: 0; }
.profile-equipped-list span, .profile-meta-grid span { display: block; color: #76502c; font-size: 10px; font-weight: 700; }
.profile-equipped-list strong, .profile-meta-grid strong { display: block; color: #3c2412; font-size: 11px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-meta-grid { grid-column: 2; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.profile-currency-bar, .profile-summary-grid { display: none !important; }

.profile-edit-name-box {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.profile-edit-name-box > div:first-child {
    white-space: normal !important;
    overflow-wrap: break-word;
    line-height: 1.35;
}
.profile-edit-name-box > div:last-child {
    width: 100%;
    flex-wrap: wrap;
}
.profile-edit-name-box .profile-name-input {
    min-width: 180px;
    width: auto;
    flex: 1 1 240px !important;
    box-sizing: border-box;
}
.profile-edit-name-box .btn-save-name,
.profile-edit-name-box .btn-cancel-name {
    flex: 0 0 auto;
    white-space: nowrap;
}

@keyframes profileCharacterIntro { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes profileAuraPulse { 0%,100% { opacity: .55; transform: scale(.92); } 50% { opacity: .9; transform: scale(1.08); } }
@keyframes profilePetIdle { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes profileTitleShimmer { 0%,100% { text-shadow: 0 2px 3px #3a2410; } 50% { text-shadow: 0 0 10px #fff1a8, 0 2px 3px #3a2410; } }

@media (max-width: 700px) {
    .profile-main-card { grid-template-columns: 1fr; }
    .profile-showcase { grid-row: auto; min-height: 270px; }
    .profile-stage { min-height: 185px; }
    .profile-stage canvas { width: 155px; height: 185px; }
    .profile-meta-grid { grid-column: auto; grid-template-columns: 1fr; }
    .profile-equipped-list { grid-template-columns: 1fr; }
    .profile-edit-name-box > div:last-child { gap: 6px; }
    .profile-edit-name-box .profile-name-input { flex: 1 1 150px; }
}

.profile-header-box {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fdf3df;
    border: 2px solid #d8b47c;
    border-radius: 12px;
    padding: 12px 16px;
}

.profile-avatar-wrapper {
    width: 56px;
    height: 72px;
    background: #2a1808;
    border: 2px solid #8b5628;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5);
}

.profile-avatar-wrapper canvas {
    width: 48px;
    height: 64px;
    image-rendering: pixelated;
}

.profile-info-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.profile-name-text {
    font-size: 18px;
    font-weight: 800;
    color: #4a2810;
    letter-spacing: 0.5px;
}

.btn-profile-action {
    background: #8b5628;
    color: #ffe4a8;
    border: 1.5px solid #4a2810;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    -webkit-appearance: none;
    appearance: none;
}

.btn-profile-action:hover {
    background: #a06838;
    color: #ffffff;
    transform: translateY(-1px);
}

.btn-profile-action:active {
    transform: scale(0.96);
}

.profile-edit-name-box {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.profile-edit-name-box.hidden {
    display: none !important;
}

.profile-name-input {
    flex: 1;
    background: #ffffff;
    border: 2px solid #8b5628;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 13px;
    font-weight: bold;
    color: #3a2010;
    outline: none;
    max-width: 200px;
}

.profile-name-input:focus {
    border-color: #d4a017;
    box-shadow: 0 0 6px rgba(212, 160, 23, 0.4);
}

/* Safari/iPhone landscape: 926x428 and nearby low-height viewports. */
@media (min-width: 800px) and (max-width: 980px) and (max-height: 460px) and (orientation: landscape) {
    html, body, .game-wrapper, #gameContainer, #gameCanvas {
        width: 100vw !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
    }

    body.has-mobile-controls .top-buttons-container {
        top: calc(5px + env(safe-area-inset-top, 0px)) !important;
        right: calc(7px + env(safe-area-inset-right, 0px)) !important;
        gap: 5px !important;
    }
    body.has-mobile-controls .top-buttons-container .btn-setting {
        width: 34px !important;
        height: 34px !important;
        font-size: 16px !important;
    }
    #mobileJoystickZone {
        left: calc(28px + env(safe-area-inset-left, 0px)) !important;
        bottom: calc(18px + env(safe-area-inset-bottom, 0px)) !important;
        transform: scale(.78) !important;
        transform-origin: left bottom !important;
    }
    #mobileActionZone {
        right: calc(10px + env(safe-area-inset-right, 0px)) !important;
        bottom: calc(9px + env(safe-area-inset-bottom, 0px)) !important;
        gap: 4px !important;
        transform: scale(.8) !important;
        transform-origin: right bottom !important;
    }
    body.has-mobile-controls #alertBannerOverlay {
        top: calc(4px + env(safe-area-inset-top, 0px)) !important;
        width: min(42vw, 320px) !important;
        height: 24px !important;
    }

    .event-modal-card,
    .notice-modal-card,
    .help-modal-card,
    .map-modal-card,
    .char-modal-box,
    .save-slot-box,
    .inv-modal-box {
        width: min(92vw, 820px) !important;
        max-width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 16px) !important;
        height: auto !important;
        max-height: calc(100dvh - 12px) !important;
        padding: 6px 9px !important;
        border-radius: 10px !important;
        overflow: hidden !important;
    }
    .event-modal-head, .notice-modal-head {
        min-height: 32px !important;
        margin-bottom: 3px !important;
        padding: 4px 8px !important;
    }
    .event-main-title, .notice-main-title { font-size: 13px !important; }
    .event-sub-title, .notice-sub-title { display: none !important; }
    .event-head-close, .notice-head-close, .inv-close-btn {
        width: 26px !important;
        height: 26px !important;
        font-size: 12px !important;
    }
    .event-body-scroll, .notice-body-scroll, .help-modal-card {
        max-height: calc(100dvh - 72px) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .event-modal-foot, .notice-modal-foot { margin-top: 2px !important; padding: 3px !important; }
    .btn-event-confirm, .btn-notice-confirm { padding: 4px 18px !important; font-size: 11px !important; }

    .inv-modal-box { height: calc(100dvh - 10px) !important; }
    .inv-scrollable { max-height: 36dvh !important; }
    .inv-hotbar-section { margin-bottom: 1px !important; }
    .inv-bottom-shortcuts { display: none !important; }

    #profileModalOverlay .event-modal-card { width: min(88vw, 720px) !important; }
    #profileModalOverlay .event-body-scroll { padding: 3px !important; }
    .profile-main-card { padding: 6px !important; gap: 7px !important; }
    .profile-showcase { min-height: 230px !important; padding: 7px !important; }
    .profile-showcase-heading { min-height: 34px !important; }
    .profile-showcase-title { font-size: 11px !important; }
    .profile-showcase-name { font-size: 10px !important; }
    .profile-stage { min-height: 150px !important; }
    .profile-stage canvas { width: 130px !important; height: 155px !important; }
    .profile-header-box { padding: 7px 9px !important; }
    .profile-equipped-list, .profile-meta-grid { gap: 4px !important; margin-top: 5px !important; }
    .profile-equipped-list div, .profile-meta-grid div { padding: 4px 6px !important; }
    .profile-level-box { padding: 7px 10px !important; }
}

.btn-save-name {
    background: linear-gradient(180deg, #5da944 0%, #3e8127 100%);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn-cancel-name {
    background: #c0382b;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.profile-badges-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.profile-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
}

.badge-slot {
    background: #5a3818;
    color: #ffe066;
    border: 1px solid #8b5628;
}

.badge-title {
    background: #ffe066;
    color: #4a2810;
    border: 1px solid #d4a017;
}

.profile-gender-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
    margin-bottom: 2px;
}

.profile-gender-label {
    font-size: 13px;
    font-weight: 800;
    color: #4a2810;
}

.btn-gender-opt {
    background: #e6c896;
    color: #5a3818;
    border: 1.5px solid #a87848;
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.btn-gender-opt:hover {
    background: #f5dcb0;
}

.btn-gender-opt.active {
    background: linear-gradient(180deg, #d4a017 0%, #b8881a 100%);
    color: #ffffff;
    border-color: #5a3818;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.profile-level-box {
    background: #fcf1d8;
    border: 1.5px solid #d8b47c;
    border-radius: 10px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.profile-level-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.profile-level-val {
    font-size: 14px;
    font-weight: 800;
    color: #4a2810;
}

.profile-exp-val {
    font-size: 12px;
    font-weight: 700;
    color: #2e6623;
}

.profile-exp-bar-track {
    width: 100%;
    height: 10px;
    background: #2a1808;
    border: 1px solid #5a3818;
    border-radius: 5px;
    overflow: hidden;
}

.profile-exp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #52c41a, #95de64);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.profile-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .profile-header-box {
        flex-direction: column;
        text-align: center;
    }
    .profile-name-row {
        justify-content: center;
    }
    .profile-badges-row {
        justify-content: center;
    }
    .profile-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.game-toast-container {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999999 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.game-toast-item {
    pointer-events: auto;
    background: rgba(20, 14, 8, 0.94);
    border: 2px solid #ffd700;
    color: #ffffff;
    font-size: 13.5px;
    font-weight: bold;
    padding: 10px 22px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 12px rgba(255, 215, 0, 0.35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    max-width: 92vw;
    animation: toastSlideDown 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.game-toast-item.hide {
    opacity: 0;
    transform: translateY(-16px) scale(0.92);
}

.game-toast-item.success {
    background: linear-gradient(135deg, rgba(20, 90, 38, 0.96), rgba(12, 55, 22, 0.96));
    border-color: #7cfc00;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 12px rgba(124, 252, 0, 0.4);
}

.game-toast-item.error {
    background: linear-gradient(135deg, rgba(150, 30, 30, 0.96), rgba(90, 15, 15, 0.96));
    border-color: #ff6b6b;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 12px rgba(255, 107, 107, 0.4);
}

.game-toast-item.info {
    background: linear-gradient(135deg, rgba(20, 40, 60, 0.96), rgba(10, 22, 38, 0.96));
    border-color: #64b5f6;
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 12px rgba(100, 181, 246, 0.4);
}

.modal-toast-container .game-toast-item {
    position: relative !important;
    max-width: 100% !important;
    width: auto !important;
}

@keyframes toastSlideDown {
    from { opacity: 0; transform: translateY(-20px) scale(0.88); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastSlideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.88); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

#landUpgradeModalCard {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.land-tab-bar {
    margin-bottom: 14px !important;
    display: flex !important;
    gap: 8px !important;
}

.land-tab-btn {
    flex: 1 !important;
    justify-content: center !important;
    text-align: center !important;
    font-size: 13px !important;
    padding: 8px 12px !important;
}

.land-upgrade-body {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    max-height: calc(85vh - 220px) !important;
    max-height: calc(85dvh - 220px) !important;
    padding-right: 6px !important;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.land-current-card {
    background: linear-gradient(135deg, #fceecb 0%, #ebdba6 100%) !important;
    border: 2px solid #d4b570 !important;
    border-radius: 16px !important;
    padding: 12px 16px !important;
    margin-bottom: 12px !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 3px !important;
}

.land-current-label {
    font-size: 10px !important;
    font-weight: 800 !important;
    color: #8b5d33 !important;
    letter-spacing: 0.5px !important;
}

.land-current-value {
    font-size: 16px !important;
    font-weight: 900 !important;
    color: #4a3215 !important;
}

.land-current-sub {
    font-size: 12px !important;
    font-weight: bold;
    color: #6e5025 !important;
}

#landUpgradeTiersList {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}

.land-tier-card {
    background: #fdfbf7 !important;
    border: 2px solid #e5d7be !important;
    border-radius: 14px !important;
    padding: 12px 14px !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02) !important;
}

.land-tier-card:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.06) !important;
}

.land-tier-current {
    background: #fffef8 !important;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.15) !important;
}

.land-tier-icon {
    font-size: 24px !important;
    width: 40px !important;
    height: 40px !important;
    background: #eedcb7 !important;
    border-radius: 50% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    flex-shrink: 0 !important;
}

.land-tier-info {
    flex-grow: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
}

.land-tier-label {
    font-size: 13.5px !important;
    font-weight: 800 !important;
    color: #44321c !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.land-tier-cost {
    font-size: 11.5px !important;
    font-weight: 600 !important;
    color: #7d654f !important;
    white-space: nowrap !important;
}

.land-tier-action {
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
}

.btn-upgrade-land-action {
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.inv-expand-card {
    background: #fdfbf7 !important;
    border: 2px solid #e5d7be !important;
    border-radius: 18px !important;
    padding: 20px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
    text-align: center !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03) !important;
    margin: 4px 0 !important;
}

.inv-expand-icon {
    font-size: 42px !important;
    margin-bottom: 4px !important;
}

.inv-expand-slots {
    font-size: 15px !important;
    font-weight: 900 !important;
    color: #4a3215 !important;
}

.inv-expand-price {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #8b5d33 !important;
}

.btn-inv-expand {
    background: linear-gradient(180deg, #3498db 0%, #2980b9 100%) !important;
    color: white !important;
    border: 2px solid #5faee3 !important;
    border-radius: 12px !important;
    padding: 10px 24px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    cursor: pointer !important;
    box-shadow: 0 4px 10px rgba(41, 128, 185, 0.3) !important;
    transition: transform 0.15s, filter 0.15s !important;
}

.btn-inv-expand:hover:not(:disabled) {
    transform: translateY(-2px) !important;
    filter: brightness(1.08) !important;
}

.btn-inv-expand:active:not(:disabled) {
    transform: translateY(0) !important;
}

.btn-inv-expand:disabled {
    background: #888888 !important;
    border-color: #aaaaaa !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
}

@media (max-width: 768px) {
    .land-tab-btn {
        font-size: 11px !important;
        padding: 6px 8px !important;
    }
    
    .land-current-card {
        padding: 10px 12px !important;
    }
    
    .land-current-value {
        font-size: 14px !important;
    }
    
    .land-tier-card {
        padding: 10px 12px !important;
        gap: 10px !important;
    }
    
    .land-tier-icon {
        font-size: 20px !important;
        width: 34px !important;
        height: 34px !important;
    }
    
    .land-tier-label {
        font-size: 12px !important;
    }
    
    .land-tier-cost {
        font-size: 10.5px !important;
    }
    
    .btn-upgrade-land-action {
        padding: 5px 10px !important;
        font-size: 10.5px !important;
    }
    
    .inv-expand-card {
        padding: 16px !important;
    }
    
    .inv-expand-icon {
        font-size: 36px !important;
    }
    
    .inv-expand-slots {
        font-size: 13.5px !important;
    }
    
    .btn-inv-expand {
        padding: 8px 18px !important;
        font-size: 12px !important;
    }

    #landUpgradeModalCard {
        padding: 10px 10px 12px 10px !important;
    }
    
    #landUpgradeModalCard .event-sub-title {
        display: none !important;
    }
    
    #landUpgradeModalCard .event-modal-foot {
        display: none !important;
    }
    
    .land-upgrade-body {
        max-height: calc(85vh - 65px) !important;
        max-height: calc(85dvh - 65px) !important;
        padding-right: 2px !important;
    }
}

@media (max-height: 550px) {
    #landUpgradeModalCard {
        padding: 8px 8px 10px 8px !important;
    }
    
    #landUpgradeModalCard .event-sub-title {
        display: none !important;
    }
    
    #landUpgradeModalCard .event-modal-foot {
        display: none !important;
    }

    .land-upgrade-body {
        max-height: calc(100vh - 55px) !important;
        max-height: calc(100dvh - 55px) !important;
        gap: 8px !important;
    }
    
    .land-current-card {
        margin-bottom: 8px !important;
    }
}

/* ==================== GROUP MODAL ==================== */
.group-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999999;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
}

.group-modal-overlay.hidden {
    display: none;
}

.group-modal-card {
    background: linear-gradient(135deg, #1a100a 0%, #0d0805 100%);
    border: 3px solid #8b6914;
    border-radius: 20px;
    padding: 0;
    width: 420px;
    max-width: 96vw;
    max-height: 90vh;
    max-height: 90dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(139, 105, 20, 0.2);
    overflow: hidden;
}

.group-modal-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(90deg, #2a1a0a 0%, #1a0f06 100%);
    border-bottom: 2px solid rgba(139, 105, 20, 0.4);
    position: relative;
}

.group-head-titles {
    flex: 1;
    text-align: center;
}

.group-main-title {
    color: #ffe066;
    font-size: 18px;
    font-weight: 800;
    margin: 0;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.group-sub-title {
    color: rgba(255, 224, 150, 0.65);
    font-size: 11px;
    margin: 2px 0 0 0;
    font-weight: 400;
    line-height: 1.4;
}

.group-head-close {
    background: rgba(220, 50, 50, 0.25);
    border: 1px solid rgba(255, 100, 100, 0.6);
    color: #ff9999;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.group-head-close:hover {
    background: #e74c3c;
    color: #fff;
    transform: scale(1.1);
}

.group-modal-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.group-icon-row {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.group-icon-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.group-icon-btn:active {
    transform: scale(0.9);
}

.group-icon-btn.discord {
    background: rgba(88, 101, 242, 0.2);
    color: #5865f2;
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.35);
}

.group-icon-btn.discord:hover {
    background: rgba(88, 101, 242, 0.35);
    box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.5), 0 0 16px rgba(88, 101, 242, 0.4);
}

.group-icon-btn.facebook {
    background: rgba(24, 119, 242, 0.2);
    color: #1877f2;
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.35);
}

.group-icon-btn.facebook:hover {
    background: rgba(24, 119, 242, 0.35);
    box-shadow: 0 0 0 3px rgba(24, 119, 242, 0.5), 0 0 16px rgba(24, 119, 242, 0.4);
}

#settingGroup:hover {
    background: rgba(0, 212, 255, 0.15) !important;
    color: #00e5ff !important;
}

@media (max-width: 480px) {
    .group-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .group-modal-card {
        width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 60vh;
        max-height: 60dvh;
    }

    .group-modal-head {
        padding: 12px 14px;
    }

    .group-main-title {
        font-size: 16px;
    }

    .group-sub-title {
        font-size: 10px;
    }

    .group-modal-body {
        padding: 14px;
        gap: 12px;
    }

    .group-icon-row {
        gap: 16px;
    }

    .group-icon-btn {
        width: 54px;
        height: 54px;
    }

    .group-icon-btn svg {
        width: 24px !important;
        height: 24px !important;
    }
}

/* ==================== MAILBOX STYLES ==================== */
.mail-empty {
    text-align: center;
    padding: 40px 20px;
    color: #85929e;
}

.mail-empty-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.mail-empty-title {
    font-size: 15px;
    font-weight: 700;
    color: #aed6f1;
}

.mail-empty-desc {
    font-size: 12px;
    margin-top: 4px;
}

.mail-item {
    margin-bottom: 12px;
    padding: 16px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.mail-item-unread {
    background: linear-gradient(135deg, #1b3d5a 0%, #152d43 100%);
    border: 2px solid #3b82c4;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.mail-item-read {
    background: #1c3347;
    border: 1.5px solid #356084;
}

.mail-item-claimed {
    background: #1a2936;
    border: 1.5px solid #2c4255;
    opacity: 0.85;
}

.mail-item-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.mail-status-badge {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 800;
    letter-spacing: 0.3px;
    color: #fff;
}

.mail-status-claimed {
    background: #4a6572;
}

.mail-status-unclaimed {
    background: #e74c3c;
}

.mail-sender {
    font-size: 12px;
    color: #b0cddb;
    font-weight: 700;
}

.mail-sender b {
    color: #fff;
}

.mail-time {
    font-size: 11px;
    color: #819db0;
    margin-left: auto;
    font-weight: 600;
}

.mail-title {
    margin: 6px 0;
    font-size: 16px;
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.mail-content {
    margin: 0;
    font-size: 13px;
    color: #d8ebf5;
    line-height: 1.45;
    white-space: pre-wrap;
}

.mail-rewards {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(10, 24, 40, 0.85);
    border-radius: 8px;
    border: 1px dashed #4aa3df;
    font-size: 12.5px;
    color: #fff;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.mail-rewards-label {
    color: #7cd1ff;
    font-weight: 800;
}

.reward-sep {
    color: rgba(255, 255, 255, 0.4);
}

.reward-gold {
    color: #ffd700;
}

.reward-gem {
    color: #00e5ff;
}

.reward-item {
    color: #ffe066;
}

.mail-action {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.mail-action-btn {
    background: linear-gradient(180deg, #2ecc71 0%, #27ae60 100%);
    color: #fff;
    border: 1.5px solid #fff;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(46, 204, 113, 0.3);
    white-space: nowrap;
}

.mail-btn-disabled {
    background: #3a4f5e;
    color: #9eb3c2;
    border: none;
    cursor: not-allowed;
}

.mailbox-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(15, 25, 35, 0.6);
    border-bottom: 1px solid rgba(84, 153, 199, 0.2);
    flex-wrap: wrap;
    gap: 8px;
}

.mailbox-count {
    font-size: 13px;
    font-weight: 700;
    color: #dbfd41;
}

.mailbox-toolbar button {
    background: linear-gradient(180deg, #27ae60 0%, #1e8449 100%);
    color: #fff;
    border: 1.5px solid #2ecc71;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 4px;
}

.mailbox-toolbar button .btn-icon {
    display: none;
}

#btnDeleteAllClaimed {
    background: linear-gradient(180deg, #c0382b 0%, #962d22 100%) !important;
    border: 1.5px solid #e74c3c !important;
}

.mailbox-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ==================== MAILBOX MOBILE RESPONSIVE ==================== */
@media (max-width: 600px) {
    #mailboxModalOverlay .event-modal-card {
        max-width: 100vw !important;
        width: 100vw !important;
        border-radius: 16px 16px 0 0 !important;
        max-height: 90vh !important;
        max-height: 90dvh !important;
        margin: 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        transform: none !important;
    }

    #mailboxModalOverlay .event-modal-head {
        padding: 12px 14px !important;
        min-height: auto !important;
    }

    #mailboxModalOverlay .event-modal-head .event-head-icon {
        display: none !important;
    }

    #mailboxModalOverlay .event-modal-head .event-main-title {
        font-size: 16px !important;
    }

    #mailboxModalOverlay .event-modal-head .event-sub-title {
        font-size: 10px !important;
        display: none !important;
    }

    #mailboxModalOverlay .mailbox-toolbar {
        padding: 8px 12px !important;
        gap: 6px !important;
    }

    #mailboxModalOverlay .mailbox-toolbar .mailbox-count {
        font-size: 11px !important;
    }

    #mailboxModalOverlay .mailbox-toolbar button {
        padding: 5px 8px !important;
        font-size: 10px !important;
        border-radius: 6px !important;
    }

    #mailboxList {
        padding: 10px 12px !important;
        max-height: calc(90vh - 120px) !important;
        max-height: calc(90dvh - 120px) !important;
    }

    #mailboxList .mail-item {
        margin-bottom: 10px !important;
        padding: 12px !important;
        border-radius: 10px !important;
    }

    #mailboxList .mail-item-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
        margin-bottom: 6px !important;
    }

    #mailboxList .mail-status-badge {
        font-size: 9px !important;
        padding: 2px 6px !important;
    }

    #mailboxList .mail-sender {
        font-size: 10px !important;
    }

    #mailboxList .mail-time {
        font-size: 9px !important;
        margin-left: 0 !important;
    }

    #mailboxList .mail-title {
        font-size: 14px !important;
        margin: 4px 0 !important;
    }

    #mailboxList .mail-content {
        font-size: 11px !important;
        line-height: 1.4 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    #mailboxList .mail-rewards {
        margin-top: 8px !important;
        padding: 6px 10px !important;
        font-size: 10px !important;
        gap: 6px !important;
    }

    #mailboxList .mail-rewards-label {
        font-size: 10px !important;
    }

    #mailboxList .mail-action {
        margin-top: 8px !important;
    }

    #mailboxList .mail-action-btn {
        width: 100% !important;
        padding: 8px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
    }

    #mailboxList .mail-empty {
        padding: 30px 16px !important;
    }

    #mailboxList .mail-empty-icon {
        font-size: 32px !important;
    }

    #mailboxList .mail-empty-title {
        font-size: 14px !important;
    }

    #mailboxList .mail-empty-desc {
        font-size: 11px !important;
    }
}

/* ===== Pet System CSS ===== */
.inv-pets-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 12px;
}

.pet-slot {
    position: relative;
    transition: transform .15s ease, box-shadow .2s ease;
    box-shadow: 0 2px 4px rgba(74, 40, 16, 0.15);
}
.pet-slot:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(74, 40, 16, 0.25);
}
.pet-slot.active {
    box-shadow: 0 0 0 3px rgba(255, 184, 74, 0.55), 0 4px 10px rgba(74, 40, 16, 0.3);
    background: rgba(255, 247, 224, 1) !important;
}
.pet-slot.active::after {
    content: '★';
    position: absolute;
    top: -6px;
    right: -6px;
    background: #ffb84a;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    line-height: 22px;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid #5a3a22;
}
.pet-slot.locked {
    opacity: 0.7;
    filter: grayscale(0.4);
}

.pet-shop-card {
    transition: transform .15s ease;
}
.pet-shop-card:hover {
    transform: translateY(-2px);
}

.pet-detail-body img {
    background: rgba(139, 86, 40, 0.1);
    border-radius: 12px;
    padding: 8px;
}

.pet-action-btn {
    transition: filter .15s ease, transform .1s ease;
}
.pet-action-btn:hover:not(:disabled) {
    filter: brightness(1.15);
}
.pet-action-btn:active:not(:disabled) {
    transform: scale(0.96);
}
.pet-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 600px) {
    .inv-pets-section {
        padding: 8px;
    }
    .inv-pets-grid {
        grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)) !important;
        gap: 6px !important;
    }
    .pet-slot {
        padding: 6px !important;
    }
    .pet-slot > div {
        font-size: 10px !important;
    }
    .pet-shop-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 8px !important;
    }
    .pet-detail-actions {
        flex-direction: column;
    }
    .pet-detail-actions .pet-action-btn {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .inv-pets-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ===== TABS TOGGLE: thu gọn / mở rộng nhóm nút ===== */
.tab-buttons-group {
    display: contents;
    transition: none;
}

.tab-buttons-group.collapsed {
    display: contents;
}

.tab-buttons-group.collapsed > .btn-setting {
    display: none;
}

/* Mailbox cũng bị ẩn khi toggle ở trạng thái collapsed */
.btn-mailbox.collapsed {
    display: none;
}

/* Nút toggle: icon ◀ khi collapsed (mở ra), ▶ khi expanded (thu lại) */
.btn-tabs-toggle {
    line-height: 1;
}

/* Final priority for 926x428 Safari landscape. */
@media (min-width: 800px) and (max-width: 980px) and (max-height: 460px) and (orientation: landscape) {
    .event-modal-card, .notice-modal-card, .help-modal-card, .map-modal-card,
    .char-modal-box, .save-slot-box, .inv-modal-box {
        max-height: calc(100dvh - 12px) !important;
        overflow: hidden !important;
    }
    .event-body-scroll, .notice-body-scroll, .help-modal-card {
        max-height: calc(100dvh - 72px) !important;
        overflow-y: auto !important;
    }
    #profileModalOverlay .event-modal-card { width: min(88vw, 720px) !important; }
    .profile-showcase { min-height: 230px !important; }
    .profile-stage { min-height: 150px !important; }
    .profile-stage canvas { width: 130px !important; height: 155px !important; }
    .inv-modal-box { height: calc(100dvh - 10px) !important; }
}
