/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
    touch-action: none;
    overscroll-behavior: none;
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
}

/* ===== Minecraft 字体 ===== */
@font-face {
    font-family: 'Minecraft';
    src: local('Minecraft'), local('Minecraftia');
}

/* ==========================================
   主菜单 - Java 版 Minecraft 风格
   ========================================== */

#main-menu {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#main-menu.hidden {
    display: none;
}

/* 动态泥土背景 */
#menu-bg {
    position: absolute;
    inset: 0;
    background-color: #6a6a6a;
    background-image:
        repeating-conic-gradient(#787878 0% 25%, #6a6a6a 0% 50%) 0 0 / 64px 64px,
        repeating-conic-gradient(#787878 0% 25%, #6a6a6a 0% 50%) 32px 32px / 64px 64px;
    animation: bgScroll 20s linear infinite;
}

@keyframes bgScroll {
    0% { background-position: 0 0, 32px 32px; }
    100% { background-position: 64px 64px, 96px 96px; }
}

/* 暗角效果 */
#menu-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.5) 100%);
    pointer-events: none;
}

/* Logo */
#menu-logo {
    position: relative;
    z-index: 2;
    margin-bottom: 30px;
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    letter-spacing: 3px;
    transform: perspective(300px) rotateX(25deg);
    text-shadow:
        3px 3px 0 #2a2a2a,
        6px 6px 0 rgba(0,0,0,0.3);
}

.logo-mine {
    color: #c8c8c8;
    text-shadow:
        3px 3px 0 #3a3a3a,
        6px 6px 0 rgba(0,0,0,0.4);
}

.logo-craft {
    color: #5a8a3a;
    text-shadow:
        3px 3px 0 #2a4a1a,
        6px 6px 0 rgba(0,0,0,0.4);
}

/* 闪烁文字 */
#splash-text {
    position: absolute;
    z-index: 3;
    top: 28%;
    right: 18%;
    transform: rotate(-15deg);
    font-size: clamp(0.7rem, 2.5vw, 1.1rem);
    font-weight: 700;
    color: #ffdd00;
    text-shadow: 2px 2px 0 #a00;
    animation: splashPulse 1s ease-in-out infinite alternate;
    max-width: 150px;
    text-align: center;
}

@keyframes splashPulse {
    0% { transform: rotate(-15deg) scale(1); }
    100% { transform: rotate(-15deg) scale(1.08); }
}

/* 主菜单按钮 */
#menu-buttons {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 400px;
    max-width: 80vw;
}

/* Minecraft 风格按钮 */
.mc-btn {
    position: relative;
    background: linear-gradient(to bottom, #8a8a8a 0%, #6e6e6e 50%, #5a5a5a 51%, #4a4a4a 100%);
    border: 2px solid #1a1a1a;
    border-top-color: #9a9a9a;
    border-left-color: #9a9a9a;
    border-right-color: #1a1a1a;
    border-bottom-color: #1a1a1a;
    color: #fff;
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    text-shadow: 2px 2px 0 #1a1a1a;
    transition: filter 0.1s;
    image-rendering: pixelated;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 44px;
}

.mc-btn:hover:not(:disabled) {
    background: linear-gradient(to bottom, #8aaa6a 0%, #6e8a4e 50%, #5a7a3e 51%, #4a6a2e 100%);
    border-top-color: #9aba7a;
    border-left-color: #9aba7a;
}

.mc-btn:active:not(:disabled) {
    filter: brightness(0.85);
}

.mc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mc-btn-red {
    background: linear-gradient(to bottom, #8a4a4a 0%, #6e3a3a 50%, #5a2a2a 51%, #4a1a1a 100%);
}

.mc-btn-red:hover:not(:disabled) {
    background: linear-gradient(to bottom, #aa5a5a 0%, #8a4a4a 50%, #6a3a3a 51%, #5a2a2a 100%);
}

.mc-btn-text {
    line-height: 1.2;
}

.mc-btn-sub {
    font-size: 0.65rem;
    color: #aaa;
    font-weight: 400;
}

.mc-btn-done {
    margin-top: 12px;
}

/* 底部信息栏 */
#menu-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 0.65rem;
    color: rgba(255,255,255,0.5);
    text-shadow: 1px 1px 0 #000;
}

/* 右侧辅助按钮 */
#menu-side {
    position: absolute;
    bottom: 30px;
    right: 12px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mc-icon-btn {
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.mc-icon-btn:hover {
    background: rgba(255,255,255,0.15);
}

/* ==========================================
   选项面板
   ========================================== */

.mc-overlay {
    position: fixed;
    inset: 0;
    z-index: 600;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mc-panel {
    background: linear-gradient(to bottom, #c6c6c6, #b0b0b0);
    border: 3px solid #1a1a1a;
    border-top-color: #f0f0f0;
    border-left-color: #f0f0f0;
    border-right-color: #2a2a2a;
    border-bottom-color: #2a2a2a;
    padding: 24px;
    min-width: 350px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mc-panel-title {
    font-size: 1.3rem;
    color: #2a2a2a;
    text-shadow: 1px 1px 0 #f0f0f0;
    text-align: center;
    margin-bottom: 8px;
}

.mc-option-row {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #2a2a2a;
    font-size: 0.9rem;
    font-weight: 600;
}

.mc-option-row span:first-child {
    min-width: 100px;
}

.mc-slider {
    flex: 1;
    height: 20px;
    -webkit-appearance: none;
    appearance: none;
    background: #1a1a1a;
    border: 2px solid;
    border-top-color: #1a1a1a;
    border-left-color: #1a1a1a;
    border-right-color: #f0f0f0;
    border-bottom-color: #f0f0f0;
    outline: none;
    cursor: pointer;
}

.mc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 20px;
    background: #8a8a8a;
    border: 2px solid #1a1a1a;
    cursor: pointer;
}

.mc-slider::-moz-range-thumb {
    width: 8px;
    height: 20px;
    background: #8a8a8a;
    border: 2px solid #1a1a1a;
    cursor: pointer;
    border-radius: 0;
}

.mc-select {
    flex: 1;
    height: 28px;
    background: #1a1a1a;
    color: #fff;
    border: 2px solid;
    border-top-color: #1a1a1a;
    border-left-color: #1a1a1a;
    border-right-color: #f0f0f0;
    border-bottom-color: #f0f0f0;
    padding: 0 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.mc-toggle {
    flex: 1;
    background: #4a4a4a;
    color: #fff;
    border: 2px solid #1a1a1a;
    border-top-color: #6a6a6a;
    border-left-color: #6a6a6a;
    border-right-color: #1a1a1a;
    border-bottom-color: #1a1a1a;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-shadow: 1px 1px 0 #1a1a1a;
}

.mc-toggle.on {
    background: #4a7a2a;
}

.mc-toggle.off {
    background: #7a2a2a;
}

/* ==========================================
   加载画面
   ========================================== */

#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

.loading-content {
    text-align: center;
}

.loading-logo {
    font-size: 2.5rem;
    font-weight: 900;
    color: #80c050;
    text-shadow: 0 0 20px rgba(128, 192, 80, 0.5);
    margin-bottom: 2rem;
    letter-spacing: 2px;
}

.loading-bar {
    width: 240px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 auto 1rem;
}

.loading-fill {
    height: 100%;
    background: linear-gradient(90deg, #80c050, #50a030);
    border-radius: 4px;
    animation: loadingAnim 1.5s ease-in-out infinite;
}

@keyframes loadingAnim {
    0% { width: 0%; }
    50% { width: 80%; }
    100% { width: 100%; }
}

.loading-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

/* ==========================================
   准星
   ========================================== */

#crosshair {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    z-index: 10;
    pointer-events: none;
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

#crosshair::before {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}

#crosshair::after {
    left: 50%;
    top: 0;
    width: 2px;
    height: 100%;
    transform: translateX(-50%);
}

/* ==========================================
   提示信息
   ========================================== */

#toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

/* ==========================================
   顶部工具栏
   ========================================== */

#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 50;
    pointer-events: none;
}

#top-bar.hidden {
    display: none;
}

.top-btn {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.2s;
}

.top-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.top-title {
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
}

/* ==========================================
   菜单面板
   ========================================== */

.panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 24px;
    z-index: 200;
    display: none;
    flex-direction: column;
    gap: 12px;
    min-width: 300px;
    max-width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.panel h2 {
    text-align: center;
    margin-bottom: 8px;
}

.panel h3 {
    font-size: 0.95rem;
    margin-bottom: 8px;
    color: #80c050;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.menu-btn:hover {
    background: rgba(128, 192, 80, 0.2);
    border-color: rgba(128, 192, 80, 0.4);
}

.menu-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.hint-section p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
    line-height: 1.5;
}

.hint-section b {
    color: #80c050;
    display: inline-block;
    min-width: 80px;
}

/* ==========================================
   快捷栏
   ========================================== */

#hotbar {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 0px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    backdrop-filter: blur(4px);
    z-index: 50;
    max-width: 95vw;
    overflow-x: auto;
}

#hotbar.hidden {
    display: none;
}

.hotbar-slot {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.15s;
}

.hotbar-slot.selected {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.hotbar-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

.hotbar-label {
    position: absolute;
    bottom: 1px;
    right: 3px;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 700;
}

.hotbar-count {
    position: absolute;
    bottom: 1px;
    left: 3px;
    font-size: 0.7rem;
    color: #fff;
    font-weight: 700;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.hotbar-slot.empty {
    opacity: 0.3;
}

/* ==========================================
   手机触控
   ========================================== */

#mobile-controls {
    position: fixed;
    inset: 0;
    z-index: 40;
    pointer-events: none;
}

#mobile-controls.hidden {
    display: none !important;
}

#joystick {
    position: fixed;
    bottom: 90px;
    left: 30px;
    width: 120px;
    height: 120px;
    pointer-events: auto;
    touch-action: none;
}

#joystick-base {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(4px);
    transition: transform 0.15s ease;
}

#look-area {
    position: fixed;
    top: 44px;
    right: 0;
    width: 50%;
    height: calc(100% - 200px);
    pointer-events: auto;
    touch-action: none;
}

#action-buttons {
    position: fixed;
    bottom: 90px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: none;
}

.ui-btn {
    pointer-events: auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    touch-action: none;
    transition: all 0.1s;
}

.ui-btn span {
    font-size: 0.6rem;
    margin-top: 1px;
}

.ui-btn.active {
    background: rgba(128, 192, 80, 0.4);
    border-color: rgba(128, 192, 80, 0.6);
    transform: scale(0.92);
}

.btn-break { background: rgba(200, 80, 60, 0.4); }
.btn-break.active { background: rgba(200, 80, 60, 0.7); }
.btn-place { background: rgba(80, 160, 80, 0.4); }
.btn-place.active { background: rgba(80, 160, 80, 0.7); }

#fly-controls {
    display: flex;
    flex-direction: row;
    gap: 8px;
    pointer-events: auto;
}

#fly-controls .ui-btn {
    width: 44px;
    height: 44px;
}

/* ==========================================
   响应式
   ========================================== */

@media (max-width: 768px) {
    .top-title { font-size: 0.85rem; }
    #hotbar { bottom: 8px; }
    .hotbar-slot { width: 38px; height: 38px; }
    .hotbar-icon { width: 28px; height: 28px; }
    #joystick { bottom: 70px; left: 20px; width: 100px; height: 100px; }
    #joystick-knob { width: 42px; height: 42px; margin: -21px 0 0 -21px; }
    #action-buttons { bottom: 70px; right: 12px; }
    .ui-btn { width: 50px; height: 50px; }
    #look-area { height: calc(100% - 180px); }
    #menu-buttons { width: 90vw; }
    #splash-text { right: 8%; }
}

@media (max-width: 400px) {
    .hotbar-slot { width: 32px; height: 32px; }
    .hotbar-icon { width: 24px; height: 24px; }
    .ui-btn { width: 44px; height: 44px; }
    #joystick { width: 90px; height: 90px; }
    .mc-panel { min-width: unset; width: 92vw; }
    .mc-option-row span:first-child { min-width: 70px; font-size: 0.8rem; }
}

@media (orientation: landscape) and (max-height: 500px) {
    #top-bar { height: 32px; }
    #hotbar { bottom: 4px; padding: 4px; }
    .hotbar-slot { width: 34px; height: 34px; }
    #joystick { bottom: 50px; left: 15px; }
    #action-buttons { bottom: 50px; right: 10px; }
    #look-area { top: 32px; height: calc(100% - 130px); }
    #menu-logo { font-size: 1.8rem; margin-bottom: 12px; }
    #menu-buttons { width: 320px; }
    .mc-btn { padding: 6px 16px; font-size: 0.9rem; }
}

img, div, button, span {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ==========================================
   生存模式 HUD
   ========================================== */

#survival-hud {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 45;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    pointer-events: none;
}

#health-bar, #hunger-bar {
    display: flex;
    gap: 1px;
    height: 18px;
}

#air-bar {
    display: flex;
    gap: 1px;
    height: 18px;
    margin-bottom: 1px;
}

#air-bar:empty {
    display: none;
}

.bubble {
    width: 18px;
    height: 18px;
    display: inline-block;
    image-rendering: pixelated;
}

.bubble.full {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='5' fill='%2370c0ff' stroke='%2340a0e0' stroke-width='1'/%3E%3Ccircle cx='6' cy='6' r='1.5' fill='%23a0e0ff'/%3E%3C/svg%3E") center/contain no-repeat;
}

.bubble.empty {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='5' fill='none' stroke='%23444' stroke-width='1' opacity='0.3'/%3E%3C/svg%3E") center/contain no-repeat;
}

#hunger-bar {
    flex-direction: row-reverse;
}

.heart, .hunger {
    width: 18px;
    height: 18px;
    display: inline-block;
    image-rendering: pixelated;
}

.heart.full {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23ff0000' d='M3 2h4v1h1v1h1V4h1V3h1V2h4v5h-1v1h-1v1h-1v1h-1v1h-1v1h-1v1H8v-1H7v-1H6v-1H5V8H4V7H3V2z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.heart.half {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23ff0000' d='M3 2h4v1h1v1h1V4h1V3h1V2h4v5h-1v1h-1v1h-1v1h-1v1h-1v1h-1v1H8v-1H7v-1H6v-1H5V8H4V7H3V2z' opacity='0.3'/%3E%3Cpath fill='%23ff0000' d='M3 2h4v1h1v1h1V4h1V3h1V2h2v5h-1v1h-1v1h-1v1h-1v1h-1v1H8v-1H7v-1H6v-1H5V8H4V7H3V2z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.heart.empty {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23444' d='M3 2h4v1h1v1h1V4h1V3h1V2h4v5h-1v1h-1v1h-1v1h-1v1h-1v1h-1v1H8v-1H7v-1H6v-1H5V8H4V7H3V2z' opacity='0.3'/%3E%3C/svg%3E") center/contain no-repeat;
}

.hunger.full {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%238b5a2b' d='M2 4h2v2h1V5h1V4h2v2H7v1H6v1H5v1H4v1H3V9H2V8H1V7H0V5h1V4h1z'/%3E%3Cpath fill='%236b3f1a' d='M8 4h2v1h1v1h1v1h1v1h1v1h1v1h-1v1h-1v1h-1v1h-1v1h-1v1h-1v-1H9v-1H8v-1H7v-1H6V9H5V8H4V7H3V6h1V5h1V4h1V3h2v1z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.hunger.half {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%238b5a2b' opacity='0.3' d='M2 4h2v2h1V5h1V4h2v2H7v1H6v1H5v1H4v1H3V9H2V8H1V7H0V5h1V4h1z'/%3E%3Cpath fill='%238b5a2b' d='M8 4h2v1h1v1h1v1h1v1h1v1h1v1h-1v1h-1v1h-1v1h-1v1h-1v1h-1v-1H9v-1H8v-1H7v-1H6V9H5V8H4V7H3V6h1V5h1V4h1V3h2v1z'/%3E%3C/svg%3E") center/contain no-repeat;
}

.hunger.empty {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23444' opacity='0.3' d='M2 4h2v2h1V5h1V4h2v2H7v1H6v1H5v1H4v1H3V9H2V8H1V7H0V5h1V4h1z'/%3E%3C/svg%3E") center/contain no-repeat;
}

@media (max-width: 768px) {
    #survival-hud { bottom: 55px; }
    .heart, .hunger, .bubble { width: 14px; height: 14px; }
}

@media (orientation: landscape) and (max-height: 500px) {
    #survival-hud { bottom: 40px; }
    .heart, .hunger, .bubble { width: 12px; height: 12px; }
}

/* ==========================================
   多人游戏 UI
   ========================================== */

#mp-room-info {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 14px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

#mp-room-code {
    color: #80c050;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 2px;
}

#mp-player-count {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
}

#btn-mp-leave {
    background: rgba(200, 80, 60, 0.5);
    border: none;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-mp-leave:hover {
    background: rgba(200, 80, 60, 0.8);
}

#mp-chat {
    position: fixed;
    top: 50px;
    left: 12px;
    z-index: 55;
    width: 280px;
    max-width: 60vw;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
}

#mp-chat-messages {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    pointer-events: auto;
}

#mp-chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

#mp-chat-messages .chat-msg {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    word-break: break-word;
}

#mp-chat-messages .chat-name {
    color: #80c050;
    font-weight: 600;
}

#mp-chat-input {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    outline: none;
    backdrop-filter: blur(4px);
}

#mp-chat-input:focus {
    border-color: rgba(128, 192, 80, 0.5);
}

.mc-option-row input[type="text"] {
    flex: 1;
    height: 28px;
    background: #1a1a1a;
    color: #fff;
    border: 2px solid;
    border-top-color: #1a1a1a;
    border-left-color: #1a1a1a;
    border-right-color: #f0f0f0;
    border-bottom-color: #f0f0f0;
    padding: 0 6px;
    font-size: 0.85rem;
}

#mp-status {
    transition: color 0.3s;
}

#mp-status.success { color: #2a7a2a !important; }
#mp-status.error { color: #8a2a2a !important; }

@media (max-width: 768px) {
    #mp-chat { width: 200px; top: 48px; }
    #mp-chat-messages { max-height: 100px; }
}

/* ===== 创造模式物品栏 ===== */
#creative-inventory {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7); z-index: 1000;
    justify-content: center; align-items: center;
}
.creative-panel {
    background: #c6c6c6; border: 4px solid #555;
    border-radius: 4px; padding: 12px;
    max-width: 600px; width: 90%; max-height: 85vh;
    display: flex; flex-direction: column; gap: 8px;
}
.creative-header {
    display: flex; gap: 8px; align-items: center;
}
.creative-search {
    flex: 1; padding: 6px 10px; border: 2px solid #555;
    background: #fff; color: #333; font-size: 0.9rem;
    border-radius: 2px; outline: none;
}
.creative-close {
    width: 32px; height: 32px; border: 2px solid #555;
    background: #d44; color: #fff; font-size: 1rem;
    cursor: pointer; border-radius: 2px;
}
.creative-close:hover { background: #e55; }
.creative-grid {
    display: grid; grid-template-columns: repeat(9, 1fr);
    gap: 3px; overflow-y: auto; flex: 1;
    background: #8b8b8b; padding: 6px; border: 2px solid #555;
    min-height: 250px;
}
.creative-slot {
    aspect-ratio: 1; background: #8b8b8b; border: 1px solid rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; image-rendering: pixelated;
}
.creative-slot:hover {
    background: #fff; border-color: #fff;
    box-shadow: 0 0 4px rgba(255,255,255,0.5);
}
.creative-slot canvas { image-rendering: pixelated; }
.creative-nav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0;
}
.creative-nav-btn {
    padding: 6px 16px; border: 2px solid #555;
    background: #999; color: #fff; font-size: 0.85rem;
    cursor: pointer; border-radius: 2px;
}
.creative-nav-btn:hover { background: #aaa; }
#creative-page-info { color: #333; font-size: 0.85rem; }

@media (max-width: 768px) {
    .creative-panel { width: 95%; padding: 8px; }
    .creative-grid { grid-template-columns: repeat(6, 1fr); }
}
