/* NizamCraft HUD & Workbench Interface */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@600;700;800&family=Rubik:wght@400;500;600;700&display=swap');

:root {
    --surface-base: #0b101d;
    --surface-panel: rgba(13, 19, 33, 0.84);
    --surface-panel-strong: rgba(13, 19, 33, 0.94);
    --surface-elevated: rgba(25, 34, 56, 0.72);
    --surface-slot: rgba(7, 11, 20, 0.65);
    --border-subtle: rgba(148, 163, 184, 0.18);
    --border-strong: rgba(148, 163, 184, 0.36);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent-blue: #1d4ed8;
    --accent-blue-hover: #1e40af;
    --accent-blue-tint: rgba(59, 130, 246, 0.2);
    --accent-emerald: #047857;
    --accent-emerald-hover: #065f46;
    --accent-violet: #6d28d9;
    --accent-violet-hover: #5b21b6;
    --accent-violet-border: rgba(192, 132, 252, 0.55);
    --accent-danger: #be123c;
    --accent-danger-hover: #9f1239;
    --focus-ring: #60a5fa;
    --font-main: 'Rubik', system-ui, -apple-system, sans-serif;
    --font-display: 'Outfit', system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

::selection {
    background: rgba(59, 130, 246, 0.35);
    color: var(--text-primary);
}

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

/* Themed Scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.35) rgba(11, 16, 29, 0.4);
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: rgba(11, 16, 29, 0.4);
    border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.35);
    border-radius: 999px;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    overflow-x: clip;
    font-family: var(--font-main);
    background-color: var(--surface-base);
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 1;
    display: block;
    touch-action: none;
}

.pixel-thumb {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 4px;
    display: block;
    box-shadow: 0 2px 6px rgba(2, 6, 23, 0.45);
}

.screen-flash-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 9999;
    pointer-events: none;
}

/* Hide gameplay HUD until player enters world */
body:not(.in-game) #guide-panel,
body:not(.in-game) #quick-access-bar,
body:not(.in-game) #actions-panel,
body:not(.in-game) #status-bars-row,
body:not(.in-game) #hotbar-wrapper,
body:not(.in-game) #crosshair,
body:not(.in-game) #mobile-joystick-container,
body:not(.in-game) #mobile-actions-container {
    display: none !important;
}

/* ==========================================
   START / PAUSE OVERLAY
   ========================================== */
#play-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: radial-gradient(circle at 50% 35%, rgba(15, 23, 42, 0.78) 0%, rgba(5, 8, 18, 0.94) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 1000;
    transition: opacity 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

#overlay-container {
    width: min(640px, 100%);
    max-height: 92dvh;
    overflow-y: auto;
    padding: 32px;
    border-radius: 20px;
    background: var(--surface-panel-strong);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 24px 56px rgba(2, 6, 23, 0.65);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.overlay-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

#play-overlay h1 {
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 5vw, 3.2rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.05;
    margin: 0 0 10px 0;
    color: var(--text-primary);
    text-wrap: balance;
}

.overlay-subtitle {
    font-size: 0.98rem;
    line-height: 1.5;
    color: var(--text-secondary);
    max-width: 52ch;
    margin: 0 0 22px 0;
}

#play-button {
    font-family: var(--font-main);
    font-size: 1.05rem;
    font-weight: 700;
    color: #ffffff;
    background: var(--accent-blue);
    border: 1px solid rgba(147, 197, 253, 0.3);
    padding: 14px 36px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.55);
    transition: background-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

#play-button:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(2, 6, 23, 0.65);
}

#play-button:active {
    transform: translateY(1px);
}

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

.overlay-actions,
.instructions,
.mobile-instructions {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 16px 18px;
}

.mobile-instructions {
    display: none;
}

.section-heading {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px 0;
}

.overlay-actions-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.overlay-btn {
    font-family: var(--font-main);
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid var(--border-subtle);
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.overlay-btn:hover {
    background: rgba(51, 65, 85, 0.9);
    transform: translateY(-1px);
}

.overlay-btn.danger {
    background: rgba(190, 18, 60, 0.22);
    border-color: rgba(251, 113, 133, 0.35);
    color: #fecdd3;
}

.overlay-btn.danger:hover {
    background: var(--accent-danger);
    color: #ffffff;
}

.instruction-row,
.instruction-row-mobile {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 0.86rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.instruction-row:last-child,
.instruction-row-mobile:last-child {
    margin-bottom: 0;
}

.key-tag,
.key-mini {
    display: inline-block;
    font-family: var(--font-main);
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-primary);
}

.key-mini {
    padding: 1px 5px;
    font-size: 0.72rem;
}

.key-tag-mobile {
    background: var(--accent-blue-tint);
    border: 1px solid rgba(96, 165, 250, 0.4);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==========================================
   CROSSHAIR & TOAST
   ========================================== */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    pointer-events: none;
    z-index: 100;
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(248, 250, 252, 0.88);
    box-shadow: 0 1px 3px rgba(2, 6, 23, 0.7);
}

#crosshair::before {
    width: 14px;
    height: 2px;
}

#crosshair::after {
    width: 2px;
    height: 14px;
}

#toast-msg {
    position: fixed;
    top: -64px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface-panel-strong);
    border: 1px solid var(--border-strong);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 600;
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.55);
    z-index: 3000;
    transition: top 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}

#toast-msg.show {
    top: max(16px, env(safe-area-inset-top));
}

/* ==========================================
   DESKTOP & MOBILE HUD PANELS
   ========================================== */
.hud-panel {
    position: fixed;
    z-index: 20;
    pointer-events: auto;
    background: var(--surface-panel);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 12px 30px rgba(2, 6, 23, 0.42);
}

#guide-panel {
    top: 16px;
    left: 16px;
    width: 236px;
}

#guide-panel h3 {
    margin: 0 0 10px 0;
    font-family: var(--font-display);
    font-size: 0.96rem;
    font-weight: 700;
    color: #93c5fd;
}

/* Quick Access Bar (Bag, Enchant, Crafting) */
#quick-access-bar {
    position: fixed;
    top: 204px;
    left: 16px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 14px;
    border-radius: 12px;
    background: var(--surface-panel);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(2, 6, 23, 0.4);
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.quick-pill-btn:hover {
    background: rgba(30, 41, 59, 0.92);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.quick-pill-btn.enchant-pill {
    border-color: var(--accent-violet-border);
    background: rgba(46, 16, 101, 0.72);
}

.quick-pill-btn.enchant-pill:hover {
    background: var(--accent-violet);
}

.pill-kbd {
    font-size: 0.7rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    margin-left: 2px;
}

/* Right Actions Panel */
#actions-panel {
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 176px;
}

.hud-action-btn {
    font-family: var(--font-main);
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid var(--border-subtle);
    padding: 9px 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: background-color 0.18s ease, transform 0.18s ease;
}

.hud-action-btn:hover {
    background: var(--accent-blue);
    border-color: rgba(147, 197, 253, 0.4);
    transform: translateX(-2px);
}

.hud-action-btn.danger:hover {
    background: var(--accent-danger);
    border-color: rgba(253, 164, 175, 0.4);
}

/* ==========================================
   STATUS BARS & CONTEXTUAL PLANT BUTTON
   ========================================== */
#plant-button-container {
    position: fixed;
    bottom: 148px;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    z-index: 25;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#plant-button-container.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

.context-plant-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent-emerald);
    border: 1px solid rgba(110, 231, 183, 0.45);
    padding: 8px 18px;
    border-radius: 999px;
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(2, 6, 23, 0.55);
}

.context-plant-btn:hover {
    background: var(--accent-emerald-hover);
}

#status-bars-row {
    position: fixed;
    bottom: 104px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
    pointer-events: none;
    font-variant-numeric: tabular-nums;
}

#health-bar-container,
#armor-bar-container,
#held-item-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-panel);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(2, 6, 23, 0.42);
}

#held-item-badge {
    border-color: var(--accent-violet-border);
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-primary);
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-icon {
    display: inline-flex;
    align-items: center;
}

.hp-icon {
    color: #fb7185;
}

.def-icon {
    color: #60a5fa;
}

#health-bar,
#armor-bar {
    width: 112px;
    height: 8px;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    overflow: hidden;
}

#armor-bar {
    width: 84px;
}

#health-fill {
    width: 100%;
    height: 100%;
    background: #10b981;
    border-radius: 999px;
    transition: width 0.2s ease-out, background-color 0.2s ease;
}

#armor-fill {
    width: 0%;
    height: 100%;
    background: #3b82f6;
    border-radius: 999px;
    transition: width 0.2s ease-out;
}

#health-text,
#armor-text {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 48px;
    text-align: right;
}

/* ==========================================
   HOTBAR & PINNED BLOCK CATALOG TRIGGER
   ========================================== */
#hotbar-wrapper {
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: stretch;
    gap: 8px;
    max-width: min(880px, 94vw);
    background: var(--surface-panel-strong);
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: 7px;
    border-radius: 18px;
    box-shadow: 0 16px 38px rgba(2, 6, 23, 0.55);
    z-index: 30;
}

#hotbar-container {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px;
}

#hotbar-container::-webkit-scrollbar {
    display: none;
}

.hotbar-slot {
    width: 62px;
    height: 62px;
    flex-shrink: 0;
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.45);
    border: 1.5px solid transparent;
    color: var(--text-primary);
    font-family: var(--font-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.hotbar-slot:hover {
    background: rgba(51, 65, 85, 0.65);
    transform: translateY(-2px);
}

.hotbar-slot.active {
    background: var(--accent-blue-tint);
    border-color: #60a5fa;
    box-shadow: 0 6px 16px rgba(2, 6, 23, 0.55);
    transform: translateY(-3px);
}

.slot-num {
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.hotbar-slot.active .slot-num {
    color: #93c5fd;
}

.block-preview {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.block-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.hotbar-slot.active .block-name {
    color: var(--text-primary);
}

#open-block-picker-btn {
    flex-shrink: 0;
    min-width: 62px;
    border-radius: 12px;
    background: var(--accent-blue);
    border: 1px solid rgba(147, 197, 253, 0.35);
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    cursor: pointer;
    transition: background-color 0.16s ease, transform 0.16s ease;
}

#open-block-picker-btn:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
}

/* ==========================================
   MODALS (PICKER, INVENTORY, CRAFTING, ENCHANT)
   ========================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(5, 8, 18, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 2000;
}

.modal-card {
    width: min(760px, 100%);
    max-height: min(88dvh, 680px);
    background: var(--surface-panel-strong);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 24px 60px rgba(2, 6, 23, 0.72);
    border-radius: 18px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

.crafting-card,
.enchant-card {
    width: min(860px, 100%);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 12px;
    flex-shrink: 0;
}

.modal-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--accent-blue-tint);
    color: #93c5fd;
}

.header-icon.enchant-accent {
    background: rgba(109, 40, 217, 0.28);
    color: #d8b4fe;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.close-btn:hover {
    background: var(--accent-danger);
    color: #ffffff;
}

/* Filter Tabs & Toggles */
.filter-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    flex-shrink: 0;
}

.filter-tab {
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--border-subtle);
    padding: 7px 13px;
    border-radius: 999px;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.filter-tab:hover {
    background: rgba(51, 65, 85, 0.8);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--accent-blue);
    border-color: rgba(147, 197, 253, 0.45);
    color: #ffffff;
}

/* Categorized Block Picker Grid */
.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    overflow-y: auto;
    padding: 2px;
}

.picker-tile {
    min-height: 74px;
    border-radius: 12px;
    background: var(--surface-slot);
    border: 1.5px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-main);
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.picker-tile:hover {
    background: rgba(30, 41, 59, 0.85);
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.picker-tile.active {
    background: var(--accent-blue-tint);
    border-color: #60a5fa;
}

.picker-tile-name {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
}

.picker-tile-key {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* ==========================================
   INVENTORY & CHEST MODAL
   ========================================== */
.inventory-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    padding-right: 2px;
}

.storage-section,
.equipment-section,
.bag-section,
.enchant-panel {
    background: rgba(15, 23, 42, 0.58);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 14px;
}

.panel-subtitle {
    margin: 0 0 10px 0;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-desc {
    margin: -4px 0 12px 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.player-and-bag-section {
    display: flex;
    gap: 14px;
}

.equipment-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bag-section {
    flex: 1.7;
}

.player-preview-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface-slot);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 10px 12px;
    font-variant-numeric: tabular-nums;
}

.player-silhouette {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    display: flex;
    align-items: center;
    justify-content: center;
}

.armor-stats {
    font-size: 0.84rem;
    line-height: 1.5;
    font-weight: 600;
    color: var(--text-primary);
}

.armor-slots-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.armor-slot {
    aspect-ratio: 1;
    background: var(--surface-slot);
    border: 1.5px dashed var(--border-strong);
    border-radius: 10px;
    color: var(--text-muted);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.16s ease, border-color 0.16s ease;
}

.armor-slot:hover {
    background: rgba(30, 41, 59, 0.8);
    border-color: #60a5fa;
}

.armor-slot.enchanted-item {
    border-style: solid;
    border-color: var(--accent-violet-border);
    background: rgba(76, 29, 149, 0.32);
}

.slot-placeholder {
    opacity: 0.45;
    display: flex;
}

.slot-item {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.inventory-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
}

.inv-slot {
    aspect-ratio: 1;
    min-height: 48px;
    background: var(--surface-slot);
    border: 1.5px solid var(--border-subtle);
    border-radius: 10px;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    padding: 4px;
    transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.inv-slot:hover {
    border-color: var(--border-strong);
    background: rgba(30, 41, 59, 0.78);
    transform: translateY(-1px);
}

.inv-slot.selected {
    border-color: #fbbf24;
    background: rgba(245, 158, 11, 0.16);
}

.inv-slot.rare-item {
    border-color: rgba(56, 189, 248, 0.45);
}

.inv-slot.enchanted-item {
    border-color: var(--accent-violet-border);
    background: linear-gradient(145deg, rgba(88, 28, 135, 0.42), rgba(15, 23, 42, 0.75));
}

.enchant-glint-dot {
    position: absolute;
    top: 4px;
    left: 5px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: #c084fc;
}

.item-visual {
    display: flex;
    align-items: center;
    justify-content: center;
}

.item-count {
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    background: rgba(2, 6, 23, 0.82);
    padding: 1px 4px;
    border-radius: 4px;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 12px;
    flex-shrink: 0;
}

.info-tip {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
    flex: 1;
    min-width: 200px;
}

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

.primary-btn,
.heal-btn,
.enchant-btn {
    font-family: var(--font-main);
    font-size: 0.82rem;
    font-weight: 700;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 9px 15px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: background-color 0.16s ease, transform 0.16s ease, opacity 0.16s ease;
}

.primary-btn {
    background: var(--accent-blue);
}

.primary-btn:hover:not(:disabled) {
    background: var(--accent-blue-hover);
    transform: translateY(-1px);
}

.heal-btn {
    background: var(--accent-emerald);
}

.heal-btn:hover:not(:disabled) {
    background: var(--accent-emerald-hover);
    transform: translateY(-1px);
}

.enchant-btn {
    background: var(--accent-violet);
    border-color: rgba(216, 180, 254, 0.4);
}

.enchant-btn:hover:not(:disabled) {
    background: var(--accent-violet-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled,
.heal-btn:disabled,
.enchant-btn:disabled {
    background: rgba(51, 65, 85, 0.55);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.72;
}

.full-width-btn {
    width: 100%;
    margin-top: auto;
}

/* ==========================================
   CRAFTING WORKBENCH
   ========================================== */
.crafting-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.ready-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.ready-toggle input {
    accent-color: var(--accent-blue);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.materials-summary-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(7, 11, 20, 0.6);
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.mat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 8px;
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid var(--border-subtle);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.mat-chip strong {
    color: var(--text-primary);
}

.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding: 2px;
}

.recipe-card {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.16s ease, transform 0.16s ease;
}

.recipe-card.craftable {
    border-color: rgba(52, 211, 153, 0.45);
    background: rgba(6, 46, 38, 0.36);
}

.recipe-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

.recipe-top {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.recipe-icon-box {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 10px;
    background: var(--surface-slot);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.recipe-qty {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background: var(--accent-blue);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.recipe-title {
    font-family: var(--font-display);
    font-size: 0.96rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 3px 0;
}

.recipe-desc {
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--text-secondary);
    margin: 0;
}

.recipe-ingredients {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-variant-numeric: tabular-nums;
}

.ing-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

.ing-pill.ok {
    border-color: rgba(52, 211, 153, 0.45);
    color: #a7f3d0;
}

.ing-pill.missing {
    border-color: rgba(251, 113, 133, 0.4);
    color: #fecdd3;
}

.empty-state-box {
    grid-column: 1 / -1;
    padding: 28px 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.88rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px dashed var(--border-subtle);
    border-radius: 12px;
}

/* ==========================================
   ENCHANTING WORKBENCH
   ========================================== */
.enchant-columns {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 14px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.enchant-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

.scribe-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    min-height: 0;
    padding-right: 4px;
}

.scribe-row {
    background: var(--surface-slot);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.scribe-row-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.scribe-name {
    font-family: var(--font-display);
    font-size: 0.92rem;
    font-weight: 700;
    color: #e9d5ff;
}

.scribe-target-tag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(109, 40, 217, 0.25);
    border: 1px solid rgba(192, 132, 252, 0.35);
    padding: 2px 7px;
    border-radius: 999px;
}

.scribe-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.scribe-levels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.scribe-lvl-btn {
    flex: 1;
    min-width: 84px;
    font-family: var(--font-main);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 6px 8px;
    border-radius: 8px;
    border: 1px solid rgba(192, 132, 252, 0.4);
    background: var(--accent-violet);
    color: #ffffff;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    transition: background-color 0.16s ease;
}

.scribe-lvl-btn:hover:not(:disabled) {
    background: var(--accent-violet-hover);
}

.scribe-lvl-btn:disabled {
    background: rgba(30, 41, 59, 0.6);
    border-color: var(--border-subtle);
    color: var(--text-muted);
    cursor: not-allowed;
}

.infuse-step {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.step-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.selectable-chip-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.select-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--surface-slot);
    border: 1.5px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.16s ease, background-color 0.16s ease;
}

.select-item-row:hover {
    background: rgba(30, 41, 59, 0.85);
}

.select-item-row.selected {
    border-color: #c084fc;
    background: rgba(109, 40, 217, 0.28);
}

.select-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.select-item-sub {
    font-size: 0.7rem;
    color: #d8b4fe;
}

/* ==========================================
   ORIENTATION PROMPT & MOBILE CONTROLS
   ========================================== */
#orientation-warning {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    background: var(--surface-base);
    color: var(--text-primary);
    z-index: 99999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px;
}

.warning-content {
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.warning-content h2 {
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
}

.warning-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.rotate-device-icon {
    color: #60a5fa;
    animation: rotatePhone 2.6s ease-in-out infinite;
}

@keyframes rotatePhone {
    0%, 15% { transform: rotate(0deg); }
    45%, 65% { transform: rotate(-90deg); }
    90%, 100% { transform: rotate(0deg); }
}

#mobile-joystick-container {
    display: none;
    position: fixed;
    bottom: max(18px, env(safe-area-inset-bottom));
    left: max(18px, env(safe-area-inset-left));
    width: 112px;
    height: 112px;
    z-index: 100;
    pointer-events: auto;
}

#mobile-joystick-base {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.68);
    border: 2px solid var(--border-strong);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#mobile-joystick-handle {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--accent-blue);
    border: 2px solid rgba(191, 219, 254, 0.55);
    box-shadow: 0 4px 12px rgba(2, 6, 23, 0.45);
    position: absolute;
}

#mobile-actions-container {
    display: none;
    position: fixed;
    bottom: max(14px, env(safe-area-inset-bottom));
    right: max(14px, env(safe-area-inset-right));
    z-index: 100;
    pointer-events: none;
}

.mobile-btn-group-right {
    display: grid;
    grid-template-columns: repeat(3, 54px);
    grid-template-rows: repeat(2, 54px);
    gap: 10px;
    pointer-events: none;
}

.mobile-action-btn {
    pointer-events: auto;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.76);
    border: 1.5px solid var(--border-strong);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(2, 6, 23, 0.45);
    touch-action: manipulation;
    transition: transform 0.1s ease, background-color 0.1s ease;
}

.mobile-action-btn:active,
.mobile-action-btn.active {
    transform: scale(0.92);
    background: var(--accent-blue);
}

#mobile-btn-shoot {
    grid-row: 1;
    grid-column: 1;
    border-color: rgba(251, 191, 36, 0.45);
}

#mobile-btn-attack {
    grid-row: 1;
    grid-column: 2;
    border-color: rgba(251, 113, 133, 0.5);
}

#mobile-btn-build {
    grid-row: 1;
    grid-column: 3;
}

#mobile-btn-dig {
    grid-row: 2;
    grid-column: 2;
}

#mobile-btn-jump {
    grid-row: 2;
    grid-column: 3;
    background: rgba(30, 58, 138, 0.72);
    border-color: rgba(147, 197, 253, 0.5);
}

body.is-mobile #mobile-joystick-container,
body.is-mobile #mobile-actions-container {
    display: block;
}

/* ==========================================
   RESPONSIVE BREAKPOINTS (MOBILE LANDSCAPE)
   ========================================== */
@media (max-width: 950px) {
    #guide-panel {
        display: none !important;
    }

    #quick-access-bar {
        top: max(10px, env(safe-area-inset-top));
        left: max(12px, env(safe-area-inset-left));
        flex-direction: row;
        gap: 6px;
    }

    .quick-pill-btn {
        min-height: 38px;
        padding: 6px 11px;
        font-size: 0.78rem;
    }

    .pill-kbd {
        display: none;
    }

    #actions-panel {
        top: max(10px, env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        width: auto;
        flex-direction: row;
        padding: 4px;
        gap: 4px;
        border-radius: 12px;
    }

    .hud-action-btn {
        width: 36px;
        height: 36px;
        padding: 0;
        justify-content: center;
    }

    .hud-action-btn .btn-label {
        display: none;
    }

    #status-bars-row {
        bottom: 74px;
        gap: 6px;
    }

    #health-bar-container,
    #armor-bar-container,
    #held-item-badge {
        padding: 4px 9px;
    }

    #health-bar {
        width: 82px;
        height: 6px;
    }

    #armor-bar {
        width: 64px;
        height: 6px;
    }

    #plant-button-container {
        bottom: 112px;
    }

    #hotbar-wrapper {
        left: calc(144px + env(safe-area-inset-left));
        right: calc(202px + env(safe-area-inset-right));
        transform: none;
        max-width: none;
        bottom: max(10px, env(safe-area-inset-bottom));
        padding: 5px;
        border-radius: 14px;
    }

    .hotbar-slot {
        width: 50px;
        height: 50px;
        border-radius: 10px;
        gap: 2px;
    }

    .block-preview {
        width: 22px;
        height: 22px;
    }

    .block-name {
        font-size: 0.69rem;
    }

    .slot-num {
        display: none;
    }

    #open-block-picker-btn {
        min-width: 54px;
        height: 50px;
        border-radius: 10px;
        padding: 4px 8px;
        font-size: 0.7rem;
    }

    .instructions {
        display: none;
    }

    .mobile-instructions {
        display: block;
    }

    .overlay-actions-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .enchant-columns {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .enchant-panel {
        overflow: visible;
    }

    .scribe-list {
        overflow: visible;
    }
}

@media (max-width: 720px) {
    .player-and-bag-section {
        flex-direction: column;
    }

    .picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}

@media (max-height: 500px) {
    #overlay-container {
        padding: 18px 20px;
        gap: 14px;
    }

    .overlay-subtitle {
        margin-bottom: 12px;
        font-size: 0.86rem;
    }

    .modal-card {
        max-height: 94dvh;
        padding: 14px 16px;
        gap: 10px;
    }
}

@media (orientation: portrait) and (max-width: 900px) {
    #orientation-warning {
        display: flex !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
